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


Python pathlib2.PurePath方法代码示例

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


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

示例1: path_matches_any

# 需要导入模块: import pathlib2 [as 别名]
# 或者: from pathlib2 import PurePath [as 别名]
def path_matches_any(text, patterns):
    """Check if the text matches any of the given wildcard patterns.

    NOTE: Intended for filepaths with wildcards where fnmatch is too greedy.
    Especially useful in cases where a username in a filepath may need to be wildcarded.

    For example;
    path_matches_any('/Users/foobar/path/to/file', {'/Users/*/path/*/file'}) == True

    Args:
        text (str): Text to examine
        patterns (iterable): Collection of string patterns, compatible with fnmatch (* wildcards)

    Returns:
        bool: True if the text matches at least one of the patterns, False otherwise.
    """
    if not isinstance(text, str):
        return False
    return any(pathlib2.PurePath(text).match(pattern) for pattern in patterns) 
开发者ID:airbnb,项目名称:streamalert,代码行数:21,代码来源:base.py

示例2: matches_glob_list

# 需要导入模块: import pathlib2 [as 别名]
# 或者: from pathlib2 import PurePath [as 别名]
def matches_glob_list(path, glob_list):
    """
    Given a list of glob patterns, returns a boolean
    indicating if a path matches any glob in the list
    """
    for glob in glob_list:
        try:
            if PurePath(path).match(glob):
                return True
        except TypeError:
            pass
    return False 
开发者ID:floydhub,项目名称:floyd-cli,代码行数:14,代码来源:files.py

示例3: create_destination_id

# 需要导入模块: import pathlib2 [as 别名]
# 或者: from pathlib2 import PurePath [as 别名]
def create_destination_id(client, container, name):
        # type: (azure.storage.StorageClient, str, str) -> str
        """Create a unique destination id
        :param azure.storage.StorageClient client: storage client
        :param str container: container name
        :param str name: entity name
        :rtype: str
        :return: unique id for the destination
        """
        path = str(pathlib.PurePath(name))
        return ';'.join((client.primary_endpoint, container, path)) 
开发者ID:Azure,项目名称:blobxfer,代码行数:13,代码来源:upload.py

示例4: path_splitter

# 需要导入模块: import pathlib2 [as 别名]
# 或者: from pathlib2 import PurePath [as 别名]
def path_splitter(flat_key):
    keys = PurePath(flat_key).parts
    return keys 
开发者ID:ianlini,项目名称:flatten-dict,代码行数:5,代码来源:splitter.py


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