@@ -37,27 +37,27 @@ def logLevel(value):
3737 return lvl
3838
3939
40- def profileMain (options ):
40+ def configFromDir (inname , dirname ):
41+ """ Returns a file name from the given config directory. """
42+ name = path .join (dirname , path .basename (path .splitext (inname )[0 ]))
43+ return '%s.py' % path .abspath (name )
44+
45+
46+ def runMain (options ):
4147 """ Runs our main function with profiling if indicated by options. """
4248 if options .profile :
4349 import cProfile , pstats
4450 prof = cProfile .Profile ()
45- prof .runcall (main , options )
51+ prof .runcall (runTransform , options )
4652 stats = pstats .Stats (prof , stream = sys .stderr )
4753 stats .strip_dirs ().sort_stats ('cumulative' )
4854 stats .print_stats ().print_callers ()
4955 return 0
5056 else :
51- return main (options )
52-
53-
54- def configFromDir (inname , dirname ):
55- """ Returns a file name from the given config directory. """
56- name = path .join (dirname , path .basename (path .splitext (inname )[0 ]))
57- return '%s.py' % path .abspath (name )
57+ return runTransform (options )
5858
5959
60- def main (options ):
60+ def runTransform (options ):
6161 """ Compile the indicated java source with the given options. """
6262 timed = defaultdict (time )
6363 timed ['overall' ]
@@ -168,7 +168,7 @@ def configColors(nocolor):
168168 escapes .clear ()
169169
170170
171- def config (argv ):
171+ def configScript (argv ):
172172 """ Return an options object from the given argument sequence. """
173173 parser = ArgumentParser (
174174 description = 'Translate Java source code to Python.' ,
@@ -230,4 +230,4 @@ def config(argv):
230230
231231
232232if __name__ == '__main__' :
233- sys .exit (profileMain ( config (sys .argv [1 :])))
233+ sys .exit (runMain ( configScript (sys .argv [1 :])))
0 commit comments