-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfiles.py
36 lines (27 loc) · 819 Bytes
/
files.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
def file_exists(path):
from os.path import exists
file_exists = exists(path)
return file_exists
def load_json(path):
if not file_exists(path):
import sys
sys.exit('File path not found: ' + path)
import json
file = open(path)
data = json.load(file)
file.close()
return data
def update_key_value(path, key, value):
if not file_exists(path):
import sys
sys.exit('File path not found: ' + path)
import os, dotenv
dotenv.load_dotenv(path)
os.environ[key] = value
dotenv.set_key(path, key, os.environ[key])
def copy_file(sourcePath, targetPath, ):
if not file_exists(sourcePath):
import sys
sys.exit('File path not found: ' + sourcePath)
import os
os.system('cp -R ' + sourcePath + ' ' + targetPath)