speasy.products.catalog module
catalog module
- class speasy.products.catalog.Catalog(name: str, meta: dict = None, events: List[Event] = None)[source]
Bases:
SpeasyProduct
The Catalog class allows to manipulate a goup of events like a simple Python list of Event plus some meta data.
- Attributes:
- namestr
Catalog name
- metadict
All additional Catalog meta data
Methods
append:
Append an Event or a list of Event to the end of the Catalog
pop:
Remove and return Event at index (default last)
Examples
>>> import speasy >>> from speasy.products import Catalog, Event >>> my_catalog = Catalog(name='MyCatalog', meta={'tags':['demo', 'docstrings']}, events=[]) >>> my_catalog.append(Event('2018-01-01', '2018-01-02', meta={'name':'My first event!'})) >>> my_catalog += Event('2019-01-01', '2019-01-02', meta={'name':'My second event!'}) >>> for e in my_catalog: ... print(e) ... <Event: 2018-01-01T00:00:00+00:00 -> 2018-01-02T00:00:00+00:00 | {'name': 'My first event!'}> <Event: 2019-01-01T00:00:00+00:00 -> 2019-01-02T00:00:00+00:00 | {'name': 'My second event!'}>
- append(events: Event) None [source]
Append an Event or a list of Event to the end of the Catalog.
- Parameters:
- eventsEvent or List[Event]
- Raises:
- TypeError
If events is neither an Event or a list of Event
See also
- meta
- name
- class speasy.products.catalog.Event(start_time: datetime, stop_time: datetime, meta=None)[source]
Bases:
DateTimeRange
The Event class is a DatetimeRange with some meta data. It is supposed to be used with Catalog
- Attributes:
- start_timedatetime.datetime
- stop_timedatetime.datetime
- metadict
Additional event data
Notes
This class support the same operations as a speasy.common.datetime_range.DateTimeRange.
- meta