diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2013-05-04 21:39:27 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2013-05-04 21:39:27 +0000 |
commit | fec6336699f34758d3e6cb41b2edf902fedb9035 (patch) | |
tree | 8256c1dbf3ca7c9e58a3dbecf07cf826fb2e0ce2 /src/python/Property.py | |
parent | 7dbffd7e2b0067e834801617c5c486e3177f6709 (diff) | |
download | libical-master.tar.gz |
libical-1.0HEADlibical-1.0master
Diffstat (limited to 'src/python/Property.py')
-rw-r--r-- | src/python/Property.py | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/src/python/Property.py b/src/python/Property.py index 1b9b5ef..a53585e 100644 --- a/src/python/Property.py +++ b/src/python/Property.py @@ -43,18 +43,16 @@ def error_type(): def test_enum(prop,enum): - kind = icalproperty_string_to_kind(prop) - e = icalproperty_string_to_enum(enum) - - t = icalproperty_enum_belongs_to_property(kind,e) + vkind = icalvalue_string_to_kind(prop) + e = icalproperty_kind_and_string_to_enum(vkind, enum) - if t == 1: + if e != 0: return 1 return None -class Property: +class Property(object): """ Represent any iCalendar Property. Usage: @@ -75,8 +73,8 @@ class Property: def __init__(self, type = None, ref = None): - assert(ref == None or isinstance(ref,StringType)) - assert(type == None or isinstance(type,StringType)) + #~ assert(ref == None or isinstance(ref,StringType)) + #~ assert(type == None or isinstance(type,StringType)) self._ref = None @@ -87,14 +85,13 @@ class Property: self._ref = icalproperty_new(kind) if type.find("X-") == 0: - icalproperty_set_x_name(self._ref, type) + icalproperty_set_x_name(self._ref, type) if self._ref == None or self._ref == 'NULL': - raise Property.ConstructorFailedError("Failed to construct Property") + raise Property.ConstructorFailedError("Failed to construct Property: %s (%s)"%(type, ref)) self._deleted = 0; - # Initialize all of the required keys @@ -110,7 +107,7 @@ class Property: def name(self,v=None): """ Return the name of the property """ - return icalproperty_get_name(self._ref) + return icalproperty_get_property_name(self._ref) def ref(self,v=None): """ Return the internal reference to the libical icalproperty """ @@ -133,7 +130,9 @@ class Property: if kind != None: # Get the default kind of value for this property - default_kind = icalvalue_kind_to_string(icalproperty_kind_to_value_kind(icalproperty_string_to_kind(self.name()))) + default_kind = icalvalue_kind_to_string( + icalproperty_kind_to_value_kind( + icalproperty_string_to_kind(self.name()))) if(kind != default_kind): self.__setitem__('VALUE',kind) @@ -148,9 +147,11 @@ class Property: icalerror_clear_errno() #e1=icalerror_supress("MALFORMEDDATA") - if (self.name().find("X-") == 0) and type(v) is StringType: - v = icallangbind_quote_as_ical(v) - v = icallangbind_quote_as_ical(v) + if (self.name() == None or self.name().find("X-") == 0) and type(v) is StringType: + v = icallangbind_quote_as_ical(v) + + if isinstance(v, unicode): + v = v.encode('utf8') icalproperty_set_value_from_string(self._ref,str(v),vt) #icalerror_restore("MALFORMEDDATA",e1) |