5 from librarian import html, ParseError
8 if __name__ == '__main__':
9 # Parse commandline arguments
10 usage = """Usage: %prog [options] SOURCE [SOURCE...]
11 Convert SOURCE files to HTML format."""
13 parser = optparse.OptionParser(usage=usage)
15 parser.add_option('-v', '--verbose', action='store_true', dest='verbose', default=False,
16 help='print status messages to stdout')
17 parser.add_option('-i', '--ignore-dublin-core', action='store_false', dest='parse_dublincore', default=True,
18 help='don\'t try to parse dublin core metadata')
20 options, input_filenames = parser.parse_args()
22 if len(input_filenames) < 1:
27 for input_filename in input_filenames:
31 output_filename = os.path.splitext(input_filename)[0] + '.html'
33 html.transform(input_filename, output_filename, parse_dublincore=options.parse_dublincore)
35 print '%(file)s:%(name)s:%(message)s' % {
36 'file': input_filename,
37 'name': e.__class__.__name__,
41 print '%(file)s:%(name)s:%(message)s' % {
42 'file': input_filename,
43 'name': e.__class__.__name__,
44 'message': e.strerror,
46 except BaseException, e:
47 print '%(file)s:%(etype)s:%(message)s' % {
48 'file': input_filename,
49 'etype': e.__class__.__name__,