CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes | Private Member Functions
BeautifulSoup.SoupStrainer Class Reference

Public Member Functions

def __init__ (self, name=None, attrs={}, text=None, kwargs)
 
def __str__ (self)
 
def search (self, markup)
 
def searchTag (self, markupName=None, markupAttrs={})
 

Public Attributes

 attrs
 
 name
 
 text
 

Private Member Functions

def _matches (self, markup, matchAgainst)
 

Detailed Description

Encapsulates a number of ways of matching a markup element (tag or
text).

Definition at line 889 of file BeautifulSoup.py.

Constructor & Destructor Documentation

def BeautifulSoup.SoupStrainer.__init__ (   self,
  name = None,
  attrs = {},
  text = None,
  kwargs 
)

Definition at line 893 of file BeautifulSoup.py.

893  def __init__(self, name=None, attrs={}, text=None, **kwargs):
894  self.name = name
895  if isinstance(attrs, basestring):
896  kwargs['class'] = _match_css_class(attrs)
897  attrs = None
898  if kwargs:
899  if attrs:
900  attrs = attrs.copy()
901  attrs.update(kwargs)
902  else:
903  attrs = kwargs
904  self.attrs = attrs
905  self.text = text
906 
def __init__(self, name=None, attrs={}, text=None, kwargs)
def _match_css_class(str)

Member Function Documentation

def BeautifulSoup.SoupStrainer.__str__ (   self)

Definition at line 907 of file BeautifulSoup.py.

References BeautifulSoup.Tag.attrs, BeautifulSoup.SoupStrainer.attrs, AlignableObjectId::entry.name, cond::persistency::RUN_INFO::RUN_NUMBER.name, cond::persistency::GLOBAL_TAG::NAME.name, cond::persistency::TAG::NAME.name, TmModule.name, cond::persistency::GLOBAL_TAG::VALIDITY.name, cond::persistency::RUN_INFO::START_TIME.name, cond::persistency::TAG::TIME_TYPE.name, cond::persistency::GLOBAL_TAG::DESCRIPTION.name, cond::persistency::RUN_INFO::END_TIME.name, cond::persistency::TAG::OBJECT_TYPE.name, cond::persistency::GLOBAL_TAG::RELEASE.name, cond::persistency::TAG::SYNCHRONIZATION.name, cond::persistency::GLOBAL_TAG::SNAPSHOT_TIME.name, cond::persistency::TAG::END_OF_VALIDITY.name, cond::persistency::GLOBAL_TAG::INSERTION_TIME.name, cond::persistency::TAG::DESCRIPTION.name, cond::persistency::GTEditorData.name, nanoaod::MergeableCounterTable::SingleColumn< T >.name, cond::persistency::TAG::LAST_VALIDATED_TIME.name, cond::persistency::TAG::INSERTION_TIME.name, preexistingValidation.PreexistingValidation.name, cond::persistency::TAG::MODIFICATION_TIME.name, PixelDCSObject< T >::Item.name, cond::persistency::GTProxyData.name, nanoaod::MergeableCounterTable::VectorColumn< T >.name, cms::DDAlgoArguments.name, alignment.Alignment.name, cond::TimeTypeSpecs.name, lumi::TriggerInfo.name, cond::persistency::GLOBAL_TAG_MAP::GLOBAL_TAG_NAME.name, PixelEndcapLinkMaker::Item.name, cond::persistency::GLOBAL_TAG_MAP::RECORD.name, PixelBarrelLinkMaker::Item.name, validateAlignments.ParallelMergeJob.name, cond::persistency::GLOBAL_TAG_MAP::LABEL.name, MEtoEDM< T >::MEtoEDMObject.name, cond::persistency::GLOBAL_TAG_MAP::TAG_NAME.name, ExpressionHisto< T >.name, XMLProcessor::_loaderBaseConfig.name, cond::persistency::PAYLOAD::HASH.name, genericValidation.GenericValidation.name, cond::persistency::PAYLOAD::OBJECT_TYPE.name, cond::persistency::PAYLOAD::DATA.name, cond::persistency::PAYLOAD::STREAMER_INFO.name, cond::persistency::PAYLOAD::VERSION.name, cond::persistency::PAYLOAD::INSERTION_TIME.name, h4DSegm.name, PhysicsTools::Calibration::Variable.name, cond::TagInfo_t.name, cond::persistency::IOV::TAG_NAME.name, TrackerSectorStruct.name, cond::persistency::IOV::SINCE.name, Mapper::definition< ScannerT >.name, classes.MonitorData.name, cond::persistency::IOV::PAYLOAD_HASH.name, cond::persistency::IOV::INSERTION_TIME.name, MuonGeometrySanityCheckPoint.name, classes.OutputData.name, h2DSegm.name, nanoaod::FlatTable::Column.name, geometry.Structure.name, cond::persistency::TAG_LOG::TAG_NAME.name, cond::persistency::TAG_LOG::EVENT_TIME.name, cond::persistency::TAG_LOG::USER_NAME.name, cond::persistency::TAG_LOG::HOST_NAME.name, cond::persistency::TAG_LOG::COMMAND.name, cond::persistency::TAG_LOG::ACTION.name, cond::persistency::TAG_LOG::USER_TEXT.name, plotscripts.SawTeethFunction.name, crabFunctions.CrabTask.name, hTMaxCell.name, BeautifulSoup.Tag.name, BeautifulSoup.SoupStrainer.name, TmCcu.text, TmApvPair.text, TmModule.text, beamerCreator.Out.text, classes.PlotData.text, TmPsu.text, BeautifulSoup.Tag.text, and BeautifulSoup.SoupStrainer.text.

Referenced by edmStreamStallGrapher.Point.__repr__().

907  def __str__(self):
908  if self.text:
909  return self.text
910  else:
911  return "%s|%s" % (self.name, self.attrs)
912 
def BeautifulSoup.SoupStrainer._matches (   self,
  markup,
  matchAgainst 
)
private

Definition at line 977 of file BeautifulSoup.py.

References str.

Referenced by BeautifulSoup.SoupStrainer.search(), and BeautifulSoup.SoupStrainer.searchTag().

977  def _matches(self, markup, matchAgainst):
978  #print "Matching %s against %s" % (markup, matchAgainst)
979  result = False
980  if matchAgainst is True:
981  result = markup is not None
982  elif callable(matchAgainst):
983  result = matchAgainst(markup)
984  else:
985  #Custom match methods take the tag as an argument, but all
986  #other ways of matching match the tag name as a string.
987  if isinstance(markup, Tag):
988  markup = markup.name
989  if markup and not isinstance(markup, basestring):
990  markup = unicode(markup)
991  #Now we know that chunk is either a string, or None.
992  if hasattr(matchAgainst, 'match'):
993  # It's a regexp object.
994  result = markup and matchAgainst.search(markup)
995  elif hasattr(matchAgainst, '__iter__'): # list-like
996  result = markup in matchAgainst
997  elif hasattr(matchAgainst, 'items'):
998  result = markup.has_key(matchAgainst)
999  elif matchAgainst and isinstance(markup, basestring):
1000  if isinstance(markup, unicode):
1001  matchAgainst = unicode(matchAgainst)
1002  else:
1003  matchAgainst = str(matchAgainst)
1004 
1005  if not result:
1006  result = matchAgainst == markup
1007  return result
1008 
def _matches(self, markup, matchAgainst)
#define str(s)
def BeautifulSoup.SoupStrainer.search (   self,
  markup 
)

Definition at line 950 of file BeautifulSoup.py.

References BeautifulSoup.SoupStrainer._matches(), FKDTree< TYPE, numberOfDimensions >.search(), BeautifulSoup.SoupStrainer.search(), BeautifulSoup.SoupStrainer.searchTag(), TmCcu.text, TmApvPair.text, TmModule.text, beamerCreator.Out.text, classes.PlotData.text, TmPsu.text, BeautifulSoup.Tag.text, and BeautifulSoup.SoupStrainer.text.

Referenced by BeautifulSoup.SoupStrainer.search().

950  def search(self, markup):
951  #print 'looking for %s in %s' % (self, markup)
952  found = None
953  # If given a list of items, scan it for a text element that
954  # matches.
955  if hasattr(markup, "__iter__") \
956  and not isinstance(markup, Tag):
957  for element in markup:
958  if isinstance(element, NavigableString) \
959  and self.search(element):
960  found = element
961  break
962  # If it's a Tag, make sure its name or attributes match.
963  # Don't bother with Tags if we're searching for text.
964  elif isinstance(markup, Tag):
965  if not self.text:
966  found = self.searchTag(markup)
967  # If it's text, make sure the text matches.
968  elif isinstance(markup, NavigableString) or \
969  isinstance(markup, basestring):
970  if self._matches(markup, self.text):
971  found = markup
972  else:
973  raise Exception, "I don't know how to match against a %s" \
974  % markup.__class__
975  return found
976 
def _matches(self, markup, matchAgainst)
def search(self, markup)
def searchTag(self, markupName=None, markupAttrs={})
def BeautifulSoup.SoupStrainer.searchTag (   self,
  markupName = None,
  markupAttrs = {} 
)

Definition at line 913 of file BeautifulSoup.py.

References BeautifulSoup.SoupStrainer._matches(), AlignableObjectId::entry.name, TmModule.name, cond::persistency::TAG::NAME.name, cond::persistency::GLOBAL_TAG::NAME.name, cond::persistency::RUN_INFO::RUN_NUMBER.name, cond::persistency::TAG::TIME_TYPE.name, cond::persistency::GLOBAL_TAG::VALIDITY.name, cond::persistency::RUN_INFO::START_TIME.name, cond::persistency::TAG::OBJECT_TYPE.name, cond::persistency::GLOBAL_TAG::DESCRIPTION.name, cond::persistency::RUN_INFO::END_TIME.name, cond::persistency::TAG::SYNCHRONIZATION.name, cond::persistency::GLOBAL_TAG::RELEASE.name, cond::persistency::TAG::END_OF_VALIDITY.name, cond::persistency::GLOBAL_TAG::SNAPSHOT_TIME.name, cond::persistency::TAG::DESCRIPTION.name, cond::persistency::GTEditorData.name, cond::persistency::GLOBAL_TAG::INSERTION_TIME.name, nanoaod::MergeableCounterTable::SingleColumn< T >.name, cond::persistency::TAG::LAST_VALIDATED_TIME.name, cond::persistency::TAG::INSERTION_TIME.name, preexistingValidation.PreexistingValidation.name, cond::persistency::TAG::MODIFICATION_TIME.name, PixelDCSObject< T >::Item.name, cond::persistency::GTProxyData.name, nanoaod::MergeableCounterTable::VectorColumn< T >.name, cms::DDAlgoArguments.name, lumi::TriggerInfo.name, alignment.Alignment.name, cond::TimeTypeSpecs.name, PixelEndcapLinkMaker::Item.name, cond::persistency::GLOBAL_TAG_MAP::GLOBAL_TAG_NAME.name, PixelBarrelLinkMaker::Item.name, cond::persistency::GLOBAL_TAG_MAP::RECORD.name, validateAlignments.ParallelMergeJob.name, cond::persistency::GLOBAL_TAG_MAP::LABEL.name, cond::persistency::GLOBAL_TAG_MAP::TAG_NAME.name, MEtoEDM< T >::MEtoEDMObject.name, ExpressionHisto< T >.name, XMLProcessor::_loaderBaseConfig.name, cond::persistency::PAYLOAD::HASH.name, genericValidation.GenericValidation.name, cond::persistency::PAYLOAD::OBJECT_TYPE.name, cond::persistency::PAYLOAD::DATA.name, cond::persistency::PAYLOAD::STREAMER_INFO.name, cond::persistency::PAYLOAD::VERSION.name, cond::persistency::PAYLOAD::INSERTION_TIME.name, h4DSegm.name, PhysicsTools::Calibration::Variable.name, cond::TagInfo_t.name, cond::persistency::IOV::TAG_NAME.name, TrackerSectorStruct.name, cond::persistency::IOV::SINCE.name, cond::persistency::IOV::PAYLOAD_HASH.name, classes.MonitorData.name, Mapper::definition< ScannerT >.name, cond::persistency::IOV::INSERTION_TIME.name, MuonGeometrySanityCheckPoint.name, classes.OutputData.name, h2DSegm.name, nanoaod::FlatTable::Column.name, geometry.Structure.name, cond::persistency::TAG_LOG::TAG_NAME.name, cond::persistency::TAG_LOG::EVENT_TIME.name, cond::persistency::TAG_LOG::USER_NAME.name, cond::persistency::TAG_LOG::HOST_NAME.name, cond::persistency::TAG_LOG::COMMAND.name, cond::persistency::TAG_LOG::ACTION.name, cond::persistency::TAG_LOG::USER_TEXT.name, plotscripts.SawTeethFunction.name, crabFunctions.CrabTask.name, hTMaxCell.name, BeautifulSoup.Tag.name, and BeautifulSoup.SoupStrainer.name.

Referenced by BeautifulSoup.SoupStrainer.search().

913  def searchTag(self, markupName=None, markupAttrs={}):
914  found = None
915  markup = None
916  if isinstance(markupName, Tag):
917  markup = markupName
918  markupAttrs = markup
919  callFunctionWithTagData = callable(self.name) \
920  and not isinstance(markupName, Tag)
921 
922  if (not self.name) \
923  or callFunctionWithTagData \
924  or (markup and self._matches(markup, self.name)) \
925  or (not markup and self._matches(markupName, self.name)):
926  if callFunctionWithTagData:
927  match = self.name(markupName, markupAttrs)
928  else:
929  match = True
930  markupAttrMap = None
931  for attr, matchAgainst in self.attrs.items():
932  if not markupAttrMap:
933  if hasattr(markupAttrs, 'get'):
934  markupAttrMap = markupAttrs
935  else:
936  markupAttrMap = {}
937  for k,v in markupAttrs:
938  markupAttrMap[k] = v
939  attrValue = markupAttrMap.get(attr)
940  if not self._matches(attrValue, matchAgainst):
941  match = False
942  break
943  if match:
944  if markup:
945  found = markup
946  else:
947  found = markupName
948  return found
949 
def _matches(self, markup, matchAgainst)
def searchTag(self, markupName=None, markupAttrs={})

Member Data Documentation

BeautifulSoup.SoupStrainer.attrs

Definition at line 904 of file BeautifulSoup.py.

Referenced by BeautifulSoup.SoupStrainer.__str__().

BeautifulSoup.SoupStrainer.name

Definition at line 894 of file BeautifulSoup.py.

Referenced by ElectronMVAID.ElectronMVAID.__call__(), dirstructure.Directory.__create_pie_image(), DisplayManager.DisplayManager.__del__(), dqm_interfaces.DirID.__eq__(), dirstructure.Directory.__get_full_path(), dirstructure.Comparison.__get_img_name(), dataset.Dataset.__getDataType(), dataset.Dataset.__getFileInfoList(), dirstructure.Comparison.__make_image(), core.autovars.NTupleVariable.__repr__(), core.autovars.NTupleObjectType.__repr__(), core.autovars.NTupleObject.__repr__(), core.autovars.NTupleCollection.__repr__(), dirstructure.Directory.__repr__(), dqm_interfaces.DirID.__repr__(), dirstructure.Comparison.__repr__(), config.Service.__setattr__(), config.CFG.__str__(), counter.Counter.__str__(), average.Average.__str__(), BeautifulSoup.SoupStrainer.__str__(), core.autovars.NTupleObjectType.addSubObjects(), core.autovars.NTupleObjectType.addVariables(), core.autovars.NTupleObjectType.allVars(), dirstructure.Directory.calcStats(), validation.Sample.digest(), python.rootplot.utilities.Hist.divide(), python.rootplot.utilities.Hist.divide_wilson(), DisplayManager.DisplayManager.Draw(), TreeCrawler.Package.dump(), core.autovars.NTupleVariable.fillBranch(), core.autovars.NTupleObject.fillBranches(), core.autovars.NTupleCollection.fillBranchesScalar(), core.autovars.NTupleCollection.fillBranchesVector(), core.autovars.NTupleCollection.get_cpp_declaration(), core.autovars.NTupleCollection.get_cpp_wrapper_class(), core.autovars.NTupleCollection.get_py_wrapper_class(), utils.StatisticalTest.get_status(), production_tasks.Task.getname(), dataset.CMSDataset.getPrimaryDatasetEntries(), dataset.PrivateDataset.getPrimaryDatasetEntries(), VIDSelectorBase.VIDSelectorBase.initialize(), personalPlayback.Applet.log(), core.autovars.NTupleVariable.makeBranch(), core.autovars.NTupleObject.makeBranches(), core.autovars.NTupleCollection.makeBranchesScalar(), core.autovars.NTupleCollection.makeBranchesVector(), dirstructure.Directory.print_report(), dataset.BaseDataset.printInfo(), dataset.Dataset.printInfo(), production_tasks.MonitorJobs.run(), BeautifulSoup.SoupStrainer.searchTag(), python.rootplot.utilities.Hist.TGraph(), python.rootplot.utilities.Hist.TH1F(), Vispa.Views.PropertyView.Property.valueChanged(), counter.Counter.write(), and average.Average.write().

BeautifulSoup.SoupStrainer.text