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


Python String.with_properties方法代码示例

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


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

示例1: test_dsl

# 需要导入模块: from flatland import String [as 别名]
# 或者: from flatland.String import with_properties [as 别名]
def test_dsl():
    Sub = String.with_properties(abc=123)

    assert 'abc' not in String.properties
    assert Sub.properties['abc'] == 123

    Disconnected = Sub.using(properties={'def': 456})
    assert Disconnected.properties['def'] == 456
    assert 'abc' not in Disconnected.properties

    assert 'def' not in Sub.properties
    assert 'def' not in String.properties

    Sub.properties['ghi'] = 789
    assert Disconnected.properties == {'def': 456}

    Disconnected2 = Sub.using(properties=Properties(jkl=123))
    assert Disconnected2.properties == {'jkl': 123}
开发者ID:dag,项目名称:flatland,代码行数:20,代码来源:test_properties.py

示例2: Page

# 需要导入模块: from flatland import String [as 别名]
# 或者: from flatland.String import with_properties [as 别名]
from flatland import Form, String


TextInput = String.with_properties(template='forms/text-input.html')
CreoleInput = String.with_properties(template='forms/creole-input.html')
CreoleArea = String.with_properties(template='forms/creole-area.html')


class Page(Form):

    title = TextInput
    body  = CreoleArea


class Translation(Form):

    definition = CreoleInput
    notes = CreoleInput
开发者ID:bdeeney,项目名称:relvlast,代码行数:20,代码来源:schemata.py

示例3: sorted

# 需要导入模块: from flatland import String [as 别名]
# 或者: from flatland.String import with_properties [as 别名]
                             into the choice_specs property; the tuples' first
                             elements become the valid values of the Enum. e.g.
                             for choice_specs = [(v1, ...), (v2, ...), ... ],
                             the valid values are v1, v2, ...

        :param sort_by: If not None, sort choice_specs by the sort_by'th
                        element.
        """
        if sort_by is not None:
            choice_specs = sorted(choice_specs, key=itemgetter(sort_by))
        else:
            choice_specs = list(choice_specs)
        return cls.valued(*[e[0] for e in choice_specs]).with_properties(choice_specs=choice_specs)


Text = String.with_properties(widget=WIDGET_TEXT)

MultilineText = String.with_properties(widget=WIDGET_MULTILINE_TEXT)

OptionalText = Text.using(optional=True)

RequiredText = Text.validated_by(Present())

OptionalMultilineText = MultilineText.using(optional=True)

RequiredMultilineText = MultilineText.validated_by(Present())


class NameNotValidError(ValueError):
    """
    The name is not valid.
开发者ID:rciorba,项目名称:moin-2.0-mirror,代码行数:33,代码来源:forms.py


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