-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
65 lines (58 loc) · 3.06 KB
/
Copy pathtest.py
File metadata and controls
65 lines (58 loc) · 3.06 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import os
import shutil
# dict for creating files
files = {
'info.txt': {'path': ['root_folder'],
'content': 'd2c2ee4cbb368731f1a5399015160d7d_23'},
'lost.json': {'path': ['root_folder'],
'content': '3a70ac2ebacf4174aa11dfbd1af835bd'},
'phones.csv': {'path': ['root_folder'],
'content': '671ab9fbf94dc377568fb7b2928960c9'},
'python.txt': {'path': ['root_folder'],
'content': 'd2c2ee4cbb368731f1a5399015160d7d_1'},
'bikeshare.csv': {'path': ['root_folder', 'calc'],
'content': '671ab9fbf94dc377568fb7b2928960c9'},
'server.php': {'path': ['root_folder', 'calc'],
'content': 'a5c662fe853b7ab48d68532791a86367'},
'db_cities.js': {'path': ['root_folder', 'files'],
'content': 'f2e5cf58ae9b2d2fd0ae9bf8fa1774da'},
'some_text.txt': {'path': ['root_folder', 'files'],
'content': 'd2c2ee4cbb368731f1a5399015160d7d_23'},
'cars.json': {'path': ['root_folder', 'files', 'stage'],
'content': '3a70ac2ebacf4174aa11dfbd1af835bd'},
'package-lock.json': {'path': ['root_folder', 'files', 'stage'],
'content': 'eebf1c62a13284ea1bcfe53820e83f11'},
'index.js': {'path': ['root_folder', 'files', 'stage', 'src'],
'content': '797ac79aa6a3c2ef733fecbaff5a655f'},
'libs.txt': {'path': ['root_folder', 'files', 'stage', 'src'],
'content': '4909fd0404ac7ebe1fb0c50447975a2a'},
'reviewSlider.js': {'path': ['root_folder', 'files', 'stage', 'src'],
'content': 'abc96a9b62c4701f27cf7c8dbd484fdc'},
'spoiler.js': {'path': ['root_folder', 'files', 'stage', 'src'],
'content': 'b614ccac263d3d78b60b37bf35e860f3'},
'src.txt': {'path': ['root_folder', 'files', 'stage', 'src'],
'content': 'eed110d0dbd1d89d1ffea807d1d88679_1'},
'toggleMiniMenu.js': {'path': ['root_folder', 'files', 'stage', 'src'],
'content': '7eceb7dd5a0daaccc32739e1dcc6c3b0_1'},
'extraversion.csv': {'path': ['root_folder', 'project'],
'content': 'fc88cf4d79437fa06e6cfdd80bd0eed2_1'},
'index.html': {'path': ['root_folder', 'project'],
'content': '3f0f7b61205b863d2051845037541835_1'},
'python_copy.txt': {'path': ['root_folder', 'project'],
'content': 'd2c2ee4cbb368731f1a5399015160d7d_1'}
}
root_dir_path = os.path.join('module', 'root_folder')
def create_files(path):
# delete root_folder
if os.path.isdir(path):
shutil.rmtree(path)
# create files
for key, dict_val in files.items():
path = os.path.join('module', *dict_val['path'])
if not os.path.isdir(path):
os.makedirs(path)
file_path = os.path.join(path, key)
with open(file_path, 'a+') as f:
f.write(dict_val['content'])
path = r"C:\Users\rahul\PycharmProjects\DuplicateFileHandlersProject1of1\root_folder"
create_files(path)