CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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, AlignableObjectId::entry.name, cond::persistency::GTEditorData.name, cond::persistency::GLOBAL_TAG::NAME.name, cond::persistency::TAG::NAME.name, cond::persistency::RUN_INFO::RUN_NUMBER.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::O2O_RUN::JOB_NAME.name, cond::persistency::GLOBAL_TAG::INSERTION_TIME.name, cms::dd::NameValuePair< T >.name, cond::persistency::TAG::DESCRIPTION.name, cond::persistency::O2O_RUN::START_TIME.name, cond::persistency::TAG::LAST_VALIDATED_TIME.name, cond::persistency::O2O_RUN::END_TIME.name, cond::persistency::TAG::INSERTION_TIME.name, cond::persistency::O2O_RUN::STATUS_CODE.name, cond::persistency::TAG::MODIFICATION_TIME.name, cond::persistency::O2O_RUN::LOG.name, nanoaod::MergeableCounterTable::SingleColumn< T >.name, cond::persistency::TAG::PROTECTION_CODE.name, preexistingValidation.PreexistingValidation.name, PixelDCSObject< class >::Item.name, AlignmentConstraint.name, cms::dd::ValuePair< T, U >.name, o2olib.O2OJob.name, cond::persistency::GTProxyData.name, cms::DDAlgoArguments.name, cond::TimeTypeSpecs.name, alignment.Alignment.name, lumi::TriggerInfo.name, XMLProcessor::_loaderBaseConfig.name, PixelEndcapLinkMaker::Item.name, MEtoEDM< T >::MEtoEDMObject.name, PixelBarrelLinkMaker::Item.name, ExpressionHisto< T >.name, cond::persistency::GLOBAL_TAG_MAP::GLOBAL_TAG_NAME.name, genericValidation.GenericValidation.name, cond::persistency::GLOBAL_TAG_MAP::RECORD.name, cond::persistency::GLOBAL_TAG_MAP::LABEL.name, cond::persistency::GLOBAL_TAG_MAP::TAG_NAME.name, cms::DDParsingContext::CompositeMaterial.name, cond::Tag_t.name, nanoaod::MergeableCounterTable::VectorColumn< T >.name, h4DSegm.name, PhysicsTools::Calibration::Variable.name, cond::TagInfo_t.name, TrackerSectorStruct.name, MuonGeometrySanityCheckPoint.name, cond::persistency::PAYLOAD::HASH.name, cond::persistency::PAYLOAD::OBJECT_TYPE.name, Mapper::definition< ScannerT >.name, cond::persistency::PAYLOAD::DATA.name, cond::persistency::PAYLOAD::STREAMER_INFO.name, cond::persistency::PAYLOAD::VERSION.name, cond::persistency::PAYLOAD::INSERTION_TIME.name, classes.MonitorData.name, classes.OutputData.name, h2DSegm.name, cond::persistency::IOV::TAG_NAME.name, cond::persistency::IOV::SINCE.name, cond::persistency::IOV::PAYLOAD_HASH.name, cond::persistency::IOV::INSERTION_TIME.name, geometry.Structure.name, nanoaod::FlatTable::Column.name, StraightTrackAlignment::RPSetPlots.name, cond::persistency::TAG_AUTHORIZATION::TAG_NAME.name, cond::persistency::TAG_AUTHORIZATION::ACCESS_TYPE.name, cond::persistency::TAG_AUTHORIZATION::CREDENTIAL.name, cond::persistency::TAG_AUTHORIZATION::CREDENTIAL_TYPE.name, cond::payloadInspector::TagReference.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)
def BeautifulSoup.SoupStrainer._matches (   self,
  markup,
  matchAgainst 
)
private

Definition at line 977 of file BeautifulSoup.py.

References str, and betterConfigParser.unicode.

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
#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(), KDTreeLinkerAlgo< DATA, DIM >.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, 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(), AlignableObjectId::entry.name, cond::persistency::TAG::NAME.name, cond::persistency::RUN_INFO::RUN_NUMBER.name, TmModule.name, cond::persistency::GTEditorData.name, cond::persistency::GLOBAL_TAG::NAME.name, cond::persistency::TAG::TIME_TYPE.name, cond::persistency::RUN_INFO::START_TIME.name, cond::persistency::GLOBAL_TAG::VALIDITY.name, cond::persistency::RUN_INFO::END_TIME.name, cond::persistency::TAG::OBJECT_TYPE.name, cond::persistency::GLOBAL_TAG::DESCRIPTION.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::O2O_RUN::JOB_NAME.name, cond::persistency::TAG::DESCRIPTION.name, cms::dd::NameValuePair< T >.name, cond::persistency::GLOBAL_TAG::INSERTION_TIME.name, cond::persistency::O2O_RUN::START_TIME.name, cond::persistency::TAG::LAST_VALIDATED_TIME.name, cond::persistency::O2O_RUN::END_TIME.name, cond::persistency::TAG::INSERTION_TIME.name, cond::persistency::O2O_RUN::STATUS_CODE.name, cond::persistency::TAG::MODIFICATION_TIME.name, cond::persistency::O2O_RUN::LOG.name, nanoaod::MergeableCounterTable::SingleColumn< T >.name, cond::persistency::TAG::PROTECTION_CODE.name, preexistingValidation.PreexistingValidation.name, AlignmentConstraint.name, PixelDCSObject< class >::Item.name, cms::dd::ValuePair< T, U >.name, o2olib.O2OJob.name, cond::persistency::GTProxyData.name, cms::DDAlgoArguments.name, cond::TimeTypeSpecs.name, alignment.Alignment.name, lumi::TriggerInfo.name, PixelEndcapLinkMaker::Item.name, XMLProcessor::_loaderBaseConfig.name, MEtoEDM< T >::MEtoEDMObject.name, PixelBarrelLinkMaker::Item.name, ExpressionHisto< T >.name, genericValidation.GenericValidation.name, cond::persistency::GLOBAL_TAG_MAP::GLOBAL_TAG_NAME.name, cond::persistency::GLOBAL_TAG_MAP::RECORD.name, cond::persistency::GLOBAL_TAG_MAP::LABEL.name, cms::DDParsingContext::CompositeMaterial.name, cond::persistency::GLOBAL_TAG_MAP::TAG_NAME.name, cond::Tag_t.name, nanoaod::MergeableCounterTable::VectorColumn< T >.name, h4DSegm.name, cond::TagInfo_t.name, PhysicsTools::Calibration::Variable.name, TrackerSectorStruct.name, MuonGeometrySanityCheckPoint.name, cond::persistency::PAYLOAD::HASH.name, Mapper::definition< ScannerT >.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, classes.MonitorData.name, classes.OutputData.name, h2DSegm.name, cond::persistency::IOV::TAG_NAME.name, cond::persistency::IOV::SINCE.name, cond::persistency::IOV::PAYLOAD_HASH.name, cond::persistency::IOV::INSERTION_TIME.name, geometry.Structure.name, nanoaod::FlatTable::Column.name, StraightTrackAlignment::RPSetPlots.name, cond::persistency::TAG_AUTHORIZATION::TAG_NAME.name, cond::persistency::TAG_AUTHORIZATION::ACCESS_TYPE.name, cond::persistency::TAG_AUTHORIZATION::CREDENTIAL.name, cond::persistency::TAG_AUTHORIZATION::CREDENTIAL_TYPE.name, cond::payloadInspector::TagReference.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

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__(), 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(), geometryComparison.GeometryComparison.createScript(), 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(), primaryVertexResolution.PrimaryVertexResolution.getRepMap(), primaryVertexValidation.PrimaryVertexValidation.getRepMap(), zMuMuValidation.ZMuMuValidation.getRepMap(), 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(), counter.Counter.write(), and average.Average.write().

BeautifulSoup.SoupStrainer.text

Definition at line 905 of file BeautifulSoup.py.

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