1 # Copyright (C) 2013 W. Trevor King <wking@tremily.us>
3 # This file is part of pycalender.
5 # pycalender is free software: you can redistribute it and/or modify it under
6 # the terms of the GNU General Public License as published by the Free Software
7 # Foundation, either version 3 of the License, or (at your option) any later
10 # pycalender is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License along with
15 # pycalender. If not, see <http://www.gnu.org/licenses/>.
17 """Classes representing calendar properties
19 As defined in :RFC:`5545`, sections 3.7 (Calendar Properties) and 3.8
20 (Component Properties).
23 from . import base as _base
25 from . import alarm as _alarm
26 from . import calendar as _calendar
27 from . import change as _change
28 from . import component as _component
29 from . import datetime as _datetime
30 from . import descriptive as _descriptive
31 from . import misc as _misc
32 from . import recurrence as _recurrence
33 from . import relationship as _relationship
34 from . import timezone as _timezone
40 def register(property):
41 """Register a property class
43 PROPERTY[property.name] = property
47 name_param,value = [x.strip() for x in line.split(':', 1)]
48 parameters = name_param.split(';')
49 name = parameters.pop(0).upper() # names are case insensitive
50 parameters = dict(tuple(x.split('=', 1)) for x in parameters)
51 for k,v in parameters.items():
53 parameters[k] = v.split(',')
54 prop_class = PROPERTY[name]
55 prop = prop_class(parameters=parameters)
56 prop.check_parameters()
57 prop.value = prop.decode(value=value)
74 for name in dir(module):
75 if name.startswith('_'):
77 obj = getattr(module, name)
78 if isinstance(obj, type) and issubclass(obj, _base.Property):
79 register(property=obj)