本文整理汇总了Python中pyasm.common.Xml.get_attributes方法的典型用法代码示例。如果您正苦于以下问题:Python Xml.get_attributes方法的具体用法?Python Xml.get_attributes怎么用?Python Xml.get_attributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.common.Xml
的用法示例。
在下文中一共展示了Xml.get_attributes方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_attrs_by_search_type
# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import get_attributes [as 别名]
def get_attrs_by_search_type(self, search_type):
node = self.xml.get_node("schema/search_type[@name='%s']" % search_type)
if node is not None:
attrs = Xml.get_attributes(node)
else:
attrs = {}
if not attrs and self.parent_schema:
attrs = self.parent_schema.get_attrs_by_search_type(search_type)
if not attrs and self.sthpw_schema:
attrs = self.sthpw_schema.get_attrs_by_search_type(search_type)
return attrs
示例2: get_attr_by_search_type
# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import get_attributes [as 别名]
def get_attr_by_search_type(self, search_type, attr):
node = self.xml.get_node("schema/search_type[@name='%s']" % search_type)
if node is None:
return {}
return Xml.get_attributes(node).get(attr)
示例3: get_element_wdg
# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import get_attributes [as 别名]
def get_element_wdg(my, xml, def_config):
element_node = xml.get_node("config/tmp/element")
attrs = Xml.get_attributes(element_node)
element_name = attrs.get("name")
widget = my.get_widget(element_name)
if widget:
return widget
if not element_name:
import random
num = random.randint(0, 100000)
element_name = "element%s" % num
xml.set_attribute(element_node, "name", element_name)
# enable an ability to have a widget only loaded once in a request
if attrs.get('load_once') in ['true', True]:
widgets = Container.get("CustomLayoutWdg:widgets")
if widgets == None:
widgets = {}
Container.put("CustomLayoutWdg:widgets", widgets)
else:
if widgets[element_name] == True:
return None
widgets[element_name] = True
# provide the ability to have shorthand format
# ie: <element display_class="tactic.ui..." />
display_node = xml.get_node("config/tmp/element/display")
if display_node is None:
view = attrs.get("view")
type = attrs.get("type")
if type == "reference":
search_type = attrs.get("search_type")
my.config = WidgetConfigView.get_by_search_type(search_type, view)
# check if definition has no name. Don't use element_name
if not attrs.get("name"):
return
element_wdg = my.config.get_display_widget(element_name, extra_options=attrs)
container = DivWdg()
container.add(element_wdg)
return container
class_name = attrs.get("display_class")
# if no class name is defined and not view is defined look
# at predefined elements
if not view and not class_name:
element_wdg = my.config.get_display_widget(element_name, extra_options=attrs)
container = DivWdg()
container.add(element_wdg)
return container
# look at the attributes
if not class_name:
class_name = "tactic.ui.panel.CustomLayoutWdg"
display_node = xml.create_element("display")
xml.set_attribute(display_node, "class", class_name)
xml.append_child(element_node, display_node)
for name, value in attrs.items():
# replace the spt_ in the name.
# NOTE: should this be restricted to only spt_ attributes?
name = name.replace("spt_", "")
attr_node = xml.create_element(name)
xml.set_node_value(attr_node, value)
xml.append_child(display_node, attr_node)
load = attrs.get("load")
if load in ["async", "sequence"]:
return my.get_async_element_wdg(xml, element_name, load)
use_container = attrs.get('use_container') == 'true'
if use_container:
# DEPRECATED
container = my.get_container(xml)
else:
container = DivWdg()
# add in attribute from the element definition
# DEPRECATED: does this make any sense to have this here?
for name, value in attrs.items():
if name == 'name':
continue
container.add_style(name, value)
#.........这里部分代码省略.........
示例4: get_attributes
# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import get_attributes [as 别名]
def get_attributes(my):
return Xml.get_attributes(my.node)
示例5: get_container
# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import get_attributes [as 别名]
def get_container(my, xml):
# handle the container
element_node = xml.get_node("config/tmp/element")
attrs = Xml.get_attributes(element_node)
element_name = attrs.get("name")
show_resize_scroll = attrs.get("show_resize_scroll")
if not show_resize_scroll:
show_resize_scroll = my.kwargs.get("show_resize_scroll")
if not show_resize_scroll:
show_resize_scroll = "false"
# look for attributes in the element tag for specifying a title action button to plug
# into the title bar of the custom section ...
#
title_action_icon = attrs.get("title_action_icon")
title_action_script = attrs.get("title_action_script")
title_action_label = attrs.get("title_action_label")
if title_action_script and not title_action_label:
title_action_label = '[action]'
# get the width and height for the element content ...
width = attrs.get("width")
height = attrs.get("height")
if width and height:
container = ContainerWdg( inner_width=width, inner_height=height, show_resize_scroll=show_resize_scroll )
else:
container = ContainerWdg(show_resize_scroll=show_resize_scroll)
# create the title
title = attrs.get("title")
if not title:
title = Common.get_display_title(element_name)
title_wdg = DivWdg()
SmartMenu.assign_as_local_activator( title_wdg, 'HEADER_CTX' )
title_wdg.add_style("margin: 0px 0px 5px 0px")
title_wdg.add_gradient("background", "background", 0)
title_wdg.add_color("color", "color")
title_wdg.add_style("padding", "5px")
if title_action_script:
# add an action button if an action script code was found in the attributes of the element
proj = Project.get_project_code()
script_search = Search("config/custom_script")
script_sobj = script_search.get_by_search_key( "config/custom_script?project=%s&code=%s" %
(proj, title_action_script) )
script = script_sobj.get_value('script')
icon_str = "HELP"
if title_action_icon:
icon_str = title_action_icon
action_btn = HtmlElement.img( IconWdg.get_icon_path(icon_str) )
action_btn.set_attr('title',title_action_label)
# action_btn = IconWdg( title_action_label, icon=icon)
action_btn.add_behavior( {'type': 'click_up', 'cbjs_action': script } )
action_btn.add_styles( "cursor: pointer; float: right;" )
title_wdg.add( action_btn )
title_wdg.add(title)
container.add(title_wdg)
return container
示例6: get_element_wdg
# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import get_attributes [as 别名]
def get_element_wdg(my, xml, def_config):
element_node = xml.get_node("config/tmp/element")
attrs = Xml.get_attributes(element_node)
element_name = attrs.get("name")
if not element_name:
import random
num = random.randint(0, 100000)
element_name = "element%s" % num
xml.set_attribute(element_node, "name", element_name)
# enable an ability to have a widget only loaded once in a request
if attrs.get('load_once') in ['true', True]:
widgets = Container.get("CustomLayoutWdg:widgets")
if widgets == None:
widgets = {}
Container.put("CustomLayoutWdg:widgets", widgets)
else:
if widgets[element_name] == True:
return None
widgets[element_name] = True
# provide the ability to have shorthand format
# ie: <element display_class="tactic.ui..." />
display_node = xml.get_node("config/tmp/element/display")
if display_node is None:
view = attrs.get("view")
# look at the attributes
class_name = attrs.get("display_class")
if not class_name:
class_name = "tactic.ui.panel.CustomLayoutWdg"
display_node = xml.create_element("display")
xml.set_attribute(display_node, "class", class_name)
xml.append_child(element_node, display_node)
for name, value in attrs.items():
# replace the spt_ in the name.
# TODO: should this be restricted to only spt_ attributes?
name = name.replace("spt_", "")
attr_node = xml.create_element(name)
xml.set_node_value(attr_node, value)
xml.append_child(display_node, attr_node)
use_container = attrs.get('use_container') == 'true'
if use_container:
# DEPRECATED
container = my.get_container(xml)
else:
container = DivWdg()
# add in attribute from the element definition
# DEPRECATED: does this make any sense to have this here?
for name, value in attrs.items():
if name == 'name':
continue
container.add_style(name, value)
# add the content
try:
view_node = xml.get_node("config/tmp/element/display/view")
if view_node is not None:
view = xml.get_node_value(view_node)
if view.startswith("."):
if my.view_folder:
xml.set_node_value(view_node, "%s%s" %(my.view_folder,view))
tmp_config = WidgetConfig.get('tmp', xml=xml)
configs = []
configs.append(tmp_config)
# add the def_config if it exists
if def_config:
configs.append(def_config)
config = WidgetConfigView('CustomLayoutWdg', 'tmp', configs, state=my.state)
# NOTE: this doesn't work too well when we go to an abasolute
# view.
parent_view = my.kwargs.get("parent_view")
if parent_view:
parent_view = parent_view.replace(".", "/")
parent_view = "%s/%s" % (parent_view, my.view)
else:
parent_view = my.view
# TODO: need some protection code for infinite loops
includes = my.kwargs.get("include")
element_wdg = config.get_display_widget(element_name, extra_options={"include":includes, "parent_view":parent_view})
element_top = element_wdg.get_top()
#.........这里部分代码省略.........