-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_config.py
68 lines (46 loc) · 1.85 KB
/
create_config.py
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
66
67
import json
from local_directory import SourceFolder, SelectedLocalFiles
from drive_directory import TargetFolder
from authentication import drive_service
def set_up():
# Source
# local folder
source_object = SourceFolder()
# list files in the local folder
listed_objects = source_object.list_files()
# set path of the local folder
source_folder = source_object.select_path()
# instances of files in the local folder
folder_content = SelectedLocalFiles(listed_objects)
folder_content.display_files()
# selected files with given option
selected_option = folder_content.select_choice()
selected_files = folder_content.select_files(selected_option)
# Target
print("\n")
print("-----Select destination-----")
target = TargetFolder()
# listing folders in MyDrive
drive_folders = target.list_drive_folders(drive_service)
# selecting a folder as destination
target_folder = target.choose_target(drive_folders)
# Drive folder name
target_folder_name = target_folder["name"]
# Drive folder ID
target_folder_drive_id = target_folder["id"]
# Config file
if selected_option == "F":
data = {"source_folder": source_folder,
"target_folder_name": target_folder_name,
"target_folder_drive_id": target_folder_drive_id,
"selected_option": selected_option}
if selected_option == "S":
data = {"source_folder": source_folder,
"target_folder_name": target_folder_name,
"target_folder_drive_id": target_folder_drive_id,
"selected_option": selected_option,
"selected_files": selected_files}
with open("config.json", "w", encoding="utf-8") as config_file:
json.dump(data, config_file, ensure_ascii=False)
if __name__ == "__main__":
set_up()