當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。