1.1 --- a/imiptools/content.py Sun Oct 26 00:45:58 2014 +0200
1.2 +++ b/imiptools/content.py Sun Oct 26 17:51:04 2014 +0100
1.3 @@ -186,18 +186,22 @@
1.4
1.5 return []
1.6
1.7 -def parse_object(f, encoding, objtype):
1.8 +def parse_object(f, encoding, objtype=None):
1.9
1.10 """
1.11 - Parse the iTIP content from 'f' having the given 'encoding'. Return None if
1.12 - the content was not readable or suitable.
1.13 + Parse the iTIP content from 'f' having the given 'encoding'. If 'objtype' is
1.14 + given, only objects of that type will be returned.
1.15 +
1.16 + Return None if the content was not readable or suitable.
1.17 """
1.18
1.19 try:
1.20 try:
1.21 doctype, attrs, elements = obj = parse(f, encoding=encoding)
1.22 - if doctype == objtype:
1.23 + if objtype and doctype == objtype:
1.24 return to_dict(obj)[objtype][0]
1.25 + elif not objtype:
1.26 + return to_dict(obj)[doctype][0]
1.27 finally:
1.28 f.close()
1.29 except (ParseError, ValueError):
1.30 @@ -248,6 +252,8 @@
1.31 except OSError:
1.32 self.publisher = None
1.33
1.34 + # Access to calendar structures and other data.
1.35 +
1.36 def get_items(self, name, all=True):
1.37 return get_items(self.details, name, all)
1.38