Skip to main content

A tool to create a directory structure based on a YAML file

Project description

Py Auto Structure

Py Auto Structure is a versatile tool designed to simplify the process of creating directory structures for your Python projects. It leverages YAML files to define project hierarchies and offers a convenient command-line interface for effortless structure creation.

Features

  • Project Structure Definition: Define and customize your project structure in a YAML file.
  • Command-Line Interface (CLI): Create project directories with ease using simple commands.
  • Customization: Tailor the project name and root folder during structure creation.

Installation

pip install py-auto-structure

Usage

1. Using it from the command line

Creating a project structure is as easy as running a command in your terminal. Use the following command, replacing <project_name> with the desired name:

py-structure -p <path_to_be_set> -n <project_name>

Options:

  • -p, --path: Path where the parent directory of the project will be set.
  • -n, --name: Specify the name of the project and it will be the root of the project.
  • --set-yaml: Path to the YAML file containing the project structure definition. Default is an internal project_structure.yaml.
  • --yaml: Returns the raw content of the default yaml in order to copy it.

By default, the script looks for the project structure definition in a file named project_structure.yaml in the current directory.

2. Using it as a module

You can also import it as a module and call the function project_build this way:

from project_builder.project_builder import project_build

project_build(path=your_path, yaml_path=your_custom_yaml_path)

Default YAML

Here is as simplified version (in order to improve readability) of the default .yaml used:

project_structure:
  - name: data
    type: directory
    content:
      - name: raw
  - name: notebooks
    type: directory
  - name: src
    type: directory
    content:
      - name: __init__.py
        type: file
      - name: feature1
        type: directory
  - name: tests
    type: directory
  - name: docs
    type: directory
  - name: outputs
    type: directory
  - name: requirements.txt
    type: file
  - name: main.py
    type: file
    content: 
      >
        def main():
            print("Hello World!")

        if __name__ == "__main__":
            main()

You can customize the default passing your own .yaml path to the function but this would create the following structure:

MyProject/
|-- data/
|   `-- raw/
|-- notebooks/
|-- src/
|   |-- __init__.py
|   `-- feature1/
|-- tests/
|-- docs/
|-- outputs/
|-- requirements.txt
|-- main.py

Make sure to follow this structure for the custom yaml:

name: <dirname | filename>
type: <file | directory>
content: <list for directories | string for files>

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py-auto-structure-0.1.5.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_auto_structure-0.1.5-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file py-auto-structure-0.1.5.tar.gz.

File metadata

  • Download URL: py-auto-structure-0.1.5.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.1

File hashes

Hashes for py-auto-structure-0.1.5.tar.gz
Algorithm Hash digest
SHA256 67ff6822fc53224e292b8be89bf42739deda4f3753911a262624a6171591881b
MD5 ac4dba43bfd5cb48935149355b93ccb7
BLAKE2b-256 d46e9e04b174ed1abfd1c70bb131beb509c3ea850d0b837651d8110d4ff52f48

See more details on using hashes here.

File details

Details for the file py_auto_structure-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for py_auto_structure-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 c8be7a015e3c37971b1d4a4fc63d35e6b2fb0e396a0e7823aa40d265a5d74417
MD5 576eb9c1be6e44425332941b737a8cf0
BLAKE2b-256 36f85f882c23fe5742732c57ce158b1dfe0b077902b1d76d22a11c956624e662

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page