Commit 4468c08d authored by Jon Dufresne's avatar Jon Dufresne Committed by Tim Graham
Browse files

Fixed #23968 -- Replaced list comprehension with generators and dict comprehension

parent b327a614
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -293,8 +293,8 @@ FieldListFilter.register(lambda f: bool(f.choices), ChoicesFieldListFilter)
class DateFieldListFilter(FieldListFilter):
    def __init__(self, field, request, params, model, model_admin, field_path):
        self.field_generic = '%s__' % field_path
        self.date_params = dict((k, v) for k, v in params.items()
                                if k.startswith(self.field_generic))
        self.date_params = {k: v for k, v in params.items()
                            if k.startswith(self.field_generic)}

        now = timezone.now()
        # When time zone support is enabled, convert "now" to the user's time
+6 −6
Original line number Diff line number Diff line
@@ -25,18 +25,18 @@ def update_contenttypes(app_config, verbosity=2, interactive=True, using=DEFAULT

    app_label = app_config.label

    app_models = dict(
        (model._meta.model_name, model)
        for model in app_config.get_models())
    app_models = {
        model._meta.model_name: model
        for model in app_config.get_models()}

    if not app_models:
        return

    # Get all the content types
    content_types = dict(
        (ct.model, ct)
    content_types = {
        ct.model: ct
        for ct in ContentType.objects.using(using).filter(app_label=app_label)
    )
    }
    to_remove = [
        ct
        for (model_name, ct) in six.iteritems(content_types)
+1 −1
Original line number Diff line number Diff line
@@ -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()}
+1 −1
Original line number Diff line number Diff line
@@ -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."
+1 −1
Original line number Diff line number Diff line
@@ -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'])
Loading