32if sys.version_info[0]==3:
40 u'float': (OFFICENS,
u'value'),
41 u'percentage': (OFFICENS,
u'value'),
42 u'currency': (OFFICENS,
u'value'),
43 u'date': (OFFICENS,
u'date-value'),
44 u'time': (OFFICENS,
u'time-value'),
45 u'boolean': (OFFICENS,
u'boolean-value'),
46 u'string': (OFFICENS,
u'string-value'),
65 assert(src==
None or 'rb' in repr(src)
or 'BufferedReader' in repr(src)
or 'BytesIO' in repr(src)
or type(src)==type(
u""))
66 assert(dest==
None or 'wb' in repr(dest)
or 'BufferedWriter' in repr(dest)
or 'BytesIO' in repr(dest)
or type(dest)==type(
u""))
72 if (sys.version_info[0]==3
and (isinstance(self.
src_file, str)
or (isinstance(self.
src_file, io.IOBase))))
or (sys.version_info[0]==2
and isinstance(self.
src_file, basestring)):
74 if not zipfile.is_zipfile(self.
src_file):
75 raise TypeError(
u"%s is no odt file." % self.
src_file)
109 all_fields = self.
document.getElementsByType(UserFieldDecl)
111 value_type = f.getAttribute(
u'valuetype')
112 if value_type ==
u'string':
113 value = f.getAttribute(
u'stringvalue')
115 value = f.getAttribute(
u'value')
116 field_name = f.getAttribute(
u'name')
118 if field_names
is None or field_name
in field_names:
119 found_fields.append((field_name,
139 def get(self, field_name):
140 assert(type(field_name)==type(
u""))
153 assert(type(field_name)==type(
u""))
157 field_name, value_type, value = fields[0]
158 return value_type, value
169 all_fields = self.
document.getElementsByType(UserFieldDecl)
171 field_name = f.getAttribute(
u'name')
172 if field_name
in data:
173 value_type = f.getAttribute(
u'valuetype')
174 value = data.get(field_name)
175 if value_type ==
u'string':
176 f.setAttribute(
u'stringvalue', value)
178 f.setAttribute(
u'value', value)
List, view and manipulate user fields.
get(self, field_name)
Extract the contents of this field from the file.
list_values(self, field_names)
Extract the contents of given field names from the file.
list_fields(self)
List (extract) all known user-fields.
__init__(self, src=None, dest=None)
Constructor.
update(self, data)
Set the value of user fields.
list_fields_and_values(self, field_names=None)
List (extract) user-fields with type and value.
get_type_and_value(self, field_name)
Extract the type and contents of this field from the file.