diff options
author | Leonard Richardson <leonard.richardson@canonical.com> | 2011-02-18 12:21:18 -0500 |
---|---|---|
committer | Leonard Richardson <leonard.richardson@canonical.com> | 2011-02-18 12:21:18 -0500 |
commit | 845dbe03bee981bcc5d24ef06ca868042968aa4c (patch) | |
tree | 83672d245b08a7a9456f3c29fa62885b13361bfa /beautifulsoup/dammit.py | |
parent | 945b719a28c229178e710b749d2af4d00a81bdba (diff) |
Made Unicode, Dammit more PEP-8 compliant.
Diffstat (limited to 'beautifulsoup/dammit.py')
-rw-r--r-- | beautifulsoup/dammit.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/beautifulsoup/dammit.py b/beautifulsoup/dammit.py index 954ca54..f810d15 100644 --- a/beautifulsoup/dammit.py +++ b/beautifulsoup/dammit.py @@ -45,12 +45,12 @@ class UnicodeDammit: CHARSET_ALIASES = { "macintosh" : "mac-roman", "x-sjis" : "shift-jis" } - def __init__(self, markup, overrideEncodings=[], - smartQuotesTo='xml', isHTML=False): - self.declaredHTMLEncoding = None + def __init__(self, markup, override_encodings=[], + smart_quotes_to='xml', isHTML=False): + self.declared_html_encoding = None self.markup, documentEncoding, sniffedEncoding = \ self._detectEncoding(markup, isHTML) - self.smartQuotesTo = smartQuotesTo + self.smart_quotes_to = smart_quotes_to self.triedEncodings = [] if markup == '' or isinstance(markup, unicode): self.originalEncoding = None @@ -59,7 +59,7 @@ class UnicodeDammit: u = None for proposedEncoding in ( - overrideEncodings + [documentEncoding, sniffedEncoding]): + override_encodings + [documentEncoding, sniffedEncoding]): if proposedEncoding is not None: u = self._convertFrom(proposedEncoding) if u: @@ -84,7 +84,7 @@ class UnicodeDammit: orig = match.group(1) sub = self.MS_CHARS.get(orig) if type(sub) == types.TupleType: - if self.smartQuotesTo == 'xml': + if self.smart_quotes_to == 'xml': sub = '&#x'.encode() + sub[1].encode() + ';'.encode() else: sub = '&'.encode() + sub[0].encode() + ';'.encode() @@ -101,7 +101,7 @@ class UnicodeDammit: # Convert smart quotes to HTML if coming from an encoding # that might have them. - if self.smartQuotesTo and proposed.lower() in("windows-1252", + if self.smart_quotes_to and proposed.lower() in("windows-1252", "iso-8859-1", "iso-8859-2"): smart_quotes_re = "([\x80-\x9f])" @@ -205,7 +205,7 @@ class UnicodeDammit: xml_encoding = xml_encoding_match.groups()[0].decode( 'ascii').lower() if isHTML: - self.declaredHTMLEncoding = xml_encoding + self.declared_html_encoding = xml_encoding if sniffed_xml_encoding and \ (xml_encoding in ('iso-10646-ucs-2', 'ucs-2', 'csunicode', 'iso-10646-ucs-4', 'ucs-4', 'csucs4', |