def find_package_paths(basepath, exclude_paths=None): """ Crawl the filesystem to find package manifest files. When a subfolder contains a file ``AMENT_IGNORE`` it is ignored. :param str basepath: The path to search in :param list exclude_paths: A list of paths which should not be searched :returns: A list of relative paths containing package manifest files ``list`` """ paths = [] real_exclude_paths = [] if exclude_paths is not None: real_exclude_paths = [os.path.realpath(p) for p in exclude_paths] for dirpath, dirnames, filenames in os.walk(basepath, followlinks=True): real_dirpath = os.path.realpath(dirpath) if 'AMENT_IGNORE' in filenames or real_dirpath in real_exclude_paths: del dirnames[:] continue elif package_exists_at(dirpath): paths.append(os.path.relpath(dirpath, basepath)) del dirnames[:] continue for dirname in dirnames: if dirname.startswith('.'): dirnames.remove(dirname) return paths
def find_package_paths(basepath, exclude_paths=None): """ Crawl the filesystem to find package manifest files. When a subfolder contains a file ``AMENT_IGNORE`` it is ignored. :param str basepath: The path to search in :param list exclude_paths: A list of paths which should not be searched :returns: A list of relative paths containing package manifest files ``list`` """ paths = [] real_exclude_paths = [] if exclude_paths is not None: real_exclude_paths = [os.path.realpath(p) for p in exclude_paths] for dirpath, dirnames, filenames in os.walk(basepath, followlinks=True): real_dirpath = os.path.realpath(dirpath) if 'AMENT_IGNORE' in filenames or real_dirpath in real_exclude_paths: del dirnames[:] continue elif package_exists_at(dirpath): paths.append(os.path.relpath(dirpath, basepath)) del dirnames[:] continue for dirname in dirnames: if dirname.startswith('.'): dirnames.remove(dirname) return paths
def validate_package_path(path): """Assert the given path is a directory with a package. :param str path: directory containing a package :raises: ValueError if path is not valid or does not contain a package """ if not os.path.isdir(path): raise ValueError("Path '{0}' is not a directory or does not exist" .format(path)) if not package_exists_at(path): raise ValueError("Path '{0}' does not contain a package".format(path))
def validate_package_path(path): """Assert the given path is a directory with a package. :param str path: directory containing a package :raises: ValueError if path is not valid or does not contain a package """ if not os.path.isdir(path): raise ValueError( "Path '{0}' is not a directory or does not exist".format(path)) if not package_exists_at(path): raise ValueError("Path '{0}' does not contain a package".format(path))
def argparse_existing_package(path): path = argparse_existing_dir(path) if not package_exists_at(path): raise argparse.ArgumentTypeError( "Path '%s' does not contain a package" % path) return path
def argparse_existing_package(path): path = argparse_existing_dir(path) if not package_exists_at(path): raise argparse.ArgumentTypeError( "Path '%s' does not contain a package" % path) return path