This repository has been archived by the owner on Mar 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfileManager.py
65 lines (50 loc) · 2.05 KB
/
fileManager.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
import glob
from grid import Grid
from clCalendar import CLCalendar
from fileIO import FileIO
class FileManager:
@classmethod
def getFileNames(self) -> list:
return FileIO.getFileNames()
@classmethod
def createFile(self, grid, fileName) -> None:
FileIO.writeDataTo(repr(grid), fileName)
@classmethod
def copyFile(self, copyName, selectedFileName) -> None:
#This method copies the content from the selectedFileName,
#then writes that data into a new cSheet with the argument
#passed into the fileName parameter for this method.
copiedData = FileIO.readDataFrom(selectedFileName)
FileIO.writeDataTo(copiedData, copyName)
@classmethod
def getFile(self, selectedFileName) -> Grid:
#This method returns raw cSheet data to be modified or logged.
return Grid.fromRepr(FileIO.readDataFrom(selectedFileName))
@classmethod
def setFile(self, updatedGrid, selectedFileName) -> None:
#This method is given raw cSheet data to modify or log a particular
#cSheet file.
FileIO.writeDataTo(repr(updatedGrid), selectedFileName)
@classmethod
def getFileDates(self) -> list:
#This method returns a list of File Dates that(if called directly after)
#getFileNames() will map to each filename.
return FileIO.getFileDates()
@classmethod
def deleteFile(self, selectedFileName) -> None:
FileIO.deleteFile(selectedFileName)
if __name__ == "__main__":
#Testing getFileNames method
fileNames = FileManager.getFileNames()
#Testing getFile method
gObj = FileManager.getFile(fileNames[0])
#Testing setFile method
FileManager.setFile(gObj, fileNames[0])
#Testing createFile method
FileManager.createFile(gObj, "test2")
#Testing copyFile method
fileNames = FileManager.getFileNames()
FileManager.copyFile("test2-copy", fileNames[1])
#Testing deleteFile method ~ deleting test2-copy.cSheet
fileNames = FileManager.getFileNames()
FileManager.deleteFile(fileNames[1])