本文整理汇总了Python中xierpa3.toolbox.transformer.TX.flatten2Class方法的典型用法代码示例。如果您正苦于以下问题:Python TX.flatten2Class方法的具体用法?Python TX.flatten2Class怎么用?Python TX.flatten2Class使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xierpa3.toolbox.transformer.TX
的用法示例。
在下文中一共展示了TX.flatten2Class方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: write_attribute
# 需要导入模块: from xierpa3.toolbox.transformer import TX [as 别名]
# 或者: from xierpa3.toolbox.transformer.TX import flatten2Class [as 别名]
def write_attribute(self, key, value):
u"""
Auxiliary function to write each attribute to @[email protected] If the *key* is defined in
@[email protected] then only output the single key name (even if this breaks XML
validation). By default the @[email protected] is empty, but it can be redefined by the
inheriting application class.
If the *key* is in @[email protected] and the *value* is tuple or
a list, then join the *value*, separated by spaces. This feature is especially used to build flexible
cascading *class_* attributes.
If the attribute has no value, then the output is skipped.
"""
line = None
if key == 'class_':
key = 'class'
value = self.class2SpaceString(value)
if key in self.SINGLE_ATTRIBUTES:
line = u' ' + key
elif isinstance(value, (list, tuple)):
if key in self.CASCADING_ATTRIBUTES:
value = TX.flatten2Class(value)
if isinstance(value, basestring):
value = value.replace('"', '"');
if value:
line = u' %s="%s"' % (key, value)
else:
raise ValueError('[XmlTagBuilder.write_attribute] No list attribute value allowed for %s="%s"' % (key, `value`))
elif value:
if isinstance(value, basestring):
value = value.replace('"', '"');
line = u' %s="%s"' % (key, value)
if line:
self.output(line)
示例2: image
# 需要导入模块: from xierpa3.toolbox.transformer import TX [as 别名]
# 或者: from xierpa3.toolbox.transformer.TX import flatten2Class [as 别名]
def image(self, component, class_=None):
u"""
"""
if component.style:
width = component.style.width_html
height = component.style.height_html
else:
width = None
height = None
if height is None and width is None:
width = '100%'
elif height is not None:
width = None
self.img(src=component.url, width_html=width, height_html=height, alt=component.alt,
class_=TX.flatten2Class(class_, component.getPrefixClass()))
示例3: image
# 需要导入模块: from xierpa3.toolbox.transformer import TX [as 别名]
# 或者: from xierpa3.toolbox.transformer.TX import flatten2Class [as 别名]
def image(self, component, class_=None):
u"""
"""
if component.style:
width = component.style.width_html # Take explicit HTML width/height if defined in component.
height = component.style.height_html
else:
width = None
height = None
if height is None and width is None:
width = '100%'
elif height is not None:
width = None
alt = component.alt or TX.path2Name(component.url)
self.img(src=component.url, width_html=width, height_html=height, alt=alt,
class_=TX.flatten2Class(class_, component.getPrefixClass()))