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