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 890 of file BeautifulSoup.py.

Constructor & Destructor Documentation

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

Definition at line 894 of file BeautifulSoup.py.

894  def __init__(self, name=None, attrs={}, text=None, **kwargs):
895  self.name = name
896  if isinstance(attrs, str):
897  kwargs['class'] = _match_css_class(attrs)
898  attrs = None
899  if kwargs:
900  if attrs:
901  attrs = attrs.copy()
902  attrs.update(kwargs)
903  else:
904  attrs = kwargs
905  self.attrs = attrs
906  self.text = text
907 
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 908 of file BeautifulSoup.py.

References BeautifulSoup.Tag.attrs, BeautifulSoup.SoupStrainer.attrs, AlignableObjectId::entry.name, cond::persistency::RUN_INFO::RUN_NUMBER.name, cond::persistency::TAG::NAME.name, TmModule.name, cond::persistency::GLOBAL_TAG::NAME.name, cond::persistency::RUN_INFO::START_TIME.name, cond::persistency::GLOBAL_TAG::VALIDITY.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, cond::persistency::TAG::LAST_VALIDATED_TIME.name, cond::persistency::TAG::INSERTION_TIME.name, nanoaod::MergeableCounterTable::SingleColumn< T >.name, cond::persistency::TAG::MODIFICATION_TIME.name, preexistingValidation.PreexistingValidation.name, PixelDCSObject< T >::Item.name, cond::persistency::GTProxyData.name, cond::TimeTypeSpecs.name, lumi::TriggerInfo.name, alignment.Alignment.name, cond::persistency::GLOBAL_TAG_MAP::GLOBAL_TAG_NAME.name, PixelEndcapLinkMaker::Item.name, cond::persistency::GLOBAL_TAG_MAP::RECORD.name, PixelBarrelLinkMaker::Item.name, cond::persistency::GLOBAL_TAG_MAP::LABEL.name, MEtoEDM< T >::MEtoEDMObject.name, cond::persistency::GLOBAL_TAG_MAP::TAG_NAME.name, ExpressionHisto< T >.name, cms::DDAlgoArguments.name, XMLProcessor::_loaderBaseConfig.name, cond::persistency::PAYLOAD::HASH.name, cond::persistency::PAYLOAD::OBJECT_TYPE.name, cond::persistency::PAYLOAD::DATA.name, cond::persistency::PAYLOAD::STREAMER_INFO.name, genericValidation.GenericValidation.name, cond::persistency::PAYLOAD::VERSION.name, cond::persistency::PAYLOAD::INSERTION_TIME.name, nanoaod::MergeableCounterTable::VectorColumn< T >.name, h4DSegm.name, PhysicsTools::Calibration::Variable.name, TrackerSectorStruct.name, cond::TagInfo_t.name, cond::persistency::IOV::TAG_NAME.name, cond::persistency::IOV::SINCE.name, cond::persistency::IOV::PAYLOAD_HASH.name, Mapper::definition< ScannerT >.name, cond::persistency::IOV::INSERTION_TIME.name, classes.MonitorData.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__().

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

Definition at line 978 of file BeautifulSoup.py.

References str.

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

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

Definition at line 951 of file BeautifulSoup.py.

References BeautifulSoup.SoupStrainer._matches(), KDTreeLinkerAlgo< DATA >.search(), 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().

951  def search(self, markup):
952  #print 'looking for %s in %s' % (self, markup)
953  found = None
954  # If given a list of items, scan it for a text element that
955  # matches.
956  if hasattr(markup, "__iter__") \
957  and not isinstance(markup, Tag):
958  for element in markup:
959  if isinstance(element, NavigableString) \
960  and self.search(element):
961  found = element
962  break
963  # If it's a Tag, make sure its name or attributes match.
964  # Don't bother with Tags if we're searching for text.
965  elif isinstance(markup, Tag):
966  if not self.text:
967  found = self.searchTag(markup)
968  # If it's text, make sure the text matches.
969  elif isinstance(markup, NavigableString) or \
970  isinstance(markup, str):
971  if self._matches(markup, self.text):
972  found = markup
973  else:
974  raise Exception("I don't know how to match against a %s" \
975  % markup.__class__)
976  return found
977 
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 914 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, cond::persistency::TAG::LAST_VALIDATED_TIME.name, cond::persistency::TAG::INSERTION_TIME.name, nanoaod::MergeableCounterTable::SingleColumn< T >.name, cond::persistency::TAG::MODIFICATION_TIME.name, preexistingValidation.PreexistingValidation.name, PixelDCSObject< T >::Item.name, cond::persistency::GTProxyData.name, cond::TimeTypeSpecs.name, lumi::TriggerInfo.name, alignment.Alignment.name, PixelEndcapLinkMaker::Item.name, cond::persistency::GLOBAL_TAG_MAP::GLOBAL_TAG_NAME.name, PixelBarrelLinkMaker::Item.name, cond::persistency::GLOBAL_TAG_MAP::RECORD.name, cond::persistency::GLOBAL_TAG_MAP::LABEL.name, cond::persistency::GLOBAL_TAG_MAP::TAG_NAME.name, cms::DDAlgoArguments.name, ExpressionHisto< T >.name, MEtoEDM< T >::MEtoEDMObject.name, XMLProcessor::_loaderBaseConfig.name, cond::persistency::PAYLOAD::HASH.name, cond::persistency::PAYLOAD::OBJECT_TYPE.name, cond::persistency::PAYLOAD::DATA.name, cond::persistency::PAYLOAD::STREAMER_INFO.name, genericValidation.GenericValidation.name, cond::persistency::PAYLOAD::VERSION.name, cond::persistency::PAYLOAD::INSERTION_TIME.name, nanoaod::MergeableCounterTable::VectorColumn< T >.name, h4DSegm.name, PhysicsTools::Calibration::Variable.name, TrackerSectorStruct.name, cond::TagInfo_t.name, cond::persistency::IOV::TAG_NAME.name, cond::persistency::IOV::SINCE.name, Mapper::definition< ScannerT >.name, cond::persistency::IOV::PAYLOAD_HASH.name, classes.MonitorData.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().

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

Member Data Documentation

BeautifulSoup.SoupStrainer.attrs

Definition at line 905 of file BeautifulSoup.py.

Referenced by BeautifulSoup.SoupStrainer.__str__().

BeautifulSoup.SoupStrainer.name

Definition at line 895 of file BeautifulSoup.py.

Referenced by ElectronMVAID.ElectronMVAID.__call__(), FWLite.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__(), FWLite.WorkingPoints._reformat_cut_definitions(), 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