|
import time |
|
import os |
|
import datetime |
|
import uuid |
|
import json |
|
|
|
|
|
def writeJson(file_name,data_dict): |
|
with open(file_name, 'w', encoding='utf-8') as outfile: |
|
json.dump(data_dict, outfile, ensure_ascii=False, indent=4) |
|
|
|
|
|
|
|
|
|
|
|
def readJson(file_name): |
|
data_dict = {} |
|
try: |
|
with open(file_name) as f_obj: |
|
data_dict = json.load(f_obj) |
|
|
|
print("readJson: data_dict: ", data_dict) |
|
except IOError: |
|
print(f"{file_name} is not found") |
|
return data_dict |
|
|
|
def createFolder(fullpath): |
|
print("fullpath:",fullpath) |
|
|
|
if not os.path.exists(fullpath): |
|
os.mkdir(fullpath) |
|
|
|
def makeDirPathName(): |
|
|
|
currentDirPath = os.getcwd() |
|
now = datetime.datetime.now() |
|
daily_folder = now.strftime("%Y-%m-%d") |
|
output_path = os.path.join(currentDirPath,"output") |
|
fullpath = os.path.join(output_path,daily_folder) |
|
|
|
return fullpath,daily_folder |
|
|
|
|
|
def getUniqueDocumentDirPathName(uniqueDocumentId): |
|
|
|
currentDirPath = os.getcwd() |
|
output_path = os.path.join(currentDirPath,"output") |
|
fullpath = os.path.join(output_path,uniqueDocumentId) |
|
|
|
return fullpath,uniqueDocumentId |
|
|
|
def makeUniqueID(): |
|
myuuid = uuid.uuid4() |
|
print('Your UUID is: ' + str(myuuid)) |
|
return myuuid |
|
|
|
|
|
if __name__ == "__main__": |
|
|
|
|
|
|
|
|
|
id = makeUniqueID() |
|
print("id: ",id) |