@@ -41,7 +41,7 @@ class ByteWriter(object):
41
41
42
42
def __init__ (self , stream , varname ):
43
43
self .stream = stream
44
- self .stream .write (' {} =\\ \n ' .format (varname ))
44
+ self .stream .write (" {} =\\ \n " .format (varname ))
45
45
self .bytecount = 0 # For line breaks
46
46
47
47
def _eol (self ):
@@ -57,7 +57,7 @@ def _bol(self):
57
57
def obyte (self , data ):
58
58
if not self .bytecount :
59
59
self ._bol ()
60
- self .stream .write (' \\ x{:02x}' .format (data ))
60
+ self .stream .write (" \\ x{:02x}" .format (data ))
61
61
self .bytecount += 1
62
62
self .bytecount %= self .bytes_per_line
63
63
if not self .bytecount :
@@ -72,7 +72,7 @@ def odata(self, bytelist):
72
72
def eot (self ): # User force EOL if one hasn't occurred
73
73
if self .bytecount :
74
74
self ._eot ()
75
- self .stream .write (' \n ' )
75
+ self .stream .write (" \n " )
76
76
77
77
78
78
# PYTHON FILE WRITING
@@ -90,17 +90,17 @@ def data():
90
90
91
91
92
92
def write_func (stream , name , arg ):
93
- stream .write (' def {}():\n return {}\n \n ' .format (name , arg ))
93
+ stream .write (" def {}():\n return {}\n \n " .format (name , arg ))
94
94
95
95
96
96
def write_data (op_path , ip_path ):
97
97
try :
98
- with open (ip_path , 'rb' ) as ip_stream :
98
+ with open (ip_path , "rb" ) as ip_stream :
99
99
try :
100
- with open (op_path , 'w' ) as op_stream :
100
+ with open (op_path , "w" ) as op_stream :
101
101
write_stream (ip_stream , op_stream )
102
102
except OSError :
103
- print ("Can't open" , op_path , ' for writing' )
103
+ print ("Can't open" , op_path , " for writing" )
104
104
return False
105
105
except OSError :
106
106
print ("Can't open" , ip_path )
@@ -110,9 +110,9 @@ def write_data(op_path, ip_path):
110
110
111
111
def write_stream (ip_stream , op_stream ):
112
112
op_stream .write (STR01 )
113
- op_stream .write (' \n ' )
113
+ op_stream .write (" \n " )
114
114
data = ip_stream .read ()
115
- bw_data = ByteWriter (op_stream , ' _data' )
115
+ bw_data = ByteWriter (op_stream , " _data" )
116
116
bw_data .odata (data )
117
117
bw_data .eot ()
118
118
op_stream .write (STR02 )
@@ -135,20 +135,20 @@ def quit(msg):
135
135
if __name__ == "__main__" :
136
136
parser = argparse .ArgumentParser (__file__ , description = DESC ,
137
137
formatter_class = argparse .RawDescriptionHelpFormatter )
138
- parser .add_argument (' infile' , type = str , help = ' Input file path' )
139
- parser .add_argument (' outfile' , type = str ,
140
- help = ' Path and name of output file. Must have .py extension.' )
138
+ parser .add_argument (" infile" , type = str , help = " Input file path" )
139
+ parser .add_argument (" outfile" , type = str ,
140
+ help = " Path and name of output file. Must have .py extension." )
141
141
142
142
args = parser .parse_args ()
143
143
144
144
if not os .path .isfile (args .infile ):
145
145
quit ("Data filename does not exist" )
146
146
147
- if not os .path .splitext (args .outfile )[1 ].upper () == ' .PY' :
148
- quit (' Output filename must have a .py extension.' )
147
+ if not os .path .splitext (args .outfile )[1 ].upper () == " .PY" :
148
+ quit (" Output filename must have a .py extension." )
149
149
150
- print (' Writing Python file.' )
150
+ print (" Writing Python file." )
151
151
if not write_data (args .outfile , args .infile ):
152
152
sys .exit (1 )
153
153
154
- print (args .outfile , ' written successfully.' )
154
+ print (args .outfile , " written successfully." )
0 commit comments