Skip to content

Commit 82202a8

Browse files
Prepare release of django-cities-light 3.8.0 (#230)
* Added my self to authos * Removed six and python 2 compatible code Updated CHANGELOG and README Support for Django 3.1 * Travis django 3.1 * Module imported but unused * Unnecessary literal * pep8 * Logging is not lazy * method could be a function * Signature of method 'Command.add_arguments()' does not match signature of base method in class 'BaseCommand' * ToSearchTextField Present for backward incompatibility. * url function is replaced with path * deprecetation warning for assertRaisesRegexp * test for the automatic deploy with travis * Cities_light_city.subregion_id Incorrect #229 * Get more cities documentation #221 #189 * added pylint to the list of env and corrected a issue from pylint * CHANGELOG 3.7.1 * Version 3.8.0 Dropped support for django 1.11 * travis jobs * travis jobs * Removed django 1.11 * Max length QA * return to matrix
1 parent 47ece31 commit 82202a8

14 files changed

+84
-41
lines changed

Diff for: .travis.yml

+15-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ matrix:
66
- env: TOXENV=py37-djangodev-mysql
77
- env: TOXENV=py37-djangodev-postgresql
88
include:
9-
- python: 3.7
10-
env: TOXENV=py37-django111-sqlite
119
- python: 3.7
1210
env: TOXENV=py37-django20-sqlite
1311
- python: 3.7
@@ -28,6 +26,21 @@ matrix:
2826
env: TOXENV=checkqa
2927
- python: 3.7
3028
env: TOXENV=docs
29+
- stage: deploy
30+
python: 3.7
31+
script: skip
32+
deploy:
33+
provider: pypi
34+
user: jazzband
35+
server: https://jazzband.co/projects/django-cities-light/upload
36+
distributions: sdist bdist_wheel
37+
password:
38+
secure: TCH5tGIggL2wsWce2svMwpEpPiwVOYqq1R3uSBTexszleP0OafNq/wZk2KZEReR5w1Aq68qp5F5Eeh2ZjJTq4f9M4LtTvqQzrmyNP55DYk/uB1rBJm9b4gBgMtAknxdI2g7unkhQEDo4suuPCVofM7rrDughySNpmvlUQYDttHQ=
39+
skip_existing: true
40+
on:
41+
tags: true
42+
repo: jazzband/django-cities-light
43+
python: 3.7
3144
install:
3245
- pip install -U pip
3346
- pip install tox codecov

Diff for: CHANGELOG

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2020-08-28 3.8.0
2+
Fix for subregion #229
3+
Documentation improvement #221 #189
4+
General improvements on warnings and pylint recomendations
5+
Dropped support of Django 1.11
6+
17
2020-08-06 3.7.0
28
Fix for subregion
39
Drop support for python 2

Diff for: README.rst

+11-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ database, you should use
3030
Requirements:
3131

3232
- Python >= 3.6
33-
- Django >= 1.11
33+
- Django >= 2.0
3434
- MySQL or PostgreSQL or SQLite.
3535

3636
Yes, for some reason, code that used to work on MySQL (not without pain xD)
@@ -82,6 +82,16 @@ By default, update procedure attempts to update all fields, including Country/Re
8282
./manage.py cities_light --keep-slugs
8383

8484

85+
Get more cities
86+
---------------
87+
88+
The configuration parameter CITIES_LIGHT_CITY_SOURCES, comes with the default value
89+
http://download.geonames.org/export/dump/cities15000.zip that has cities with a population
90+
over 15000, if you need to load cities with less population please use another source. For the list
91+
of available source please check here: http://download.geonames.org/export/dump/readme.txt
92+
93+
94+
8595
Using fixtures
8696
--------------
8797

Diff for: cities_light/contrib/restframework3.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,16 @@
1313
If rest_framework (v3) is installed, all you have to do is add this url
1414
include::
1515
16-
url(r'^cities_light/api/', include('cities_light.contrib.restframework3')),
16+
path(r'^cities_light/api/',
17+
include('cities_light.contrib.restframework3')),
1718
1819
And that's all !
1920
"""
21+
from django.urls import include, path
2022
from rest_framework import viewsets, relations
2123
from rest_framework.serializers import HyperlinkedModelSerializer
2224
from rest_framework import routers
2325

24-
from django.conf.urls import url, include
2526

2627
from ..loading import get_cities_models
2728

@@ -127,7 +128,7 @@ def get_queryset(self):
127128
"""
128129
Allows a GET param, 'q', to be used against search_names.
129130
"""
130-
queryset = super(CitiesLightListModelViewSet, self).get_queryset()
131+
queryset = self.queryset
131132

132133
if self.request.GET.get('q', None):
133134
return queryset.filter(
@@ -146,5 +147,5 @@ def get_queryset(self):
146147
basename='cities-light-api-subregion')
147148

148149
urlpatterns = [
149-
url(r'^', include(router.urls)),
150+
path('', include(router.urls)),
150151
]

Diff for: cities_light/downloader.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ def download(self, source, destination, force=False):
4242

4343
return True
4444

45-
def source_matches_destination(self, source, destination):
45+
@staticmethod
46+
def source_matches_destination(source, destination):
4647
"""Return True if source and destination point to the same file."""
4748
parsed_source = urlparse(source)
4849
if parsed_source.scheme == 'file':
@@ -56,7 +57,8 @@ def source_matches_destination(self, source, destination):
5657
return True
5758
return False
5859

59-
def needs_downloading(self, source, destination, force):
60+
@staticmethod
61+
def needs_downloading(source, destination, force):
6062
"""Return True if source should be downloaded to destination."""
6163
src_file = urlopen(source)
6264
src_size = int(src_file.headers['content-length'])

Diff for: cities_light/geonames.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Geonames(object):
1414
def __init__(self, url, force=False):
1515
# Creating a directory if not exist
1616
if not os.path.exists(DATA_DIR):
17-
self.logger.info('Creating %s' % DATA_DIR)
17+
self.logger.info('Creating %s', DATA_DIR)
1818
os.mkdir(DATA_DIR)
1919

2020
destination_file_name = url.split('/')[-1]
@@ -39,10 +39,11 @@ def __init__(self, url, force=False):
3939
self.file_path = os.path.join(
4040
DATA_DIR, destination_file_name)
4141

42-
def download(self, url, path, force=False):
42+
@staticmethod
43+
def download(url, path, force=False):
4344
downloader = Downloader()
44-
# Returns true or false(either downloded or not based on
45-
# the condition in downloader.py)
45+
# Returns true or false(either downloaded or not based on
46+
# the condition in downloader.py
4647
return downloader.download(
4748
source=url,
4849
destination=path,
@@ -52,19 +53,17 @@ def download(self, url, path, force=False):
5253
def extract(self, zip_path, file_name):
5354
destination = os.path.join(DATA_DIR, file_name)
5455

55-
self.logger.info('Extracting %s from %s into %s' % (
56-
file_name, zip_path, destination))
56+
self.logger.info('Extracting %s from %s into %s',
57+
file_name, zip_path, destination)
5758
# Extracting the file in the data directory
5859
zip_file = zipfile.ZipFile(zip_path)
5960
if zip_file:
6061
zip_file.extract(file_name, DATA_DIR)
6162

6263
def parse(self):
6364
file = open(self.file_path, encoding='utf-8', mode='r')
64-
line = True
6565

6666
for line in file:
67-
6867
line = line.strip()
6968
# If the line is blank/empty or a comment, skip it and continue
7069
if len(line) < 1 or line[0] == '#':

Diff for: cities_light/management/commands/cities_light.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,8 @@ def _clear_identity_maps(self):
256256
del self._subregion_codes
257257
self._country_codes = {}
258258
self._region_codes = collections.defaultdict(dict)
259-
self._subregion_codes = collections.defaultdict(dict)
259+
self._subregion_codes = collections.defaultdict(
260+
lambda: collections.defaultdict(dict))
260261

261262
def _get_country_id(self, country_code2):
262263
"""
@@ -289,12 +290,12 @@ def _get_subregion_id(self, country_code2, region_id, subregion_id):
289290
self._region_codes[country_id][region_id] = Region.objects.get(
290291
country_id=country_id, geoname_code=region_id).pk
291292

292-
if subregion_id not in self._subregion_codes[country_id]:
293-
self._subregion_codes[country_id][subregion_id] = \
293+
if subregion_id not in self._subregion_codes[country_id][region_id]:
294+
self._subregion_codes[country_id][region_id][subregion_id] = \
294295
SubRegion.objects.get(
295296
region_id=self._region_codes[country_id][region_id],
296297
geoname_code=subregion_id).pk
297-
return self._subregion_codes[country_id][subregion_id]
298+
return self._subregion_codes[country_id][region_id][subregion_id]
298299

299300
def country_import(self, items):
300301
try:

Diff for: cities_light/management/commands/cities_light_fixtures.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ def create_parser(self, *args, **kwargs):
5959
parser.formatter_class = RawTextHelpFormatter
6060
return parser
6161

62-
@staticmethod
63-
def add_arguments(parser):
62+
def add_arguments(self, parser):
6463
parser.add_argument(
6564
'subcommand',
6665
type=str,

Diff for: cities_light/receivers.py

+13-3
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,18 @@ def city_country(sender, instance, **kwargs):
3333
def city_search_names(sender, instance, **kwargs):
3434
search_names = set()
3535

36-
country_names = set((instance.country.name,))
36+
country_names = {instance.country.name, }
3737
if instance.country.alternate_names:
3838
for n in instance.country.alternate_names.split(';'):
3939
country_names.add(n)
4040

41-
city_names = set((instance.name,))
41+
city_names = {instance.name, }
4242
if instance.alternate_names:
4343
for n in instance.alternate_names.split(';'):
4444
city_names.add(n)
4545

4646
if instance.region_id:
47-
region_names = set((instance.region.name,))
47+
region_names = {instance.region.name, }
4848
if instance.region.alternate_names:
4949
for n in instance.region.alternate_names.split(';'):
5050
region_names.add(n)
@@ -94,6 +94,8 @@ def filter_non_cities(sender, items, **kwargs):
9494
"""
9595
if items[7] not in INCLUDE_CITY_TYPES:
9696
raise InvalidItems()
97+
98+
9799
city_items_pre_import.connect(filter_non_cities)
98100

99101

@@ -110,6 +112,8 @@ def filter_non_included_countries_country(sender, items, **kwargs):
110112

111113
if items[0].split('.')[0] not in INCLUDE_COUNTRIES:
112114
raise InvalidItems()
115+
116+
113117
country_items_pre_import.connect(filter_non_included_countries_country)
114118

115119

@@ -126,6 +130,8 @@ def filter_non_included_countries_region(sender, items, **kwargs):
126130

127131
if items[0].split('.')[0] not in INCLUDE_COUNTRIES:
128132
raise InvalidItems()
133+
134+
129135
region_items_pre_import.connect(filter_non_included_countries_region)
130136

131137

@@ -142,6 +148,8 @@ def filter_non_included_countries_subregion(sender, items, **kwargs):
142148

143149
if items[0].split('.')[0] not in INCLUDE_COUNTRIES:
144150
raise InvalidItems()
151+
152+
145153
subregion_items_pre_import.connect(filter_non_included_countries_subregion)
146154

147155

@@ -158,4 +166,6 @@ def filter_non_included_countries_city(sender, items, **kwargs):
158166

159167
if items[8].split('.')[0] not in INCLUDE_COUNTRIES:
160168
raise InvalidItems()
169+
170+
161171
city_items_pre_import.connect(filter_non_included_countries_city)

Diff for: cities_light/tests/test_contrib.py

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from ..contrib.ajax_selects_lookups import (
1212
CountryLookup,
1313
RegionLookup,
14-
SubRegionLookup,
1514
CityLookup
1615
)
1716

Diff for: cities_light/tests/test_fixtures.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def test_call_with_base_url_and_fixtures_base_url_is_none(self, m_exists):
143143
# --base-url not specified
144144
with mock.patch(func) as _mock:
145145
exc = 'Please specify --base-url or settings'
146-
with self.assertRaisesRegexp(CommandError, exc):
146+
with self.assertRaisesRegex(CommandError, exc):
147147
call_command('cities_light_fixtures', 'load')
148148
_mock.assert_not_called()
149149

Diff for: cities_light/tests/test_migrations.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
from __future__ import unicode_literals
2-
import pytest
3-
import io
2+
43
from django import test
54
from django.apps import apps
6-
from django.db.migrations.state import ProjectState
7-
from django.db.migrations import Migration
5+
from django.db.migrations.autodetector import MigrationAutodetector
86
from django.db.migrations.loader import MigrationLoader
97
from django.db.migrations.questioner import (
10-
InteractiveMigrationQuestioner, MigrationQuestioner,
11-
)
12-
from django.db.migrations.autodetector import MigrationAutodetector
8+
InteractiveMigrationQuestioner, )
9+
from django.db.migrations.state import ProjectState
1310

1411

1512
class TestNoMigrationLeft(test.TestCase):

Diff for: setup.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
from setuptools import setup, find_packages
2-
import shutil
3-
import sys
1+
from setuptools import setup
42
import os
53
import os.path
64

Diff for: tox.ini

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
[tox]
22
envlist =
3-
py{35,36, 37,38}-django{111,22,30,31}{-sqlite,-mysql,-postgresql},
3+
py{35,36, 37,38}-django{20,22,30,31}{-sqlite,-mysql,-postgresql},
44
py{35,36, 37,38}-djangodev{-sqlite,-mysql,-postgresql},
55
checkqa,
6+
pylint,
67
docs
78
skip_missing_interpreters = True
89
sitepackages = False
@@ -39,6 +40,8 @@ deps =
3940
pytest-cov
4041
mock
4142
coverage
43+
pylint
44+
pylint-django
4245
djangorestframework
4346
django-dbdiff>=0.4.0
4447
django-ajax-selects==1.6.0
@@ -56,7 +59,6 @@ whitelist_externals =
5659
psql
5760
deps =
5861
{[test]deps}
59-
django111: Django>=1.11a,<2.0
6062
django20: Django>=2.0,<2.1
6163
django22: Django>=2.2,<3.0
6264
django30: Django>=3.0,<3.1
@@ -78,10 +80,16 @@ setenv =
7880
passenv = TEST_* DBDIFF_* DB_*
7981

8082
[testenv:checkqa]
81-
basepython = python3.5
83+
basepython = python3.7
8284
commands = pep8 --ignore=E402,E124,E128 --exclude=tests,migrations cities_light
8385
deps = pep8
8486

87+
[testenv:pylint]
88+
basepython = python3.7
89+
commands = pylint -j 4 --load-plugins pylint_django cities_light/ -E
90+
deps =
91+
{[base]deps}
92+
8593
[testenv:dev]
8694
commands =
8795
deps =

0 commit comments

Comments
 (0)