本文整理汇总了Python中helper.H.base64_decode方法的典型用法代码示例。如果您正苦于以下问题:Python H.base64_decode方法的具体用法?Python H.base64_decode怎么用?Python H.base64_decode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类helper.H
的用法示例。
在下文中一共展示了H.base64_decode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_response_properties
# 需要导入模块: from helper import H [as 别名]
# 或者: from helper.H import base64_decode [as 别名]
def get_response_properties(response, default_key=None):
"""
Return a dictionary with available properties from response.
Keyword arguments:
response -- Response from debugger engine.
default_key -- Index key to use when property has no name.
"""
properties = H.new_dictionary()
# Walk through elements in response
for child in response:
# Read property elements
if child.tag == dbgp.ELEMENT_PROPERTY or child.tag == dbgp.ELEMENT_PATH_PROPERTY:
# Get property attribute values
property_name_short = child.get(dbgp.PROPERTY_NAME)
property_name = child.get(dbgp.PROPERTY_FULLNAME, property_name_short)
property_type = child.get(dbgp.PROPERTY_TYPE)
property_children = child.get(dbgp.PROPERTY_CHILDREN)
property_numchildren = child.get(dbgp.PROPERTY_NUMCHILDREN)
property_classname = child.get(dbgp.PROPERTY_CLASSNAME)
property_encoding = child.get(dbgp.PROPERTY_ENCODING)
property_value = None
# Set property value
if child.text:
property_value = child.text
# Try to decode property value when encoded with base64
if property_encoding is not None and property_encoding == 'base64':
try:
property_value = H.base64_decode(child.text)
except:
pass
if property_name is not None and len(property_name) > 0:
property_key = property_name
# Ignore following properties
if property_name == "::":
continue
# Avoid nasty static functions/variables from turning in an infinitive loop
if property_name.count("::") > 1:
continue
# Filter password values
if get_value(S.KEY_HIDE_PASSWORD, True) and property_name.lower().find('password') != -1 and property_value is not None:
property_value = '******'
else:
property_key = default_key
# Store property
if property_key:
properties[property_key] = { 'name': property_name, 'type': property_type, 'value': property_value, 'numchildren': property_numchildren, 'children' : None }
# Get values for children
if property_children:
properties[property_key]['children'] = get_response_properties(child, default_key)
# Set classname, if available, as type for object
if property_classname and property_type == 'object':
properties[property_key]['type'] = property_classname
# Handle error elements
elif child.tag == dbgp.ELEMENT_ERROR or child.tag == dbgp.ELEMENT_PATH_ERROR:
message = 'error'
for step_child in child:
if step_child.tag == dbgp.ELEMENT_MESSAGE or step_child.tag == dbgp.ELEMENT_PATH_MESSAGE and step_child.text:
message = step_child.text
break
if default_key:
properties[default_key] = { 'name': None, 'type': message, 'value': None, 'numchildren': None, 'children': None }
return properties