Commit f0903e168bec0bbb6f95536f7fa27bcaa48c4265

Authored by Antoine Goutenoir
1 parent 6e04d5e5
Exists in master

chore: move to python 3 API

Spent time is not attached to this commit only.
/spend 11h
flaskr/content.py
1 1 from collections import namedtuple
2   -from yaml import safe_load as yaml_safe_load
3 2 from os.path import abspath, dirname, join
4 3  
  4 +from yaml import safe_load as yaml_safe_load
  5 +
  6 +# Move this to ENV, perhaps
  7 +base_url = "https://travel-footprint-calculator.irap.omp.eu"
5 8  
6 9 PROJECT_DIRECTORY = abspath(dirname(dirname(__file__)))
7 10  
... ... @@ -21,7 +24,7 @@ class Struct(object):
21 24 def __new__(cls, data):
22 25 if isinstance(data, dict):
23 26 return namedtuple(
24   - 'Struct', data.iterkeys()
  27 + 'Struct', data.keys()
25 28 )(
26 29 *(Struct(val) for val in data.values())
27 30 )
... ... @@ -33,9 +36,6 @@ class Struct(object):
33 36  
34 37 content = Struct(content_dict)
35 38  
36   -# Move this to ENV, perhaps
37   -base_url = "https://travel-footprint-calculator.irap.omp.eu"
38   -
39 39  
40 40 # For Python3?
41 41 # def dict2obj(d):
... ...
flaskr/controllers/main_controller.py
... ... @@ -154,8 +154,9 @@ def gather_addresses(from_list, from_file):
154 154 for address in addresses:
155 155 if not address:
156 156 continue
157   - if type(address).__name__ == 'str':
158   - address = unicode(address, 'utf-8')
  157 + # if type(address).__name__ == 'str':
  158 + # address = str(address).encode('utf-8')
  159 + address = str(address)
159 160 if to_ignore.match(address) is not None:
160 161 continue
161 162 clean_addresses.append(address)
... ...
requirements.txt
... ... @@ -10,7 +10,7 @@ Flask-DebugToolbar==0.10.0
10 10 Flask-Login==0.4.0
11 11 Flask-Mail==0.9.1
12 12 Flask-Script==2.0.5
13   -Flask-SQLAlchemy==2.1
  13 +Flask-SQLAlchemy==2.5.1
14 14 Flask-WTF==0.14
15 15 Flask-Sessionstore==0.4.5
16 16 Flask-Session-Captcha==1.2.0
... ...