1414
1515class Package (object ):
1616
17- def __init__ (self , inDir , outDir , version = 0 , status = 4 , installDir = "~" ):
17+ def __init__ (self , inDir , outDir , version = "0" , status = 4 , installDir = "~" ):
1818 #List of files to remove on exit
1919 self .version = str (version )
2020 self .status = str (status )
@@ -28,20 +28,46 @@ def __init__(self, inDir, outDir, version=0, status=4, installDir="~"):
2828
2929 def runall (self ):
3030 self .getFileList ()
31+ self .copyTestData ()
3132 self .copy ()
3233 self .makeSetupFile ()
3334 self .preprocess ()
34- if self .test ():
35- self .makeZipFile ()
36- self .cleanup ()
35+ # if self.test():
36+ self .makeZipFile ()
37+ # self.cleanup()
3738
3839
3940 def getExcludeList (self ):
4041 rv = []
4142 for item in exclude :
4243 rv .append (item .replace ("__basedir__" , self .inDir ))
4344 return rv
44-
45+
46+ def copyTestData (self ):
47+ outDir = "tests/testdata"
48+ try :
49+ os .mkdir (outDir )
50+ except OSError :
51+ #the directory already exists
52+ pass
53+ inBaseDir = os .path .abspath (os .path .join (self .inDir , "../testdata" ))
54+ dirWalker = os .walk (inBaseDir )
55+ for (curDir , dirs , files ) in dirWalker :
56+ outDir = os .path .join (self .inDir , "tests" , "testdata" , curDir [len (inBaseDir )+ 1 :])
57+ for dir in dirs [:]:
58+ if self .excludeItem (curDir , dir ):
59+ dirs .remove (dir )
60+ else :
61+ try :
62+ os .mkdir (os .path .join (outDir , dir ))
63+ except OSError :
64+ #the directory already exists
65+ pass
66+ for fn in files [:]:
67+ if not self .excludeItem (curDir , fn ):
68+ newFn = os .path .join (outDir , fn )
69+ shutil .copy (os .path .join (curDir , fn ), newFn )
70+ self .cleanupFiles .append (newFn )
4571 def getFileList (self ):
4672 """Get a list of files to copy"""
4773 fileList = []
@@ -95,7 +121,6 @@ def copy(self):
95121 self .outFiles .append (outPath )
96122 if os .path .isdir (inPath ):
97123 try :
98-
99124 os .mkdir (outPath )
100125 except OSError :
101126 #File may already exist
@@ -191,4 +216,13 @@ def add(self, line):
191216 def move (self , line ):
192217 self .outPath = os .path .abspath (os .path .join (self .inDir ,
193218 line [line .find ("move" )+ 4 :].strip (),
194- self .outPath [len (self .inDir )+ 1 :]))
219+ self .outPath [len (self .inDir )+ 1 :]))
220+ dirName = os .path .dirname (self .outPath )
221+ if not os .path .exists (dirName ):
222+ dirsToCreate = []
223+ while not os .path .exists (dirName ):
224+ dirsToCreate .append (dirName )
225+ dirName = os .path .dirname (dirName )
226+
227+ for item in dirsToCreate [::- 1 ]:
228+ os .mkdir (item )
0 commit comments