Package: pstruc
Project Structure GeneratorOverviewProject Structure Generator is a versatile tool available both as a command-line interface and as a library. It enables users to generate directory structures in JSON, YAML, or plain text formats and offers the ability to pretty-print the structure with color.FeaturesGenerate directory structures in JSON, YAML, Dictionary or plain text.Exclude patterns specified in.gitignore.Pretty-print the directory structure with colorful output.Command-line interface for ease of use.Ability to include content of specified files.Customizable patterns for more precise control over the directory structure output.InstallationTo install the package, use the following command:pip install pstrucCLI UsageThepstructool supports various arguments for generating and customizing the directory structure.Argumentsdirectory: Specify the directory to inspect (not specified: current directory)-f,--format: Choose the output format (json, yaml, txt, dict).-o,--output: Specify the output file name.-p,--print: Print the directory structure without saving it.-ns,--not-save: Do not save the generated structure to an output file.-ip,--add-ignore-patterns: Add custom patterns to ignore.-iff,--ignore-from-files: List of files to get the ignore patterns from.-igi,--ignore-git-ignore: Ignore the patterns inside .gitignore file.-fc,--add-content-file-patterns: Include content of specified files.Examplepython pstruc.py /path/to/directory -f json -o output_structure -ip "*.log","__pycache__" -fc "*.md","*.txt"This command will generate a JSON fileoutput_structure.jsonrepresenting the directory structure of/path/to/directory, ignoring files matching*.logand__pycache__, and including content of markdown and text files.Library UsageAs a library,pstrucprovides a straightforward API for generating and manipulating directory structures. The core functionality is based on generating the structure, saving it, and pretty-printing.Examplefrompstrucimportget_project_structure,save_structure_to_file,pretty_print# Generate directory structurestructure=get_project_structure('/path/to/directory','json',ignore_patterns=["*.log","__pycache__"],file_content=["*.md","*.txt"])# Save to a filesave_structure_to_file('output_structure.json',structure)# Pretty-print the structurepretty_print(structure)Library Available Methodsget_project_structure(start_path, output_format, ignore_patterns, file_content): Generates the directory structure.start_path (str): The directory to inspect.output_format (str): The desired output format ('json', 'yaml', 'txt', 'dict').ignore_patterns (list): List of patterns to ignore.file_content (list): List of patterns to determine which file content to include in the structure.save_structure_to_file(output_file, structure): Saves the directory structure to a file.output_file (str): The name of the output file.structure (str): The directory structure content to be saved.pretty_print(structure): Pretty-prints the directory structure.structure (str or dict): The directory structure to print.indentation (str): The current indentation level.get_all_ignore_patterns(start_path, files_with_ignore_patterns, extra_ignore_patterns): Retrieves a combined list of ignore patterns from specified files and additional user-provided patterns.start_path (str): The root directory path from where the search for ignore files begins.files_with_ignore_patterns (list of str): Filenames from which to read ignore patterns (e.g., '.gitignore').extra_ignore_patterns (list of str): Additional patterns provided by the user.ContributingContributions are welcome! Please follow ourContributing Guidelines.LicenseThis project is licensed under the MIT License - see theLICENSEfile for details.Acknowledgmentscolorama- For colorful output.