def _fingerprint_dirs(self, dirpaths, topdown=True, onerror=None, followlinks=False):
    """Returns a fingerprint of the given file directories and all their sub contents.

    This assumes that the file directories are of reasonable size
    to cause memory or performance issues.
    """
    # Note that we don't sort the dirpaths, as their order may have meaning.
    filepaths = []
    for dirpath in dirpaths:
      dirs = os.walk(dirpath, topdown=topdown, onerror=onerror,
                     followlinks=followlinks)
      sorted_dirs = sorted(dirs, key=lambda d: d[0])
      filepaths.extend([os.path.join(dirpath, filename)
                   for dirpath, dirnames, filenames in sorted_dirs
                   for filename in sorted(filenames)])
    return self._fingerprint_files(filepaths)
Returns a fingerprint of the given file directories and all their sub contents.

    This assumes that the file directories are of reasonable size
    to cause memory or performance issues.