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


Python COUNTRIES.keys方法代码示例

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


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

示例1: dict

# 需要导入模块: from django_countries.data import COUNTRIES [as 别名]
# 或者: from django_countries.data.COUNTRIES import keys [as 别名]
from .image_generator import generate_image

DEFAULT_IDENTIFIER = "default"
DEFAULT_NAME = "Default"

DEFAULT_ADDRESS_DATA = dict(
    prefix="Sir",
    name=u"Dog Hello",
    suffix=", Esq.",
    postal_code="K9N",
    street="Woof Ave.",
    city="Dog Fort",
    country="GB"
)

COUNTRY_CODES = sorted(COUNTRIES.keys())


class FuzzyBoolean(fuzzy.BaseFuzzyAttribute):
    def __init__(self, probability, **kwargs):
        self.probability = probability
        super(FuzzyBoolean, self).__init__()

    def fuzz(self):
        return (random.random() < self.probability)


class UserFactory(DjangoModelFactory):
    class Meta:
        model = settings.AUTH_USER_MODEL
开发者ID:US365,项目名称:shoop,代码行数:32,代码来源:factories.py

示例2: construct_address_form

# 需要导入模块: from django_countries.data import COUNTRIES [as 别名]
# 或者: from django_countries.data.COUNTRIES import keys [as 别名]

def construct_address_form(country_code, i18n_rules):
    class_name = 'AddressForm%s' % country_code
    base_class = CountryAwareAddressForm
    form_kwargs = {
        'Meta': type(str('Meta'), (base_class.Meta, object), {}),
        'formfield_callback': None}
    class_ = type(base_class)(str(class_name), (base_class, ), form_kwargs)
    update_base_fields(class_, i18n_rules)
    class_.i18n_country_code = country_code
    class_.i18n_fields_order = property(get_form_i18n_lines)
    return class_


for country in COUNTRIES.keys():
    try:
        country_rules = i18naddress.get_validation_rules(
            {'country_code': country})
    except ValueError:
        country_rules = i18naddress.get_validation_rules({})
        UNKNOWN_COUNTRIES.add(country)

COUNTRY_CHOICES = [(code, label) for code, label in COUNTRIES.items()
                   if code not in UNKNOWN_COUNTRIES]
# Sort choices list by country name
COUNTRY_CHOICES = sorted(COUNTRY_CHOICES, key=lambda choice: choice[1])

for country, label in COUNTRY_CHOICES:
    country_rules = i18naddress.get_validation_rules({'country_code': country})
    COUNTRY_FORMS[country] = construct_address_form(country, country_rules)
开发者ID:elwoodxblues,项目名称:saleor,代码行数:32,代码来源:i18n.py


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