1
0
mirror of https://github.com/balkian/bitter.git synced 2024-12-22 08:28:12 +00:00

Fix py2 compatibility

This commit is contained in:
J. Fernando Sánchez 2017-12-20 16:51:53 +01:00
parent 27bc3557b2
commit 7c829ee102
2 changed files with 8 additions and 2 deletions

View File

@ -1 +1 @@
0.7.6 0.7.7

View File

@ -30,6 +30,12 @@ from bitter.models import Following, User, ExtractorEntry, make_session
from bitter import config from bitter import config
# Fix Python 2.x.
try:
UNICODE_EXISTS = bool(type(unicode))
except NameError:
unicode = lambda s: str(s)
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -90,7 +96,7 @@ def read_config(conffile):
elif 'BITTER_CONFIG' not in os.environ: elif 'BITTER_CONFIG' not in os.environ:
raise Exception('No config file or BITTER_CONFIG env variable.') raise Exception('No config file or BITTER_CONFIG env variable.')
else: else:
f = io.StringIO(os.environ.get('BITTER_CONFIG', "").strip().replace('\\n', '\n')) f = io.StringIO(unicode(os.environ.get('BITTER_CONFIG', "")).strip().replace('\\n', '\n'))
return yaml.load(f) or {'credentials': []} return yaml.load(f) or {'credentials': []}