3
from shutil import copy2, copytree
8
if __name__ == "__main__":
10
Указываешь сначала сервис, потом имя модели Пример | blueprint.py purchase purchase_order
16
copytree('core/blueprint', path)
17
for root, dirs, files in os.walk(path):
18
print(root, dirs, files)
19
for filename in files:
20
replace_name = filename
21
if filename != '__init__.py':
23
new_filename = f'{model}_{filename}'
24
original_path = os.path.join(root, filename)
25
new_path = os.path.join(root, new_filename)
26
if not os.path.exists(new_path):
27
os.rename(original_path, new_path)
28
replace_name = new_filename
29
f = open(os.path.join(root, replace_name), 'r')
32
newdata = filedata.replace("new_service", app)
33
newdata = newdata.replace("blueprint", model)
34
newdata = newdata.replace("blueprint".capitalize(), model.capitalize())
35
f = open(os.path.join(root, replace_name), 'w')
38
os.rename(f'{path}/module', f'{path}/{model}')