Esempio n. 1
0
 def _find_packages_iter(cls, base_path):
     dirs = cls._all_dirs(base_path)
     suitable = filterfalse(lambda n: '.' in n, dirs)
     return (
         path.replace(os.path.sep, '.')
         for path in suitable
         if cls._looks_like_package(os.path.join(base_path, path))
     )
Esempio n. 2
0
 def _find_packages_iter(cls, base_path):
     dirs = cls._all_dirs(base_path)
     suitable = filterfalse(lambda n: '.' in n, dirs)
     return (
         path.replace(os.path.sep, '.')
         for path in suitable
         if cls._looks_like_package(os.path.join(base_path, path))
     )
Esempio n. 3
0
File: misc.py Progetto: gzqichang/wa
 def find(cls, where='.', exclude=(), include=('*',)):
     out = cls._find_packages_iter(convert_path(where))
     # out = test_paths(out, "_find_packages_iter:")
     out = cls.require_parents(out)
     # out = test_paths(out, "require_parents:")
     out = filter(cls._build_filter(*include), out)
     out = filterfalse(cls._build_filter('ez_setup', '*__pycache__', 'build*', 'dist*', *exclude), out)
     out = test_paths(out, "for return:")
     return list(out)
Esempio n. 4
0
 def _candidate_dirs(base_path):
     """
     Return all dirs in base_path that might be packages.
     """
     has_dot = lambda name: '.' in name
     for root, dirs, files in os.walk(base_path, followlinks=True):
         # Exclude directories that contain a period, as they cannot be
         #  packages. Mutate the list to avoid traversal.
         dirs[:] = filterfalse(has_dot, dirs)
         for dir in dirs:
             yield os.path.relpath(os.path.join(root, dir), base_path)
Esempio n. 5
0
 def _candidate_dirs(base_path):
     """
     Return all dirs in base_path that might be packages.
     """
     has_dot = lambda name: '.' in name
     for root, dirs, files in os.walk(base_path, followlinks=True):
         # Exclude directories that contain a period, as they cannot be
         #  packages. Mutate the list to avoid traversal.
         dirs[:] = filterfalse(has_dot, dirs)
         for dir in dirs:
             yield os.path.relpath(os.path.join(root, dir), base_path)
Esempio n. 6
0
File: misc.py Progetto: gzqichang/wa
 def _find_packages_iter(cls, base_path):
     print("base_path:", base_path)
     dirs = cls._all_dirs(base_path)
     # dirs = test_paths(dirs, "_all_dirs:")
     suitable = filterfalse(lambda n: '.' in n, dirs)
     # suitable = test_paths(suitable, "suitable:")
     packages = (
         path.replace(os.path.sep, '.')
         for path in suitable
         # if cls._looks_like_package(os.path.join(base_path, path))
     )
     # packages = test_paths(packages, "_looks_like_package:")
     return packages
Esempio n. 7
0
def unique_everseen(iterable, key=None):
    "List unique elements, preserving order. Remember all elements ever seen."
    # unique_everseen('AAAABBBCCDAABBB') --> A B C D
    # unique_everseen('ABBCcAD', str.lower) --> A B C D
    seen = set()
    seen_add = seen.add
    if key is None:
        for element in filterfalse(seen.__contains__, iterable):
            seen_add(element)
            yield element
    else:
        for element in iterable:
            k = key(element)
            if k not in seen:
                seen_add(k)
                yield element
Esempio n. 8
0
def unique_everseen(iterable, key=None):
    "List unique elements, preserving order. Remember all elements ever seen."
    # unique_everseen('AAAABBBCCDAABBB') --> A B C D
    # unique_everseen('ABBCcAD', str.lower) --> A B C D
    seen = set()
    seen_add = seen.add
    if key is None:
        for element in filterfalse(seen.__contains__, iterable):
            seen_add(element)
            yield element
    else:
        for element in iterable:
            k = key(element)
            if k not in seen:
                seen_add(k)
                yield element
Esempio n. 9
0
    def find(cls, where=".", exclude=(), include=("*",)):
        """Return a list all Python packages found within directory 'where'

        'where' should be supplied as a "cross-platform" (i.e. URL-style)
        path; it will be converted to the appropriate local path syntax.
        'exclude' is a sequence of package names to exclude; '*' can be used
        as a wildcard in the names, such that 'foo.*' will exclude all
        subpackages of 'foo' (but not 'foo' itself).

        'include' is a sequence of package names to include.  If it's
        specified, only the named packages will be included.  If it's not
        specified, all found packages will be included.  'include' can contain
        shell style wildcard patterns just like 'exclude'.

        The list of included packages is built up first and then any
        explicitly excluded packages are removed from it.
        """
        out = cls._find_packages_iter(convert_path(where))
        includes = cls._build_filter(*include)
        excludes = cls._build_filter("ez_setup", "*__pycache__", *exclude)
        out = filter(includes, out)
        out = filterfalse(excludes, out)
        return list(out)
Esempio n. 10
0
    def find(cls, where='.', exclude=(), include=('*',)):
        """Return a list all Python packages found within directory 'where'

        'where' should be supplied as a "cross-platform" (i.e. URL-style)
        path; it will be converted to the appropriate local path syntax.
        'exclude' is a sequence of package names to exclude; '*' can be used
        as a wildcard in the names, such that 'foo.*' will exclude all
        subpackages of 'foo' (but not 'foo' itself).

        'include' is a sequence of package names to include.  If it's
        specified, only the named packages will be included.  If it's not
        specified, all found packages will be included.  'include' can contain
        shell style wildcard patterns just like 'exclude'.

        The list of included packages is built up first and then any
        explicitly excluded packages are removed from it.
        """
        out = cls._find_packages_iter(convert_path(where))
        includes = cls._build_filter(*include)
        excludes = cls._build_filter('ez_setup', '*__pycache__', *exclude)
        out = filter(includes, out)
        out = filterfalse(excludes, out)
        return list(out)
Esempio n. 11
0
        yield Distribution(
            location, metadata, '-'.join(parts[:p]), '-'.join(parts[p:]),
            py_version=py_version, precedence = precedence,
            platform = platform
        )

# From Python 2.7 docs
def unique_everseen(iterable, key=None):
    "List unique elements, preserving order. Remember all elements ever seen."
    # unique_everseen('AAAABBBCCDAABBB') --> A B C D
    # unique_everseen('ABBCcAD', str.lower) --> A B C D
    seen = set()
    seen_add = seen.add
    if key is None:
<<<<<<< HEAD
        for element in filterfalse(seen.__contains__, iterable):
=======
        for element in six.moves.filterfalse(seen.__contains__, iterable):
>>>>>>> 54eef0be98b1b67c8507db91f4cfa90b64991027
            seen_add(element)
            yield element
    else:
        for element in iterable:
            k = key(element)
            if k not in seen:
                seen_add(k)
                yield element

def unique_values(func):
    """
    Wrap a function returning an iterable such that the resulting iterable