Skip to content

Commit 0415875

Browse files
committed
add use_abspath flag to create_file_list
remove create_abspath_list
1 parent 2f8703a commit 0415875

File tree

1 file changed

+11
-50
lines changed

1 file changed

+11
-50
lines changed

rsconnect/bundle.py

Lines changed: 11 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,7 @@ def create_html_manifest(
891891
manifest = Manifest(app_mode=AppModes.STATIC, entrypoint=entrypoint, primary_html=entrypoint, image=image)
892892
manifest.deploy_dir = deploy_dir
893893

894-
file_list = create_abspath_list(path, extra_files, excludes)
894+
file_list = create_file_list(path, extra_files, excludes, use_abspath=True)
895895
for abs_path in file_list:
896896
manifest.add_file(abs_path)
897897

@@ -944,6 +944,7 @@ def create_file_list(
944944
path: str,
945945
extra_files: typing.List[str] = None,
946946
excludes: typing.List[str] = None,
947+
use_abspath: bool = False,
947948
) -> typing.List[str]:
948949
"""
949950
Builds a full list of files under the given path that should be included
@@ -962,7 +963,8 @@ def create_file_list(
962963
file_set = set(extra_files) # type: typing.Set[str]
963964

964965
if isfile(path):
965-
file_set.add(path)
966+
path_to_add = abspath(path) if use_abspath else path
967+
file_set.add(path_to_add)
966968
return sorted(file_set)
967969

968970
for cur_dir, sub_dirs, files in os.walk(path):
@@ -971,57 +973,16 @@ def create_file_list(
971973
if any(parent in exclude_paths for parent in Path(cur_dir).parents):
972974
continue
973975
for file in files:
974-
abs_path = os.path.join(cur_dir, file)
975-
rel_path = relpath(abs_path, path)
976+
cur_path = os.path.join(cur_dir, file)
977+
rel_path = relpath(cur_path, path)
976978

977-
if Path(abs_path) in exclude_paths:
979+
if Path(cur_path) in exclude_paths:
978980
continue
979981
if keep_manifest_specified_file(rel_path, exclude_paths | directories_to_ignore) and (
980-
rel_path in extra_files or not glob_set.matches(abs_path)
982+
rel_path in extra_files or not glob_set.matches(cur_path)
981983
):
982-
file_set.add(rel_path)
983-
return sorted(file_set)
984-
985-
986-
def create_abspath_list(
987-
path: str,
988-
extra_files: typing.List[str] = None,
989-
excludes: typing.List[str] = None,
990-
) -> typing.List[str]:
991-
"""
992-
Builds a absolute path list of files under the given path that should be included
993-
in a manifest or bundle.
994-
995-
:param path: a file, or a directory to walk for files.
996-
:param extra_files: a sequence of any extra files to include in the bundle.
997-
:param excludes: a sequence of glob patterns that will exclude matched files.
998-
:return: the list of relevant files, relative to the given directory.
999-
"""
1000-
extra_files = extra_files or []
1001-
excludes = excludes if excludes else []
1002-
glob_set = create_glob_set(path, excludes)
1003-
exclude_paths = {Path(p) for p in excludes}
1004-
file_set = set(extra_files) # type: typing.Set[str]
1005-
1006-
if isfile(path):
1007-
file_set.add(abspath(path))
1008-
return sorted(file_set)
1009-
1010-
for cur_dir, sub_dirs, files in os.walk(path):
1011-
if Path(cur_dir) in exclude_paths:
1012-
continue
1013-
if any(parent in exclude_paths for parent in Path(cur_dir).parents):
1014-
continue
1015-
for file in files:
1016-
abs_path = os.path.join(cur_dir, file)
1017-
rel_path = relpath(abs_path, path)
1018-
1019-
if Path(abs_path) in exclude_paths:
1020-
continue
1021-
if keep_manifest_specified_file(rel_path, exclude_paths | directories_to_ignore) and (
1022-
rel_path in extra_files or not glob_set.matches(abs_path)
1023-
):
1024-
file_set.add(abspath(abs_path))
984+
path_to_add = abspath(cur_path) if use_abspath else rel_path
985+
file_set.add(path_to_add)
1025986
return sorted(file_set)
1026987

1027988

@@ -1733,7 +1694,7 @@ def create_voila_manifest(
17331694

17341695
manifest.add_to_buffer(join(deploy_dir, environment.filename), environment.contents)
17351696

1736-
file_list = create_abspath_list(path, extra_files, excludes)
1697+
file_list = create_file_list(path, extra_files, excludes, use_abspath=True)
17371698
for abs_path in file_list:
17381699
manifest.add_file(abs_path)
17391700
return manifest

0 commit comments

Comments
 (0)