This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You have to write a python script that: | |
1. Recursively crawls a directory, creating a nested dictionary representing the file and folder structure, with the first key being said directory. | |
2. The recursion could have a limit, like the standard `tree` bash command. | |
3. Using a recursive funcion is not a must, you could use a `while` loop if it helps performance and readability, or be creative with `dict` merging and splitting paths. | |
3. accepts a directory as an input | |
4. accepts a level optional argument to limit | |
5. accepts an optional alias for the input directory | |
6. uses pathlib for path related functions and argparse for argument parsing | |
Example: for a folder named "myfolder/" with the following structure: |