Package PyFoam :: Package Applications :: Module PackCase
[hide private]
[frames] | no frames]

Source Code for Module PyFoam.Applications.PackCase

 1  """ 
 2  Application-class that implements pyFoamPackCase.py 
 3  """ 
 4   
 5  from PyFoamApplication import PyFoamApplication 
 6   
 7  from PyFoam.RunDictionary.SolutionDirectory import SolutionDirectory 
 8   
9 -class PackCase(PyFoamApplication):
10 - def __init__(self):
11 description=""" 12 Packs a case into a tar-file copying the system, constant and 0-directories. 13 Excludes all .svn-direcotries and all files ending with ~ 14 """ 15 PyFoamApplication.__init__(self,description=description,usage="%prog <case>",interspersed=True,nr=1)
16
17 - def addOptions(self):
18 self.parser.add_option("--last", 19 action="store_true", 20 dest="last", 21 default=False, 22 help="Also add the last time-step") 23 self.parser.add_option("--pyfoam", 24 action="store_true", 25 dest="pyfoam", 26 default=False, 27 help="Add all files starting with PyFoam to the tarfile") 28 self.parser.add_option("--chemkin", 29 action="store_true", 30 dest="chemkin", 31 default=False, 32 help="Also add the Chemkin-directory") 33 self.parser.add_option("--add", 34 action="append", 35 dest="additional", 36 default=[], 37 help="Add all files and directories in the case directory that fit a glob-pattern to the tar (can be used more than once)") 38 self.parser.add_option("--exclude", 39 action="append", 40 dest="exclude", 41 default=[], 42 help="Exclude all files and directories that fit this glob pattern from being added, no matter at level (can be used more than once)") 43 self.parser.add_option("--tarname", 44 action="store", 45 dest="tarname", 46 default=None, 47 help='Name of the tarfile. If unset the name of the case plus ".tgz" will be used')
48
49 - def run(self):
50 sName=self.parser.getArgs()[0] 51 if self.parser.getOptions().tarname!=None: 52 dName=self.parser.getOptions().tarname 53 else: 54 dName=sName+".tgz" 55 if self.parser.getOptions().pyfoam: 56 self.parser.getOptions().additional.append("PyFoam*") 57 58 sol=SolutionDirectory(sName) 59 60 if self.parser.getOptions().chemkin: 61 sol.addToClone("chemkin") 62 63 sol.packCase(dName, 64 last=self.parser.getOptions().last, 65 additional=self.parser.getOptions().additional, 66 exclude=self.parser.getOptions().exclude)
67