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


Python inspect.formatargvalues方法代码示例

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


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

示例1: format_signature

# 需要导入模块: import inspect [as 别名]
# 或者: from inspect import formatargvalues [as 别名]
def format_signature(func, *args, **kwargs):
    # XXX: Should this use inspect.formatargvalues/formatargspec?
    module, name = get_func_name(func)
    module = [m for m in module if m]
    if module:
        module.append(name)
        module_path = '.'.join(module)
    else:
        module_path = name
    arg_str = list()
    previous_length = 0
    for arg in args:
        formatted_arg = _format_arg(arg)
        if previous_length > 80:
            formatted_arg = '\n%s' % formatted_arg
        previous_length = len(formatted_arg)
        arg_str.append(formatted_arg)
    arg_str.extend(['%s=%s' % (v, _format_arg(i)) for v, i in kwargs.items()])
    arg_str = ', '.join(arg_str)

    signature = '%s(%s)' % (name, arg_str)
    return module_path, signature 
开发者ID:flennerhag,项目名称:mlens,代码行数:24,代码来源:func_inspect.py

示例2: format_signature

# 需要导入模块: import inspect [as 别名]
# 或者: from inspect import formatargvalues [as 别名]
def format_signature(func, *args, **kwargs):
    # XXX: Should this use inspect.formatargvalues/formatargspec?
    module, name = get_func_name(func)
    module = [m for m in module if m]
    if module:
        module.append(name)
        module_path = '.'.join(module)
    else:
        module_path = name
    arg_str = list()
    previous_length = 0
    for arg in args:
        arg = pformat(arg, indent=2)
        if len(arg) > 1500:
            arg = '%s...' % arg[:700]
        if previous_length > 80:
            arg = '\n%s' % arg
        previous_length = len(arg)
        arg_str.append(arg)
    arg_str.extend(['%s=%s' % (v, pformat(i)) for v, i in kwargs.items()])
    arg_str = ', '.join(arg_str)

    signature = '%s(%s)' % (name, arg_str)
    return module_path, signature 
开发者ID:bbfamily,项目名称:abu,代码行数:26,代码来源:func_inspect.py

示例3: test_frame

# 需要导入模块: import inspect [as 别名]
# 或者: from inspect import formatargvalues [as 别名]
def test_frame(self):
        args, varargs, varkw, locals = inspect.getargvalues(mod.fr)
        self.assertEqual(args, ['x', 'y'])
        self.assertEqual(varargs, None)
        self.assertEqual(varkw, None)
        self.assertEqual(locals, {'x': 11, 'p': 11, 'y': 14})
        self.assertEqual(inspect.formatargvalues(args, varargs, varkw, locals),
                         '(x=11, y=14)') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:10,代码来源:test_inspect.py

示例4: test_previous_frame

# 需要导入模块: import inspect [as 别名]
# 或者: from inspect import formatargvalues [as 别名]
def test_previous_frame(self):
        args, varargs, varkw, locals = inspect.getargvalues(mod.fr.f_back)
        self.assertEqual(args, ['a', 'b', 'c', 'd', ['e', ['f']]])
        self.assertEqual(varargs, 'g')
        self.assertEqual(varkw, 'h')
        self.assertEqual(inspect.formatargvalues(args, varargs, varkw, locals),
             '(a=7, b=8, c=9, d=3, (e=4, (f=5,)), *g=(), **h={})') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:9,代码来源:test_inspect.py

示例5: test_previous_frame

# 需要导入模块: import inspect [as 别名]
# 或者: from inspect import formatargvalues [as 别名]
def test_previous_frame(self):
        args, varargs, varkw, locals = inspect.getargvalues(mod.fr.f_back)
        self.assertEqual(args, ['a', 'b', 'c', 'd', 'e', 'f'])
        self.assertEqual(varargs, 'g')
        self.assertEqual(varkw, 'h')
        self.assertEqual(inspect.formatargvalues(args, varargs, varkw, locals),
             '(a=7, b=8, c=9, d=3, e=4, f=5, *g=(), **h={})') 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:9,代码来源:test_inspect.py

示例6: _get_call_info

# 需要导入模块: import inspect [as 别名]
# 或者: from inspect import formatargvalues [as 别名]
def _get_call_info(level):
        """
        输出调用日志打印的函数的函数名及形参、实参。仅当配置的日志打印级别为DEBUG时的情况下才会输出这些详细信息
        """
        frames = inspect.stack()
        fr = frames[4][0]
        args_pretty = inspect.formatargvalues(*(inspect.getargvalues(fr)), formatvalue=Logger._formatvalue)
        filename, lineno, funcname, _, _ = inspect.getframeinfo(fr, -1)
        filename = filename.split('/')[-1]
        if level != logging.DEBUG and funcname != "<module>":
            return '%s:%d/%s%s' % (filename, lineno, funcname, args_pretty)
        else:
            return '%s:%d/%s' % (filename, lineno, funcname) 
开发者ID:baidu,项目名称:ARK,代码行数:15,代码来源:log.py

示例7: test_frame

# 需要导入模块: import inspect [as 别名]
# 或者: from inspect import formatargvalues [as 别名]
def test_frame(self):
        args, varargs, varkw, locals = inspect.getargvalues(mod.fr)
        self.assertEqual(args, ['x', 'y'])
        self.assertEqual(varargs, None)
        self.assertEqual(varkw, None)
        self.assertEqual(locals, {'x': 11, 'p': 11, 'y': 14})
        self.assertEqual(inspect.formatargvalues(args, varargs, varkw, locals),
                         '(x=11, y=14)')

    # TODO - test_previous_frame could be rewritten such that we could
    # introspect on the previous frame but without a dependency on
    # tuple unpacking 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:14,代码来源:test_inspect.py

示例8: GetMyRepresentation

# 需要导入模块: import inspect [as 别名]
# 或者: from inspect import formatargvalues [as 别名]
def GetMyRepresentation(value):
    """
    Give a shorter representation of some wx-objects. Returns normal repr()
    for everything else. Also adds a "=" sign at the beginning to make it
    useful as a "formatvalue" function for inspect.formatargvalues().
    """
    typeString = repr(type(value))
    if typeString.startswith("<class 'wx._core."):
        return "=<wx.%s>" % typeString[len("<class 'wx._core."): -2]
    if typeString.startswith("<class 'wx._controls."):
        return "=<wx.%s>" % typeString[len("<class 'wx._controls."): -2]
    return "=" + repr(value) 
开发者ID:EventGhost,项目名称:EventGhost,代码行数:14,代码来源:Utils.py

示例9: format_signature

# 需要导入模块: import inspect [as 别名]
# 或者: from inspect import formatargvalues [as 别名]
def format_signature(self, func, *args, **kwds):
        # XXX: This should be moved out to a function
        # XXX: Should this use inspect.formatargvalues/formatargspec?
        module, name = get_func_name(func)
        module = [m for m in module if m]
        if module:
            module.append(name)
            module_path = '.'.join(module)
        else:
            module_path = name
        arg_str = list()
        previous_length = 0
        for arg in args:
            arg = self.format(arg, indent=2)
            if len(arg) > 1500:
                arg = '%s...' % arg[:700]
            if previous_length > 80:
                arg = '\n%s' % arg
            previous_length = len(arg)
            arg_str.append(arg)
        arg_str.extend(['%s=%s' % (v, self.format(i)) for v, i in
                                    kwds.iteritems()])
        arg_str = ', '.join(arg_str)

        signature = '%s(%s)' % (name, arg_str)
        return module_path, signature

    # Make make public 
开发者ID:jtamames,项目名称:SqueezeMeta,代码行数:30,代码来源:memory.py


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