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,\
36 print '%(file)s:%(name)s:%(message)s' % {
37 'file': input_filename,
38 'name': e.__class__.__name__,
39 'message': e.message.encode('utf-8')
42 print '%(file)s:%(name)s:%(message)s' % {
43 'file': input_filename,
44 'name': e.__class__.__name__,
45 'message': e.strerror,
47 except BaseException, e:
48 print '%(file)s:%(etype)s:%(message)s' % {
49 'file': input_filename,
50 'etype': e.__class__.__name__,
51 'message': e.message.encode('utf-8'),