CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes | Private Member Functions
BeautifulSoup.SoupStrainer Class Reference

Public Member Functions

def __init__
 
def __str__
 
def search
 
def searchTag
 

Public Attributes

 attrs
 
 name
 
 text
 

Private Member Functions

def _matches
 

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.

894  def __init__(self, name=None, attrs={}, text=None, **kwargs):
895  self.name = name
896  if isinstance(attrs, basestring):
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

Member Function Documentation

def BeautifulSoup.SoupStrainer.__str__ (   self)

Definition at line 907 of file BeautifulSoup.py.

References BeautifulSoup.Tag.attrs, BeautifulSoup.SoupStrainer.attrs, entry.name, TmModule.name, cond::persistency::TAG::NAME.name, cond::persistency::GLOBAL_TAG::NAME.name, cond::persistency::TAG::TIME_TYPE.name, genericValidation.GenericValidation.name, cond::persistency::GLOBAL_TAG::VALIDITY.name, cond::persistency::COND_LOG_TABLE::EXECTIME.name, cond::persistency::TAG::OBJECT_TYPE.name, preexistingValidation.PreexistingValidation.name, cond::persistency::GLOBAL_TAG::DESCRIPTION.name, ora::RecordSpecImpl::Item.name, cond::persistency::COND_LOG_TABLE::IOVTAG.name, cond::persistency::TAG::SYNCHRONIZATION.name, cond::persistency::GLOBAL_TAG::RELEASE.name, cond::persistency::COND_LOG_TABLE::USERTEXT.name, cond::persistency::TAG::END_OF_VALIDITY.name, cond::persistency::GLOBAL_TAG::SNAPSHOT_TIME.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, cond::persistency::TAG::MODIFICATION_TIME.name, PixelDCSObject< class >::Item.name, alignment.Alignment.name, cond::persistency::GTProxyData.name, XMLHTRZeroSuppressionLoader::_loaderBaseConfig.name, XMLRBXPedestalsLoader::_loaderBaseConfig.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, RecAnalyzerMinbias.name, PixelBarrelLinkMaker::Item.name, cond::persistency::GLOBAL_TAG_MAP::LABEL.name, Mapper::definition< ScannerT >.name, cond::persistency::GLOBAL_TAG_MAP::TAG_NAME.name, ExpressionHisto< T >.name, cond::persistency::PAYLOAD::HASH.name, XMLProcessor::_loaderBaseConfig.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, cond::TagInfo_t.name, h4DSegm.name, PhysicsTools::Calibration::Variable.name, MEtoEDM< T >::MEtoEDMObject.name, cond::persistency::IOV::TAG_NAME.name, cond::persistency::IOV::SINCE.name, cond::persistency::IOV::PAYLOAD_HASH.name, cond::persistency::IOV::INSERTION_TIME.name, MuonGeometrySanityCheckPoint.name, h2DSegm.name, cond::persistency::TAG_MIGRATION::SOURCE_ACCOUNT.name, cond::persistency::TAG_MIGRATION::SOURCE_TAG.name, cond::persistency::TAG_MIGRATION::TAG_NAME.name, cond::persistency::TAG_MIGRATION::STATUS_CODE.name, cond::persistency::TAG_MIGRATION::INSERTION_TIME.name, cond::persistency::PAYLOAD_MIGRATION::SOURCE_ACCOUNT.name, cond::persistency::PAYLOAD_MIGRATION::SOURCE_TOKEN.name, cond::persistency::PAYLOAD_MIGRATION::PAYLOAD_HASH.name, cond::persistency::PAYLOAD_MIGRATION::INSERTION_TIME.name, conddblib.Tag.name, conddblib.GlobalTag.name, plotscripts.SawTeethFunction.name, hTMaxCell.name, BeautifulSoup.Tag.name, BeautifulSoup.SoupStrainer.name, TmCcu.text, TmApvPair.text, TmModule.text, TmPsu.text, BeautifulSoup.Tag.text, and BeautifulSoup.SoupStrainer.text.

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

Definition at line 977 of file BeautifulSoup.py.

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, basestring):
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 = markup.has_key(matchAgainst)
1000  elif matchAgainst and isinstance(markup, basestring):
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
def BeautifulSoup.SoupStrainer.search (   self,
  markup 
)

Definition at line 950 of file BeautifulSoup.py.

References BeautifulSoup.SoupStrainer._matches(), BeautifulSoup.SoupStrainer.search(), BeautifulSoup.SoupStrainer.searchTag(), TmCcu.text, TmApvPair.text, TmModule.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, basestring):
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
def BeautifulSoup.SoupStrainer.searchTag (   self,
  markupName = None,
  markupAttrs = {} 
)

Definition at line 913 of file BeautifulSoup.py.

References BeautifulSoup.SoupStrainer._matches(), entry.name, TmModule.name, cond::persistency::GLOBAL_TAG::NAME.name, cond::persistency::TAG::NAME.name, cond::persistency::TAG::TIME_TYPE.name, genericValidation.GenericValidation.name, cond::persistency::GLOBAL_TAG::VALIDITY.name, cond::persistency::TAG::OBJECT_TYPE.name, cond::persistency::GLOBAL_TAG::DESCRIPTION.name, preexistingValidation.PreexistingValidation.name, cond::persistency::COND_LOG_TABLE::EXECTIME.name, cond::persistency::TAG::SYNCHRONIZATION.name, cond::persistency::GLOBAL_TAG::RELEASE.name, ora::RecordSpecImpl::Item.name, cond::persistency::COND_LOG_TABLE::IOVTAG.name, cond::persistency::COND_LOG_TABLE::USERTEXT.name, cond::persistency::TAG::END_OF_VALIDITY.name, cond::persistency::GLOBAL_TAG::SNAPSHOT_TIME.name, cond::persistency::GTEditorData.name, cond::persistency::TAG::DESCRIPTION.name, cond::persistency::GLOBAL_TAG::INSERTION_TIME.name, cond::persistency::TAG::LAST_VALIDATED_TIME.name, cond::persistency::TAG::INSERTION_TIME.name, cond::persistency::TAG::MODIFICATION_TIME.name, PixelDCSObject< class >::Item.name, alignment.Alignment.name, cond::persistency::GTProxyData.name, XMLHTRZeroSuppressionLoader::_loaderBaseConfig.name, XMLRBXPedestalsLoader::_loaderBaseConfig.name, cond::TimeTypeSpecs.name, lumi::TriggerInfo.name, cond::persistency::GLOBAL_TAG_MAP::GLOBAL_TAG_NAME.name, PixelEndcapLinkMaker::Item.name, RecAnalyzerMinbias.name, cond::persistency::GLOBAL_TAG_MAP::RECORD.name, PixelBarrelLinkMaker::Item.name, Mapper::definition< ScannerT >.name, cond::persistency::GLOBAL_TAG_MAP::LABEL.name, cond::persistency::GLOBAL_TAG_MAP::TAG_NAME.name, ExpressionHisto< T >.name, cond::persistency::PAYLOAD::HASH.name, XMLProcessor::_loaderBaseConfig.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, cond::TagInfo_t.name, PhysicsTools::Calibration::Variable.name, MEtoEDM< T >::MEtoEDMObject.name, cond::persistency::IOV::TAG_NAME.name, cond::persistency::IOV::SINCE.name, cond::persistency::IOV::PAYLOAD_HASH.name, cond::persistency::IOV::INSERTION_TIME.name, MuonGeometrySanityCheckPoint.name, h2DSegm.name, cond::persistency::TAG_MIGRATION::SOURCE_ACCOUNT.name, cond::persistency::TAG_MIGRATION::SOURCE_TAG.name, cond::persistency::TAG_MIGRATION::TAG_NAME.name, cond::persistency::TAG_MIGRATION::STATUS_CODE.name, cond::persistency::TAG_MIGRATION::INSERTION_TIME.name, cond::persistency::PAYLOAD_MIGRATION::SOURCE_ACCOUNT.name, cond::persistency::PAYLOAD_MIGRATION::SOURCE_TOKEN.name, cond::persistency::PAYLOAD_MIGRATION::PAYLOAD_HASH.name, cond::persistency::PAYLOAD_MIGRATION::INSERTION_TIME.name, conddblib.Tag.name, conddblib.GlobalTag.name, plotscripts.SawTeethFunction.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

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(), dqm_interfaces.DirID.__eq__(), dirstructure.Directory.__get_full_path(), dirstructure.Comparison.__get_img_name(), dataset.Dataset.__getDataType(), dataset.Dataset.__getFileInfoList(), cuy.divideElement.__init__(), cuy.plotElement.__init__(), cuy.additionElement.__init__(), cuy.superimposeElement.__init__(), cuy.graphElement.__init__(), 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.CFG.__str__(), counter.Counter.__str__(), average.Average.__str__(), BeautifulSoup.SoupStrainer.__str__(), core.autovars.NTupleObjectType.allVars(), dirstructure.Directory.calcStats(), python.rootplot.utilities.Hist.divide(), python.rootplot.utilities.Hist.divide_wilson(), 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(), 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(), 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

Definition at line 905 of file BeautifulSoup.py.

Referenced by Vispa.Views.TableView.TableWidgetItem.__lt__(), BeautifulSoup.SoupStrainer.__str__(), and BeautifulSoup.SoupStrainer.search().