trivial: apply black/isort
This commit is contained in:
parent
0472d972ca
commit
982f109c17
|
@ -1,7 +1,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
@ -14,12 +14,25 @@ class Migration(migrations.Migration):
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='ImioLiegeLisrue',
|
name='ImioLiegeLisrue',
|
||||||
fields=[
|
fields=[
|
||||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
(
|
||||||
|
'id',
|
||||||
|
models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True),
|
||||||
|
),
|
||||||
('title', models.CharField(max_length=50)),
|
('title', models.CharField(max_length=50)),
|
||||||
('slug', models.SlugField(unique=True)),
|
('slug', models.SlugField(unique=True)),
|
||||||
('description', models.TextField()),
|
('description', models.TextField()),
|
||||||
('service_url', models.CharField(help_text='SIG Web Service URL (ex: https://e-services.liege.be:8443/)', max_length=128, verbose_name='Service URL')),
|
(
|
||||||
('verify_cert', models.BooleanField(default=True, verbose_name='Check HTTPS Certificate validity')),
|
'service_url',
|
||||||
|
models.CharField(
|
||||||
|
help_text='SIG Web Service URL (ex: https://e-services.liege.be:8443/)',
|
||||||
|
max_length=128,
|
||||||
|
verbose_name='Service URL',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
'verify_cert',
|
||||||
|
models.BooleanField(default=True, verbose_name='Check HTTPS Certificate validity'),
|
||||||
|
),
|
||||||
('users', models.ManyToManyField(to='base.ApiUser', blank=True)),
|
('users', models.ManyToManyField(to='base.ApiUser', blank=True)),
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
|
|
|
@ -14,6 +14,19 @@ class Migration(migrations.Migration):
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='imioliegelisrue',
|
model_name='imioliegelisrue',
|
||||||
name='log_level',
|
name='log_level',
|
||||||
field=models.CharField(default=b'NOTSET', max_length=10, verbose_name='Log Level', choices=[(b'NOTSET', b'NOTSET'), (b'DEBUG', b'DEBUG'), (b'INFO', b'INFO'), (b'WARNING', b'WARNING'), (b'ERROR', b'ERROR'), (b'CRITICAL', b'CRITICAL'), (b'FATAL', b'FATAL')]),
|
field=models.CharField(
|
||||||
|
default=b'NOTSET',
|
||||||
|
max_length=10,
|
||||||
|
verbose_name='Log Level',
|
||||||
|
choices=[
|
||||||
|
(b'NOTSET', b'NOTSET'),
|
||||||
|
(b'DEBUG', b'DEBUG'),
|
||||||
|
(b'INFO', b'INFO'),
|
||||||
|
(b'WARNING', b'WARNING'),
|
||||||
|
(b'ERROR', b'ERROR'),
|
||||||
|
(b'CRITICAL', b'CRITICAL'),
|
||||||
|
(b'FATAL', b'FATAL'),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
|
@ -14,11 +14,26 @@ class Migration(migrations.Migration):
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='imioliegelisrue',
|
model_name='imioliegelisrue',
|
||||||
name='profile',
|
name='profile',
|
||||||
field=models.CharField(default=b'Liege', max_length=100, choices=[(b'LIEGE', b'Liege'), (b'NAMUR', b'Namur')]),
|
field=models.CharField(
|
||||||
|
default=b'Liege', max_length=100, choices=[(b'LIEGE', b'Liege'), (b'NAMUR', b'Namur')]
|
||||||
|
),
|
||||||
),
|
),
|
||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name='imioliegelisrue',
|
model_name='imioliegelisrue',
|
||||||
name='log_level',
|
name='log_level',
|
||||||
field=models.CharField(default=b'INFO', max_length=10, verbose_name='Log Level', choices=[(b'NOTSET', b'NOTSET'), (b'DEBUG', b'DEBUG'), (b'INFO', b'INFO'), (b'WARNING', b'WARNING'), (b'ERROR', b'ERROR'), (b'CRITICAL', b'CRITICAL'), (b'FATAL', b'FATAL')]),
|
field=models.CharField(
|
||||||
|
default=b'INFO',
|
||||||
|
max_length=10,
|
||||||
|
verbose_name='Log Level',
|
||||||
|
choices=[
|
||||||
|
(b'NOTSET', b'NOTSET'),
|
||||||
|
(b'DEBUG', b'DEBUG'),
|
||||||
|
(b'INFO', b'INFO'),
|
||||||
|
(b'WARNING', b'WARNING'),
|
||||||
|
(b'ERROR', b'ERROR'),
|
||||||
|
(b'CRITICAL', b'CRITICAL'),
|
||||||
|
(b'FATAL', b'FATAL'),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
import unicodedata
|
import unicodedata
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils.encoding import force_str
|
from django.utils.encoding import force_str
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
@ -38,16 +37,12 @@ class ImioLiegeLisrue(BaseResource):
|
||||||
help_text=_("SIG Web Service URL (ex: https://e-services.liege.be:8443/)"),
|
help_text=_("SIG Web Service URL (ex: https://e-services.liege.be:8443/)"),
|
||||||
)
|
)
|
||||||
profile = models.CharField(max_length=100, choices=PROFILE_CHOICES, default="Liege")
|
profile = models.CharField(max_length=100, choices=PROFILE_CHOICES, default="Liege")
|
||||||
include_all_of_belgium = models.BooleanField(
|
include_all_of_belgium = models.BooleanField(default=True, verbose_name=_("Include all of Belgium"))
|
||||||
default=True, verbose_name=_("Include all of Belgium")
|
|
||||||
)
|
|
||||||
street_with_postal_code = models.BooleanField(
|
street_with_postal_code = models.BooleanField(
|
||||||
default=False, verbose_name=_("Return street with postal code")
|
default=False, verbose_name=_("Return street with postal code")
|
||||||
)
|
)
|
||||||
|
|
||||||
verify_cert = models.BooleanField(
|
verify_cert = models.BooleanField(default=True, verbose_name=_("Check HTTPS Certificate validity"))
|
||||||
default=True, verbose_name=_("Check HTTPS Certificate validity")
|
|
||||||
)
|
|
||||||
|
|
||||||
category = _("Geographic information system")
|
category = _("Geographic information system")
|
||||||
|
|
||||||
|
@ -83,13 +78,9 @@ class ImioLiegeLisrue(BaseResource):
|
||||||
# url += "jsonlisrue2"
|
# url += "jsonlisrue2"
|
||||||
url += "jsonlgrue12/"
|
url += "jsonlgrue12/"
|
||||||
if q:
|
if q:
|
||||||
q = force_str(unicodedata.normalize("NFKD", request.GET["q"]).encode(
|
q = force_str(unicodedata.normalize("NFKD", request.GET["q"]).encode("ascii", "ignore"))
|
||||||
"ascii", "ignore"
|
|
||||||
))
|
|
||||||
url += q.lower()
|
url += q.lower()
|
||||||
result = requests.get(
|
result = requests.get(url, headers={"Accept": "application/json"}, verify=self.verify_cert).json()
|
||||||
url, headers={"Accept": "application/json"}, verify=self.verify_cert
|
|
||||||
).json()
|
|
||||||
if "data" in result:
|
if "data" in result:
|
||||||
result["rues"] = result.pop("data")
|
result["rues"] = result.pop("data")
|
||||||
if isinstance(result["rues"], list):
|
if isinstance(result["rues"], list):
|
||||||
|
@ -117,9 +108,7 @@ class ImioLiegeLisrue(BaseResource):
|
||||||
continue
|
continue
|
||||||
known_street_labels[street_label] = True
|
known_street_labels[street_label] = True
|
||||||
if self.street_with_postal_code:
|
if self.street_with_postal_code:
|
||||||
street_label = u"{} - {}".format(
|
street_label = u"{} - {}".format(street_label, str(item.get("codePostal"))).strip()
|
||||||
street_label, str(item.get("codePostal"))
|
|
||||||
).strip()
|
|
||||||
else:
|
else:
|
||||||
street_label = street_label.strip()
|
street_label = street_label.strip()
|
||||||
|
|
||||||
|
@ -132,21 +121,16 @@ class ImioLiegeLisrue(BaseResource):
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
elif (
|
elif (
|
||||||
(item.get("statutVO") is not None
|
item.get("statutVO") is not None and item.get("statutVO").get("code") == 1
|
||||||
and item.get("statutVO").get("code") == 1) or "jsonlgrue12" in url
|
) or "jsonlgrue12" in url:
|
||||||
):
|
|
||||||
streets.append(
|
streets.append(
|
||||||
{
|
{
|
||||||
"id": item.get("codeRue") or item.get("codeStreet"),
|
"id": item.get("codeRue") or item.get("codeStreet"),
|
||||||
"text": street_label,
|
"text": street_label,
|
||||||
"codeCommissariat": item.get("commissariat").get(
|
"codeCommissariat": item.get("commissariat").get("codeCommissariat")
|
||||||
"codeCommissariat"
|
|
||||||
)
|
|
||||||
if item.get("commissariat")
|
if item.get("commissariat")
|
||||||
else "",
|
else "",
|
||||||
"libelleCommissariat": item.get("commissariat").get(
|
"libelleCommissariat": item.get("commissariat").get("libelleCommissariat")
|
||||||
"libelleCommissariat"
|
|
||||||
)
|
|
||||||
if item.get("commissariat")
|
if item.get("commissariat")
|
||||||
else "",
|
else "",
|
||||||
}
|
}
|
||||||
|
@ -169,14 +153,10 @@ class ImioLiegeLisrue(BaseResource):
|
||||||
else:
|
else:
|
||||||
url = self.service_url
|
url = self.service_url
|
||||||
url = "{}?outSrid=31370".format(url)
|
url = "{}?outSrid=31370".format(url)
|
||||||
q = force_str(unicodedata.normalize("NFKD", request.GET["q"]).encode(
|
q = force_str(unicodedata.normalize("NFKD", request.GET["q"]).encode("ascii", "ignore"))
|
||||||
"ascii", "ignore"
|
|
||||||
))
|
|
||||||
url = "{}&q={}".format(url, q.lower())
|
url = "{}&q={}".format(url, q.lower())
|
||||||
|
|
||||||
result = requests.get(
|
result = requests.get(url, headers={"Accept": "application/json"}, verify=self.verify_cert).json()
|
||||||
url, headers={"Accept": "application/json"}, verify=self.verify_cert
|
|
||||||
).json()
|
|
||||||
streets = []
|
streets = []
|
||||||
for item in result:
|
for item in result:
|
||||||
if item.get("postCode") == postCode or postCode is None:
|
if item.get("postCode") == postCode or postCode is None:
|
||||||
|
|
24
setup.py
24
setup.py
|
@ -4,12 +4,12 @@
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
from distutils.cmd import Command
|
||||||
from setuptools.command.install_lib import install_lib as _install_lib
|
|
||||||
from distutils.command.build import build as _build
|
from distutils.command.build import build as _build
|
||||||
from distutils.command.sdist import sdist
|
from distutils.command.sdist import sdist
|
||||||
from distutils.cmd import Command
|
|
||||||
from setuptools import setup, find_packages
|
from setuptools import find_packages, setup
|
||||||
|
from setuptools.command.install_lib import install_lib as _install_lib
|
||||||
|
|
||||||
|
|
||||||
class eo_sdist(sdist):
|
class eo_sdist(sdist):
|
||||||
|
@ -27,14 +27,17 @@ class eo_sdist(sdist):
|
||||||
|
|
||||||
def get_version():
|
def get_version():
|
||||||
'''Use the VERSION, if absent generates a version with git describe, if not
|
'''Use the VERSION, if absent generates a version with git describe, if not
|
||||||
tag exists, take 0.0- and add the length of the commit log.
|
tag exists, take 0.0- and add the length of the commit log.
|
||||||
'''
|
'''
|
||||||
if os.path.exists('VERSION'):
|
if os.path.exists('VERSION'):
|
||||||
with open('VERSION', 'r') as v:
|
with open('VERSION', 'r') as v:
|
||||||
return v.read()
|
return v.read()
|
||||||
if os.path.exists('.git'):
|
if os.path.exists('.git'):
|
||||||
p = subprocess.Popen(['git', 'describe', '--dirty=.dirty', '--match=v*'],
|
p = subprocess.Popen(
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
['git', 'describe', '--dirty=.dirty', '--match=v*'],
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.PIPE,
|
||||||
|
)
|
||||||
result = p.communicate()[0]
|
result = p.communicate()[0]
|
||||||
if p.returncode == 0:
|
if p.returncode == 0:
|
||||||
result = result.decode('ascii').strip()[1:] # strip spaces/newlines and initial v
|
result = result.decode('ascii').strip()[1:] # strip spaces/newlines and initial v
|
||||||
|
@ -45,9 +48,7 @@ def get_version():
|
||||||
version = result
|
version = result
|
||||||
return version
|
return version
|
||||||
else:
|
else:
|
||||||
return '0.0.post%s' % len(
|
return '0.0.post%s' % len(subprocess.check_output(['git', 'rev-list', 'HEAD']).splitlines())
|
||||||
subprocess.check_output(
|
|
||||||
['git', 'rev-list', 'HEAD']).splitlines())
|
|
||||||
return '0.0'
|
return '0.0'
|
||||||
|
|
||||||
|
|
||||||
|
@ -64,6 +65,7 @@ class compile_translations(Command):
|
||||||
def run(self):
|
def run(self):
|
||||||
try:
|
try:
|
||||||
from django.core.management import call_command
|
from django.core.management import call_command
|
||||||
|
|
||||||
for path, dirs, files in os.walk('passerelle_imio_liege_lisrue'):
|
for path, dirs, files in os.walk('passerelle_imio_liege_lisrue'):
|
||||||
if 'locale' not in dirs:
|
if 'locale' not in dirs:
|
||||||
continue
|
continue
|
||||||
|
@ -109,5 +111,5 @@ setup(
|
||||||
'compile_translations': compile_translations,
|
'compile_translations': compile_translations,
|
||||||
'install_lib': install_lib,
|
'install_lib': install_lib,
|
||||||
'sdist': eo_sdist,
|
'sdist': eo_sdist,
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue