aboutsummaryrefslogtreecommitdiff
path: root/budget/utils.py
diff options
context:
space:
mode:
authorJocelyn Delalande <jocelyn@crapouillou.net>2017-03-29 15:31:28 +0200
committerJocelyn Delalande <jocelyn@crapouillou.net>2017-03-29 15:31:28 +0200
commit95d0c71827502f6e5ab0f5280176d07725073858 (patch)
tree613b07689687c9f14c5622f5b1f96ccc5ebb49cb /budget/utils.py
parentf6236b43ca5556c6df764e95428d5efced8ff4e1 (diff)
downloadihatemoney-mirror-95d0c71827502f6e5ab0f5280176d07725073858.zip
ihatemoney-mirror-95d0c71827502f6e5ab0f5280176d07725073858.tar.gz
ihatemoney-mirror-95d0c71827502f6e5ab0f5280176d07725073858.tar.bz2
Use propper base64 encoding version for py3
Removes py3-only warning (this alias might be removed in future py3 version): > DeprecationWarning: encodestring() is a deprecated alias, use encodebytes() > ('%s:%s' % (username, password)).encode('utf-8')).decode('utf-8').replace('\n', '') py2-compatible change.
Diffstat (limited to 'budget/utils.py')
-rw-r--r--budget/utils.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/budget/utils.py b/budget/utils.py
index f518049..0e6251b 100644
--- a/budget/utils.py
+++ b/budget/utils.py
@@ -1,3 +1,4 @@
+import base64
import re
import inspect
@@ -120,3 +121,6 @@ def list_of_dicts2csv(dict_to_convert):
if six.PY3:
csv_file = BytesIO(csv_file.getvalue().encode('utf-8'))
return csv_file
+
+# base64 encoding that works with both py2 and py3 and yield no warning
+base64_encode = base64.encodestring if six.PY2 else base64.encodebytes