CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 63 of file newFWLiteAna.py.

References edm.print(), and split.

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

Definition at line 54 of file newFWLiteAna.py.

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

Definition at line 12 of file newFWLiteAna.py.

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