25
25
Note that it dumps UTF-16 characters in text strings as-is.
26
26
"""
27
27
28
- ################################################################################
28
+ ###############################################################################
29
29
30
30
def check_size (fsize , minsize ):
31
31
"""Ensure that the filesize is at least minsize bytes.
@@ -40,7 +40,7 @@ def check_size(fsize, minsize):
40
40
(fsize , minsize )
41
41
return fsize >= minsize
42
42
43
- ################################################################################
43
+ ###############################################################################
44
44
45
45
def nice_open_file (filename ):
46
46
"""Checks if the output file with the given name already exists,
@@ -57,7 +57,7 @@ def nice_open_file(filename):
57
57
else :
58
58
return True
59
59
60
- ################################################################################
60
+ ###############################################################################
61
61
62
62
def nice_open_dir (dirname ):
63
63
"""Checks if the output directory with the given name already exists,
@@ -75,7 +75,7 @@ def nice_open_dir(dirname):
75
75
else :
76
76
return True
77
77
78
- ################################################################################
78
+ ###############################################################################
79
79
80
80
def do_mkdir (dirname ):
81
81
"""Version of os.mkdir() which does not throw an exception if the directory
@@ -90,7 +90,7 @@ def do_mkdir(dirname):
90
90
if errno == 17 :
91
91
pass # directory already exists
92
92
93
- ################################################################################
93
+ ###############################################################################
94
94
95
95
def strip_blanks (instring ):
96
96
"""Strip the leading and trailing blanks from the input string.
@@ -103,7 +103,7 @@ def strip_blanks(instring):
103
103
rstr = instring .rstrip ("\0 \t \n \r \v \f \377 " )
104
104
return rstr .lstrip (" \t \n \r \v \f \377 " )
105
105
106
- ################################################################################
106
+ ###############################################################################
107
107
108
108
def open_info_file (infile ):
109
109
"""Open the informational text file.
@@ -122,7 +122,7 @@ def open_info_file(infile):
122
122
else :
123
123
return None
124
124
125
- ################################################################################
125
+ ###############################################################################
126
126
127
127
def dump_png (infile , pnglen , maxlen , pngid ):
128
128
"""Dump the embedded PNG file from the archive file to an output file.
@@ -146,7 +146,7 @@ def dump_png(infile, pnglen, maxlen, pngid):
146
146
print "PNG image %s too large (%i instead of maximal %i bytes), " \
147
147
"file not written." % (pngid , pnglen , maxlen )
148
148
149
- ################################################################################
149
+ ###############################################################################
150
150
151
151
def dump_info (infile , txtfile , what ):
152
152
"""Dumps the 9 information strings from the input file.
@@ -163,7 +163,7 @@ def dump_info(infile, txtfile, what):
163
163
if len (info ) > 0 :
164
164
print >> txtfile , lang [i ], ":" , info
165
165
166
- ################################################################################
166
+ ###############################################################################
167
167
168
168
def mstime (intime ):
169
169
"""Convert the time given in Microsoft format to a normal time tuple.
@@ -180,7 +180,7 @@ def mstime(intime):
180
180
(num_t & 0xFFFF ) >> 11 , (num_t >> 5 ) & 0x3F , (num_t & 0x1F ) * 2 ,
181
181
0 , 0 , - 1 )
182
182
183
- ################################################################################
183
+ ###############################################################################
184
184
185
185
def do_utime (targetname , atime , mtime ):
186
186
"""Set the access and update date/time of the target.
@@ -199,7 +199,7 @@ def do_utime(targetname, atime, mtime):
199
199
os .utime (targetname ,
200
200
(time .mktime (mstime (atime )), time .mktime (mstime (mtime ))))
201
201
202
- ################################################################################
202
+ ###############################################################################
203
203
204
204
def check_sha1 (sha1 , entry , infile , start , end ):
205
205
"""Check the SHA1 value of the specified range of the input file.
@@ -231,7 +231,7 @@ def check_sha1(sha1, entry, infile, start, end):
231
231
return ret + "wrong (should be " + hexdig + " actual " + \
232
232
found_sha1 .hexdigest () + ")"
233
233
234
- ################################################################################
234
+ ###############################################################################
235
235
236
236
def get_cluster (startclust , offset ):
237
237
"""get the real starting cluster"""
@@ -243,7 +243,7 @@ def get_cluster(startclust, offset):
243
243
# END wxPirs
244
244
return rst
245
245
246
- ################################################################################
246
+ ###############################################################################
247
247
248
248
def fill_directory (infile , txtfile , contents , firstclust , makedir , start ,
249
249
offset ):
@@ -345,7 +345,7 @@ def fill_directory(infile, txtfile, contents, firstclust, makedir, start,
345
345
for _ in xrange (paths [oldpathind ].count ("/" )):
346
346
os .chdir (".." )
347
347
348
- ################################################################################
348
+ ###############################################################################
349
349
350
350
def write_common_part (infile , txtfile , png2stop , start ):
351
351
"""Writes out the common part of PIRS/LIVE and CON files.
@@ -459,7 +459,7 @@ def write_common_part(infile, txtfile, png2stop, start):
459
459
460
460
txtfile .close ()
461
461
462
- ################################################################################
462
+ ###############################################################################
463
463
464
464
def handle_live_pirs (infile , fsize ):
465
465
"""LIVE and PIRS files are archive files.
@@ -498,13 +498,14 @@ def handle_live_pirs(infile, fsize):
498
498
### END wxPirs ###
499
499
write_common_part (infile , txtfile , 0xB000 , start )
500
500
501
- ################################################################################
501
+ ###############################################################################
502
502
503
503
# End of code taken from extract360.py.
504
504
505
505
def getFileOrURL (filename , url ):
506
506
# Check if a file named filename exists on disk.
507
- # If so, return its contents. If not, download it, save it, and return its contents.
507
+ # If so, return its contents. If not, download it, save it, and return its
508
+ # contents.
508
509
try :
509
510
f = open (filename )
510
511
print "Found" , filename , "cached on disk, using local copy"
@@ -544,11 +545,12 @@ def extractPirsFromZip(systemupdate):
544
545
if len (sys .argv ) == 2 :
545
546
target = sys .argv [1 ]
546
547
if not os .path .isfile (target ):
547
- fw = getFileOrURL ("SystemUpdate.zip" , "http://www.xbox.com/system-update-usb" )
548
+ fw = getFileOrURL ("SystemUpdate.zip" ,
549
+ "http://www.xbox.com/system-update-usb" )
548
550
pirs = extractPirsFromZip (fw )
549
551
550
- lang = ["English" , "Japanese" , "German" , "French" , "Spanish" , "Italian" ,
551
- "Korean" , "Chinese" , "Portuguese" ]
552
+ lang = ["English" , "Japanese" , "German" , "French" , "Spanish" ,
553
+ "Italian" , " Korean" , "Chinese" , "Portuguese" ]
552
554
sio = StringIO .StringIO (pirs )
553
555
basename = "FFFE07DF00000001"
554
556
sio .name = basename
0 commit comments