Package Gnumed :: Package timelinelib :: Package test :: Module utils |
[frames] | no frames]

# Module utils

source code

Contains unit test utility functions.

Many functions use a human readable date and time string as argument. Such a string has a day, month, year and an optional time like this:

      "1 Aug 2012" or "12 Jan 2017 12:05:30"

Classes
| ObjectWithTruthValue An object of this class can be treated as a boolean.

Functions
gregorian_period(human_start_time, human_end_time) Create a gregorian TimePeriod object. | source code
numeric_period(start, end) Create a numeric TimePeriod object. | source code
human_time_to_gregorian(human_time) Create a :doc:`GregorianTime <timelinelib.calendar.gregorian.time>` object from a human readable date and time string. | source code
a_time_period() Create a random :doc:`TimePeriod <timelinelib_canvas_data_timeperiod>` object. | source code
human_time_to_ymdhm(human_time) Convert a human readable date and time string into a tuple of numeric values. | source code
an_event() Create an :doc:`Event <timelinelib_canvas_data_event>` object. | source code
an_event_with(human_start_time=None, human_end_time=None, time=ANY_TIME, text="foo", fuzzy=False, locked=False, ends_today=False, category=None, default_color=None) Create an :doc:`Event <timelinelib_canvas_data_event>` object. | source code
a_subevent() Create a :doc:`Subevent <timelinelib_canvas_data_subevent>` object. | source code
a_subevent_with(start=None, end=None, time=ANY_TIME, text="sub", category=None, container=None) Create a :doc:`Subevent <timelinelib_canvas_data_subevent>` object. | source code
a_container(name, category, sub_events) Create a :doc:`Container <timelinelib_canvas_data_container>` object. | source code
a_container_with(text="container", category=None) Create a :doc:`Container <timelinelib_canvas_data_container>` object. | source code
a_category() Create a :doc:`Category <timelinelib_canvas_data_category>` object. | source code
a_category_with(name, color=(255,0,0), font_color=(0,255,255), parent=None) Create a :doc:`Category <timelinelib_canvas_data_category>` object. | source code
a_gregorian_era() Create an :doc:`Era <timelinelib_canvas_data_era>` object. | source code
a_gregorian_era_with(start=None, end=None, time=ANY_TIME, name="foo", color=(128,128,128), time_type=GregorianTimeType(), ends_today=False) Create an :doc:`Era <timelinelib_canvas_data_era>` object. | source code
a_numeric_era() Create an :doc:`Era <timelinelib_canvas_data_era>` object. | source code
a_numeric_era_with(start=None, end=None, time=ANY_NUM_TIME, name="foo", color=(128,128,128)) Create an :doc:`Era <timelinelib_canvas_data_era>` object. | source code
inc(number) Return the number + 1. | source code
new_cat(event) Return a new category. | source code
new_parent(category) Return a new category parent. | source code
new_progress(event) Return the event's progress + 1. | source code
modifier_change_ends_today(event) Toggle the event's ends-today property. | source code
select_language(language) Select the system locale language. | source code

Variables
| ANY_TIME = `"1 Jan 2010"`
| ANY_NUM_TIME = `10`
| EVENT_MODIFIERS = `[("change fuzzy", lambda event: event.set_fu`...``
| SUBEVENT_MODIFIERS = `[("change fuzzy", lambda event: event.set`...``
| CONTAINER_MODIFIERS = `[("change time period", lambda event: ev`...``
| CATEGORY_MODIFIERS = `[("change name", lambda category: categor`...``
| TIME_PERIOD_MODIFIERS = `[("zoom", lambda time_period: time_per`...``
| ERA_MODIFIERS = `[("change id", lambda era: era.set_id(inc(era.`...``
| NUM_ERA_MODIFIERS = `[("change id", lambda era: era.set_id(inc(`...``
| TIME_MODIFIERS = `[("add", lambda time: time+ GregorianDelta(1)),]`
| ANY = `_ANY()` This object is always considered equal to any other object.

Imports: random, GregorianDateTime, ABBREVIATED_ENGLISH_MONTH_NAMES, GregorianDelta, GregorianTimeType, Category, Container, Era, Event, Subevent, TimePeriod

Function Details

### gregorian_period(human_start_time, human_end_time) | source code
Create a gregorian TimePeriod object. The start and end times are strings in a human readable format.

### numeric_period(start, end) | source code
Create a numeric TimePeriod object. The start and end are numeric values.

### inc(number) | source code
Return the number + 1. If number is None return 8.

### new_progress(event) | source code
Return the event's progress + 1. If the event's progress is None, return 8.

### select_language(language) | source code
Select the system locale language. This function is Windows specific.

Variables Details

  ### EVENT_MODIFIERS Value:
      [("change fuzzy", lambda event: event.set_fuzzy(not event.get_fuzzy())
      ), ("change locked", lambda event: event.set_locked(not event.get_lock
      ed())), ("change ends today", modifier_change_ends_today), ("change id
      ", lambda event: event.set_id(inc(event.get_id()))), ("change time per
      iod", lambda event: event.set_time_period(event.get_time_period().move
      _delta(GregorianDelta.from_days(1)))), ("change text", lambda event: e
      vent.set_text("was: %s" % event.get_text())), ("change category", lamb
      da event: event.set_category(new_cat(event))), ("change icon", lambda
      ...

  ### SUBEVENT_MODIFIERS Value:
      [("change fuzzy", lambda event: event.set_fuzzy(not event.get_fuzzy())
      ), ("change locked", lambda event: event.set_locked(not event.get_lock
      ed())), ("change ends today", modifier_change_ends_today), ("change id
      ", lambda event: event.set_id(inc(event.get_id()))), ("change time per
      iod", lambda event: event.set_time_period(event.get_time_period().move
      _delta(GregorianDelta.from_days(1)))), ("change text", lambda event: e
      vent.set_text("was: %s" % event.get_text())), ("change category", lamb
      da event: event.set_category(new_cat(event))), ("change icon", lambda
      ...

  ### CONTAINER_MODIFIERS Value:
      [("change time period", lambda event: event.set_time_period(event.get_
      time_period().move_delta(GregorianDelta.from_days(1)))), ("change text
      ", lambda event: event.set_text("was: %s" % event.get_text())), ("chan
      ge category", lambda event: event.set_category(new_cat(event))),]

  ### CATEGORY_MODIFIERS Value:
      [("change name", lambda category: category.set_name("was: %s" % catego
      ry.get_name())), ("change id", lambda category: category.set_id(inc(ca
      tegory.get_id()))), ("change color", lambda category: category.set_col
      or(category.get_color()+(1, 0, 3))), ("change font color", lambda cate
      gory: category.set_font_color(category.get_font_color()+(1, 0, 3))), (
      "change parent", lambda category: category.set_parent(new_parent(categ
      ory))),]

  ### TIME_PERIOD_MODIFIERS Value:
      [("zoom", lambda time_period: time_period.zoom(-1)), ("move left", lam
      bda time_period: time_period.move(-1)), ("move right", lambda time_per
      iod: time_period.move(1)),]

  ### ERA_MODIFIERS Value:
      [("change id", lambda era: era.set_id(inc(era.get_id()))), ("change ti
      me period", lambda era: era.set_time_period(era.get_time_period().move
      _delta(GregorianDelta.from_days(1)))), ("change text", lambda era: era
      .set_name("was: %s" % era.get_name())), ("change color", lambda era: e
      ra.set_color(tuple([x+ 1 for x in era.get_color()])))]

  ### NUM_ERA_MODIFIERS Value:
      [("change id", lambda era: era.set_id(inc(era.get_id()))), ("change ti
      me period", lambda era: era.set_time_period(era.get_time_period().move
      _delta(1))), ("change text", lambda era: era.set_name("was: %s" % era.
      get_name())), ("change color", lambda era: era.set_color(tuple([x+ 1 f
      or x in era.get_color()])))]