CMS 3D CMS Logo

Functions | Variables
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)
 

Variables

 all_mods_info
 
 f
 
 kFilter
 
 kProducer
 
 modules
 
 t
 

Function Documentation

◆ checkout_package()

def edmConvertToStreamModule.checkout_package (   fileName)

Definition at line 62 of file edmConvertToStreamModule.py.

References print().

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") 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 
79 
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47

◆ edit_file()

def edmConvertToStreamModule.edit_file (   fileName,
  moduleType,
  moduleName 
)

Definition at line 80 of file edmConvertToStreamModule.py.

References 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 
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def edit_file(fileName, moduleType, moduleName)

◆ find_all_module_classes()

def edmConvertToStreamModule.find_all_module_classes ( )

Definition at line 12 of file edmConvertToStreamModule.py.

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

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:19

◆ find_file_for_module()

def edmConvertToStreamModule.find_file_for_module (   name,
  all_modules 
)

Definition at line 33 of file edmConvertToStreamModule.py.

References print(), and print_lines().

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)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47

◆ print_lines()

def edmConvertToStreamModule.print_lines (   lines)

Definition at line 28 of file edmConvertToStreamModule.py.

References 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 
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47

Variable Documentation

◆ all_mods_info

edmConvertToStreamModule.all_mods_info

Definition at line 124 of file edmConvertToStreamModule.py.

◆ f

edmConvertToStreamModule.f

Definition at line 128 of file edmConvertToStreamModule.py.

◆ kFilter

edmConvertToStreamModule.kFilter

Definition at line 10 of file edmConvertToStreamModule.py.

◆ kProducer

edmConvertToStreamModule.kProducer

Definition at line 9 of file edmConvertToStreamModule.py.

◆ modules

edmConvertToStreamModule.modules

Definition at line 121 of file edmConvertToStreamModule.py.

◆ t

edmConvertToStreamModule.t

Definition at line 128 of file edmConvertToStreamModule.py.