logilab/doctools

view transform.py @ 0:cc367abb080e

forget the past. forget the past.
author root
date Wed, 26 Apr 2006 10:48:09 +0000
parents
children c3e73486dd16
line source
1 #!/usr/bin/env python
3 # -*- coding: ISO-8859-1 -*-
5 # Copyright (c) 2000-2003 LOGILAB S.A. (Paris, FRANCE).
6 # http://www.logilab.fr/ -- mailto:contact@logilab.fr
7 #
8 # This program is free software; you can redistribute it and/or modify it under
9 # the terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 2 of the License, or (at your option) any later
11 # version.
12 #
13 # This program is distributed in the hope that it will be useful, but WITHOUT
14 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License along with
18 # this program; if not, write to the Free Software Foundation, Inc.,
19 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 """main entry point for the transformer"""
23 __revision__ = '$Id: transform.py,v 1.12 2004-10-31 02:18:06 nico Exp $'
25 import sys
26 from logilab.doctools.transformer import Transformer, FormattingException, \
27 GuessException
29 def run(args):
30 """
31 main
32 """
33 transformer = Transformer()
34 transformer.load_file_configuration()
35 args = transformer.load_command_line_configuration(args)
36 if not args:
37 print transformer.help()
38 return 4
39 status = 0
40 for filename in args:
41 if len(args) > 1:
42 print '*' * 80
43 try:
44 output_file = transformer.transform(filename)
45 except GuessException, exc:
46 print 'Error:', exc
47 status = 1
48 except FormattingException, exc:
49 print 'Error:', exc
50 status = 2
51 except:
52 import traceback
53 traceback.print_exc()
54 status = 3
55 return status
57 if __name__ == '__main__':
58 sys.exit(run(sys.argv[1:]))