22# Mode: -*- python -*-
33#
44# Copyright (c) 2000-2002 by hartmut Goebel <h.goebel@crazy-compilers.com>
5- #
5+ # Copyright (c) 2015 by Rocky Bernstein
6+
67"""
78Usage: uncompyle6 [OPTIONS]... [ FILE | DIR]...
89
@@ -41,15 +42,19 @@ Extensions of generated files:
4142"""
4243
4344from __future__ import print_function
44- import sys , os , getopt
45+ import sys , os , getopt , time
4546
4647program = os .path .basename (__file__ )
4748
48- Usage_short = \
49- "%s [--help] [--verify] [--showasm] [--showast] [-o <path>] FILE|DIR..." % program
49+ from uncompyle6 import verify , check_python_version
50+ from uncompyle6 .main import main , status_msg
51+
52+ def usage ():
53+ print ("""usage:
54+ %s [--help] [--verify] [--showasm] [--showast] [-o <path>] FILE|DIR...
55+ """ % program )
56+ sys .exit (1 )
5057
51- from uncompyle6 import main , status_msg , verify , check_python_version
52- import time
5358
5459check_python_version (program )
5560
@@ -91,9 +96,8 @@ for opt, val in opts:
9196 elif opt == '-r' :
9297 recurse_dirs = True
9398 else :
94- print (opt )
95- print (Usage_short )
96- sys .exit (1 )
99+ print (opt , file = sys .stderr )
100+ usage ()
97101
98102# expand directory if specified
99103if recurse_dirs :
@@ -117,6 +121,11 @@ if src_base:
117121 files = [f [sb_len :] for f in files ]
118122 del sb_len
119123
124+ if not files :
125+ print ("No files given" , file = sys .stderr )
126+ usage ()
127+
128+
120129if outfile == '-' :
121130 outfile = None # use stdout
122131elif outfile and os .path .isdir (outfile ):
@@ -162,7 +171,7 @@ else:
162171 if f is None :
163172 break
164173 (t , o , f , v ) = \
165- main (src_base , out_base , [f ], codes , outfile , showasm , showast , do_verify )
174+ main (src_base , out_base , [f ], codes , outfile , showasm , showast , do_verify )
166175 tot_files += t
167176 okay_files += o
168177 failed_files += f
0 commit comments