How to use the fbs.resources._paths function in fbs

To help you get started, we’ve selected a few fbs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mherrmann / fbs / fbs / resources.py View on Github external
def _get_files_to_copy(src_dir_or_file, dest_dir, exclude):
    excludes = _paths(map(path, exclude))
    if isfile(src_dir_or_file) and src_dir_or_file not in excludes:
        yield src_dir_or_file, join(dest_dir, basename(src_dir_or_file))
    else:
        for (subdir, _, files) in os.walk(src_dir_or_file):
            dest_subdir = join(dest_dir, relpath(subdir, src_dir_or_file))
            for file_ in files:
                file_path = join(subdir, file_)
                dest_path = join(dest_subdir, file_)
                if file_path not in excludes:
                    yield file_path, dest_path
github mherrmann / fbs / fbs / resources.py View on Github external
def copy_with_filtering(
    src_dir_or_file, dest_dir, replacements=None, files_to_filter=None,
    exclude=None, placeholder='${%s}'
):
    """
    Copy the given file or directory to the given destination, optionally
    applying filtering.
    """
    if replacements is None:
        replacements = SETTINGS
    if files_to_filter is None:
        files_to_filter = []
    if exclude is None:
        exclude = []
    to_copy = _get_files_to_copy(src_dir_or_file, dest_dir, exclude)
    to_filter = _paths(files_to_filter)
    for src, dest in to_copy:
        makedirs(dirname(dest), exist_ok=True)
        if files_to_filter is None or src in to_filter:
            _copy_with_filtering(src, dest, replacements, placeholder)
        else:
            copy(src, dest)