CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 62 of file edmConvertToStreamModule.py.

References print().

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

Definition at line 80 of file edmConvertToStreamModule.py.

References print().

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

Definition at line 12 of file edmConvertToStreamModule.py.

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

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

Definition at line 33 of file edmConvertToStreamModule.py.

References print(), and print_lines().

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

Definition at line 28 of file edmConvertToStreamModule.py.

References print().

Referenced by find_file_for_module().

28 
29 def print_lines(lines):
30  for l in lines:
31  if len(l)>0:
32  print(" ",l)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47

Variable Documentation

tuple edmConvertToStreamModule.all_mods_info = find_all_module_classes()

Definition at line 124 of file edmConvertToStreamModule.py.

int edmConvertToStreamModule.kFilter = 1

Definition at line 10 of file edmConvertToStreamModule.py.

int edmConvertToStreamModule.kProducer = 0

Definition at line 9 of file edmConvertToStreamModule.py.

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

Definition at line 121 of file edmConvertToStreamModule.py.