get_file_paths¶
-
FunctionalityWrapper.
get_file_paths
(style='rel_path', anon=False)[source] Yields the paths of all files server_home/anon_root, in the given style.
Parameters: - style ({'rel_path', 'url'}, default 'rel_path') –
- ‘rel_path’:
- path relative to server_home/anon_root is returned.
- ’url’:
- url to the file is returned.
- anon (bool) –
- True:
- filepaths/urls of all files in anon_root is returned.
- False:
- filepaths/urls of all files in server_home is returned.
Yields: file_path (str) – Generator of all filepaths in the server_home/anon_root
Raises: TypeError
– If style is not astr
TypeError
– If anon is not abool
ValueError
– If the value of style is not ‘rel_path’ or ‘url’
Examples
Assuming a file structure as follows.
filesystem +---server_home | +---test_file1 | +---test_folder | +---test_file2 | +---anon_root +---test_file3 +---test_folder +---test_file4
>>> list(ftpserver.get_file_paths(style="rel_path", anon=False)) ["test_file1", "test_folder/test_file2"]
>>> list(ftpserver.get_file_paths(style="rel_path", anon=True)) ["test_file3", "test_folder/test_file4"]
>>> list(ftpserver.get_file_paths(style="url", anon=False)) ["ftp://fakeusername:qweqwe@localhost:8888/test_file1", "ftp://fakeusername:qweqwe@localhost:8888/test_folder/test_file2"]
>>> list(ftpserver.get_file_paths(style="url", anon=True)) ["ftp://localhost:8888/test_file3", "ftp://localhost:8888/test_folder/test_file4"]
- style ({'rel_path', 'url'}, default 'rel_path') –