Skip to content

Instantly share code, notes, and snippets.

@derekpappas
Created December 18, 2023 16:29
Show Gist options
  • Select an option

  • Save derekpappas/e01cd57be54beade7c484fe2d461a7e7 to your computer and use it in GitHub Desktop.

Select an option

Save derekpappas/e01cd57be54beade7c484fe2d461a7e7 to your computer and use it in GitHub Desktop.

Revisions

  1. derekpappas created this gist Dec 18, 2023.
    55 changes: 55 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,55 @@
    #!/usr/bin/python3

    import os
    from pathlib import Path

    def create_project_structure():
    # Define project structure
    project_structure = [
    'bin',
    'classes',
    'json',
    'jobs',
    'resources',
    'tests'
    # Add more directories as needed
    ]

    # Create directories
    for directory in project_structure:
    create_directory(directory)

    # Define boilerplate files
    boilerplate_files = {
    'README.md': '# Project Title',
    'main.py': '# Your main Python script',
    'tests/__init__.py': '',
    'requirements.txt': '',
    '.gitignore': '*.pyc\n__pycache__\n*.pyo\n*.pyd\n.env\n'
    # Add more files as needed
    }

    # Create boilerplate files
    for file, content in boilerplate_files.items():
    create_file(file, content)

    def create_directory(directory):
    # Check if the directory already exists
    if not os.path.exists(directory):
    os.makedirs(directory)
    print(f'Created directory: {directory}')
    else:
    print(f'Directory already exists: {directory}')

    def create_file(file, content):
    # Check if the file already exists
    file_path = Path(file)
    if not file_path.is_file():
    with open(file, 'w') as f:
    f.write(content)
    print(f'Created file: {file}')
    else:
    print(f'File already exists: {file}')

    if __name__ == "__main__":
    create_project_structure()