Commit 8f04f53d authored by Aymeric Augustin's avatar Aymeric Augustin
Browse files

Removed a few gratuitous lambdas.

parent 4e7aa573
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -46,9 +46,12 @@ from django.views.decorators.csrf import csrf_protect
IS_POPUP_VAR = '_popup'
TO_FIELD_VAR = '_to_field'


HORIZONTAL, VERTICAL = 1, 2
# returns the <ul> class for a given radio_admin field
get_ul_class = lambda x: 'radiolist%s' % (' inline' if x == HORIZONTAL else '')


def get_ul_class(radio_style):
    return 'radiolist' if radio_style == VERTICAL else 'radiolist inline'


class IncorrectLookupParameters(Exception):
+1 −1
Original line number Diff line number Diff line
@@ -333,7 +333,7 @@ def date_hierarchy(cl):
        month_lookup = cl.params.get(month_field)
        day_lookup = cl.params.get(day_field)

        link = lambda d: cl.get_query_string(d, [field_generic])
        link = lambda filters: cl.get_query_string(filters, [field_generic])

        if not (year_lookup or month_lookup or day_lookup):
            # select appropriate start level
+5 −1
Original line number Diff line number Diff line
@@ -21,7 +21,11 @@ from django.contrib.sites.models import get_current_site

UNMASKED_DIGITS_TO_SHOW = 6

mask_password = lambda p: "%s%s" % (p[:UNMASKED_DIGITS_TO_SHOW], "*" * max(len(p) - UNMASKED_DIGITS_TO_SHOW, 0))

def mask_password(password):
    shown = password[:UNMASKED_DIGITS_TO_SHOW]
    masked = "*" * max(len(password) - UNMASKED_DIGITS_TO_SHOW, 0)
    return shown + masked


class ReadOnlyPasswordHashWidget(forms.Widget):
+9 −5
Original line number Diff line number Diff line
from django.conf import settings
from django.utils.module_loading import import_by_path as get_storage
from django.utils.module_loading import import_by_path


# Callable with the same interface as the storage classes i.e.  accepts a
# 'request' object.  It is wrapped in a lambda to stop 'settings' being used at
# the module level
default_storage = lambda request: get_storage(settings.MESSAGE_STORAGE)(request)
def default_storage(request):
    """
    Callable with the same interface as the storage classes.

    This isn't just default_storage = import_by_path(settings.MESSAGE_STORAGE)
    to avoid accessing the settings at the module level.
    """
    return import_by_path(settings.MESSAGE_STORAGE)(request)
+3 −5
Original line number Diff line number Diff line
from __future__ import unicode_literals

from collections import OrderedDict
import re
from bisect import bisect
from collections import OrderedDict
import warnings

from django.apps import apps
@@ -13,10 +12,9 @@ from django.db.models.fields.proxy import OrderWrt
from django.utils import six
from django.utils.functional import cached_property
from django.utils.encoding import force_text, smart_text, python_2_unicode_compatible
from django.utils.text import camel_case_to_spaces
from django.utils.translation import activate, deactivate_all, get_language, string_concat

# Calculate the verbose_name by converting from InitialCaps to "lowercase with spaces".
get_verbose_name = lambda class_name: re.sub('(((?<=[a-z])[A-Z])|([A-Z](?![A-Z]|$)))', ' \\1', class_name).lower().strip()

DEFAULT_NAMES = ('verbose_name', 'verbose_name_plural', 'db_table', 'ordering',
                 'unique_together', 'permissions', 'get_latest_by',
@@ -109,7 +107,7 @@ class Options(object):
        # First, construct the default values for these options.
        self.object_name = cls.__name__
        self.model_name = self.object_name.lower()
        self.verbose_name = get_verbose_name(self.object_name)
        self.verbose_name = camel_case_to_spaces(self.object_name)

        # Store the original user-defined values for each option,
        # for use when serializing the model definition
Loading