CMS 3D CMS Logo

Functions
newFWLiteAna Namespace Reference

Functions

def addBuildPiece (targetBuild, buildPiece)
 
def createBuildFile (buildfile)
 
def extractBuildFilePiece (buildfile, copy, target='dummy')
 

Function Documentation

def newFWLiteAna.addBuildPiece (   targetBuild,
  buildPiece 
)
Adds needed piece for new executable.  Returns true upon
success.

Definition at line 62 of file newFWLiteAna.py.

References split.

62 def addBuildPiece (targetBuild, buildPiece):
63  """Adds needed piece for new executable. Returns true upon
64  success."""
65  backup = targetBuild + ".bak"
66  shutil.copyfile (targetBuild, backup)
67  oldBuild = open (backup, 'r')
68  newBuild = open (targetBuild, 'w')
69  environRE = re.compile (r'<\s*environment')
70  success = False
71  for line in oldBuild:
72  newBuild.write (line)
73  if environRE.search (line):
74  newBuild.write ('\n\n')
75  newBuild.write (buildPiece)
76  success = True
77  oldBuild.close()
78  newBuild.close()
79  return success
80 
81 
82 
def addBuildPiece(targetBuild, buildPiece)
Definition: newFWLiteAna.py:62
def newFWLiteAna.createBuildFile (   buildfile)
Creates a BuildFile if one doesn't already exist

Definition at line 53 of file newFWLiteAna.py.

53 def createBuildFile (buildfile):
54  """Creates a BuildFile if one doesn't already exist"""
55  if os.path.exists (buildfile):
56  return
57  build = open (buildfile, 'w')
58  build.write ("<!-- -*- XML -*- -->\n\n<environment>\n\n</environment>\n")
59  build.close()
60 
61 
def createBuildFile(buildfile)
Definition: newFWLiteAna.py:53
def newFWLiteAna.extractBuildFilePiece (   buildfile,
  copy,
  target = 'dummy' 
)
Extracts necessary piece of the buildfile.  Returns empty
string if not found.

Definition at line 11 of file newFWLiteAna.py.

11 def extractBuildFilePiece (buildfile, copy, target = 'dummy'):
12  """Extracts necessary piece of the buildfile. Returns empty
13  string if not found."""
14  try:
15  build = open (buildfile, 'r')
16  except:
17  raise RuntimeError("Could not open BuildFile '%s' for reading. Aboring." \
18  % buildfile)
19  # make my regex
20  startBinRE = re.compile (r'<\s*bin\s+name=(\S+)')
21  endBinRE = re.compile (r'<\s*/bin>')
22  exeNameRE = re.compile (r'(\w+)\.exe')
23  ccName = os.path.basename (copy)
24  match = ccRE.match (ccName)
25  if match:
26  ccName = match.group (1)
27  retval = ''
28  foundBin = False
29  for line in build:
30  # Are we in the middle of copying what we need?
31  if foundBin:
32  retval += line
33  # Are we copying what we need and reach the end?
34  if foundBin and endBinRE.search (line):
35  # all done
36  break
37  # Is this the start of a bin line with the right name?
38  match = startBinRE.search (line)
39  if match:
40  # strip of .exe if it's there
41  exeName = match.group (1)
42  exeMatch = exeNameRE.search (exeName)
43  if exeMatch:
44  exeName = exeMatch.group (1)
45  if exeName == ccName:
46  foundBin = True
47  line = re.sub (exeName, target, line)
48  retval = line
49  build.close()
50  return retval
51 
52 
def extractBuildFilePiece(buildfile, copy, target='dummy')
Definition: newFWLiteAna.py:11