split-secret/scripts/classes/Paths.py

43 lines
1.6 KiB
Python
Raw Permalink Normal View History

2022-12-10 21:48:24 +01:00
import os
2022-12-09 13:22:57 +01:00
2022-12-10 22:19:57 +01:00
class Paths():
2022-12-10 12:21:43 +01:00
2022-12-10 13:22:09 +01:00
TYPE_ENCRYPTED="encrypted"
2022-12-10 21:48:24 +01:00
TYPE_DECRYPTED="decrypted"
ROOT_PATH= os.path.join(os.path.dirname(os.path.abspath(__file__)),"../","../")
2022-12-10 13:22:09 +01:00
def __init__(self):
2022-12-10 21:48:24 +01:00
self.data_folder = os.path.join(self.ROOT_PATH,"data") + '/'
2022-12-09 20:10:12 +01:00
def getDataFolderPath(self,folder_type):
2022-12-09 20:10:12 +01:00
return self.data_folder + folder_type + "/"
def getGroupFilesFolderPath(self,folder_type):
return self.getDataFolderPath(folder_type) + "group_files/"
2022-12-09 20:10:12 +01:00
def getUserFilesPath(self,folder_type):
return self.getDataFolderPath(folder_type) + "user_files/"
def getEncryptedMainDataFile(self):
2022-12-10 22:19:57 +01:00
return self.getDataFolderPath(Paths.TYPE_ENCRYPTED) + "main_data.tar.gz.gpg"
def getDecryptedMainDataStandartFolder(self):
2022-12-10 22:19:57 +01:00
return self.getDataFolderPath(Paths.TYPE_DECRYPTED) + "main_data/"
2022-12-09 20:10:12 +01:00
def getFileExtension(self,file_type):
2022-12-10 22:19:57 +01:00
if file_type == Paths.TYPE_ENCRYPTED:
2022-12-09 20:39:00 +01:00
return '.gpg'
return ''
def getUserFileSuffix(self,file_type):
return '.json' + self.getFileExtension(file_type)
2022-12-09 20:10:12 +01:00
def getUserFilePath(self,user_id,file_type):
return self.getUserFilesPath(file_type) + user_id + self.getUserFileSuffix(file_type);
2022-12-09 20:10:12 +01:00
def getGroupFilePath(self,group_id,file_type):
return self.getGroupFilesFolderPath(file_type) + str(group_id) + '.txt' + self.getFileExtension(file_type);
def getAccumulatedFilePath(self,file_type):
return self.getDataFolderPath(file_type) + 'accumulated.json' + self.getFileExtension(file_type);