本文整理汇总了Python中pyasm.common.Common.process_unicode_string方法的典型用法代码示例。如果您正苦于以下问题:Python Common.process_unicode_string方法的具体用法?Python Common.process_unicode_string怎么用?Python Common.process_unicode_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.common.Common
的用法示例。
在下文中一共展示了Common.process_unicode_string方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_display
# 需要导入模块: from pyasm.common import Common [as 别名]
# 或者: from pyasm.common.Common import process_unicode_string [as 别名]
def get_display(my):
sobject = my.get_current_sobject()
mode = my.get_option("mode")
if not mode:
mode = "sandbox"
widget = Widget()
sobject_dir = ""
sobject_lib_dir = ""
# find the path to open explorer
if sobject.is_insert():
button = IconWdg("No Path Found", IconWdg.CROSS, long=False)
else:
try:
if mode == "sandbox":
sobject_dir = my.get_base_dir(sobject)
elif mode in ["client_repo", "repository"]:
sobject_dir = my.get_client_repo_dir(sobject)
sobject_lib_dir = my.get_lib_dir(sobject)
sobject_dir = sobject_dir.strip()
sobject_dir = Common.process_unicode_string(sobject_dir)
except TacticException, e:
print "WARNING: ", str(e)
button = IconWdg("No Path Found", IconWdg.CROSS, long=False)
else:
示例2: handle_group
# 需要导入模块: from pyasm.common import Common [as 别名]
# 或者: from pyasm.common.Common import process_unicode_string [as 别名]
def handle_group(my, table, i, sobject, group_name, group_value):
tr, td = table.add_row_cell()
tr.add_color("background", "background3", 5)
tr.add_color("color", "color3")
if group_value == '__NONE__':
label = '---'
else:
label = Common.process_unicode_string(group_value)
td.add(label)
td.add_style("height: 25px")
td.add_style("padding-left: %spx" % (i*15+5))
td.add_style("border-style: solid")
border_color = td.get_color("border")
td.add_style("border-width: 0px 0px 0px 1px")
td.add_style("border-color: %s" % border_color)
td.add_style("font-weight: bold")
示例3: get_display
# 需要导入模块: from pyasm.common import Common [as 别名]
# 或者: from pyasm.common.Common import process_unicode_string [as 别名]
def get_display(my):
'''override the get display function of Widget. This is the function
that actually draws the html element to the buffer'''
html = WebContainer.get_buffer()
buffer = html.get_buffer()
buffer.write("<%s" % my.type)
attrs = []
if my.attrs:
for x,y in my.attrs.items():
if type(x) == types.UnicodeType:
x = Common.process_unicode_string(x)
if type(y) == types.UnicodeType:
y = Common.process_unicode_string(y)
attrs.append( ' %s="%s"' % (x,y) )
attr = " ".join( attrs )
"""
attr = " ".join( [' %s="%s"' % (x,y) for x,y in my.attrs.items()] )
if type(attr) == types.UnicodeType:
attr = Common.process_unicode_string(attr)
"""
buffer.write(attr)
attr = None
# now process behaviors and, if there are any, construct the SPT_BVR_LIST attribute and write it out.
# also add the SPT_BVR class to the element if it does have behaviors.
if my.behaviors:
my.add_class('SPT_BVR')
bvr_str_list = [ ' SPT_BVR_LIST="[' ]
bvr_type_list = [ ' SPT_BVR_TYPE_LIST="[' ]
#for c in range(len(my.behaviors)):
for c, behavior in enumerate(my.behaviors):
if c:
bvr_str_list.append(',')
bvr_type_list.append(',')
bvr_spec_str = HtmlElement.get_json_string(behavior)
# NOTE: this is to make the HTML be XML compliant
#bvr_spec_str = bvr_spec_str.replace("<", "<")
#bvr_spec_str = bvr_spec_str.replace(">", ">")
#bvr_spec_str = bvr_spec_str.replace("&", "&")
bvr_str_list.append( bvr_spec_str )
bvr_info = {
'type': behavior.get("type"),
}
if behavior.get("_handoff_"):
bvr_info['_handoff_'] = behavior.get("_handoff_")
bvr_info_str = HtmlElement.get_json_string(bvr_info)
bvr_type_list.append( bvr_info_str )
bvr_str_list.append( ']"' )
bvr_type_list.append( ']"' )
buffer.write( "".join( bvr_str_list ) )
buffer.write( "".join( bvr_type_list ) )
bvr_str_list = None
bvr_type_list = None
# handle the style
if my.styles:
styles = []
for name, value in my.styles.items():
styles.append( "%s: %s" % (name,value) )
buffer.write( " style='%s'" % ";".join(styles) )
styles = None
# handle relay styles
if my.relay_styles:
for relay_style in my.relay_styles:
my.add(relay_style)
# handle the class
if my.classes:
classes = my.classes.keys()
buffer.write(" class='%s'" % " ".join(classes))
classes = None
# handle events
if my.events:
for key in my.events.keys():
functions = my.events.get(key)
function = "javascript:%s" % ";".join(functions)
buffer.write( ' %s="%s"' % (key,function) )
functions = None
self_close = False
if my.type in ["img", "br"] or (my.type == "input" and not my.widgets):
self_close = True
else:
buffer.write(">")
super(HtmlElement,my).get_display()
#.........这里部分代码省略.........
示例4: get_display
# 需要导入模块: from pyasm.common import Common [as 别名]
# 或者: from pyasm.common.Common import process_unicode_string [as 别名]
#.........这里部分代码省略.........
if xml:
mako_node = xml.get_node("config/%s/mako" % my.view)
if mako_node is not None:
mako_str = xml.get_node_value(mako_node)
html = "<%%\n%s\n%%>\n%s" % (mako_str, html)
from pyasm.web import Palette
num_palettes = Palette.num_palettes()
#if include_mako in ['true', True]:
if include_mako not in ['false', False]:
html = html.replace("<", "<")
html = html.replace(">", ">")
html = my.process_mako(html)
# preparse out expressions
# use relative expressions - [expr]xxx[/expr]
p = re.compile('\[expr\](.*?)\[\/expr\]')
parser = ExpressionParser()
matches = p.finditer(html)
for m in matches:
full_expr = m.group()
expr = m.groups()[0]
result = parser.eval(expr, sobjects, single=True, state=my.state)
if isinstance(result, basestring):
result = Common.process_unicode_string(result)
else:
result = str(result)
html = html.replace(full_expr, result )
# use absolute expressions - [expr]xxx[/expr]
p = re.compile('\[abs_expr\](.*?)\[\/abs_expr\]')
parser = ExpressionParser()
matches = p.finditer(html)
for m in matches:
full_expr = m.group()
expr = m.groups()[0]
result = parser.eval(expr, single=True)
if isinstance(result, basestring):
result = Common.process_unicode_string(result)
else:
result = str(result)
html = html.replace(full_expr, result )
# need a top widget that can be used to refresh
top = my.top
my.set_as_panel(top)
top.add_class("spt_custom_top")
ignore_events = my.kwargs.get("ignore_events") in ['true', True]
if ignore_events:
top.add_style("pointer-events: none")
示例5: get_display
# 需要导入模块: from pyasm.common import Common [as 别名]
# 或者: from pyasm.common.Common import process_unicode_string [as 别名]
#.........这里部分代码省略.........
tr.add_class("tactic_hover")
"""
tr = table.add_row()
tr.add_color("background", "background", -5)
th = table.add_header("Property")
th.add_style("min-width: 200px")
th.add_style("padding: 5px")
th = table.add_header("Value")
#th.add_style("min-width: 400px")
th.add_style("padding: 5px")
"""
keys = metadata.get("__keys__")
if not keys:
keys = metadata.keys()
empty = False
if not keys:
empty = True
keys = ['','','','','','','']
table.add_smart_styles("spt_cell", {
'height': '20px'
} )
keys.sort()
for i, key in enumerate(keys):
value = metadata.get(key)
value = Common.process_unicode_string(value)
if not isinstance(key, basestring):
key = str(key)
#title = Common.get_display_title(key)
title = key
tr = table.add_row()
tr.add_class("tactic_hover")
if i % 2:
tr.add_color("background", "background", -2)
tr.add_color("color", "color")
else:
tr.add_color("background", "background")
tr.add_color("color", "color")
td = table.add_cell()
td.add_class("spt_cell")
td.add(title)
td.add_style("width: 300px")
td.add_style("min-width: 200px")
td = table.add_cell()
td.add_class("spt_cell")
if len(str(value)) > 500:
inside = DivWdg()
td.add(inside)
value = value[:500]
inside.add(value)
inside.add_style("max-width: 600px")