Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions T7_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import os

project_list = ['settings', 'mainapp', 'adminapp', 'authapp']
for name in project_list:
dir_path = os.path.join('my_project', name)
if not os.path.exists(dir_path):
os.makedirs(dir_path)
else:
print(f'Папка с именем {name} уже существует')
13 changes: 13 additions & 0 deletions T7_3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from os import path, walk, listdir
import shutil

project_name = 'my_project'

try:
for root, dirs, files in walk(project_name):
print(root, dirs, files)
if 'templates' in dirs and root != project_name:
for el in listdir(path.join(root, 'templates')):
shutil.copytree(path.join(root, 'templates', el), path.join(project_name, 'templates', el))
except FileExistsError:
print('Шаболоны уже собраны в папку Templates')
24 changes: 24 additions & 0 deletions T7_4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import os
from collections import defaultdict

import django

root_dir = django.__path__[0]
django_files = defaultdict(int)
size_list_new = []
for root, dirs, files in os.walk(root_dir):
for file in files:
if os.stat(os.path.join(root, file)).st_size < 100:
size_list_new.append('100')
elif 100 <= os.stat(os.path.join(root, file)).st_size < 1000:
size_list_new.append('1000')
elif 1000 <= os.stat(os.path.join(root, file)).st_size < 10000:
size_list_new.append('10000')
else:
size_list_new.append('100000')

for el in size_list_new:
django_files[el] += 1

for key, value in sorted(django_files.items()):
print(f'{key}: {value}')