some fixes, pulled the codename from the code
This commit is contained in:
parent
4e38899e97
commit
f427df17ab
4 changed files with 18 additions and 12 deletions
|
@ -154,6 +154,7 @@ std_headers = {
|
|||
'Accept-Encoding': 'gzip, deflate',
|
||||
'Accept-Language': 'en-us,en;q=0.5',
|
||||
}
|
||||
|
||||
def preferredencoding():
|
||||
"""Get preferred encoding.
|
||||
|
||||
|
@ -187,6 +188,11 @@ else:
|
|||
with open(fn, 'w', encoding='utf-8') as f:
|
||||
json.dump(obj, f)
|
||||
|
||||
# Some library functions return bytestring on 2.X and unicode on 3.X
|
||||
def enforce_unicode(s, encoding='utf-8'):
|
||||
if type(s) != type(u''):
|
||||
return s.decode(encoding)
|
||||
return s
|
||||
|
||||
def htmlentity_transform(matchobj):
|
||||
"""Transforms an HTML entity to a character.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue