1.1 --- a/imiptools/data.py Thu May 12 17:51:10 2016 +0200
1.2 +++ b/imiptools/data.py Thu May 12 22:58:57 2016 +0200
1.3 @@ -161,14 +161,16 @@
1.4 def get_duration(self, name):
1.5 return get_duration(self.get_value(name))
1.6
1.7 + # Serialisation.
1.8 +
1.9 def to_node(self):
1.10 return to_node({self.objtype : [(self.details, self.attr)]})
1.11
1.12 - def to_part(self, method):
1.13 - return to_part(method, [self.to_node()])
1.14 + def to_part(self, method, encoding="utf-8", line_length=None):
1.15 + return to_part(method, [self.to_node()], encoding, line_length)
1.16
1.17 - def to_string(self):
1.18 - return to_string(self.to_node())
1.19 + def to_string(self, encoding="utf-8", line_length=None):
1.20 + return to_string(self.to_node(), encoding, line_length)
1.21
1.22 # Direct access to the structure.
1.23
1.24 @@ -615,7 +617,7 @@
1.25 # Get a constrained view if start and end limits are specified.
1.26
1.27 if period:
1.28 - periods = freebusy.period_overlaps(period, True)
1.29 + periods = freebusy.get_overlapping(period)
1.30 else:
1.31 periods = freebusy
1.32
1.33 @@ -677,17 +679,16 @@
1.34
1.35 return parse_object(StringIO(s), encoding, objtype)
1.36
1.37 -def to_part(method, calendar):
1.38 +def to_part(method, fragments, encoding="utf-8", line_length=None):
1.39
1.40 """
1.41 - Write using the given 'method', the 'calendar' details to a MIME
1.42 + Write using the given 'method', the given 'fragments' to a MIME
1.43 text/calendar part.
1.44 """
1.45
1.46 - encoding = "utf-8"
1.47 out = StringIO()
1.48 try:
1.49 - to_stream(out, make_calendar(calendar, method), encoding)
1.50 + to_stream(out, make_calendar(fragments, method), encoding, line_length)
1.51 part = MIMEText(out.getvalue(), "calendar", encoding)
1.52 part.set_param("method", method)
1.53 return part
1.54 @@ -695,19 +696,19 @@
1.55 finally:
1.56 out.close()
1.57
1.58 -def to_stream(out, fragment, encoding="utf-8"):
1.59 +def to_stream(out, fragment, encoding="utf-8", line_length=None):
1.60
1.61 "Write to the 'out' stream the given 'fragment'."
1.62
1.63 - iterwrite(out, encoding=encoding).append(fragment)
1.64 + iterwrite(out, encoding=encoding, line_length=line_length).append(fragment)
1.65
1.66 -def to_string(fragment, encoding="utf-8"):
1.67 +def to_string(fragment, encoding="utf-8", line_length=None):
1.68
1.69 "Return a string encoding the given 'fragment'."
1.70
1.71 out = StringIO()
1.72 try:
1.73 - to_stream(out, fragment, encoding)
1.74 + to_stream(out, fragment, encoding, line_length)
1.75 return out.getvalue()
1.76
1.77 finally: