From 654e8dc3a02b5c1f2cbe2f455bf30e57017512e7 Mon Sep 17 00:00:00 2001 From: Lukas Puehringer Date: Wed, 20 Nov 2019 14:12:01 +0100 Subject: [PATCH] doc: Fix targets file paths in tutorial snippets - Correctly show that repo.get_filepaths_in_directory() returns absolute and not relative paths - Pass absolute path to repo.targets.add_target() to fix exception - Also see theupdateframework/tuf#957 Signed-off-by: Lukas Puehringer --- docs/TUTORIAL.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/TUTORIAL.md b/docs/TUTORIAL.md index 1e2262a2ad..d430958e60 100644 --- a/docs/TUTORIAL.md +++ b/docs/TUTORIAL.md @@ -356,15 +356,15 @@ the target filepaths to metadata. # in targets metadata. >>> repository = load_repository('repository') -# get_filepaths_in_directory() returns a list of file paths in a directory. It can also return -# files in sub-directories if 'recursive_walk' is True. ->>> list_of_targets = repository.get_filepaths_in_directory("repository/targets/", - recursive_walk=False, followlinks=True) +# get_filepaths_in_directory() returns a list of file paths in a directory. It +# can also return files in sub-directories if 'recursive_walk' is True. +>>> list_of_targets = repository.get_filepaths_in_directory( +... "repository/targets/", recursive_walk=False, followlinks=True) # Note: Since we set the 'recursive_walk' argument to false, the 'myproject' # sub-directory is excluded from 'list_of_targets'. >>> list_of_targets -['repository/targets/file2.txt', 'repository/targets/file1.txt', 'repository/targets/file3.txt'] +['/path/to/repository/targets/file2.txt', '/path/to/repository/targets/file1.txt', '/path/to/repository/targets/file3.txt'] # Add the list of target paths to the metadata of the top-level Targets role. # Any target file paths that might already exist are NOT replaced, and @@ -385,7 +385,7 @@ the target filepaths to metadata. # (octal number specifying file access for owner, group, others (e.g., 0755) is # added alongside the default fileinfo. All target objects in metadata include # the target's filepath, hash, and length. ->>> target4_filepath = "repository/targets/myproject/file4.txt" +>>> target4_filepath = os.path.abspath("repository/targets/myproject/file4.txt") >>> octal_file_permissions = oct(os.stat(target4_filepath).st_mode)[4:] >>> custom_file_permissions = {'file_permissions': octal_file_permissions} >>> repository.targets.add_target(target4_filepath, custom_file_permissions)