File: registry_tools.py

package info (click to toggle)
python-calendra 7.11.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,600 kB
  • sloc: python: 16,840; makefile: 6
file content (28 lines) | stat: -rw-r--r-- 717 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""
Tools to update the ISO registry.
"""


def iso_register(iso_code):
    """
    Registers Calendar class as country or region in IsoRegistry.

    Registered country must set class variables ``iso`` using this decorator.

    >>> from calendra.core import Calendar
    >>> from calendra.registry import registry
    >>> from calendra.registry_tools import iso_register
    >>> @iso_register('MC-MR')
    ... class MyRegion(Calendar):
    ...     'My Region'

    Region calendar is then retrievable from registry:

    >>> calendar = registry.get('MC-MR')
    """

    def wrapper(cls):
        from calendra.registry import registry
        registry.register(iso_code, cls)
        return cls
    return wrapper