当前位置: 首页>>代码示例>>Python>>正文


Python H.url_decode方法代码示例

本文整理汇总了Python中helper.H.url_decode方法的典型用法代码示例。如果您正苦于以下问题:Python H.url_decode方法的具体用法?Python H.url_decode怎么用?Python H.url_decode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在helper.H的用法示例。


在下文中一共展示了H.url_decode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: generate_stack_output

# 需要导入模块: from helper import H [as 别名]
# 或者: from helper.H import url_decode [as 别名]
def generate_stack_output(response):
    values = H.unicode_string('')

    # Display exception name and message
    if S.BREAKPOINT_EXCEPTION:
        values += H.unicode_string('[{name}] {message}\n' \
                                  .format(name=S.BREAKPOINT_EXCEPTION['name'], message=S.BREAKPOINT_EXCEPTION['message']))

    # Walk through elements in response
    has_output = False
    try:
        for child in response:
            # Get stack attribute values
            if child.tag == dbgp.ELEMENT_STACK or child.tag == dbgp.ELEMENT_PATH_STACK:
                stack_level = child.get(dbgp.STACK_LEVEL, 0)
                stack_type = child.get(dbgp.STACK_TYPE)
                stack_file = H.url_decode(child.get(dbgp.STACK_FILENAME))
                stack_line = child.get(dbgp.STACK_LINENO, 0)
                stack_where = child.get(dbgp.STACK_WHERE, '{unknown}')
                # Append values
                values += H.unicode_string('[{level}] {filename}.{where}:{lineno}\n' \
                                          .format(level=stack_level, type=stack_type, where=stack_where, lineno=stack_line, filename=stack_file))
                has_output = True
    except:
        pass

    # When no stack use values from exception
    if not has_output and S.BREAKPOINT_EXCEPTION:
        values += H.unicode_string('[{level}] {filename}.{where}:{lineno}\n' \
                                  .format(level=0, where='{unknown}', lineno=S.BREAKPOINT_EXCEPTION['lineno'], filename=S.BREAKPOINT_EXCEPTION['filename']))

    return values
开发者ID:willbeaufoy,项目名称:SublimeTextXdebug,代码行数:34,代码来源:view.py

示例2: get_stack_values

# 需要导入模块: from helper import H [as 别名]
# 或者: from helper.H import url_decode [as 别名]
def get_stack_values():
    """
    Get stack information for current context.
    """
    values = H.unicode_string('')
    if S.SESSION:
        try:
            # Get stack information
            S.SESSION.send(dbgp.STACK_GET)
            response = S.SESSION.read()

            for child in response:
                # Get stack attribute values
                if child.tag == dbgp.ELEMENT_STACK or child.tag == dbgp.ELEMENT_PATH_STACK:
                    stack_level = child.get(dbgp.STACK_LEVEL, 0)
                    stack_type = child.get(dbgp.STACK_TYPE)
                    stack_file = H.url_decode(child.get(dbgp.STACK_FILENAME))
                    stack_line = child.get(dbgp.STACK_LINENO, 0)
                    stack_where = child.get(dbgp.STACK_WHERE, '{unknown}')
                    # Append values
                    values += H.unicode_string('[{level}] {filename}.{where}:{lineno}\n' \
                                              .format(level=stack_level, type=stack_type, where=stack_where, lineno=stack_line, filename=stack_file))
        except (socket.error, ProtocolConnectionException):
            e = sys.exc_info()[1]
            connection_error("%s" % e)
    return values
开发者ID:pirog,项目名称:SublimeTextXdebug,代码行数:28,代码来源:session.py

示例3: generate_stack_output

# 需要导入模块: from helper import H [as 别名]
# 或者: from helper.H import url_decode [as 别名]
def generate_stack_output(response):
    values = H.unicode_string('')

    # Display exception name and message
    if S.BREAKPOINT_EXCEPTION:
        values += H.unicode_string('[{name}] {message}\n' \
                                  .format(name=S.BREAKPOINT_EXCEPTION['name'], message=S.BREAKPOINT_EXCEPTION['message']))

    # Walk through elements in response
    has_output = False
    try:
        for child in response:
            # Get stack attribute values
            if child.tag == dbgp.ELEMENT_STACK or child.tag == dbgp.ELEMENT_PATH_STACK:
                stack_level = child.get(dbgp.STACK_LEVEL, 0)
                stack_type = child.get(dbgp.STACK_TYPE)
                stack_file = H.url_decode(child.get(dbgp.STACK_FILENAME))
                stack_line = child.get(dbgp.STACK_LINENO, 0)
                stack_where = child.get(dbgp.STACK_WHERE, '{unknown}')
                # Append values
                filename = os.path.basename(stack_file)
                values += H.unicode_string('[{level}] {lineno} {filename} {where} {filepath}\n' \
                                          .format(level=stack_level, type=stack_type, where=stack_where, lineno=stack_line, filepath=stack_file, filename=filename))
                has_output = True
    except:
        pass

    # When no stack use values from exception
    if not has_output and S.BREAKPOINT_EXCEPTION:
        filename = os.path.basename(stack_file)
        values += H.unicode_string('[{level}] {lineno} {filename} {where} {filepath}\n' \
                                  .format(level=0, where='{unknown}', lineno=S.BREAKPOINT_EXCEPTION['lineno'], filepath=S.BREAKPOINT_EXCEPTION['filename'], filename=filename))

    # Space all out equally
    lines = values.split('\n')
    lines_bits = [x.strip().split(' ') for x in lines]
    bit_widths = []
    for line_bits in lines_bits:
        for i, line_bit in enumerate(line_bits):
            line_bits[i] = line_bit.strip()
            if len(bit_widths) <= i:
                bit_widths.append(0)
            bit_widths[i] = max(bit_widths[i], len(line_bit.strip()))
    new_lines = []
    for i, line_bits in enumerate(lines_bits):
        if(len(line_bits) > 1):
            line_bits[1] = line_bits[1].rjust(bit_widths[1])
        new_lines.append(' '.join([b.ljust(bit_widths[j]) for j, b in enumerate(line_bits)]))
    values = '\n'.join(new_lines)
    return values
开发者ID:sligodave,项目名称:SublimeTextXdebug,代码行数:52,代码来源:view.py

示例4: generate_stack_output

# 需要导入模块: from helper import H [as 别名]
# 或者: from helper.H import url_decode [as 别名]
def generate_stack_output(response):
    values = H.unicode_string('')
    # Walk through elements in response
    try:
        for child in response:
            # Get stack attribute values
            if child.tag == dbgp.ELEMENT_STACK or child.tag == dbgp.ELEMENT_PATH_STACK:
                stack_level = child.get(dbgp.STACK_LEVEL, 0)
                stack_type = child.get(dbgp.STACK_TYPE)
                stack_file = H.url_decode(child.get(dbgp.STACK_FILENAME))
                stack_line = child.get(dbgp.STACK_LINENO, 0)
                stack_where = child.get(dbgp.STACK_WHERE, '{unknown}')
                # Append values
                values += H.unicode_string('[{level}] {filename}.{where}:{lineno}\n' \
                                          .format(level=stack_level, type=stack_type, where=stack_where, lineno=stack_line, filename=stack_file))
    except:
        pass

    return values
开发者ID:federivo,项目名称:SublimeTextXdebug,代码行数:21,代码来源:view.py

示例5: get_real_path

# 需要导入模块: from helper import H [as 别名]
# 或者: from helper.H import url_decode [as 别名]
def get_real_path(uri, server=False):
    """
    Get real path

    Keyword arguments:
    uri -- Uri of file that needs to be mapped and located
    server -- Map local path to server path

    TODO: Fix mapping for root (/) and drive letters (P:/)
    """
    if uri is None:
        return uri

    # URLdecode uri
    uri = H.url_decode(uri)

    # Split scheme from uri to get absolute path
    try:
        # scheme:///path/file => scheme, /path/file
        # scheme:///C:/path/file => scheme, C:/path/file
        transport, filename = uri.split(':///', 1) 
    except:
        filename = uri

    # Normalize path for comparison and remove duplicate/trailing slashes
    uri = os.path.normpath(filename)

    # Pattern for checking if uri is a windows path
    drive_pattern = re.compile(r'^[a-zA-Z]:[\\/]')

    # Append leading slash if filesystem is not Windows
    if not drive_pattern.match(uri) and not os.path.isabs(uri):
        uri = os.path.normpath('/' + uri)

    path_mapping = S.get_config_value('path_mapping')
    if isinstance(path_mapping, dict):
        # Go through path mappings
        for server_path, local_path in path_mapping.items():
            server_path = os.path.normpath(server_path)
            local_path = os.path.normpath(local_path)
            # Replace path if mapping available
            if server:
                # Map local path to server path
                if local_path in uri:
                    uri = uri.replace(local_path, server_path)
                    break
            else:
                # Map server path to local path
                if server_path in uri:
                    uri = uri.replace(server_path, local_path)
                    break
    else:
        sublime.set_timeout(lambda: sublime.status_message("Xdebug: No path mapping defined, returning given path."), 0)

    # Replace slashes
    if not drive_pattern.match(uri):
        uri = uri.replace("\\", "/")

    # Append scheme
    if server:
        return H.url_encode("file://" + uri)

    return uri
开发者ID:federivo,项目名称:SublimeTextXdebug,代码行数:65,代码来源:util.py


注:本文中的helper.H.url_decode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。