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


Python iterutils.remap方法代码示例

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


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

示例1: pop

# 需要导入模块: from boltons import iterutils [as 别名]
# 或者: from boltons.iterutils import remap [as 别名]
def pop(self, key: str) -> Any:
        """Delete and return value at key.

        Args:
            key (str): Key to pop.

        Returns:
            Any: Popped value.

        """
        path, target = self.parse_key(key)
        value = self.get(key)
        remapped = iterutils.remap(self._config, lambda p, k,
                                   v: False if p == path and k == target else True)
        self._config = remapped
        self.log.debug(f"popped config value {value} <- [{key}]")
        return self.sync() 
开发者ID:BradenM,项目名称:micropy-cli,代码行数:19,代码来源:config.py

示例2: get_file_report

# 需要导入模块: from boltons import iterutils [as 别名]
# 或者: from boltons.iterutils import remap [as 别名]
def get_file_report(file_sha256, report_url, environment_id, type_, apikey, secret, verify):
    user_agent = {'User-agent': 'VxStream Sandbox'}
    params = {'apikey': apikey, 'secret': secret, 'environmentId': environment_id, 'type': type_}
    resource_url = '%s/%s' % (report_url, file_sha256)

    try:
        res = requests.get(resource_url, headers=user_agent, params=params, verify=verify)
        if res.status_code == 200:
            # walk entire json blob to fix
            # the keys known to cause issues
            remapped = remap(res.json(), visit=visit)
            return remapped
        else:
            print('Error code: {}, returned when getting report: {}'.format(res.status_code, file_sha256))
            return res
    except requests.exceptions.HTTPError as err:
        print(err) 
开发者ID:mitre,项目名称:multiscanner,代码行数:19,代码来源:VxStream.py

示例3: pretty

# 需要导入模块: from boltons import iterutils [as 别名]
# 或者: from boltons.iterutils import remap [as 别名]
def pretty(self, attrs='class="table"'):
        return display(
            HTML(j2h.convert(json=remap(self, visit=visit), table_attributes=attrs))
        ) 
开发者ID:materialsproject,项目名称:MPContribs,代码行数:6,代码来源:__init__.py

示例4: dict_match_mocks

# 需要导入模块: from boltons import iterutils [as 别名]
# 或者: from boltons.iterutils import remap [as 别名]
def dict_match_mocks(self, d1):
        from unittest.mock import Mock
        # Mocks
        remapped = iterutils.remap(d1, lambda p, k, v: (
            k, "MOCKED_VALUE") if isinstance(v, Mock) else True)
        return remapped 
开发者ID:BradenM,项目名称:micropy-cli,代码行数:8,代码来源:conftest.py

示例5: permute_nested_values

# 需要导入模块: from boltons import iterutils [as 别名]
# 或者: from boltons.iterutils import remap [as 别名]
def permute_nested_values(dicts: "List[dict]", gen_val: "Callable[[int], Any]"):
    """
    This function permutes the values of a nested mapping, for testing that out merge
    method work regardless of the values types.

    Assumes the intial dictionary had integers for values.
    """
    dicts = deepcopy(dicts)
    initial_values = [
        x[1] for x in research(dicts, query=lambda p, k, v: isinstance(v, int))
    ]
    mapping = {k: gen_val(k) for k in initial_values}
    return [remap(d, exit=partial(map_values, mapping)) for d in dicts] 
开发者ID:theislab,项目名称:anndata,代码行数:15,代码来源:test_concatenate.py

示例6: _item_to_csv

# 需要导入模块: from boltons import iterutils [as 别名]
# 或者: from boltons.iterutils import remap [as 别名]
def _item_to_csv(self, item):
        from boltons.iterutils import remap
        output = io.BytesIO()
        writer = self._create_csv_writer(output)
        item = remap(item, visit=self._encode_string)
        writer.writerow(item)
        return output.getvalue().rstrip() 
开发者ID:scrapinghub,项目名称:exporters,代码行数:9,代码来源:csv_export_formatter.py


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