1
1
#!/usr/bin/env python
2
2
# Mode: -*- python -*-
3
3
#
4
- # Copyright (c) 2015-2016, 2018, 2020, 2022 by Rocky Bernstein <[email protected] >
4
+ # Copyright (c) 2015-2016, 2018, 2020, 2022-2023 by Rocky Bernstein <[email protected] >
5
5
#
6
6
from __future__ import print_function
7
- import sys , os , getopt
7
+
8
+ import getopt
9
+ import os
10
+ import sys
8
11
9
12
from uncompyle6 .code_fns import disassemble_file
10
13
from uncompyle6 .version import __version__
40
43
-V | --version show version and stop
41
44
-h | --help show this message
42
45
43
- """ .format (program )
46
+ """ .format (
47
+ program
48
+ )
49
+
50
+ PATTERNS = ("*.pyc" , "*.pyo" )
44
51
45
- PATTERNS = ('*.pyc' , '*.pyo' )
46
52
47
53
def main ():
48
- Usage_short = """usage: %s FILE...
49
- Type -h for for full help.""" % program
54
+ Usage_short = (
55
+ """usage: %s FILE...
56
+ Type -h for for full help."""
57
+ % program
58
+ )
50
59
51
60
if len (sys .argv ) == 1 :
52
61
print ("No file(s) given" , file = sys .stderr )
53
62
print (Usage_short , file = sys .stderr )
54
63
sys .exit (1 )
55
64
56
65
try :
57
- opts , files = getopt .getopt (sys .argv [1 :], 'hVU' ,
58
- ['help' , 'version' , 'uncompyle6' ])
66
+ opts , files = getopt .getopt (
67
+ sys .argv [1 :], "hVU" , ["help" , "version" , "uncompyle6" ]
68
+ )
59
69
except getopt .GetoptError as e :
60
- print (' %s: %s' % (os .path .basename (sys .argv [0 ]), e ), file = sys .stderr )
70
+ print (" %s: %s" % (os .path .basename (sys .argv [0 ]), e ), file = sys .stderr )
61
71
sys .exit (- 1 )
62
72
63
73
for opt , val in opts :
64
- if opt in ('-h' , ' --help' ):
74
+ if opt in ("-h" , " --help" ):
65
75
print (__doc__ )
66
76
sys .exit (1 )
67
- elif opt in ('-V' , ' --version' ):
77
+ elif opt in ("-V" , " --version" ):
68
78
print ("%s %s" % (program , __version__ ))
69
79
sys .exit (0 )
70
80
else :
@@ -76,11 +86,11 @@ def main():
76
86
if os .path .exists (files [0 ]):
77
87
disassemble_file (file , sys .stdout )
78
88
else :
79
- print ("Can't read %s - skipping" % files [0 ],
80
- file = sys .stderr )
89
+ print ("Can't read %s - skipping" % files [0 ], file = sys .stderr )
81
90
pass
82
91
pass
83
92
return
84
93
85
- if __name__ == '__main__' :
94
+
95
+ if __name__ == "__main__" :
86
96
main ()
0 commit comments