from optparse import OptionParser from sys import exit # Import from lpod from lpod import __version__ from lpod.document import odf_get_document from lpod.cleaner import clean_document if __name__ == '__main__': # Options initialisation usage = "%prog <input.odt> <output.odt>" description = "Clean malformed ODT documents" parser = OptionParser(usage, version=__version__, description=description) # Parse ! options, args = parser.parse_args() # Go ! if len(args) != 2: parser.print_help() exit(1) indoc = odf_get_document(args[0]) outdoc, error_nb = clean_document(indoc) if error_nb != 0: print('%d error(s) fixed.' % error_nb) outdoc.save(target=args[1])