3 import os, zipfile, md5, pdb
7 files = os.listdir( path )
9 if ( i[-4:] !=
'.pk4' ):
17 zippy = zipfile.ZipFile( pak )
18 files += zippy.namelist()
28 zippy = zipfile.ZipFile( os.path.join( path, fname ) )
29 files += zippy.namelist()
44 zippy = zipfile.ZipFile( os.path.join( path, fname ) )
45 for file
in zippy.namelist():
46 if ( ret.has_key( file ) ):
48 data = zippy.read( file )
51 ret[ file ] = ( fname, m.hexdigest() )
65 for file
in pak_md5.keys():
66 if ( file[-1] ==
'/' ):
68 path = os.path.join( base_path, file )
70 ret =
ifind( base_path, file )
72 not_found.append( file )
75 case_table[ path ] = ret[ 1 ]
76 path = os.path.join( base_path, ret[ 1 ] )
83 raise "internal error: ifind success but later read failed"
84 not_found.append( file )
88 if ( m.hexdigest() != pak_md5[ file ][ 1 ] ):
90 updated.append( file )
91 return ( updated, not_found, case_table )
100 test_path = os.path.join( path, i )
101 if ( os.path.isfile( test_path ) ):
103 elif ( os.path.isdir( test_path ) ):
107 return ( files, dirs, missing )
111 zippy = zipfile.ZipFile( pak,
'w', zipfile.ZIP_DEFLATED )
113 source_path = os.path.join( path, i )
115 zippy.write( source_path, i )
136 tmp.append( i.lower() )
140 check_files = f.readlines()
143 for i
in check_files:
145 s = s.replace(
'\n',
'' )
146 s = s.replace(
'\r',
'' )
152 for i
in check_files:
153 if ( i[ :4 ] ==
'dds/' ):
154 if ( i[ len(i)-4: ] ==
'.tga' ):
155 i = i[ :-4 ] +
'.dds'
156 elif ( i[ len(i)-4: ] !=
'.dds' ):
157 print 'File not understood: ' + i
163 print 'Not found: ' + i
165 elif ( i[ len(i)-4: ] ==
'.wav' ):
166 i = i[ :-4 ] +
'.ogg'
170 print 'Not found: ' + i
172 missing.append( i[ :-4 ] +
'.wav' )
173 elif ( i[ len(i)-4: ] ==
'.tga' ):
178 print 'Not found: ' + i
180 i =
'dds/' + i[ :-4 ] +
'.dds'
181 print 'Add dds : ' + i
187 print 'Not found: ' + i
189 return ( missing, bad )
195 path = os.path.normpath( path )
196 path = os.path.normcase( path )
198 if ( os.path.exists( path ) ):
199 return (
True, path )
202 while ( len( head ) ):
203 ( head, chunk ) = os.path.split( head )
204 components.append( chunk )
208 for root, dirs, files
in os.walk( base, topdown =
True ):
209 if ( level < len( components ) - 1 ):
213 if (
not i.lower() == components[ level ].lower() ):
219 if ( len( dirs ) != 1 ):
221 return (
False, root[ len( base ) + 1: ] )
225 if ( i.lower() == components[-1].lower() ):
226 return (
True, os.path.join( root, i )[ len( base ) + 1: ] )
227 return (
False, root[ len( base ) + 1: ] )
235 ret =
ifind( base, i )
237 cased.append( ret[ 1 ] )
240 return [ cased, notfound ]
def status_files_for_path
def check_files_against_build