desc
stringlengths
3
26.7k
decl
stringlengths
11
7.89k
bodies
stringlengths
8
553k
'Reset the dictionary.'
def _clear(self):
self.billingPos = None
'Set the name of the person.'
def set_name(self, name):
d = analyze_name(name, canonical=1) self.data.update(d)
'Valid keys to append to the data.keys() list.'
def _additional_keys(self):
addkeys = [] if self.data.has_key('name'): addkeys += ['canonical name', 'long imdb name', 'long imdb canonical name'] if self.data.has_key('headshot'): addkeys += ['full-size headshot'] return addkeys
'Handle special keys.'
def _getitem(self, key):
if self.data.has_key('name'): if (key == 'name'): return normalizeName(self.data['name']) elif (key == 'canonical name'): return self.data['name'] elif (key == 'long imdb name'): return build_name(self.data, canonical=0) elif (key == 'long...
'Return the personID.'
def getID(self):
return self.personID
'The Person is "false" if the self.data does not contain a name.'
def __nonzero__(self):
if self.data.has_key('name'): return 1 return 0
'Return true if this Person has worked in the given Movie, or if the fiven Character was played by this Person.'
def __contains__(self, item):
from Movie import Movie from Character import Character if isinstance(item, Movie): for m in flatten(self.data, yieldDictKeys=1, scalar=Movie): if item.isSame(m): return 1 elif isinstance(item, Character): for m in flatten(self.data, yieldDictKeys=1, scalar=Mo...
'Return true if two persons have the same name and imdbIndex and/or personID.'
def isSameName(self, other):
if (not isinstance(other, self.__class__)): return 0 if (self.data.has_key('name') and other.data.has_key('name') and (build_name(self.data, canonical=1) == build_name(other.data, canonical=1))): return 1 if ((self.accessSystem == other.accessSystem) and self.personID and (self.personID == o...
'Return a deep copy of a Person instance.'
def __deepcopy__(self, memo):
p = Person(name=u'', personID=self.personID, myName=self.myName, myID=self.myID, data=deepcopy(self.data, memo), currentRole=deepcopy(self.currentRole, memo), roleIsPerson=self._roleIsPerson, notes=self.notes, accessSystem=self.accessSystem, titlesRefs=deepcopy(self.titlesRefs, memo), namesRefs=deepcopy(self.namesR...
'String representation of a Person object.'
def __repr__(self):
r = ('<Person id:%s[%s] name:_%s_>' % (self.personID, self.accessSystem, self.get('long imdb canonical name'))) if isinstance(r, unicode): r = r.encode('utf_8', 'replace') return r
'Simply print the short name.'
def __str__(self):
return self.get('name', u'').encode('utf_8', 'replace')
'Simply print the short title.'
def __unicode__(self):
return self.get('name', u'')
'Return a string with a pretty-printed summary for the person.'
def summary(self):
if (not self): return u'' s = (u'Person\n=====\nName: %s\n' % self.get('long imdb canonical name', u'')) bdate = self.get('birth date') if bdate: s += (u'Birth date: %s' % bdate) bnotes = self.get('birth notes') if bnotes: s += (u' (...
'Compute .mo name from .po name or language'
def make_filenames(self, filename, outfile=None):
if filename.endswith('.po'): infile = filename else: infile = (filename + '.po') if (outfile is None): outfile = (os.path.splitext(infile)[0] + '.mo') return (infile, outfile)
'Add a non-fuzzy translation to the dictionary.'
def add(self, id, str, fuzzy):
if ((not fuzzy) and str): self.messages[id] = str
'Return the generated output.'
def generate_mo(self):
keys = self.messages.keys() keys.sort() offsets = [] ids = '' strs = '' for id in keys: offsets.append((len(ids), len(id), len(strs), len(self.messages[id]))) ids += (id + '\x00') strs += (self.messages[id] + '\x00') output = [] keystart = ((7 * 4) + (16 * len(key...
'Initialize the parser. useModule can be used to force it to use \'BeautifulSoup\' or \'lxml\'; by default, it\'s auto-detected, using \'lxml\' if available and falling back to \'BeautifulSoup\' otherwise.'
def __init__(self, useModule=None):
if (useModule is None): useModule = ('lxml', 'BeautifulSoup') if (not isinstance(useModule, (tuple, list))): useModule = [useModule] self._useModule = useModule nrMods = len(useModule) _gotError = False for (idx, mod) in enumerate(useModule): mod = mod.strip().lower() ...
'Reset the parser.'
def reset(self):
self._namesRefs = {} self._titlesRefs = {} self._charactersRefs = {} self._reset()
'Subclasses can override this method, if needed.'
def _init(self):
pass
'Subclasses can override this method, if needed.'
def _reset(self):
pass
'Return the dictionary generated from the given html string; getRefs can be used to force the gathering of movies/persons/characters references.'
def parse(self, html_string, getRefs=None, **kwds):
self.reset() if (getRefs is not None): self.getRefs = getRefs else: self.getRefs = self._defGetRefs if (not isinstance(html_string, unicode)): html_string = unicode(html_string, 'latin_1', 'replace') html_string = subXMLRefs(html_string) html_string = self.preprocess_stri...
'Return a dom object, from the given string.'
def get_dom(self, html_string):
try: dom = self.fromstring(html_string) if (dom is None): dom = self._build_empty_dom() self._logger.error('%s: using a fake empty DOM', self._cname) return dom except Exception as e: self._logger.error('%s: caught exception parsing...
'Return elements matching the given XPath.'
def xpath(self, element, path):
try: xpath_result = element.xpath(path) if self._is_xml_unicode: return xpath_result result = [] for item in xpath_result: if isinstance(item, str): item = unicode(item) result.append(item) return result except Exception...
'Convert the element to a string.'
def tostring(self, element):
if isinstance(element, (unicode, str)): return unicode(element) else: try: return self._tostring(element, encoding=unicode) except Exception as e: self._logger.error('%s: unable to convert to string', self._cname, exc_info=True) return u...
'Clone an element.'
def clone(self, element):
return self.fromstring(self.tostring(element))
'Here we can modify the text, before it\'s parsed.'
def preprocess_string(self, html_string):
if (not html_string): return html_string html_string = html_string.replace(u' \xbb', u'') html_string = html_string.replace(u'&ndash;', u'-') try: preprocessors = self.preprocessors except AttributeError: return html_string for (src, sub) in preprocessors: if c...
'Collect references.'
def gather_refs(self, dom):
grParser = GatherRefs(useModule=self._useModule) grParser._as = self._as grParser._modFunct = self._modFunct refs = grParser.parse_dom(dom) refs = grParser.postprocess_data(refs) self._namesRefs = refs['names refs'] self._titlesRefs = refs['titles refs'] self._charactersRefs = refs...
'Last chance to modify the dom, before the rules in self.extractors are applied by the parse_dom method.'
def preprocess_dom(self, dom):
return dom
'Parse the given dom according to the rules specified in self.extractors.'
def parse_dom(self, dom):
result = {} for extractor in self.extractors: if (extractor.group is None): elements = [(extractor.label, element) for element in self.xpath(dom, extractor.path)] else: groups = self.xpath(dom, extractor.group) elements = [] for group in groups: ...
'Here we can modify the data.'
def postprocess_data(self, data):
return data
'Set parameters of Movie/Person/... instances, since they are not always set in the parser\'s code.'
def set_objects_params(self, data):
for obj in flatten(data, yieldDictKeys=True, scalar=_Container): obj.accessSystem = self._as obj.modFunct = self._modFunct
'Modify data according to the expected output.'
def add_refs(self, data):
if self.getRefs: titl_re = (u'(%s)' % '|'.join([re.escape(x) for x in self._titlesRefs.keys()])) if (titl_re != u'()'): re_titles = re.compile(titl_re, re.U) else: re_titles = None nam_re = (u'(%s)' % '|'.join([re.escape(x) for x in self._namesRefs.keys()])) ...
'Initialize an Extractor object, used to instruct the DOM parser about how to parse a document.'
def __init__(self, label, path, attrs, group=None, group_key=None, group_key_normalize=None):
self.label = label self.group = group if (group_key is None): self.group_key = './/text()' else: self.group_key = group_key self.group_key_normalize = group_key_normalize self.path = path if isinstance(attrs, Attribute): attrs = [attrs] self.attrs = attrs
'String representation of an Extractor object.'
def __repr__(self):
r = ('<Extractor id:%s (label=%s, path=%s, attrs=%s, group=%s, group_key=%s group_key_normalize=%s)>' % (id(self), self.label, self.path, repr(self.attrs), self.group, self.group_key, self.group_key_normalize)) return r
'Initialize an Attribute object, used to specify the attribute to consider, for a given node.'
def __init__(self, key, multi=False, path=None, joiner=None, postprocess=None):
self.key = key self.multi = multi self.path = path if (joiner is None): joiner = '' self.joiner = joiner self.postprocess = postprocess
'String representation of an Attribute object.'
def __repr__(self):
r = ('<Attribute id:%s (key=%s, multi=%s, path=%s, joiner=%s, postprocess=%s)>' % (id(self), self.key, self.multi, repr(self.path), self.joiner, repr(self.postprocess))) return r
'Initialize a proxy for the given module; defaultKeys, if set, muste be a dictionary of values to set for instanced objects.'
def __init__(self, module, defaultKeys=None, oldParsers=False, useModule=None, fallBackToNew=False):
if (oldParsers or fallBackToNew): _aux_logger.warn('The old set of parsers was removed; falling back to the new parsers.') self.useModule = useModule if (defaultKeys is None): defaultKeys = {} self._defaultKeys = defaultKeys self._module = module
'Called only when no look-up is found.'
def __getattr__(self, name):
_sm = self._module if (name in _sm._OBJECTS): _entry = _sm._OBJECTS[name] kwds = {} if self.useModule: kwds = {'useModule': self.useModule} parserClass = _entry[0][0] obj = parserClass(**kwds) attrsToSet = self._defaultKeys.copy() attrsToSet.up...
'Return the used proxy, or an empty string.'
def get_proxy(self):
return self.proxies.get('http', '')
'Set the proxy.'
def set_proxy(self, proxy):
if (not proxy): if self.proxies.has_key('http'): del self.proxies['http'] else: if (not proxy.lower().startswith('http://')): proxy = ('http://%s' % proxy) self.proxies['http'] = proxy
'Set a default header.'
def set_header(self, header, value, _overwrite=True):
if _overwrite: self.del_header(header) self.addheaders.append((header, value))
'Return the first value of a header, or None if not present.'
def get_header(self, header):
for index in xrange(len(self.addheaders)): if (self.addheaders[index][0] == header): return self.addheaders[index][1] return None
'Remove a default header.'
def del_header(self, header):
for index in xrange(len(self.addheaders)): if (self.addheaders[index][0] == header): del self.addheaders[index] break
'Retrieves the given URL, and returns a unicode string, trying to guess the encoding of the data (assuming latin_1 by default)'
def retrieve_unicode(self, url, size=(-1)):
encode = None try: if (size != (-1)): self.set_header('Range', ('bytes=0-%d' % size)) uopener = self.open(url) kwds = {} if ((PY_VERSION > (2, 3)) and (not IN_GAE)): kwds['size'] = size content = uopener.read(**kwds) self._last_url = uopene...
'Initialize the access system.'
def __init__(self, isThin=0, adultSearch=1, proxy=(-1), oldParsers=False, fallBackToNew=False, useModule=None, cookie_id=(-1), timeout=30, cookie_uu=None, *arguments, **keywords):
IMDbBase.__init__(self, *arguments, **keywords) self.urlOpener = IMDbURLopener() self.isThin = isThin self._getRefs = True self._mdparse = False if isThin: self._http_logger.warn(('"httpThin" access system no longer ' + 'supported; "http" used automatically'), exc...
'Normalize the given movieID.'
def _normalize_movieID(self, movieID):
try: return ('%07d' % int(movieID)) except ValueError as e: raise IMDbParserError(('invalid movieID "%s": %s' % (movieID, e)))
'Normalize the given personID.'
def _normalize_personID(self, personID):
try: return ('%07d' % int(personID)) except ValueError as e: raise IMDbParserError(('invalid personID "%s": %s' % (personID, e)))
'Normalize the given characterID.'
def _normalize_characterID(self, characterID):
try: return ('%07d' % int(characterID)) except ValueError as e: raise IMDbParserError(('invalid characterID "%s": %s' % (characterID, e)))
'Normalize the given companyID.'
def _normalize_companyID(self, companyID):
try: return ('%07d' % int(companyID)) except ValueError as e: raise IMDbParserError(('invalid companyID "%s": %s' % (companyID, e)))
'Translate a movieID in an imdbID; in this implementation the movieID _is_ the imdbID.'
def get_imdbMovieID(self, movieID):
return movieID
'Translate a personID in an imdbID; in this implementation the personID _is_ the imdbID.'
def get_imdbPersonID(self, personID):
return personID
'Translate a characterID in an imdbID; in this implementation the characterID _is_ the imdbID.'
def get_imdbCharacterID(self, characterID):
return characterID
'Translate a companyID in an imdbID; in this implementation the companyID _is_ the imdbID.'
def get_imdbCompanyID(self, companyID):
return companyID
'Return the used proxy or an empty string.'
def get_proxy(self):
return self.urlOpener.get_proxy()
'Set the web proxy to use. It should be a string like \'http://localhost:8080/\'; if the string is empty, no proxy will be used. If set, the value of the environment variable HTTP_PROXY is automatically used.'
def set_proxy(self, proxy):
self.urlOpener.set_proxy(proxy)
'Set the default timeout, in seconds, of the connection.'
def set_timeout(self, timeout):
try: timeout = int(timeout) except Exception: timeout = 0 if (timeout <= 0): timeout = None socket.setdefaulttimeout(timeout)
'Set a cookie to access an IMDb\'s account.'
def set_cookies(self, cookie_id, cookie_uu):
c_header = ('id=%s; uu=%s' % (cookie_id, cookie_uu)) self.urlOpener.set_header('Cookie', c_header)
'Remove the used cookie.'
def del_cookies(self):
self.urlOpener.del_header('Cookie')
'If doAdult is true, \'adult\' movies are included in the search results; cookie_id and cookie_uu are optional parameters to select a specific account (see your cookie or cookies.txt file.'
def do_adult_search(self, doAdult, cookie_id=_cookie_id, cookie_uu=_cookie_uu):
if doAdult: self.set_cookies(cookie_id, cookie_uu) else: self.urlOpener.del_header('Cookie')
'Retrieve the given URL.'
def _retrieve(self, url, size=(-1), _noCookies=False):
_cookies = None if _noCookies: _cookies = self.urlOpener.get_header('Cookie') self.del_cookies() self._http_logger.debug('fetching url %s (size: %d)', url, size) try: ret = self.urlOpener.retrieve_unicode(url, size=size) finally: if (_noCookies and _cookie...
'Retrieve the web page for a given search. kind can be \'tt\' (for titles), \'nm\' (for names), \'char\' (for characters) or \'co\' (for companies). ton is the title or the name to search. results is the maximum number of results to be retrieved.'
def _get_search_content(self, kind, ton, results):
if isinstance(ton, unicode): try: ton = ton.encode('utf-8') except Exception as e: try: ton = ton.encode('iso8859-1') except Exception as e: pass params = ('q=%s&s=%s&mx=%s' % (quote_plus(ton), kind, str(results))) if (kind ...
'Sets up the initial relations between this element and other elements.'
def setup(self, parent=None, previous=None):
self.parent = parent self.previous = previous self.next = None self.previousSibling = None self.nextSibling = None if (self.parent and self.parent.contents): self.previousSibling = self.parent.contents[(-1)] self.previousSibling.nextSibling = self
'Destructively rips this element out of the tree.'
def extract(self):
if self.parent: try: self.parent.contents.remove(self) except ValueError: pass lastChild = self._lastRecursiveChild() nextElement = lastChild.next if self.previous: self.previous.next = nextElement if nextElement: nextElement.previous = self.pr...
'Finds the last element beneath this object to be parsed.'
def _lastRecursiveChild(self):
lastChild = self while (hasattr(lastChild, 'contents') and lastChild.contents): lastChild = lastChild.contents[(-1)] return lastChild
'Appends the given tag to the contents of this tag.'
def append(self, tag):
self.insert(len(self.contents), tag)
'Returns the first item that matches the given criteria and appears after this Tag in the document.'
def findNext(self, name=None, attrs={}, text=None, **kwargs):
return self._findOne(self.findAllNext, name, attrs, text, **kwargs)
'Returns all items that match the given criteria and appear after this Tag in the document.'
def findAllNext(self, name=None, attrs={}, text=None, limit=None, **kwargs):
return self._findAll(name, attrs, text, limit, self.nextGenerator, **kwargs)
'Returns the closest sibling to this Tag that matches the given criteria and appears after this Tag in the document.'
def findNextSibling(self, name=None, attrs={}, text=None, **kwargs):
return self._findOne(self.findNextSiblings, name, attrs, text, **kwargs)
'Returns the siblings of this Tag that match the given criteria and appear after this Tag in the document.'
def findNextSiblings(self, name=None, attrs={}, text=None, limit=None, **kwargs):
return self._findAll(name, attrs, text, limit, self.nextSiblingGenerator, **kwargs)
'Returns the first item that matches the given criteria and appears before this Tag in the document.'
def findPrevious(self, name=None, attrs={}, text=None, **kwargs):
return self._findOne(self.findAllPrevious, name, attrs, text, **kwargs)
'Returns all items that match the given criteria and appear before this Tag in the document.'
def findAllPrevious(self, name=None, attrs={}, text=None, limit=None, **kwargs):
return self._findAll(name, attrs, text, limit, self.previousGenerator, **kwargs)
'Returns the closest sibling to this Tag that matches the given criteria and appears before this Tag in the document.'
def findPreviousSibling(self, name=None, attrs={}, text=None, **kwargs):
return self._findOne(self.findPreviousSiblings, name, attrs, text, **kwargs)
'Returns the siblings of this Tag that match the given criteria and appear before this Tag in the document.'
def findPreviousSiblings(self, name=None, attrs={}, text=None, limit=None, **kwargs):
return self._findAll(name, attrs, text, limit, self.previousSiblingGenerator, **kwargs)
'Returns the closest parent of this Tag that matches the given criteria.'
def findParent(self, name=None, attrs={}, **kwargs):
r = None l = self.findParents(name, attrs, 1) if l: r = l[0] return r
'Returns the parents of this Tag that match the given criteria.'
def findParents(self, name=None, attrs={}, limit=None, **kwargs):
return self._findAll(name, attrs, None, limit, self.parentGenerator, **kwargs)
'Iterates over a generator looking for things that match.'
def _findAll(self, name, attrs, text, limit, generator, **kwargs):
if isinstance(name, SoupStrainer): strainer = name else: strainer = SoupStrainer(name, attrs, text, **kwargs) results = ResultSet(strainer) g = generator() while True: try: i = g.next() except StopIteration: break if i: foun...
'Encodes an object to a string in some encoding, or to Unicode.'
def toEncoding(self, s, encoding=None):
if isinstance(s, unicode): if encoding: s = s.encode(encoding) elif isinstance(s, str): if encoding: s = s.encode(encoding) else: s = unicode(s) elif encoding: s = self.toEncoding(str(s), encoding) else: s = unicode(s) retur...
'Create a new NavigableString. When unpickling a NavigableString, this method is called with the string in DEFAULT_OUTPUT_ENCODING. That encoding needs to be passed in to the superclass\'s __new__ or the superclass won\'t know how to handle non-ASCII characters.'
def __new__(cls, value):
if isinstance(value, unicode): return unicode.__new__(cls, value) return unicode.__new__(cls, value, DEFAULT_OUTPUT_ENCODING)
'text.string gives you text. This is for backwards compatibility for Navigable*String, but for CData* it lets you get the string without the CData wrapper.'
def __getattr__(self, attr):
if (attr == 'string'): return self else: raise AttributeError, ("'%s' object has no attribute '%s'" % (self.__class__.__name__, attr))
'Cheap function to invert a hash.'
def _invert(h):
i = {} for (k, v) in h.items(): i[v] = k return i
'Used in a call to re.sub to replace HTML, XML, and numeric entities with the appropriate Unicode characters. If HTML entities are being converted, any unrecognized entities are escaped.'
def _convertEntities(self, match):
x = match.group(1) if (self.convertHTMLEntities and (x in name2codepoint)): return unichr(name2codepoint[x]) elif (x in self.XML_ENTITIES_TO_SPECIAL_CHARS): if self.convertXMLEntities: return self.XML_ENTITIES_TO_SPECIAL_CHARS[x] else: return (u'&%s;' % x) ...
'Basic constructor.'
def __init__(self, parser, name, attrs=None, parent=None, previous=None):
self.parserClass = parser.__class__ self.isSelfClosing = parser.isSelfClosingTag(name) self.name = name if (attrs == None): attrs = [] self.attrs = attrs self.contents = [] self.setup(parent, previous) self.hidden = False self.containsSubstitutions = False self.convertHTM...
'Returns the value of the \'key\' attribute for the tag, or the value given for \'default\' if it doesn\'t have that attribute.'
def get(self, key, default=None):
return self._getAttrMap().get(key, default)
'tag[key] returns the value of the \'key\' attribute for the tag, and throws an exception if it\'s not there.'
def __getitem__(self, key):
return self._getAttrMap()[key]
'Iterating over a tag iterates over its contents.'
def __iter__(self):
return iter(self.contents)
'The length of a tag is the length of its list of contents.'
def __len__(self):
return len(self.contents)
'A tag is non-None even if it has no contents.'
def __nonzero__(self):
return True
'Setting tag[key] sets the value of the \'key\' attribute for the tag.'
def __setitem__(self, key, value):
self._getAttrMap() self.attrMap[key] = value found = False for i in range(0, len(self.attrs)): if (self.attrs[i][0] == key): self.attrs[i] = (key, value) found = True if (not found): self.attrs.append((key, value)) self._getAttrMap()[key] = value
'Deleting tag[key] deletes all \'key\' attributes for the tag.'
def __delitem__(self, key):
for item in self.attrs: if (item[0] == key): self.attrs.remove(item) self._getAttrMap() if self.attrMap.has_key(key): del self.attrMap[key]
'Calling a tag like a function is the same as calling its findAll() method. Eg. tag(\'a\') returns a list of all the A tags found within this tag.'
def __call__(self, *args, **kwargs):
return apply(self.findAll, args, kwargs)
'Returns true iff this tag has the same name, the same attributes, and the same contents (recursively) as the given tag. NOTE: right now this will return false if two tags have the same attributes in a different order. Should this be fixed?'
def __eq__(self, other):
if ((not hasattr(other, 'name')) or (not hasattr(other, 'attrs')) or (not hasattr(other, 'contents')) or (self.name != other.name) or (self.attrs != other.attrs) or (len(self) != len(other))): return False for i in range(0, len(self.contents)): if (self.contents[i] != other.contents[i]): ...
'Returns true iff this tag is not identical to the other tag, as defined in __eq__.'
def __ne__(self, other):
return (not (self == other))
'Renders this tag as a string.'
def __repr__(self, encoding=DEFAULT_OUTPUT_ENCODING):
return self.__str__(encoding)
'Used with a regular expression to substitute the appropriate XML entity for an XML special character.'
def _sub_entity(self, x):
return (('&' + self.XML_SPECIAL_CHARS_TO_ENTITIES[x.group(0)[0]]) + ';')
'Returns a string or Unicode representation of this tag and its contents. To get Unicode, pass None for encoding. NOTE: since Python\'s HTML parser consumes whitespace, this method is not certain to reproduce the whitespace present in the original string.'
def __str__(self, encoding=DEFAULT_OUTPUT_ENCODING, prettyPrint=False, indentLevel=0):
encodedName = self.toEncoding(self.name, encoding) attrs = [] if self.attrs: for (key, val) in self.attrs: fmt = '%s="%s"' if isString(val): if (self.containsSubstitutions and ('%SOUP-ENCODING%' in val)): val = self.substituteEncoding(val, ...
'Recursively destroys the contents of this tree.'
def decompose(self):
contents = [i for i in self.contents] for i in contents: if isinstance(i, Tag): i.decompose() else: i.extract() self.extract()
'Renders the contents of this tag as a string in the given encoding. If encoding is None, returns a Unicode string..'
def renderContents(self, encoding=DEFAULT_OUTPUT_ENCODING, prettyPrint=False, indentLevel=0):
s = [] for c in self: text = None if isinstance(c, NavigableString): text = c.__str__(encoding) elif isinstance(c, Tag): s.append(c.__str__(encoding, prettyPrint, indentLevel)) if (text and prettyPrint): text = text.strip() if text: ...
'Return only the first child of this Tag matching the given criteria.'
def find(self, name=None, attrs={}, recursive=True, text=None, **kwargs):
r = None l = self.findAll(name, attrs, recursive, text, 1, **kwargs) if l: r = l[0] return r
'Extracts a list of Tag objects that match the given criteria. You can specify the name of the Tag and any attributes you want the Tag to have. The value of a key-value pair in the \'attrs\' map can be a string, a list of strings, a regular expression object, or a callable that takes a string and returns whether or no...
def findAll(self, name=None, attrs={}, recursive=True, text=None, limit=None, **kwargs):
generator = self.recursiveChildGenerator if (not recursive): generator = self.childGenerator return self._findAll(name, attrs, text, limit, generator, **kwargs)
'Initializes a map representation of this tag\'s attributes, if not already initialized.'
def _getAttrMap(self):
if (not getattr(self, 'attrMap')): self.attrMap = {} for (key, value) in self.attrs: self.attrMap[key] = value return self.attrMap