-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUtils.py
104 lines (71 loc) · 3.07 KB
/
Utils.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import sys
import os
from numpy import choose
applicationPath = os.environ['APPLICATION_PATH']
class Contract():
"To be moved to a utils folder for other apps"
def __init__(self):
Contract.filePath = "Has Not Been Updated"
Contract.clear = lambda: os.system('cls')
def ChooseFile(self, filePath, selectionType):
directoryNames = []
choices = ""
for (dirpath, dirnames, filenames) in os.walk(filePath):
directoryNames.extend(filenames)
for index in range(len(directoryNames)):
choices += (str(index)+" - "+directoryNames[index]+"\n")
choices += (str(len(directoryNames))+" - New "+ selectionType + " \n")
print(choices)
print(len(directoryNames))
choiceSelection = int(input("Selection: "))
if choiceSelection == len(directoryNames):
print("Making new "+selectionType)
else:
Contract.filePath = directoryNames[choiceSelection]
print(Contract.filePath)
def SelectContract(self):
filePath = "\\Contracts Folder"
memory = open(applicationPath+"\Data\contractMemory.txt", "r")
#Recent Payment Choices
selectionMemory = memory.read()
selectionMemory = selectionMemory.split("\n")
if len(selectionMemory) > 3:
selectionMemory.pop()
choices = ""
for index in range(len(selectionMemory)):
choices += (str(index)+" - "+selectionMemory[index].rsplit('/', 1)[-1]+"\n")
choices += str(len(selectionMemory))+" - Other"
print("Recently Selected Contracts")
print(choices)
selection = int(input("Selection: "))
Contract.clear()
#All contracts choices
if selection == 3:
for i in range(2):
if i == 2:
selectionMemory.insert(0,filePath)
with open(applicationPath+"\Data\contractMemory.txt", "w") as file:
file_lines = "\n".join(selectionMemory)
file.write(file_lines)
directoryNames = []
for (dirpath, dirnames, filenames) in os.walk(filePath):
directoryNames.extend(dirnames)
break
if i == 0:
filteredDirectoryNames = [k for k in directoryNames if 'Contracts' in k]
directoryNames = filteredDirectoryNames
choices = ""
for index in range(len(directoryNames)):
choices += (str(index)+" - "+directoryNames[index]+"\n")
print(choices)
companySelection = int(input("Selection: "))
try:
filePath = filePath+"/"+directoryNames[companySelection]
except:
x=1
else:
filePath = selectionMemory[selection]
print(filePath)
Contract.filePath = filePath
if __name__ == '__main__':
sys.exit()