Create template.py
Browse files- template.py +38 -0
template.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
import logging
|
| 4 |
+
|
| 5 |
+
logging.basicConfig(level=logging.INFO, format='[%(asctime)s]: %(message)s:')
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
list_of_files = [
|
| 9 |
+
"src/__init__.py",
|
| 10 |
+
"src/helper.py",
|
| 11 |
+
"src/prompt.py",
|
| 12 |
+
".env",
|
| 13 |
+
"setup.py",
|
| 14 |
+
"research/trials.ipynb",
|
| 15 |
+
"app.py",
|
| 16 |
+
"store_index.py",
|
| 17 |
+
"static/.gitkeep",
|
| 18 |
+
"templates/chat.html"
|
| 19 |
+
|
| 20 |
+
]
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
for filepath in list_of_files:
|
| 24 |
+
filepath = Path(filepath)
|
| 25 |
+
filedir, filename = os.path.split(filepath)
|
| 26 |
+
|
| 27 |
+
if filedir !="":
|
| 28 |
+
os.makedirs(filedir, exist_ok=True)
|
| 29 |
+
logging.info(f"Creating directory; {filedir} for the file {filename}")
|
| 30 |
+
|
| 31 |
+
if (not os.path.exists(filepath)) or (os.path.getsize(filepath) == 0):
|
| 32 |
+
with open(filepath, 'w') as f:
|
| 33 |
+
pass
|
| 34 |
+
logging.info(f"Creating empty file: {filepath}")
|
| 35 |
+
|
| 36 |
+
else:
|
| 37 |
+
logging.info(f"{filename} is already created")
|
| 38 |
+
|