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


Python reprlib.repr方法代码示例

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


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

示例1: __str__

# 需要导入模块: import reprlib [as 别名]
# 或者: from reprlib import repr [as 别名]
def __str__(self, indentation="\n"):
        """print(Email(**args)) method.
           Indentation value can be overridden in the function call.
           The default is new line"""
        return (
            "{}From: {}"
            "{}To: {}"
            "{}Body: {}"
            "{}Attachments: {}"
            "{}SID: {}".format(
                indentation,
                self.from_,
                indentation,
                self.to,
                indentation,
                reprlib.repr(self.body),
                indentation,
                self.attachments,
                indentation,
                self.sid,
            )
        ) 
开发者ID:trp07,项目名称:messages,代码行数:24,代码来源:text.py

示例2: __str__

# 需要导入模块: import reprlib [as 别名]
# 或者: from reprlib import repr [as 别名]
def __str__(self, indentation="\n"):
        """print(Telegram(**args)) method.
           Indentation value can be overridden in the function call.
           The default is new line"""
        return (
            "{}From: {}"
            "{}To: {}"
            "{}Chat ID: {}"
            "{}Subject: {}"
            "{}Body: {}"
            "{}Attachments: {}".format(
                indentation,
                self.from_,
                indentation,
                self.to,
                indentation,
                self.chat_id,
                indentation,
                self.subject,
                indentation,
                reprlib.repr(self.body),
                indentation,
                self.attachments,
            )
        ) 
开发者ID:trp07,项目名称:messages,代码行数:27,代码来源:telegram.py

示例3: __str__

# 需要导入模块: import reprlib [as 别名]
# 或者: from reprlib import repr [as 别名]
def __str__(self, indentation="\n"):
        """print(SlackWebhook(**args)) method.
           Indentation value can be overridden in the function call.
           The default is new line"""
        return (
            "{}URL: {}"
            "{}From: {}"
            "{}Subject: {}"
            "{}Body: {}"
            "{}Attachments: {}".format(
                indentation,
                self.url,
                indentation,
                self.from_ or "Not Specified",
                indentation,
                self.subject,
                indentation,
                reprlib.repr(self.body),
                indentation,
                self.attachments,
            )
        ) 
开发者ID:trp07,项目名称:messages,代码行数:24,代码来源:slack.py

示例4: _repr_info

# 需要导入模块: import reprlib [as 别名]
# 或者: from reprlib import repr [as 别名]
def _repr_info(self):
        info = [self._state.lower()]
        if self._state == _FINISHED:
            if self._exception is not None:
                info.append('exception={!r}'.format(self._exception))
            else:
                # use reprlib to limit the length of the output, especially
                # for very long strings
                result = reprlib.repr(self._result)
                info.append('result={}'.format(result))
        if self._callbacks:
            info.append(self.__format_callbacks())
        if self._source_traceback:
            frame = self._source_traceback[-1]
            info.append('created at %s:%s' % (frame[0], frame[1]))
        return info 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:18,代码来源:futures.py

示例5: _format_callback

# 需要导入模块: import reprlib [as 别名]
# 或者: from reprlib import repr [as 别名]
def _format_callback(func, args, suffix=''):
    if isinstance(func, functools.partial):
        if args is not None:
            suffix = _format_args(args) + suffix
        return _format_callback(func.func, func.args, suffix)

    if hasattr(func, '__qualname__'):
        func_repr = getattr(func, '__qualname__')
    elif hasattr(func, '__name__'):
        func_repr = getattr(func, '__name__')
    else:
        func_repr = repr(func)

    if args is not None:
        func_repr += _format_args(args)
    if suffix:
        func_repr += suffix
    return func_repr 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:20,代码来源:events.py

示例6: trace_dispatch

# 需要导入模块: import reprlib [as 别名]
# 或者: from reprlib import repr [as 别名]
def trace_dispatch(self, frame, event, arg):
        if self.quitting:
            return # None
        if event == 'line':
            return self.dispatch_line(frame)
        if event == 'call':
            return self.dispatch_call(frame, arg)
        if event == 'return':
            return self.dispatch_return(frame, arg)
        if event == 'exception':
            return self.dispatch_exception(frame, arg)
        if event == 'c_call':
            return self.trace_dispatch
        if event == 'c_exception':
            return self.trace_dispatch
        if event == 'c_return':
            return self.trace_dispatch
        print('bdb.Bdb.dispatch: unknown debugging event:', repr(event))
        return self.trace_dispatch 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:21,代码来源:bdb.py

示例7: _future_repr_info

# 需要导入模块: import reprlib [as 别名]
# 或者: from reprlib import repr [as 别名]
def _future_repr_info(future):
    # (Future) -> str
    """helper function for Future.__repr__"""
    info = [future._state.lower()]
    if future._state == _FINISHED:
        if future._exception is not None:
            info.append(f'exception={future._exception!r}')
        else:
            # use reprlib to limit the length of the output, especially
            # for very long strings
            result = reprlib.repr(future._result)
            info.append(f'result={result}')
    if future._callbacks:
        info.append(_format_callbacks(future._callbacks))
    if future._source_traceback:
        frame = future._source_traceback[-1]
        info.append(f'created at {frame[0]}:{frame[1]}')
    return info 
开发者ID:CedricGuillemet,项目名称:Imogen,代码行数:20,代码来源:base_futures.py

示例8: _format_callback

# 需要导入模块: import reprlib [as 别名]
# 或者: from reprlib import repr [as 别名]
def _format_callback(func, args, kwargs, suffix=''):
    if isinstance(func, functools.partial):
        suffix = _format_args_and_kwargs(args, kwargs) + suffix
        return _format_callback(func.func, func.args, func.keywords, suffix)

    if hasattr(func, '__qualname__') and func.__qualname__:
        func_repr = func.__qualname__
    elif hasattr(func, '__name__') and func.__name__:
        func_repr = func.__name__
    else:
        func_repr = repr(func)

    func_repr += _format_args_and_kwargs(args, kwargs)
    if suffix:
        func_repr += suffix
    return func_repr 
开发者ID:CedricGuillemet,项目名称:Imogen,代码行数:18,代码来源:format_helpers.py

示例9: _repr_info

# 需要导入模块: import reprlib [as 别名]
# 或者: from reprlib import repr [as 别名]
def _repr_info(self):
        info = [self._state.lower()]
        if self._state == _FINISHED:
            if self._exception is not None:
                info.append('exception={!r}'.format(self._exception))
            else:
                # use reprlib to limit the length of the output, especially
                # for very long strings
                result = reprlib.repr(self._result)
                info.append('result={}'.format(result))
        if self._callbacks:
            info.append(self._format_callbacks())
        if self._source_traceback:
            frame = self._source_traceback[-1]
            info.append('created at %s:%s' % (frame[0], frame[1]))
        return info 
开发者ID:hhstore,项目名称:annotated-py-projects,代码行数:18,代码来源:futures.py

示例10: _format_callback

# 需要导入模块: import reprlib [as 别名]
# 或者: from reprlib import repr [as 别名]
def _format_callback(func, args, suffix=''):
    if isinstance(func, functools.partial):
        if args is not None:
            suffix = _format_args(args) + suffix
        return _format_callback(func.func, func.args, suffix)

    func_repr = getattr(func, '__qualname__', None)
    if not func_repr:
        func_repr = repr(func)

    if args is not None:
        func_repr += _format_args(args)
    if suffix:
        func_repr += suffix

    source = _get_function_source(func)     # 获取方法源
    if source:
        func_repr += ' at %s:%s' % source
    return func_repr 
开发者ID:hhstore,项目名称:annotated-py-projects,代码行数:21,代码来源:events.py

示例11: _format_callback

# 需要导入模块: import reprlib [as 别名]
# 或者: from reprlib import repr [as 别名]
def _format_callback(func, args, kwargs, suffix=''):
    if isinstance(func, functools.partial):
        suffix = _format_args_and_kwargs(args, kwargs) + suffix
        return _format_callback(func.func, func.args, func.keywords, suffix)

    if hasattr(func, '__qualname__'):
        func_repr = getattr(func, '__qualname__')
    elif hasattr(func, '__name__'):
        func_repr = getattr(func, '__name__')
    else:
        func_repr = repr(func)

    func_repr += _format_args_and_kwargs(args, kwargs)
    if suffix:
        func_repr += suffix
    return func_repr 
开发者ID:ShikyoKira,项目名称:Project-New-Reign---Nemesis-Main,代码行数:18,代码来源:events.py

示例12: execute

# 需要导入模块: import reprlib [as 别名]
# 或者: from reprlib import repr [as 别名]
def execute(self, operation, parameters=None):
        self._current_response, self._iterator, self._paging_state = None, None, None
        execute_statement_args = dict(self._prepare_execute_args(operation),
                                      includeResultMetadata=True)
        if parameters:
            execute_statement_args["parameters"] = self._format_parameter_set(parameters)
        logger.debug("execute %s", reprlib.repr(operation.strip()))
        try:
            res = self._client.execute_statement(**execute_statement_args)
            if "columnMetadata" in res:
                self._set_description(res["columnMetadata"])
            self._current_response = self._render_response(res)
        except self._client.exceptions.BadRequestException as e:
            if "Please paginate your query" in str(e):
                self._start_paginated_query(execute_statement_args)
            elif "Database response exceeded size limit" in str(e):
                self._start_paginated_query(execute_statement_args, records_per_page=max(1, self.arraysize // 2))
            else:
                raise self._get_database_error(e) from e
        self._iterator = iter(self) 
开发者ID:chanzuckerberg,项目名称:aurora-data-api,代码行数:22,代码来源:__init__.py

示例13: total_size

# 需要导入模块: import reprlib [as 别名]
# 或者: from reprlib import repr [as 别名]
def total_size(o, handlers={}, verbose=False):
    """ Returns the approximate memory footprint an object and all of its contents.

    Automatically finds the contents of the following builtin containers and
    their subclasses:  tuple, list, deque, dict, set and frozenset.
    To search other containers, add handlers to iterate over their contents:

        handlers = {SomeContainerClass: iter,
                    OtherContainerClass: OtherContainerClass.get_elements}

    """
    dict_handler = lambda d: chain.from_iterable(d.items())
    all_handlers = {tuple: iter,
                    list: iter,
                    deque: iter,
                    dict: dict_handler,
                    set: iter,
                    frozenset: iter,
                   }
    all_handlers.update(handlers)     # user handlers take precedence
    seen = set()                      # track which object id's have already been seen
    default_size = getsizeof(0)       # estimate sizeof object without __sizeof__

    def sizeof(o):
        if id(o) in seen:       # do not double count the same object
            return 0
        seen.add(id(o))
        s = getsizeof(o, default_size)

        if verbose:
            print(s, type(o), repr(o), file=stderr)

        for typ, handler in all_handlers.items():
            if isinstance(o, typ):
                s += sum(map(sizeof, handler(o)))
                break
        return s

    return sizeof(o) 
开发者ID:kafkasl,项目名称:contextualLSTM,代码行数:41,代码来源:memory.py

示例14: __str__

# 需要导入模块: import reprlib [as 别名]
# 或者: from reprlib import repr [as 别名]
def __str__(self):
        return f'{self.tag}, {_r(self.value)}, {self.type}, {self.error}' 
开发者ID:ottowayi,项目名称:pycomm3,代码行数:4,代码来源:__init__.py

示例15: __repr__

# 需要导入模块: import reprlib [as 别名]
# 或者: from reprlib import repr [as 别名]
def __repr__(self):
        return f'{self.__class__.__name__}({self.data_type!r}, {_r(self.value)}, {self.service_status!r})' 
开发者ID:ottowayi,项目名称:pycomm3,代码行数:4,代码来源:responses.py


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