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