Skip to content

Commit 20cd3fd

Browse files
committed
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#957 Signed-off-by: Lukas Puehringer <[email protected]>
1 parent fd001b0 commit 20cd3fd

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

docs/TUTORIAL.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -356,15 +356,15 @@ the target filepaths to metadata.
356356
# in targets metadata.
357357
>>> repository = load_repository('repository')
358358

359-
# get_filepaths_in_directory() returns a list of file paths in a directory. It can also return
360-
# files in sub-directories if 'recursive_walk' is True.
361-
>>> list_of_targets = repository.get_filepaths_in_directory("repository/targets/",
362-
recursive_walk=False, followlinks=True)
359+
# get_filepaths_in_directory() returns a list of file paths in a directory. It
360+
# can also return files in sub-directories if 'recursive_walk' is True.
361+
>>> list_of_targets = repository.get_filepaths_in_directory(
362+
... "repository/targets/", recursive_walk=False, followlinks=True)
363363

364364
# Note: Since we set the 'recursive_walk' argument to false, the 'myproject'
365365
# sub-directory is excluded from 'list_of_targets'.
366366
>>> list_of_targets
367-
['repository/targets/file2.txt', 'repository/targets/file1.txt', 'repository/targets/file3.txt']
367+
['/path/to/repository/targets/file2.txt', '/path/to/repository/targets/file1.txt', '/path/to/repository/targets/file3.txt']
368368

369369
# Add the list of target paths to the metadata of the top-level Targets role.
370370
# Any target file paths that might already exist are NOT replaced, and
@@ -385,7 +385,7 @@ the target filepaths to metadata.
385385
# (octal number specifying file access for owner, group, others (e.g., 0755) is
386386
# added alongside the default fileinfo. All target objects in metadata include
387387
# the target's filepath, hash, and length.
388-
>>> target4_filepath = "repository/targets/myproject/file4.txt"
388+
>>> target4_filepath = os.path.abspath("repository/targets/myproject/file4.txt")
389389
>>> octal_file_permissions = oct(os.stat(target4_filepath).st_mode)[4:]
390390
>>> custom_file_permissions = {'file_permissions': octal_file_permissions}
391391
>>> repository.targets.add_target(target4_filepath, custom_file_permissions)

0 commit comments

Comments
 (0)