test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions | Variables
edmConvertToStreamModule Namespace Reference

Functions

def checkout_package
 
def edit_file
 
def find_all_module_classes
 
def find_file_for_module
 
def print_lines
 

Variables

tuple all_mods_info = find_all_module_classes()
 
int kFilter = 1
 
int kProducer = 0
 
list modules = sys.argv[1:]
 

Function Documentation

def edmConvertToStreamModule.checkout_package (   fileName)

Definition at line 61 of file edmConvertToStreamModule.py.

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

Definition at line 79 of file edmConvertToStreamModule.py.

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

Definition at line 11 of file edmConvertToStreamModule.py.

References bitset_utilities.append(), cmsPerfStripChart.dict, and join().

11 
13  s = set()
14  found = subprocess.check_output(["git","grep", "class *[A-Za-z0-9_<>]* *: *public "])
15  s.update(found.split("\n"))
16 
17  ret = dict()
18  for l in s:
19  parts = l.split(":")
20  if len(parts)>2:
21  file = parts[0]
22  name = parts[1]
23  name = name[name.find("class")+5:].strip()
24  ret.setdefault(name,[]).append((":".join(parts[2:]), file))
25 
26  return ret
boost::dynamic_bitset append(const boost::dynamic_bitset<> &bs1, const boost::dynamic_bitset<> &bs2)
this method takes two bitsets bs1 and bs2 and returns result of bs2 appended to the end of bs1 ...
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().

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

Definition at line 27 of file edmConvertToStreamModule.py.

Referenced by find_file_for_module().

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

Variable Documentation

tuple edmConvertToStreamModule.all_mods_info = find_all_module_classes()

Definition at line 123 of file edmConvertToStreamModule.py.

int edmConvertToStreamModule.kFilter = 1

Definition at line 9 of file edmConvertToStreamModule.py.

int edmConvertToStreamModule.kProducer = 0

Definition at line 8 of file edmConvertToStreamModule.py.

list edmConvertToStreamModule.modules = sys.argv[1:]

Definition at line 120 of file edmConvertToStreamModule.py.

Referenced by HcalIsoTrkAnalyzer.analyze(), IsoTrig.analyze(), GeometricDetLoader.beginRun(), PGeometricDetBuilder.beginRun(), GeometricSearchTrackerBuilder.build(), HLTConfigData.extract(), FEDBadModuleFilter.FEDBadModuleFilter(), edm::Schedule.fillModuleAndConsumesInfo(), AlCaHBHEMuonFilter.filter(), AlCaIsoTracksFilter.filter(), SiPixelActionExecutor.GetBladeSubdirs(), egHLT::trigTools.getL1SeedFilterOfPath(), ZIterativeAlgorithmWithFit.getWeight(), LogErrorEventFilter.LogErrorEventFilter(), Phase2TrackerCablingCfgESSource.make(), HLTMuonValidator.moduleLabels(), HLTMuonOfflineAnalyzer.moduleLabels(), edm::EDConsumerBase.modulesWhoseProductsAreConsumed(), MTVHistoProducerAlgoForTracker.MTVHistoProducerAlgoForTracker(), edm::service::PrescaleService.postBeginJob(), FastTimerService.preStreamBeginRun(), SiStripDetCabling.printSummary(), FastTimerService.queryModuleTimeByLabel(), and StripCPE.StripCPE().