-
Notifications
You must be signed in to change notification settings - Fork 280
Description
Description of issue or feature request:
#1008 removes ambiguity in interfaces that take TARGETPATH arguments, by only accepting paths and path patterns that use "/" as directory separator and don't start with "/", as recommended in the specification (see #1018 for even stricter vetting of these arguments).
To provide a friendly user interface we should add normalizing functionality that transforms paths as returned by os.listdir
, os.walk
, repository_tool.Repository.get_filepaths_in_directory
, etc... into a format that is accepted by methods that take TARGETPATHs.
Normalizing includes
- strip targets directory prefix from absolute paths
- convert Windows-style dir separators "" to Unix-style separators "/"
- maybe perform
os.path.normpath
-like normalization, like collapsing redundant separators and up-level references
#957 has some discussions about least-suprise in TARGETPATH, e.g. what do do if an absolute path does not have the targets directory as prefix, or a relative path is passed, etc...
I envision an interface that may be used like this:
target_role.add_targets(normalize_target_paths(get_filepaths_in_directory(dir_path)))
or the with the latter two combined
target_role.add_targets(get_normalized_paths_in_directory(dir_path)))