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 62 of file edmConvertToStreamModule.py.

References edm.print().

Referenced by edit_file().

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"])
79 
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def edmConvertToStreamModule.edit_file (   fileName,
  moduleType,
  moduleName 
)

Definition at line 80 of file edmConvertToStreamModule.py.

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

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)
120 
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def edit_file(fileName, moduleType, moduleName)
def edmConvertToStreamModule.find_all_module_classes ( )

Definition at line 12 of file edmConvertToStreamModule.py.

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

Referenced by edit_file().

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
27 
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def edmConvertToStreamModule.find_file_for_module (   name,
  all_modules 
)

Definition at line 33 of file edmConvertToStreamModule.py.

References edm.print(), and print_lines().

Referenced by edit_file().

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)
61 
def find_file_for_module(name, all_modules)
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def edmConvertToStreamModule.print_lines (   lines)

Definition at line 28 of file edmConvertToStreamModule.py.

References edm.print().

Referenced by find_file_for_module().

28 def print_lines(lines):
29  for l in lines:
30  if len(l)>0:
31  print(" ",l)
32 
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66