167
def main(args=sys.argv):
169
print 'Usage: %s file.odt'%args[0]
171
mi = get_metadata(open(args[1], 'rb'))
175
if __name__ == '__main__':
178
#now = time.localtime()[:6]
180
#writemeta = False # Do we change any meta data?
181
#usenormalize = False
184
# opts, args = getopt.getopt(sys.argv[1:], "cdlI:A:a:o:x:X:")
185
#except getopt.GetoptError:
189
# opts = [ ('-l','') ]
192
# if o in ('-a','-A','-I'):
194
# if a.find(":") >= 0:
195
# k,v = a.split(":",1)
200
# k = fields.get(k,k)
201
# addfields[k] = unicode(v,'utf-8')
203
# yieldfields[k] = True
205
# deletefields[k] = True
208
# addfields[(DCNS,u'date')] = "%04d-%02d-%02dT%02d:%02d:%02d" % now
209
# deletefields[(DCNS,u'date')] = True
211
# usenormalize = True
213
# Xfields = fields.values()
215
# xfields.append(fields.get(a,a))
217
# Xfields.append(fields.get(a,a))
221
## The specification says we should change the element to our own,
222
## and must not export the original identifier.
224
# addfields[(METANS,u'generator')] = TOOLSVERSION
225
# deletefields[(METANS,u'generator')] = True
227
#odfs = odfmetaparser()
228
#parser = xml.sax.make_parser()
229
#parser.setFeature(xml.sax.handler.feature_namespaces, 1)
230
#parser.setContentHandler(odfs)
233
# zin = zipfile.ZipFile(sys.stdin,'r')
235
# if not zipfile.is_zipfile(args[0]):
237
# zin = zipfile.ZipFile(args[0], 'r')
239
#content = zin.read('meta.xml')
240
#parser.parse(StringIO(content))
243
# if outputfile == '-':
244
# if sys.stdout.isatty():
245
# sys.stderr.write("Won't write ODF file to terminal\n")
247
# zout = zipfile.ZipFile(sys.stdout,"w")
249
# zout = zipfile.ZipFile(outputfile,"w")
253
# # Loop through the input zipfile and copy the content to the output until we
254
# # get to the meta.xml. Then substitute.
255
# for zinfo in zin.infolist():
256
# if zinfo.filename == "meta.xml":
258
# zi = zipfile.ZipInfo("meta.xml", now)
259
# zi.compress_type = zipfile.ZIP_DEFLATED
260
# zout.writestr(zi,odfs.meta() )
262
# payload = zin.read(zinfo.filename)
263
# zout.writestr(zinfo, payload)