-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.py
More file actions
37 lines (32 loc) · 965 Bytes
/
template.py
File metadata and controls
37 lines (32 loc) · 965 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import os
from pathlib import Path
import logging
logging.basicConfig(level=logging.INFO,format='[%(asctime)s]: %(message)s')
from pathlib import Path
import os
import logging
# List of files to create
list_of_files = [
"src/__init__.py",
"src/helper.py",
"src/prompt.py",
".env",
"setup.py",
"App.py",
"research/trials.iypnb",
"test.py"
]
# Iterate through the file paths
for filepath in list_of_files:
filepath = Path(filepath)
filedir = filepath.parent
filename = filepath.name
if filedir != "":
filedir.mkdir(parents=True, exist_ok=True)
logging.info(f"Creating directory: {filedir} for the file: {filename}")
# Check if the file exists or is empty
if not filepath.exists() or filepath.stat().st_size == 0:
filepath.touch() # Create an empty file
logging.info(f"Creating empty file: {filepath}")
else:
logging.info(f"{filename} already exists")