本文整理汇总了Python中pyasm.common.Common.clean_filesystem_name方法的典型用法代码示例。如果您正苦于以下问题:Python Common.clean_filesystem_name方法的具体用法?Python Common.clean_filesystem_name怎么用?Python Common.clean_filesystem_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.common.Common
的用法示例。
在下文中一共展示了Common.clean_filesystem_name方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
# 需要导入模块: from pyasm.common import Common [as 别名]
# 或者: from pyasm.common.Common import clean_filesystem_name [as 别名]
def execute(self):
print "kwargs: ", self.kwargs
options = {}
class_name = "tactic.ui.panel.CustomLayoutWdg"
widget_key = ""
for key, value in self.kwargs.items():
if value == '':
continue
if key.startswith("xxx_option"):
parts = key.split("|")
option_key = parts[1]
if option_key == "display_class":
class_name = value
elif option_key == "widget_key":
widget_key = value
else:
options[option_key] = value
elif key.startswith("option|"):
parts = key.split("|")
option_key = parts[1]
options[option_key] = value
print "options: ", options
name = self.kwargs.get("name")
description = self.kwargs.get("description") or " "
if not name:
raise Exception("No name provided")
name = Common.clean_filesystem_name(name)
login = Environment.get_user_name()
view = "pages.%s.%s" % (login, name)
# find if this user page already exists
search = Search("config/widget_config")
search.add_filter("category", "CustomLayoutWg")
search.add_filter("view", view)
config = search.get_sobject()
if config:
raise Exception("Page with name [%s] already exists" % name)
option_xml = []
for key, value in options.items():
option_xml.append("<%s>%s</%s>" % (key, value, key))
option_str = "\n".join(option_xml)
if widget_key:
display_line = '''<display widget="%s">''' % widget_key
else:
display_line = '''<display class="%s">''' % class_name
# all pages are custom layouts
config_xml = '''<config>
<%s>
<html>
<div style="margin: 20px">
<div style="font-size: 25px">%s</div>
<div>%s</div>
<hr/>
<element>
%s
%s
</display>
</element>
</div>
</html>
</%s>
</config>
''' % (view, name, description, display_line, option_str, view)
print "config_xml: ", config_xml
xml = Xml()
xml.read_string(config_xml)
config_xml = xml.to_string()
config = SearchType.create("config/widget_config")
config.set_value("category", "CustomLayoutWdg")
config.set_value("view", view)
config.set_value("config", config_xml)
config.commit()