summaryrefslogtreecommitdiff
path: root/django/contrib/gis
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2014-12-06 13:00:09 -0800
committerTim Graham <timograham@gmail.com>2014-12-08 07:58:23 -0500
commit4468c08d70b5b722f3ebd4872909e56580ec7d68 (patch)
tree3da12d757bc9b586df4ba39da20b8793abcae76e /django/contrib/gis
parentb327a614eb7d885441c6a2575e10b70ac1352aae (diff)
downloaddjango-4468c08d70b5b722f3ebd4872909e56580ec7d68.tar.gz
Fixed #23968 -- Replaced list comprehension with generators and dict comprehension
Diffstat (limited to 'django/contrib/gis')
-rw-r--r--django/contrib/gis/gdal/field.py2
-rw-r--r--django/contrib/gis/gdal/geomtype.py2
-rw-r--r--django/contrib/gis/gdal/libgdal.py2
-rw-r--r--django/contrib/gis/geoip/base.py2
-rw-r--r--django/contrib/gis/geoip/libgeoip.py6
-rw-r--r--django/contrib/gis/geoip/prototypes.py2
-rw-r--r--django/contrib/gis/geometry/test_data.py2
-rw-r--r--django/contrib/gis/geos/libgeos.py4
-rw-r--r--django/contrib/gis/management/commands/ogrinspect.py6
-rw-r--r--django/contrib/gis/measure.py8
-rw-r--r--django/contrib/gis/tests/geo3d/tests.py2
-rw-r--r--django/contrib/gis/utils/layermapping.py2
12 files changed, 20 insertions, 20 deletions
diff --git a/django/contrib/gis/gdal/field.py b/django/contrib/gis/gdal/field.py
index dd60f3b953..f9bc1f7a55 100644
--- a/django/contrib/gis/gdal/field.py
+++ b/django/contrib/gis/gdal/field.py
@@ -216,4 +216,4 @@ OGRFieldTypes = {
10: OFTTime,
11: OFTDateTime,
}
-ROGRFieldTypes = dict((cls, num) for num, cls in OGRFieldTypes.items())
+ROGRFieldTypes = {cls: num for num, cls in OGRFieldTypes.items()}
diff --git a/django/contrib/gis/gdal/geomtype.py b/django/contrib/gis/gdal/geomtype.py
index 1b5e079ef8..dc1f0480a3 100644
--- a/django/contrib/gis/gdal/geomtype.py
+++ b/django/contrib/gis/gdal/geomtype.py
@@ -28,7 +28,7 @@ class OGRGeomType(object):
7 + wkb25bit: 'GeometryCollection25D',
}
# Reverse type dictionary, keyed by lower-case of the name.
- _str_types = dict((v.lower(), k) for k, v in _types.items())
+ _str_types = {v.lower(): k for k, v in _types.items()}
def __init__(self, type_input):
"Figures out the correct OGR Type based upon the input."
diff --git a/django/contrib/gis/gdal/libgdal.py b/django/contrib/gis/gdal/libgdal.py
index 7bcf93f518..65e58a3a33 100644
--- a/django/contrib/gis/gdal/libgdal.py
+++ b/django/contrib/gis/gdal/libgdal.py
@@ -91,7 +91,7 @@ def gdal_version_info():
m = version_regex.match(ver)
if not m:
raise OGRException('Could not parse GDAL version string "%s"' % ver)
- return dict((key, m.group(key)) for key in ('major', 'minor', 'subminor'))
+ return {key: m.group(key) for key in ('major', 'minor', 'subminor')}
_verinfo = gdal_version_info()
GDAL_MAJOR_VERSION = int(_verinfo['major'])
diff --git a/django/contrib/gis/geoip/base.py b/django/contrib/gis/geoip/base.py
index 08125e3615..9409019d94 100644
--- a/django/contrib/gis/geoip/base.py
+++ b/django/contrib/gis/geoip/base.py
@@ -48,7 +48,7 @@ class GeoIP(object):
GEOIP_CHECK_CACHE = 2
GEOIP_INDEX_CACHE = 4
GEOIP_MMAP_CACHE = 8
- cache_options = dict((opt, None) for opt in (0, 1, 2, 4, 8))
+ cache_options = {opt: None for opt in (0, 1, 2, 4, 8)}
# Paths to the city & country binary databases.
_city_file = ''
diff --git a/django/contrib/gis/geoip/libgeoip.py b/django/contrib/gis/geoip/libgeoip.py
index 73aa5fc9bf..cc4d92c7d0 100644
--- a/django/contrib/gis/geoip/libgeoip.py
+++ b/django/contrib/gis/geoip/libgeoip.py
@@ -4,9 +4,9 @@ from ctypes.util import find_library
from django.conf import settings
# Creating the settings dictionary with any settings, if needed.
-GEOIP_SETTINGS = dict((key, getattr(settings, key))
- for key in ('GEOIP_PATH', 'GEOIP_LIBRARY_PATH', 'GEOIP_COUNTRY', 'GEOIP_CITY')
- if hasattr(settings, key))
+GEOIP_SETTINGS = {key: getattr(settings, key)
+ for key in ('GEOIP_PATH', 'GEOIP_LIBRARY_PATH', 'GEOIP_COUNTRY', 'GEOIP_CITY')
+ if hasattr(settings, key)}
lib_path = GEOIP_SETTINGS.get('GEOIP_LIBRARY_PATH', None)
# The shared library for the GeoIP C API. May be downloaded
diff --git a/django/contrib/gis/geoip/prototypes.py b/django/contrib/gis/geoip/prototypes.py
index 8ddcb9d974..22c17f006f 100644
--- a/django/contrib/gis/geoip/prototypes.py
+++ b/django/contrib/gis/geoip/prototypes.py
@@ -58,7 +58,7 @@ def check_record(result, func, cargs):
# Checking the pointer to the C structure, if valid pull out elements
# into a dictionary.
rec = result.contents
- record = dict((fld, getattr(rec, fld)) for fld, ctype in rec._fields_)
+ record = {fld: getattr(rec, fld) for fld, ctype in rec._fields_}
# Now converting the strings to unicode using the proper encoding.
encoding = geoip_encodings[record['charset']]
diff --git a/django/contrib/gis/geometry/test_data.py b/django/contrib/gis/geometry/test_data.py
index 3ad2f4aaea..d6a8bf8263 100644
--- a/django/contrib/gis/geometry/test_data.py
+++ b/django/contrib/gis/geometry/test_data.py
@@ -24,7 +24,7 @@ def tuplize(seq):
def strconvert(d):
"Converts all keys in dictionary to str type."
- return dict((str(k), v) for k, v in six.iteritems(d))
+ return {str(k): v for k, v in six.iteritems(d)}
def get_ds_file(name, ext):
diff --git a/django/contrib/gis/geos/libgeos.py b/django/contrib/gis/geos/libgeos.py
index e503bbd3e6..207fa780a4 100644
--- a/django/contrib/gis/geos/libgeos.py
+++ b/django/contrib/gis/geos/libgeos.py
@@ -145,8 +145,8 @@ def geos_version_info():
m = version_regex.match(ver)
if not m:
raise GEOSException('Could not parse version info string "%s"' % ver)
- return dict((key, m.group(key)) for key in (
- 'version', 'release_candidate', 'capi_version', 'major', 'minor', 'subminor'))
+ return {key: m.group(key) for key in (
+ 'version', 'release_candidate', 'capi_version', 'major', 'minor', 'subminor')}
# Version numbers and whether or not prepared geometry support is available.
_verinfo = geos_version_info()
diff --git a/django/contrib/gis/management/commands/ogrinspect.py b/django/contrib/gis/management/commands/ogrinspect.py
index 01930ff047..2e53eda6ad 100644
--- a/django/contrib/gis/management/commands/ogrinspect.py
+++ b/django/contrib/gis/management/commands/ogrinspect.py
@@ -90,8 +90,8 @@ class Command(BaseCommand):
# and options.
from django.contrib.gis.utils.ogrinspect import _ogrinspect, mapping
# Filter options to params accepted by `_ogrinspect`
- ogr_options = dict((k, v) for k, v in options.items()
- if k in inspect.getargspec(_ogrinspect).args and v is not None)
+ ogr_options = {k: v for k, v in options.items()
+ if k in inspect.getargspec(_ogrinspect).args and v is not None}
output = [s for s in _ogrinspect(ds, model_name, **ogr_options)]
if options['mapping']:
@@ -104,7 +104,7 @@ class Command(BaseCommand):
mapping_dict = mapping(ds, **kwargs)
# This extra legwork is so that the dictionary definition comes
# out in the same order as the fields in the model definition.
- rev_mapping = dict((v, k) for k, v in mapping_dict.items())
+ rev_mapping = {v: k for k, v in mapping_dict.items()}
output.extend(['', '# Auto-generated `LayerMapping` dictionary for %s model' % model_name,
'%s_mapping = {' % model_name.lower()])
output.extend(" '%s' : '%s'," % (
diff --git a/django/contrib/gis/measure.py b/django/contrib/gis/measure.py
index 456f1c7277..90b316bb60 100644
--- a/django/contrib/gis/measure.py
+++ b/django/contrib/gis/measure.py
@@ -295,7 +295,7 @@ class Distance(MeasureBase):
'Yard (Indian)': 'indian_yd',
'Yard (Sears)': 'sears_yd'
}
- LALIAS = dict((k.lower(), v) for k, v in ALIAS.items())
+ LALIAS = {k.lower(): v for k, v in ALIAS.items()}
def __mul__(self, other):
if isinstance(other, self.__class__):
@@ -313,9 +313,9 @@ class Distance(MeasureBase):
class Area(MeasureBase):
STANDARD_UNIT = AREA_PREFIX + Distance.STANDARD_UNIT
# Getting the square units values and the alias dictionary.
- UNITS = dict(('%s%s' % (AREA_PREFIX, k), v ** 2) for k, v in Distance.UNITS.items())
- ALIAS = dict((k, '%s%s' % (AREA_PREFIX, v)) for k, v in Distance.ALIAS.items())
- LALIAS = dict((k.lower(), v) for k, v in ALIAS.items())
+ UNITS = {'%s%s' % (AREA_PREFIX, k): v ** 2 for k, v in Distance.UNITS.items()}
+ ALIAS = {k: '%s%s' % (AREA_PREFIX, v) for k, v in Distance.ALIAS.items()}
+ LALIAS = {k.lower(): v for k, v in ALIAS.items()}
def __truediv__(self, other):
if isinstance(other, NUMERIC_TYPES):
diff --git a/django/contrib/gis/tests/geo3d/tests.py b/django/contrib/gis/tests/geo3d/tests.py
index 47c141a2ac..740f0d5692 100644
--- a/django/contrib/gis/tests/geo3d/tests.py
+++ b/django/contrib/gis/tests/geo3d/tests.py
@@ -38,7 +38,7 @@ city_data = (
)
# Reference mapping of city name to its altitude (Z value).
-city_dict = dict((name, coords) for name, coords in city_data)
+city_dict = {name: coords for name, coords in city_data}
# 3D freeway data derived from the National Elevation Dataset:
# http://seamless.usgs.gov/products/9arc.php
diff --git a/django/contrib/gis/utils/layermapping.py b/django/contrib/gis/utils/layermapping.py
index 49a5f5f274..5031aadab8 100644
--- a/django/contrib/gis/utils/layermapping.py
+++ b/django/contrib/gis/utils/layermapping.py
@@ -329,7 +329,7 @@ class LayerMapping(object):
if isinstance(self.unique, six.string_types):
return {self.unique: kwargs[self.unique]}
else:
- return dict((fld, kwargs[fld]) for fld in self.unique)
+ return {fld: kwargs[fld] for fld in self.unique}
#### Verification routines used in constructing model keyword arguments. ####
def verify_ogr_field(self, ogr_field, model_field):