summaryrefslogtreecommitdiff
path: root/django/utils/formats.py
diff options
context:
space:
mode:
authorAnton Samarchyan <anton.samarchyan@savoirfairelinux.com>2017-01-24 15:32:33 -0500
committerTim Graham <timograham@gmail.com>2017-02-11 16:11:08 -0500
commit9718fa2e8abe430c3526a9278dd976443d4ae3c6 (patch)
treecc9e2c659759bbfdb4c7785c59a909cb2655af0d /django/utils/formats.py
parent98bcc5d81bca578f3a5b4d47907ba4ac40446887 (diff)
Refs #27656 -- Updated django.utils docstring verbs according to PEP 257.
Diffstat (limited to 'django/utils/formats.py')
-rw-r--r--django/utils/formats.py36
1 files changed, 16 insertions, 20 deletions
diff --git a/django/utils/formats.py b/django/utils/formats.py
index 74af39eade..3cb0c0420c 100644
--- a/django/utils/formats.py
+++ b/django/utils/formats.py
@@ -59,9 +59,7 @@ def reset_format_cache():
def iter_format_modules(lang, format_module_path=None):
- """
- Does the heavy lifting of finding format modules.
- """
+ """Find format modules."""
if not check_for_language(lang):
return
@@ -88,9 +86,7 @@ def iter_format_modules(lang, format_module_path=None):
def get_format_modules(lang=None, reverse=False):
- """
- Returns a list of the format modules found
- """
+ """Return a list of the format modules found."""
if lang is None:
lang = get_language()
if lang not in _format_modules_cache:
@@ -103,11 +99,11 @@ def get_format_modules(lang=None, reverse=False):
def get_format(format_type, lang=None, use_l10n=None):
"""
- For a specific format type, returns the format for the current
- language (locale), defaults to the format in the settings.
- format_type is the name of the format, e.g. 'DATE_FORMAT'
+ For a specific format type, return the format for the current
+ language (locale). Default to the format in the settings.
+ format_type is the name of the format, e.g. 'DATE_FORMAT'.
- If use_l10n is provided and is not None, that will force the value to
+ If use_l10n is provided and is not None, it forces the value to
be localized (or not), overriding the value of settings.USE_L10N.
"""
use_l10n = use_l10n or (use_l10n is None and settings.USE_L10N)
@@ -151,8 +147,8 @@ get_format_lazy = lazy(get_format, str, list, tuple)
def date_format(value, format=None, use_l10n=None):
"""
- Formats a datetime.date or datetime.datetime object using a
- localizable format
+ Format a datetime.date or datetime.datetime object using a
+ localizable format.
If use_l10n is provided and is not None, that will force the value to
be localized (or not), overriding the value of settings.USE_L10N.
@@ -162,9 +158,9 @@ def date_format(value, format=None, use_l10n=None):
def time_format(value, format=None, use_l10n=None):
"""
- Formats a datetime.time object using a localizable format
+ Format a datetime.time object using a localizable format.
- If use_l10n is provided and is not None, that will force the value to
+ If use_l10n is provided and is not None, it forces the value to
be localized (or not), overriding the value of settings.USE_L10N.
"""
return dateformat.time_format(value, get_format(format or 'TIME_FORMAT', use_l10n=use_l10n))
@@ -172,9 +168,9 @@ def time_format(value, format=None, use_l10n=None):
def number_format(value, decimal_pos=None, use_l10n=None, force_grouping=False):
"""
- Formats a numeric value using localization settings
+ Format a numeric value using localization settings.
- If use_l10n is provided and is not None, that will force the value to
+ If use_l10n is provided and is not None, it forces the value to
be localized (or not), overriding the value of settings.USE_L10N.
"""
if use_l10n or (use_l10n is None and settings.USE_L10N):
@@ -193,10 +189,10 @@ def number_format(value, decimal_pos=None, use_l10n=None, force_grouping=False):
def localize(value, use_l10n=None):
"""
- Checks if value is a localizable type (date, number...) and returns it
+ Check if value is a localizable type (date, number...) and return it
formatted as a string using current locale format.
- If use_l10n is provided and is not None, that will force the value to
+ If use_l10n is provided and is not None, it forces the value to
be localized (or not), overriding the value of settings.USE_L10N.
"""
if isinstance(value, str): # Handle strings first for performance reasons.
@@ -216,7 +212,7 @@ def localize(value, use_l10n=None):
def localize_input(value, default=None):
"""
- Checks if an input value is a localizable type and returns it
+ Check if an input value is a localizable type and return it
formatted with the appropriate formatting string of the current locale.
"""
if isinstance(value, str): # Handle strings first for performance reasons.
@@ -241,7 +237,7 @@ def localize_input(value, default=None):
def sanitize_separators(value):
"""
- Sanitizes a value according to the current decimal and
+ Sanitize a value according to the current decimal and
thousand separator setting. Used with form field input.
"""
if settings.USE_L10N and isinstance(value, str):