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.

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 

References edm.print().

◆ edit_file()

def edmConvertToStreamModule.edit_file (   fileName,
  moduleType,
  moduleName 
)

Definition at line 80 of file edmConvertToStreamModule.py.

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 

References edm.print().

◆ find_all_module_classes()

def edmConvertToStreamModule.find_all_module_classes ( )

Definition at line 12 of file edmConvertToStreamModule.py.

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 

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

◆ find_file_for_module()

def edmConvertToStreamModule.find_file_for_module (   name,
  all_modules 
)

Definition at line 33 of file edmConvertToStreamModule.py.

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 

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

◆ print_lines()

def edmConvertToStreamModule.print_lines (   lines)

Definition at line 28 of file edmConvertToStreamModule.py.

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

References edm.print().

Referenced by find_file_for_module().

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.

digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
join
static std::string join(char **cmd)
Definition: RemoteFile.cc:17
edmConvertToStreamModule.edit_file
def edit_file(fileName, moduleType, moduleName)
Definition: edmConvertToStreamModule.py:80
edmConvertToStreamModule.checkout_package
def checkout_package(fileName)
Definition: edmConvertToStreamModule.py:62
mps_setup.append
append
Definition: mps_setup.py:85
edmConvertToStreamModule.find_file_for_module
def find_file_for_module(name, all_modules)
Definition: edmConvertToStreamModule.py:33
edm::print
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
edmConvertToStreamModule.print_lines
def print_lines(lines)
Definition: edmConvertToStreamModule.py:28
edmConvertToStreamModule.find_all_module_classes
def find_all_module_classes()
Definition: edmConvertToStreamModule.py:12