#PyTreefy
##PyTreefy is a Python script designed to explore a specified directory, generate a visual representation of its directory tree, and collect all Python scripts (*.py) present in that directory. The collected scripts are then combined with the directory tree structure and written to an output file.
Directory Tree Generation: Creates a visual representation of the directory structure, including subdirectories and files. Python Script Collection: Collects and concatenates the contents of all Python scripts located in the specified directory. Output File Creation: Writes the directory tree and collected Python scripts to a single output file. Installation Ensure you have Python 3.x installed on your system.
Clone the repository or download the script directly:
git clone https://github.com/infinition/pytreefy.git cd pytreefy Usage To run the script, follow these steps:
Navigate to the script directory:
cd path/to/pytreefy Run the script:
python pytreefy.py Provide the required input: The script will prompt you to enter the path of the directory you wish to explore.
Example:
Entrez le chemin du répertoire à explorer: /path/to/directory Output: The script will generate an output file named output.txt in the specified directory. This file will contain the directory tree and the contents of all Python scripts found.
Example
python pytreefy.py
Entrez le chemin du répertoire à explorer: /home/user/projects
Les scripts ont été collectés et écrits dans /home/user/projects/output.txt Script Details generate_directory_tree(root_dir) This function generates a visual representation of the directory tree.
Parameters: root_dir (str): The root directory to explore. Returns: A string representing the directory tree structure. collect_python_scripts(directory) This function collects and concatenates the contents of all Python scripts in the specified directory.
Parameters: directory (str): The directory to search for Python scripts. Returns: A string containing the concatenated contents of all Python scripts. write_to_output_file(output_file, text) This function writes the provided text to the specified output file.
Parameters: output_file (str): The path to the output file. text (str): The text to write to the file. Example Output The output.txt file generated by the script will have the following structure:
Arborescence des fichiers:
directory/ subdirectory1/ file1.py file2.txt subdirectory2/ file3.py file4.py
License This project is licensed under the MIT License. See the LICENSE file for details.