CMS 3D CMS Logo

Functions
edmConvertToStreamModule Namespace Reference

Functions

def checkout_package (fileName)
 
def edit_file (fileName, moduleType, moduleName)
 
def find_all_module_classes ()
 
def find_file_for_module (name, all_modules)
 
def print_lines (lines)
 

Function Documentation

def edmConvertToStreamModule.checkout_package (   fileName)

Definition at line 61 of file edmConvertToStreamModule.py.

Referenced by edit_file().

61 def checkout_package(fileName):
62  c = fileName.split("/")
63  print "checking out "+c[0]+"/"+c[1]
64  sparce_checkout = ".git/info/sparse-checkout"
65  f = open(sparce_checkout,"r")
66  linesInSparse = set(f.readlines())
67  f.close()
68  linesInSparse.add(c[0]+"/"+c[1]+"\n")
69 
70  f = open(sparce_checkout+"_new","w")
71  for l in linesInSparse:
72  if l:
73  f.write(l)
74  f.close()
75  shutil.move(sparce_checkout,sparce_checkout+"_old")
76  shutil.move(sparce_checkout+"_new",sparce_checkout)
77  subprocess.call(["git","read-tree","-mu","HEAD"])
78 
def edmConvertToStreamModule.edit_file (   fileName,
  moduleType,
  moduleName 
)

Definition at line 79 of file edmConvertToStreamModule.py.

References checkout_package(), find_all_module_classes(), and find_file_for_module().

79 def edit_file(fileName,moduleType,moduleName):
80  print " editting "+fileName
81  fOld = open(fileName)
82  fNew = open(fileName+"_NEW","w")
83 
84  lookingForChanges = True
85  addedInclude = False
86  for l in fOld.readlines():
87  if lookingForChanges:
88  if -1 != l.find("#include"):
89  if moduleType == kProducer:
90  if -1 != l.find("FWCore/Framework/interface/EDProducer.h"):
91  l='#include "FWCore/Framework/interface/stream/EDProducer.h"\n'
92  addedInclude = True
93  elif moduleType == kFilter:
94  if -1 != l.find("FWCore/Framework/interface/EDFilter.h"):
95  l = '#include "FWCore/Framework/interface/stream/EDFilter.h"\n'
96  addedInclude = True
97  elif -1 != l.find("class"):
98  if -1 != l.find(moduleName):
99  if moduleType == kProducer:
100  if -1 != l.find("edm::EDProducer"):
101  l = l.replace("edm::EDProducer","edm::stream::EDProducer<>")
102  lookingForChanges = False
103  elif moduleType == kFilter:
104  if -1 != l.find("edm::EDFilter"):
105  l=l.replace("edm::EDFilter","edm::stream::EDFilter<>")
106  fNew.write(l)
107  if -1 != l.find(" beginJob("):
108  print " WARNING: beginJob found but not supported by stream"
109  print " ",l
110  if -1 != l.find(" endJob("):
111  print " WARNING: endJob found but not supported by stream"
112  print " ",l
113  if not addedInclude:
114  print " WARNING: did not write include into "+fileName
115  fNew.close()
116  fOld.close()
117  shutil.move(fileName,fileName+"_OLD")
118  shutil.move(fileName+"_NEW",fileName)
119 
def edit_file(fileName, moduleType, moduleName)
def edmConvertToStreamModule.find_all_module_classes ( )

Definition at line 11 of file edmConvertToStreamModule.py.

References mps_setup.append, cmsPerfStripChart.dict, join(), and digitizers_cfi.strip.

Referenced by edit_file().

12  s = set()
13  found = subprocess.check_output(["git","grep", "class *[A-Za-z0-9_<>]* *: *public "])
14  s.update(found.split("\n"))
15 
16  ret = dict()
17  for l in s:
18  parts = l.split(":")
19  if len(parts)>2:
20  file = parts[0]
21  name = parts[1]
22  name = name[name.find("class")+5:].strip()
23  ret.setdefault(name,[]).append((":".join(parts[2:]), file))
24 
25  return ret
26 
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def edmConvertToStreamModule.find_file_for_module (   name,
  all_modules 
)

Definition at line 32 of file edmConvertToStreamModule.py.

References print_lines().

Referenced by edit_file().

32 def find_file_for_module(name,all_modules):
33  if name in all_modules:
34  info = all_modules[name]
35  if len(info) != 1:
36  print "ERROR: more than one declaration for '"+name+"'\n"
37  for inherits,file in info:
38  print " ",file, inherits
39  return (None,None)
40  inherits,file = info[0]
41  if -1 != inherits.find("edm::EDProducer"):
42  type = kProducer
43  elif -1 != inherits.find("edm::EDFilter"):
44  type = kFilter
45  else:
46  print "ERROR: class '"+name+"' does not directly inherit from EDProducer or EDFilter\n "+inherits
47  return (None,None)
48  return (file,type)
49  print "ERROR: did not find a standard class declaration for '"+name+"'"
50  try:
51  found = subprocess.check_output(["git","grep", "class *"+name+" *:"])
52  print_lines( found.split("\n") )
53  except:
54  try:
55  found = subprocess.check_output(["git","grep", "typedef *.* "+name])
56  print_lines( found.split("\n") )
57  except:
58  pass
59  return (None,None)
60 
def find_file_for_module(name, all_modules)
def edmConvertToStreamModule.print_lines (   lines)

Definition at line 27 of file edmConvertToStreamModule.py.

Referenced by find_file_for_module().

27 def print_lines(lines):
28  for l in lines:
29  if len(l)>0:
30  print " ",l
31