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


Python Tools.reverse方法代码示例

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


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

示例1: rpcdecode

# 需要导入模块: from mx import Tools [as 别名]
# 或者: from mx.Tools import reverse [as 别名]
def rpcdecode(url,prefix='',decode=1,

              splitat=TextTools.splitat,charsplit=TextTools.charsplit,
              len=len,tuple=tuple,urldecode=urldecode):

    """ Decode a RPC encoded function/method call.

        Returns a tuple (name,args,kws) where args is a tuple of
        string arguments and kws is a dictionary containing the given
        keyword parameters or None. All parameters are returned as
        strings; it is up to the caller to decode them into
        e.g. integers, etc.

        If prefix is given and found it is removed from the name prior
        to returning it. decode can be set to false to prevent the url
        from being urldecoded prior to processing.

        The decode function also supports the syntax 'method' instead
        of 'method()' for calls without arguments.

    """
    if decode:
        url = urldecode(url)
    # Decode the method: method[(arg0,arg1,...,kw0=val0,kw1=val1,...)]
    name,rawargs = splitat(url,'(')
    if rawargs:
        # Cut out the pure argument part, ignoring any character after 
        # the final ')'
        rawargs,rest = splitat(rawargs,')',-1)
        # Argument list: split at ','
        args = charsplit(rawargs,',')
        if '=' in rawargs:
            kws = {}
            for i,arg in Tools.reverse(Tools.irange(args)):
                if '=' in arg:
                    k,v = splitat(arg,'=')
                    kws[k] = v
                    del args[i]
        else:
            kws = None
        args = tuple(args)
    else:
        args = ()
        kws = None
    if prefix:
        if name[:len(prefix)] == prefix:
            name = name[len(prefix):]
        return name,args,kws
    else:
        return name,args,kws
开发者ID:GymWenFLL,项目名称:tpp_libs,代码行数:52,代码来源:URL.py


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