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


Python CaseInsensitiveDict.__str__方法代码示例

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


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

示例1: CommandResponseStatus

# 需要导入模块: from requests.structures import CaseInsensitiveDict [as 别名]
# 或者: from requests.structures.CaseInsensitiveDict import __str__ [as 别名]
class CommandResponseStatus(Command, metaclass=CommandRegister):
    pretty_name = "RESPONSE STATUS"

    def __init__(self, result_collector):
        super(CommandResponseStatus, self).__init__(result_collector)
        self.mapping = CaseInsensitiveDict()
        self.mapping["Ok"] = 200
        self.mapping["Not found"] = 404

    def map_status_code(self, status):
        """

        author Damian Mirecki

        :param status
        :return:
        :rtype: int
        :raise LookupError: When status is not implemented yet.
        """

        if status not in self.mapping:
            raise LookupError("Status " + status + " not found in " + self.mapping.__str__())

        return self.mapping[status]

    def parse(self, path):
        response = self.result_collector.get_response()
        if response is None:
            raise ParsingException(self, result.ERROR_RESPONSE_NOT_FOUND)

        actual = response.status_code

        if len(path) == 0:
            return actual, ParsedValue(self, None, "")

        status = path[0]

        if not status.isdigit():
            try:
                status = self.map_status_code(status)
            except LookupError as e:
                raise ParsingException(self, Error.from_exception(self, e))
        else:
            if int(status) not in _codes.keys():
                raise ParsingException(self, result.ERROR_INVALID_STATUS_CODE)

        expected = int(status)
        return actual, ParsedValue(self, expected, "")
开发者ID:nokia-wroclaw,项目名称:innovativeproject-resttest,代码行数:50,代码来源:command_response.py


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