当前位置: 首页>>代码示例>>Python>>正文


Python formats.get_format_modules方法代码示例

本文整理汇总了Python中django.utils.formats.get_format_modules方法的典型用法代码示例。如果您正苦于以下问题:Python formats.get_format_modules方法的具体用法?Python formats.get_format_modules怎么用?Python formats.get_format_modules使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.utils.formats的用法示例。


在下文中一共展示了formats.get_format_modules方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_formats

# 需要导入模块: from django.utils import formats [as 别名]
# 或者: from django.utils.formats import get_format_modules [as 别名]
def get_formats():
    """
    Returns all formats strings required for i18n to work
    """
    FORMAT_SETTINGS = (
        'DATE_FORMAT', 'DATETIME_FORMAT', 'TIME_FORMAT',
        'YEAR_MONTH_FORMAT', 'MONTH_DAY_FORMAT', 'SHORT_DATE_FORMAT',
        'SHORT_DATETIME_FORMAT', 'FIRST_DAY_OF_WEEK', 'DECIMAL_SEPARATOR',
        'THOUSAND_SEPARATOR', 'NUMBER_GROUPING',
        'DATE_INPUT_FORMATS', 'TIME_INPUT_FORMATS', 'DATETIME_INPUT_FORMATS'
    )
    result = {}
    for module in [settings] + get_format_modules(reverse=True):
        for attr in FORMAT_SETTINGS:
            result[attr] = get_format(attr)
    formats = {}
    for k, v in result.items():
        if isinstance(v, (six.string_types, int)):
            formats[k] = smart_text(v)
        elif isinstance(v, (tuple, list)):
            formats[k] = [smart_text(value) for value in v]
    return formats 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:24,代码来源:i18n.py

示例2: get_formats

# 需要导入模块: from django.utils import formats [as 别名]
# 或者: from django.utils.formats import get_format_modules [as 别名]
def get_formats():
    """
    Returns all formats strings required for i18n to work
    """
    FORMAT_SETTINGS = (
        'DATE_FORMAT', 'DATETIME_FORMAT', 'TIME_FORMAT',
        'YEAR_MONTH_FORMAT', 'MONTH_DAY_FORMAT', 'SHORT_DATE_FORMAT',
        'SHORT_DATETIME_FORMAT', 'FIRST_DAY_OF_WEEK', 'DECIMAL_SEPARATOR',
        'THOUSAND_SEPARATOR', 'NUMBER_GROUPING',
        'DATE_INPUT_FORMATS', 'TIME_INPUT_FORMATS', 'DATETIME_INPUT_FORMATS'
    )
    result = {}
    for module in [settings] + get_format_modules(reverse=True):
        for attr in FORMAT_SETTINGS:
            result[attr] = get_format(attr)
    src = []
    for k, v in result.items():
        if isinstance(v, (six.string_types, int)):
            src.append("formats['%s'] = '%s';\n" % (javascript_quote(k), javascript_quote(smart_text(v))))
        elif isinstance(v, (tuple, list)):
            v = [javascript_quote(smart_text(value)) for value in v]
            src.append("formats['%s'] = ['%s'];\n" % (javascript_quote(k), "', '".join(v)))
    return ''.join(src) 
开发者ID:blackye,项目名称:luscan-devel,代码行数:25,代码来源:i18n.py

示例3: get_formats

# 需要导入模块: from django.utils import formats [as 别名]
# 或者: from django.utils.formats import get_format_modules [as 别名]
def get_formats():
    """
    Returns all formats strings required for i18n to work
    """
    FORMAT_SETTINGS = (
        "DATE_FORMAT",
        "DATETIME_FORMAT",
        "TIME_FORMAT",
        "YEAR_MONTH_FORMAT",
        "MONTH_DAY_FORMAT",
        "SHORT_DATE_FORMAT",
        "SHORT_DATETIME_FORMAT",
        "FIRST_DAY_OF_WEEK",
        "DECIMAL_SEPARATOR",
        "THOUSAND_SEPARATOR",
        "NUMBER_GROUPING",
        "DATE_INPUT_FORMATS",
        "TIME_INPUT_FORMATS",
        "DATETIME_INPUT_FORMATS",
    )
    result = {}
    for module in [settings] + get_format_modules(reverse=True):
        for attr in FORMAT_SETTINGS:
            result[attr] = get_format(attr)
    formats = {}
    for k, v in list(result.items()):
        if isinstance(v, (six.string_types, int)):
            formats[k] = smart_text(v)
        elif isinstance(v, (tuple, list)):
            formats[k] = [smart_text(value) for value in v]
    return formats 
开发者ID:WikipediaLibrary,项目名称:TWLight,代码行数:33,代码来源:views.py

示例4: _add12hrFormats

# 需要导入模块: from django.utils import formats [as 别名]
# 或者: from django.utils.formats import get_format_modules [as 别名]
def _add12hrFormats():
    # Time12hrInput will not work unless django.forms.fields.TimeField
    # can process 12hr times, so sneak them into the default and all the
    # selectable locales that define TIME_INPUT_FORMATS.

    # strptime does not accept %P, %p is for both cases here.
    _12hrFormats = ['%I:%M%p', # 2:30pm
                    '%I%p']    # 7am

    # TIME_INPUT_FORMATS is defined in django.conf.global_settings if not
    # by the user's local settings.
    if (_12hrFormats[0] not in settings.TIME_INPUT_FORMATS or
        _12hrFormats[1] not in settings.TIME_INPUT_FORMATS):
        settings.TIME_INPUT_FORMATS += _12hrFormats

    # Many of the built-in locales define TIME_INPUT_FORMATS
    langCodes = [language[0] for language in get_available_admin_languages()]
    langCodes.append(settings.LANGUAGE_CODE)
    for lang in langCodes:
        for module in get_format_modules(lang):
            inputFormats = getattr(module, 'TIME_INPUT_FORMATS', None)
            if (inputFormats is not None and
                (_12hrFormats[0] not in inputFormats or
                 _12hrFormats[1] not in inputFormats)):
                inputFormats += _12hrFormats

# ------------------------------------------------------------------------------ 
开发者ID:linuxsoftware,项目名称:ls.joyous,代码行数:29,代码来源:edit_handlers.py


注:本文中的django.utils.formats.get_format_modules方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。