本文整理汇总了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}
示例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
示例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.