Commit 378868fc authored by Jürg Billeter's avatar Jürg Billeter
Browse files

utils.py: Remove list_dirs parameter from list_relative_paths()

list_dirs was always True in the BuildStream code base. There was also a
bug in the list_dirs=False code path as it did not return symlinks in
`dirnames`.

This is an API break, however, there are no known external callers.
parent f4af343b
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -97,7 +97,7 @@ class LocalSource(Source):
        with self.timed_activity("Staging local files at {}".format(self.path)):
        with self.timed_activity("Staging local files at {}".format(self.path)):


            if os.path.isdir(self.fullpath):
            if os.path.isdir(self.fullpath):
                files = list(utils.list_relative_paths(self.fullpath, list_dirs=True))
                files = list(utils.list_relative_paths(self.fullpath))
                utils.copy_files(self.fullpath, directory, files=files)
                utils.copy_files(self.fullpath, directory, files=files)
            else:
            else:
                destfile = os.path.join(directory, os.path.basename(self.path))
                destfile = os.path.join(directory, os.path.basename(self.path))
+6 −8
Original line number Original line Diff line number Diff line
@@ -111,7 +111,7 @@ class FileListResult():
        return ret
        return ret




def list_relative_paths(directory, *, list_dirs=True):
def list_relative_paths(directory):
    """A generator for walking directory relative paths
    """A generator for walking directory relative paths


    This generator is useful for checking the full manifest of
    This generator is useful for checking the full manifest of
@@ -125,7 +125,6 @@ def list_relative_paths(directory, *, list_dirs=True):


    Args:
    Args:
       directory (str): The directory to list files in
       directory (str): The directory to list files in
       list_dirs (bool): Whether to list directories


    Yields:
    Yields:
       Relative filenames in `directory`
       Relative filenames in `directory`
@@ -152,7 +151,6 @@ def list_relative_paths(directory, *, list_dirs=True):
        # subdirectories in the walked `dirpath`, so we extract
        # subdirectories in the walked `dirpath`, so we extract
        # these symlinks from `dirnames`
        # these symlinks from `dirnames`
        #
        #
        if list_dirs:
        for d in dirnames:
        for d in dirnames:
            fullpath = os.path.join(dirpath, d)
            fullpath = os.path.join(dirpath, d)
            if os.path.islink(fullpath):
            if os.path.islink(fullpath):
@@ -161,7 +159,7 @@ def list_relative_paths(directory, *, list_dirs=True):
        # We've decended into an empty directory, in this case we
        # We've decended into an empty directory, in this case we
        # want to include the directory itself, but not in any other
        # want to include the directory itself, but not in any other
        # case.
        # case.
        if list_dirs and not filenames:
        if not filenames:
            yield relpath
            yield relpath


        # List the filenames in the walked directory
        # List the filenames in the walked directory