diff options
author | Leonard Richardson <leonard.richardson@canonical.com> | 2009-04-09 16:14:09 -0400 |
---|---|---|
committer | Leonard Richardson <leonard.richardson@canonical.com> | 2009-04-09 16:14:09 -0400 |
commit | 87e7a7949e1cbcfbc7feebda48d67ad6ef0da303 (patch) | |
tree | e76f3ef348040ae69d8fe734df5b18e45c64097a /BeautifulSoup.py | |
parent | 4440f31504605ac7572ca8d84d4cbfd7af19aa1e (diff) | |
parent | a7ab21b82202d9b8e6bddb7657de6774ebfc9071 (diff) |
Merge from work on laptop.
Diffstat (limited to 'BeautifulSoup.py')
-rw-r--r-- | BeautifulSoup.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/BeautifulSoup.py b/BeautifulSoup.py index 99ce460..aceb6d3 100644 --- a/BeautifulSoup.py +++ b/BeautifulSoup.py @@ -509,6 +509,8 @@ class Tag(PageElement, Entities): self.isSelfClosing = builder.isSelfClosingTag(name) if attrs == None: attrs = [] + if isinstance(attrs, types.DictType): + self.attrMap = attrs self.attrs = attrs self.contents = [] self.setup(parent, previous) @@ -523,8 +525,10 @@ class Tag(PageElement, Entities): if val is None: return kval return (k, re.sub("&(#\d+|#x[0-9a-fA-F]+|\w+);", convert_one, val)) - - self.attrs = map(convert, self.attrs) + if isinstance(attrs, types.DictType): + self.attrs = [convert(kv) for kv in attrs.items()] + else: + self.attrs = map(convert, attrs) def get(self, key, default=None): """Returns the value of the 'key' attribute for the tag, or @@ -1660,6 +1664,8 @@ class BeautifulSoup(BeautifulStoneSoup): def _defaultBuilder(self): return HTMLParserBuilder() +class ICantBelieveItsBeautifulSoup(BeautifulStoneSoup): + pass class StopParsing(Exception): pass |