doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
prepare.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # prepare content for SDK
3 
4 import shutil, os, stat
5 
6 media = '../../../../../media-sdk'
7 media = os.path.abspath( media )
8 
9 try:
10  shutil.rmtree( 'Doom3_SDK' )
11 except:
12  print 'Could not remove Doom3_SDK'
13  pass
14 
15 # copy source from list
16 f = open( 'source.list' )
17 l = [ s[:-1] for s in f.readlines() ]
18 f.close()
19 for p in l:
20  sp = os.path.join( '../../..', p )
21  dp = os.path.join( 'Doom3_SDK/src', p )
22  try:
23  os.makedirs( os.path.dirname( dp ) )
24  except:
25  pass
26  print 'cp ' + sp + ' -> ' + dp
27  shutil.copy( sp, dp )
28 
29 # copy explicit media content over
30 for root, dirs, files in os.walk( media ):
31  if '.svn' in dirs:
32  dirs.remove( '.svn' )
33  for f in files:
34  sp = os.path.join( root, f )
35  dp = os.path.join( 'Doom3_SDK', sp[ len( media ) + 1: ] )
36  try:
37  os.makedirs( os.path.dirname( dp ) )
38  except:
39  pass
40  print 'cp ' + sp + ' -> ' + dp
41  shutil.copy( sp, dp )
42 
43 def makewritable( path ):
44  for root, dirs, files in os.walk( path ):
45  for f in files:
46  os.chmod( os.path.join( root, f ), stat.S_IWRITE )
47 
48 # cleanup '.svn'
49 for root, dirs, files in os.walk( 'Doom3_SDK' ):
50  if '.svn' in dirs:
51  print 'remove ' + os.path.join( root, '.svn' )
52  # SVN sets readonly on some files, which causes rmtree failure on win32
53  makewritable( os.path.join( root, '.svn' ) )
54  shutil.rmtree( os.path.join( root, '.svn' ) )
55  dirs.remove( '.svn' )
def makewritable
Definition: prepare.py:43