summaryrefslogtreecommitdiff
path: root/src/python/Property.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/python/Property.py')
-rw-r--r--src/python/Property.py33
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)