CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
pkg.AbstractPkg Class Reference
Inheritance diagram for pkg.AbstractPkg:

Public Member Functions

def __init__ (self, config=None)
 
def generate (self)
 
def get_kwds (self)
 
def parse_etags (self, line)
 
def print_etags (self)
 
def print_tags (self)
 
def tmpl_etags (self)
 
def tmpl_tags (self)
 
def write (self, fname, tmpl_name, kwds)
 

Public Attributes

 author
 
 config
 
 date
 
 debug
 
 not_in_dir
 
 pname
 
 tdir
 
 tmpl
 
 working_dir
 

Detailed Description

AbstractPkg takes care how to generate code from template/PKG
package area. The PKG can be any directory which may include
any types of files, e.g. C++ (.cc), python (.py), etc.
This class relies on specific logic which we outline here:

    - each template may use tags defined with double underscores
      enclosure, e.g. __class__, __record__, etc.
    - each template may have example tags, such tags should
      start with @example_. While processing template user may
      choose to strip them off or keep the code behind those tags
    - in addition user may specify pure python code which can
      operate with user defined tags. This code snipped should
      be enclosed with #python_begin and #python_end lines
      which declares start and end of python block

Definition at line 22 of file pkg.py.

Constructor & Destructor Documentation

◆ __init__()

def pkg.AbstractPkg.__init__ (   self,
  config = None 
)

Definition at line 39 of file pkg.py.

39  def __init__(self, config=None):
40  super(AbstractPkg, self).__init__()
41  if not config:
42  self.config = {}
43  else:
44  self.config = config
45  self.pname = self.config.get('pname', None)
46  self.tmpl = self.config.get('tmpl', None)
47  self.debug = self.config.get('debug', 0)
48  self.tdir = template_directory()
49  self.author = user_info(self.config.get('author', None))
50  self.date = time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime())
51  self.not_in_dir = self.config.get('not_in_dir', [])
52  self.working_dir = self.config.get('working_dir')
53 
def __init__(self, dataset, job_number, job_id, job_name, isDA, isMC, applyBOWS, applyEXTRACOND, extraconditions, runboundary, lumilist, intlumi, maxevents, gt, allFromGT, alignmentDB, alignmentTAG, apeDB, apeTAG, bowDB, bowTAG, vertextype, tracktype, refittertype, ttrhtype, applyruncontrol, ptcut, CMSSW_dir, the_dir)
def user_info(ainput=None)
Definition: utils.py:112
def template_directory()
Definition: utils.py:23

Member Function Documentation

◆ generate()

def pkg.AbstractPkg.generate (   self)

Definition at line 164 of file pkg.py.

References AllInOneConfig::Options.config, geometry.Alignables.config, pkg.AbstractPkg.config, cscdqm::EventProcessorMutex.config, CSCOfflineClient.config, CSCMonitorModule.config, cscdqm::Collection.config, cscdqm::Dispatcher.config, cscdqm::EventProcessor.config, HcalOfflineHarvesting.debug, HcalOnlineHarvesting.debug, HFRaddamTask.debug, LaserTask.debug, NoCQTask.debug, PedestalTask.debug, QIE10Task.debug, QIE11Task.debug, RecHitTask.debug, UMNioTask.debug, ZDCTask.debug, RawTask.debug, TPTask.debug, DigiTask.debug, LEDTask.debug, DTDigiToRawModule.debug, CSCRPCData.debug, CSCTMBScope.debug, DTDigiToRaw.debug, ALIUtils.debug, DTSegmentsTask.debug, crabFunctions.CrabController.debug, DTOccupancyEfficiency.debug, CSCGEMData.debug, DTDDUUnpacker.debug, pkg.AbstractPkg.debug, DTTTrigCorrectionFirst.debug, CSCDCCEventData.debug, DTT0CalibrationRMS.debug, DTTTrigWriter.debug, DTTPDeadWriter.debug, PPSAlignmentConfigurationESSource.debug, DTOccupancyPoint.debug, DTNoiseComputation.debug, DTROS25Unpacker.debug, util.rrapi.RRApi.debug, DTT0Calibration.debug, DTTTrigSyncT0Only.debug, DTEfficiencyTask.debug, CSCDDUEventData.debug, DTTTrigCalibration.debug, DTRunConditionVar.debug, DTChamberEfficiencyTask.debug, HCALResponse.debug, DTChamberEfficiency.debug, FCDTask.debug, CSCDCCUnpacker.debug, CSCComparatorData.debug, DTTMax.debug, DTVDriftCalibration.debug, DTTTrigSyncFromDB.debug, CSCTMBData.debug, DTTTrigSyncTOFCorr.debug, CSCEventData.debug, BaseParticlePropagator.debug, CSCTMBHeader.debug, CSCALCTTrailer.debug, CSCALCTHeader.debug, crabFunctions.CrabTask.debug, spr.find(), pkg.AbstractPkg.get_kwds(), join(), pkg.AbstractPkg.not_in_dir, pkg.AbstractPkg.pname, print(), python.rootplot.root2matplotlib.replace(), submitPVValidationJobs.split(), pkg.AbstractPkg.tdir, pkg.AbstractPkg.tmpl, pkg.AbstractPkg.working_dir, edm::ThreadSafeOutputFileStream.write(), Json::Writer.write(), AlignmentCorrelationsIO.write(), edm::RunAuxiliary.write(), FRDOutputModule.write(), l1ct::HadCaloObjEmu.write(), edm::TestGlobalOutput.write(), edm::TestLimitedOutput.write(), edm::RunLumiEntryInfo.write(), ExTestEcalChannelStatusAnalyzer.write(), AlignmentCorrelationsIORoot.write(), edm::LuminosityBlockAuxiliary.write(), SurveyOutput.write(), HcalSiPMCharacteristicsPopConAnalyzer.write(), HcalSiPMParametersPopConAnalyzer.write(), HcalTPChannelParametersPopConAnalyzer.write(), HcalTPParametersPopConAnalyzer.write(), FileBlob.write(), HcalFrontEndMapPopConAnalyzer.write(), HcalPFCutsPopConAnalyzer.write(), edm::EventEntryInfo.write(), CastorPedestalsPopConAnalyzer.write(), HcalLutMetadataPopConAnalyzer.write(), HcalQIEDataPopConAnalyzer.write(), HcalQIETypesPopConAnalyzer.write(), HcalRespCorrsPopConAnalyzer.write(), HcalTimeCorrsPopConAnalyzer.write(), HcalElectronicsMapPopConAnalyzer.write(), HcalTimingParamsPopConAnalyzer.write(), HcalZSThresholdsPopConAnalyzer.write(), CastorSaturationCorrsPopConAnalyzer.write(), HcalPFCorrsPopConAnalyzer.write(), HcalRecoParamsPopConAnalyzer.write(), HcalGainWidthsPopConAnalyzer.write(), CastorChannelQualityPopConAnalyzer.write(), HcalValidationCorrsPopConAnalyzer.write(), CastorElectronicsMapPopConAnalyzer.write(), CastorGainsPopConAnalyzer.write(), CastorGainWidthsPopConAnalyzer.write(), CastorPedestalWidthsPopConAnalyzer.write(), CastorQIEDataPopConAnalyzer.write(), CastorRecoParamsPopConAnalyzer.write(), HcalChannelQualityPopConAnalyzer.write(), HcalDcsMapPopConAnalyzer.write(), HcalDcsValuesPopConAnalyzer.write(), HcalFlagHFDigiTimeParamsPopConAnalyzer.write(), HcalGainsPopConAnalyzer.write(), HcalL1TriggerObjectsPopConAnalyzer.write(), HcalLongRecoParamsPopConAnalyzer.write(), HcalLUTCorrsPopConAnalyzer.write(), HcalMCParamsPopConAnalyzer.write(), HcalPedestalsPopConAnalyzer.write(), HcalPedestalWidthsPopConAnalyzer.write(), HcalZDCLowGainFractionsPopConAnalyzer.write(), edm::TestOneOutput.write(), MultiFileBlob.write(), personalPlayback.Applet.write(), SiPixelConfigWriter.write(), SiStripConfigWriter.write(), edm::AsciiOutputModule.write(), l1ct::EmCaloObjEmu.write(), edm::CompactEventAuxiliaryVector::CompactEventAuxiliaryExtra.write(), AlignmentParametersIO.write(), AlignmentUserVariablesIO.write(), popcon::PopConAnalyzer< S >.write(), edm::ProductProvenance.write(), Json::FastWriter.write(), edm::TestOutputWithGetterOfProducts.write(), edm::TestOutputWithGetterOfProductsGlobal.write(), edm::EventEntryDescription.write(), edm::TestOutputWithGetterOfProductsLimited.write(), popcon::PopCon.write(), edm::ModuleDescription.write(), edm::ProvenanceCheckerOutputModule.write(), edm::GetProductCheckerOutputModule.write(), RawEventOutputModuleForBU< Consumer >.write(), edm::Parentage.write(), ProduceDropBoxMetadata.write, l1ct::TkObjEmu.write(), electronCompare.flushfile.write(), l1t::LUT.write(), edm::StableProvenance.write(), electronStore.flushfile.write(), MuonAlignmentOutputXML.write(), XMLDOMBlock.write(), Benchmark.write(), edmplugin::CacheParser.write(), edm::EventAuxiliary.write(), l1ct::MuObjEmu.write(), CSCPairResidualsConstraint.write(), edm::BranchDescription.write(), uploads.output.write(), Json::StyledWriter.write(), edm::Provenance.write(), l1ct::PFChargedObjEmu.write(), edm::CompactEventAuxiliaryVector::CompactEventAuxiliary.write(), ztee.GZipLog.write(), amc13::Packet.write(), l1ct::PFNeutralObjEmu.write(), MuonResidualsTwoBin.write(), edmtest::TableTestOutputModule.write(), l1ct::PFRegionEmu.write(), DTWorkflow.DTWorkflow.write(), pkg.AbstractPkg.write(), l1ct::PuppiObjEmu.write(), Json::StyledStreamWriter.write(), edm::ProductResolverBase.write(), XMLProcessor.write(), l1ct::EGIsoObjEmu.write(), evf::GlobalEvFOutputModule.write(), esMonitoring.LineHistoryEnd.write(), MuonResidualsFitter.write(), esMonitoring.LineHistoryStart.write(), l1ct::EGIsoEleObjEmu.write(), StraightTrackAlignment::RPSetPlots.write(), DQMRootOutputModule.write(), betterConfigParser.BetterConfigParser.write(), edm::core::OutputModuleCore.write(), l1ct::PVObjEmu.write(), l1ct::RawInputs.write(), querying.connection.write(), l1ct::RegionizerDecodedInputs.write(), l1ct::PFInputRegion.write(), l1ct::OutputRegion.write(), l1ct::OutputBoard.write(), and l1ct::Event.write().

164  def generate(self):
165  "Generate package templates in a given directory"
166 
167  # keep current location, since generate will switch directories
168  cdir = os.getcwd()
169 
170  # read from configutation which template files to create
171  tmpl_files = self.config.get('tmpl_files', 'all')
172 
173  # setup keyword arguments which we'll pass to write method
174  kwds = self.get_kwds()
175 
176  # create template package dir and cd into it
177  if tmpl_files == 'all' and self.tmpl not in self.not_in_dir:
178  if os.path.isdir(self.pname):
179  msg = "Can't create package '%s'\n" % self.pname
180  msg += "Directory %s is already exists" % self.pname
181  print(msg)
182  sys.exit(1)
183  os.makedirs(self.pname)
184  os.chdir(self.pname)
185 
186  # read directory driver information and create file list to generate
187  sdir = os.path.join(self.tdir, self.tmpl)
188  sources = [s for s in os.listdir(sdir) \
189  if s != 'Driver.dir' and s.find('~') == -1]
190  driver = os.path.join(sdir, 'Driver.dir')
191  if os.path.isfile(driver):
192  sources = [s.replace('\n', '') for s in open(driver, 'r').readlines()]
193  if 'CVS' in sources:
194  sources.remove('CVS')
195 
196  # special case of Skeleton, which requires to generate only given
197  # file type if self.pname has extension of that type
198  names = set([s.split('.')[0] for s in sources])
199  if names == set(['Skeleton']):
200  if self.pname.find('.') != -1:
201  _, ext = os.path.splitext(self.pname)
202  sources = [s for s in sources if s.rfind(ext) != -1]
203  self.pname = self.pname.replace(ext, '')
204  kwds = self.get_kwds()
205  if not sources:
206  msg = 'Unable to find skeleton for extension "%s"' % ext
207  print(msg)
208  sys.exit(1)
209  bdir = os.environ.get('CMSSW_BASE', '')
210  dirs = os.getcwd().replace(bdir, '').split('/')
211  ldir = os.getcwd().split('/')[-1]
212  idir = ''
213  subsys = kwds['__subsys__']
214  pkgname = kwds['__pkgname__']
215  if sources == ['Skeleton.cc', 'Skeleton.h']:
216  if ldir == 'interface' and os.getcwd().find(bdir) != -1:
217  idir = '%s/%s/interface/' % (subsys, pkgname)
218  # run within some directory of the Sybsystem/Pkg area
219  # and only for mkskel <file>.cc
220  elif sources == ['Skeleton.cc'] and \
221  len(dirs) == 5 and dirs[0] == '' and dirs[1] == 'src':
222  idir = '%s/%s/interface/' % (subsys, pkgname)
223  elif sources == ['Skeleton.h'] and ldir == 'interface' and \
224  len(dirs) == 5 and dirs[0] == '' and dirs[1] == 'src':
225  idir = '%s/%s/interface/' % (subsys, pkgname)
226  kwds.update({'__incdir__': idir})
227 
228  # loop over source files, create dirs as necessary and generate files
229  # names for writing templates
230  gen_files = []
231  for src in sources:
232  if tmpl_files != 'all':
233  fname, ext = os.path.splitext(src)
234  if tmpl_files != ext:
235  continue
236  #also reject if this is the wrong directory
237  if self.working_dir and src.split('/')[-2] != self.working_dir:
238  continue
239  src = src.split('/')[-1]
240  if self.debug:
241  print("Read", src)
242  items = src.split('/')
243  if items[-1] == '/':
244  items = items[:-1]
245  tname = items[-1] # template file name
246  tmpl_name = os.path.join(sdir, items[-1]) # full tmpl file name
247  if os.path.isfile(tmpl_name):
248  ftype = 'file'
249  else:
250  ftype = 'dir'
251  name2gen = src # new file we'll create
252  if items[-1] == 'testBuildFile.xml':
253  name2gen = '/'.join(src.split('/')[:-1])+'/BuildFile.xml'
254  if -1 !=tname.split('.')[0].find(self.tmpl): # need to substitute
255  name2gen = name2gen.replace(self.tmpl, self.pname)
256  name2gen = os.path.join(os.getcwd(), name2gen)
257  if self.debug:
258  print("Create", name2gen)
259  if ftype == 'dir':
260  if not os.path.isdir(name2gen):
261  os.makedirs(name2gen)
262  continue # we're done with dir
263  fdir = os.path.dirname(name2gen)
264  if not os.path.isdir(fdir):
265  os.makedirs(fdir)
266  self.write(name2gen, tmpl_name, kwds)
267  gen_files.append(name2gen.split('/')[-1])
268  if tmpl_files == 'all' and self.tmpl not in self.not_in_dir:
269  msg = 'New package "%s" of %s type is successfully generated' \
270  % (self.pname, self.tmpl)
271  else:
272  msg = 'Generated %s file' % ', '.join(gen_files)
273  if len(gen_files) > 1:
274  msg += 's'
275  print(msg)
276  # return back where we started
277  os.chdir(cdir)
278  if msg.find('New package') != -1:
279  tree(self.pname)
280 
def replace(string, replacements)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
void generate(uint32_t const nbins, float const *initValues, std::vector< float > &values)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
static std::string join(char **cmd)
Definition: RemoteFile.cc:19
Definition: tree.py:1

◆ get_kwds()

def pkg.AbstractPkg.get_kwds (   self)

Definition at line 147 of file pkg.py.

References pkg.AbstractPkg.author, AllInOneConfig::Options.config, geometry.Alignables.config, pkg.AbstractPkg.config, cscdqm::EventProcessorMutex.config, CSCOfflineClient.config, CSCMonitorModule.config, cscdqm::Collection.config, cscdqm::Dispatcher.config, cscdqm::EventProcessor.config, pkg.AbstractPkg.date, HcalOfflineHarvesting.debug, HcalOnlineHarvesting.debug, HFRaddamTask.debug, LaserTask.debug, NoCQTask.debug, PedestalTask.debug, QIE10Task.debug, QIE11Task.debug, RecHitTask.debug, UMNioTask.debug, ZDCTask.debug, RawTask.debug, TPTask.debug, DigiTask.debug, LEDTask.debug, DTDigiToRawModule.debug, CSCRPCData.debug, DTDigiToRaw.debug, CSCTMBScope.debug, ALIUtils.debug, crabFunctions.CrabController.debug, DTSegmentsTask.debug, DTOccupancyEfficiency.debug, CSCGEMData.debug, DTDDUUnpacker.debug, pkg.AbstractPkg.debug, DTTTrigCorrectionFirst.debug, CSCDCCEventData.debug, DTT0CalibrationRMS.debug, DTTTrigWriter.debug, DTTPDeadWriter.debug, PPSAlignmentConfigurationESSource.debug, DTOccupancyPoint.debug, DTNoiseComputation.debug, DTROS25Unpacker.debug, util.rrapi.RRApi.debug, DTT0Calibration.debug, DTTTrigSyncT0Only.debug, DTEfficiencyTask.debug, DTTTrigCalibration.debug, CSCDDUEventData.debug, DTRunConditionVar.debug, DTChamberEfficiencyTask.debug, HCALResponse.debug, DTChamberEfficiency.debug, FCDTask.debug, CSCDCCUnpacker.debug, CSCComparatorData.debug, DTTMax.debug, DTVDriftCalibration.debug, DTTTrigSyncFromDB.debug, CSCTMBData.debug, DTTTrigSyncTOFCorr.debug, CSCEventData.debug, BaseParticlePropagator.debug, CSCTMBHeader.debug, CSCALCTTrailer.debug, CSCALCTHeader.debug, crabFunctions.CrabTask.debug, pkg.AbstractPkg.pname, and print().

Referenced by pkg.AbstractPkg.generate().

147  def get_kwds(self):
148  "Return keyword arguments to be used in methods"
149  kwds = {'__pkgname__': self.config.get('pkgname', 'Package'),
150  '__author__': self.author,
151  '__date__': self.date,
152  '__class__': self.pname,
153  '__class_lowercase__': self.pname.lower(),
154  '__class_space__': " "*len(self.pname),
155  '__name__': self.pname,
156  '__subsys__': self.config.get('subsystem', 'Subsystem')}
157  args = self.config.get('args', None)
158  kwds.update(args)
159  if self.debug:
160  print("Template tags:")
161  pprint.pprint(kwds)
162  return kwds
163 
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47

◆ parse_etags()

def pkg.AbstractPkg.parse_etags (   self,
  line 
)
Determine either skip or keep given line based on class tags
meta-strings

Definition at line 97 of file pkg.py.

References AllInOneConfig::Options.config, geometry.Alignables.config, pkg.AbstractPkg.config, cscdqm::EventProcessorMutex.config, CSCOfflineClient.config, CSCMonitorModule.config, cscdqm::Collection.config, cscdqm::Dispatcher.config, cscdqm::EventProcessor.config, and pkg.AbstractPkg.tmpl_etags().

Referenced by pkg.AbstractPkg.write().

97  def parse_etags(self, line):
98  """
99  Determine either skip or keep given line based on class tags
100  meta-strings
101  """
102  tmpl_etags = self.tmpl_etags()
103  keep_etags = self.config.get('tmpl_etags', [])
104  for tag in tmpl_etags:
105  for valid_tag in keep_etags:
106  if line.find(valid_tag) != -1:
107  line = line.replace(valid_tag, '')
108  return line
109  if line.find(tag) != -1:
110  line = ''
111  return line
112  if len(keep_etags) == 0:
113  return line.replace('@default', '')
114  if '@default' in line:
115  return ''
116  return line
117 

◆ print_etags()

def pkg.AbstractPkg.print_etags (   self)

Definition at line 71 of file pkg.py.

References print(), and pkg.AbstractPkg.tmpl_etags().

71  def print_etags(self):
72  "Print out template example tags"
73  for key in self.tmpl_etags():
74  print(key)
75 
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47

◆ print_tags()

def pkg.AbstractPkg.print_tags (   self)

Definition at line 92 of file pkg.py.

References print(), and pkg.AbstractPkg.tmpl_tags().

92  def print_tags(self):
93  "Print out template keys"
94  for key in self.tmpl_tags():
95  print(key)
96 
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47

◆ tmpl_etags()

def pkg.AbstractPkg.tmpl_etags (   self)

Definition at line 54 of file pkg.py.

References pkg.AbstractPkg.tdir, and pkg.AbstractPkg.tmpl.

Referenced by pkg.AbstractPkg.parse_etags(), and pkg.AbstractPkg.print_etags().

54  def tmpl_etags(self):
55  "Scan template files and return example tags"
56  keys = []
57  sdir = '%s/%s' % (self.tdir, self.tmpl)
58  for name in os.listdir(sdir):
59  if name[-1] == '~':
60  continue
61  if name == 'CVS':
62  continue
63  fname = os.path.join(sdir, name)
64  with open(fname, 'r') as stream:
65  for line in stream.readlines():
66  if line.find('@example_') != -1: # possible tag
67  keys += [k for k in line.split() if \
68  k.find('@example_') != -1]
69  return set(keys)
70 

◆ tmpl_tags()

def pkg.AbstractPkg.tmpl_tags (   self)

Definition at line 76 of file pkg.py.

References utils.parse_word(), pkg.AbstractPkg.tdir, and pkg.AbstractPkg.tmpl.

Referenced by pkg.AbstractPkg.print_tags().

76  def tmpl_tags(self):
77  "Scan template files and return template tags"
78  keys = []
79  sdir = '%s/%s' % (self.tdir, self.tmpl)
80  for name in os.listdir(sdir):
81  if name[-1] == '~':
82  continue
83  if name == 'CVS':
84  continue
85  fname = os.path.join(sdir, name)
86  with open(fname, 'r') as stream:
87  for line in stream.readlines():
88  if line.find('__') != -1: # possible key
89  keys += [k for k in parse_word(line)]
90  return set(keys)
91 
def parse_word(word)
Definition: utils.py:37

◆ write()

def pkg.AbstractPkg.write (   self,
  fname,
  tmpl_name,
  kwds 
)

Definition at line 118 of file pkg.py.

References HcalOfflineHarvesting.debug, NoCQTask.debug, PedestalTask.debug, QIE10Task.debug, QIE11Task.debug, RecHitTask.debug, UMNioTask.debug, ZDCTask.debug, HcalOnlineHarvesting.debug, HFRaddamTask.debug, LaserTask.debug, RawTask.debug, TPTask.debug, LEDTask.debug, DigiTask.debug, DTDigiToRawModule.debug, CSCRPCData.debug, CSCTMBScope.debug, DTDigiToRaw.debug, ALIUtils.debug, DTSegmentsTask.debug, crabFunctions.CrabController.debug, DTOccupancyEfficiency.debug, CSCGEMData.debug, DTTTrigCorrectionFirst.debug, DTDDUUnpacker.debug, pkg.AbstractPkg.debug, CSCDCCEventData.debug, DTTTrigWriter.debug, DTT0CalibrationRMS.debug, DTTPDeadWriter.debug, PPSAlignmentConfigurationESSource.debug, DTOccupancyPoint.debug, DTNoiseComputation.debug, DTROS25Unpacker.debug, util.rrapi.RRApi.debug, DTT0Calibration.debug, DTTTrigSyncT0Only.debug, DTEfficiencyTask.debug, DTTTrigCalibration.debug, CSCDDUEventData.debug, DTRunConditionVar.debug, DTChamberEfficiencyTask.debug, HCALResponse.debug, DTChamberEfficiency.debug, FCDTask.debug, CSCDCCUnpacker.debug, CSCComparatorData.debug, DTTMax.debug, DTVDriftCalibration.debug, DTTTrigSyncFromDB.debug, CSCTMBData.debug, DTTTrigSyncTOFCorr.debug, CSCEventData.debug, BaseParticlePropagator.debug, CSCTMBHeader.debug, CSCALCTTrailer.debug, CSCALCTHeader.debug, crabFunctions.CrabTask.debug, utils.functor(), and pkg.AbstractPkg.parse_etags().

Referenced by pkg.AbstractPkg.generate().

118  def write(self, fname, tmpl_name, kwds):
119  "Create new file from given template name and set of arguments"
120  code = ""
121  read_code = False
122  if os.path.exists(fname):
123  return
124  with open(fname, 'w') as stream:
125  for line in open(tmpl_name, 'r').readlines():
126  line = self.parse_etags(line)
127  if not line:
128  continue
129  if line.find('#python_begin') != -1:
130  read_code = True
131  continue
132  if line.find('#python_end') != -1:
133  read_code = False
134  if read_code:
135  code += line
136  if code and not read_code:
137  res = functor(code, kwds, self.debug)
138  stream.write(res)
139  code = ""
140  continue
141  if not read_code:
142  for key, val in kwds.items():
143  if isinstance(val, str):
144  line = line.replace(key, val)
145  stream.write(line)
146 
def functor(code, kwds, debug=0)
Definition: utils.py:70

Member Data Documentation

◆ author

pkg.AbstractPkg.author

Definition at line 49 of file pkg.py.

Referenced by pkg.AbstractPkg.get_kwds().

◆ config

◆ date

pkg.AbstractPkg.date

Definition at line 50 of file pkg.py.

Referenced by pkg.AbstractPkg.get_kwds().

◆ debug

◆ not_in_dir

pkg.AbstractPkg.not_in_dir

Definition at line 51 of file pkg.py.

Referenced by pkg.AbstractPkg.generate().

◆ pname

pkg.AbstractPkg.pname

Definition at line 45 of file pkg.py.

Referenced by pkg.AbstractPkg.generate(), and pkg.AbstractPkg.get_kwds().

◆ tdir

pkg.AbstractPkg.tdir

◆ tmpl

pkg.AbstractPkg.tmpl

◆ working_dir

pkg.AbstractPkg.working_dir

Definition at line 52 of file pkg.py.

Referenced by pkg.AbstractPkg.generate().