4.0 Alpha (Build 20220)
This commit is contained in:
15
.vscode/launch.json
vendored
Normal file
15
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
// Use IntelliSense to learn about possible attributes.
|
||||||
|
// Hover to view descriptions of existing attributes.
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Python: Current File",
|
||||||
|
"type": "python",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${file}",
|
||||||
|
"console": "integratedTerminal"
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -84,4 +84,8 @@
|
|||||||
4.0 Alpha (Build 20219)
|
4.0 Alpha (Build 20219)
|
||||||
- Ukończenie karty "GENERATOR CSV" (poza przyciskiem "START")
|
- Ukończenie karty "GENERATOR CSV" (poza przyciskiem "START")
|
||||||
- Usunięcie instrukcji w karcie "FORMAT DANYCH" w celu późniejszego umieszczenia ich w pliku readme
|
- Usunięcie instrukcji w karcie "FORMAT DANYCH" w celu późniejszego umieszczenia ich w pliku readme
|
||||||
- Przekształcenie interfejsu na podstawie funkcji w interfejs na podstawie klasy
|
- Przekształcenie interfejsu na podstawie funkcji w interfejs na podstawie klasy
|
||||||
|
|
||||||
|
4.0 Alpha (Build 20220)
|
||||||
|
- Zastosowanie nowego systemu przetwarzania plików konfiguracyjnych dla pliku 'config.cfg' (tylko odczyt)
|
||||||
|
- Rozpoczęcie prac nad skryptem przetwarzającym dane
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
secret = entersecretstringhere
|
secret(S) = entersecretstringhere
|
||||||
allowedCharactersInSeparator = ['`', '~', '!', '@', '#', '$', '%', '^', '&', '(', ')', '-', '_', '=', '+', '[', ']', '\', '|', ';', ':', ''', '"', ',', '<', '.', '>', '/', '?', ' ']
|
allowedCharactersInSeparator(SCA) = ['`', '~', '!', '@', '#', '$', '%', '^', '&', '(', ')', '-', '_', '=', '+', '[', ']', '\', '|', ';', ':', ''', '"', ',', '<', '.', '>', '/', '?', ' ']
|
||||||
inputCoding = utf-8
|
inputCoding(S) = utf-8
|
||||||
outputCoding = utf-8
|
outputCoding(S) = utf-8
|
||||||
domain = losobolew.pl
|
domain(S) = losobolew.pl
|
||||||
quota = 500
|
quota(I) = 500
|
||||||
country = Rzeczypospolita Polska
|
country(S) = Rzeczypospolita Polska
|
||||||
yearsOfLO = 4
|
yearsOfLO(I) = 4
|
||||||
yearsOfBS = 3
|
yearsOfBS(I) = 3
|
||||||
schoolyearStart =
|
schoolyearStart(D) = 01.09.* *:*:*
|
||||||
242
generator.pyw
242
generator.pyw
@@ -61,7 +61,10 @@ MSGlist = {
|
|||||||
'E0006' : 'Niepoprawne dane w pliku formatu',
|
'E0006' : 'Niepoprawne dane w pliku formatu',
|
||||||
'A0001' : 'Czy chcesz zapisać? Zostanie utworzony nowy plik',
|
'A0001' : 'Czy chcesz zapisać? Zostanie utworzony nowy plik',
|
||||||
'A0002' : 'Czy chcesz zapisać? Plik zostanie nadpisany',
|
'A0002' : 'Czy chcesz zapisać? Plik zostanie nadpisany',
|
||||||
'A0003' : 'Czy chcesz rozpocząć przetwarzanie plików?'
|
'A0003' : 'Czy chcesz rozpocząć przetwarzanie plików?',
|
||||||
|
'E0007' : 'Wymagany przynajmniej jeden plik wejściowy',
|
||||||
|
'E0008' : 'Nie można odnaleźć jednego z powyższych plików',
|
||||||
|
'E0009' : 'Nie można odnaleźć jednego z powyższych format presetów',
|
||||||
}
|
}
|
||||||
|
|
||||||
def MSG(code, terminate, *optionalInfo):
|
def MSG(code, terminate, *optionalInfo):
|
||||||
@@ -104,7 +107,7 @@ def MSG(code, terminate, *optionalInfo):
|
|||||||
appdata = PT.Path.home() / 'Appdata/Roaming'
|
appdata = PT.Path.home() / 'Appdata/Roaming'
|
||||||
|
|
||||||
#TODO
|
#TODO
|
||||||
#SU.rmtree(str(appdata) + '/Generator CSV')
|
SU.rmtree(str(appdata) + '/Generator CSV')
|
||||||
#TODO
|
#TODO
|
||||||
if 'Generator CSV' not in [x for x in OS.listdir(appdata)]:
|
if 'Generator CSV' not in [x for x in OS.listdir(appdata)]:
|
||||||
try:
|
try:
|
||||||
@@ -122,7 +125,8 @@ if 'Generator CSV' not in [x for x in OS.listdir(appdata)]:
|
|||||||
# ----------------------------- # Ładowanie pliku konfiguracyjnego # ---------------------------- #
|
# ----------------------------- # Ładowanie pliku konfiguracyjnego # ---------------------------- #
|
||||||
|
|
||||||
class CFG:
|
class CFG:
|
||||||
def __checkInstance(self, write):
|
# Funkcje sprawdzające istnienie
|
||||||
|
def __checkIfConfigFileExist(self, write):
|
||||||
if write:
|
if write:
|
||||||
try:
|
try:
|
||||||
file = open((str(appdata) + '\Generator CSV\config.cfg'), 'a')
|
file = open((str(appdata) + '\Generator CSV\config.cfg'), 'a')
|
||||||
@@ -141,65 +145,117 @@ class CFG:
|
|||||||
except Exception as exceptInfo:
|
except Exception as exceptInfo:
|
||||||
MSG('E0002', True, exceptInfo)
|
MSG('E0002', True, exceptInfo)
|
||||||
|
|
||||||
def __checkContent(self, write, content):
|
def __checkIfRecordExist(self, content, record):
|
||||||
if write:
|
if record in list(content.keys()):
|
||||||
return [True, content]
|
return [True]
|
||||||
else:
|
else:
|
||||||
class functions:
|
return [False, 'Brak danych - klucz: %s' % record]
|
||||||
def string(self, var):
|
|
||||||
if var in list(content.keys()):
|
|
||||||
return [True]
|
|
||||||
else:
|
|
||||||
return [False, 'Brak danych - klucz: %s' % var]
|
|
||||||
def array(self, var):
|
|
||||||
if var in list(content.keys()):
|
|
||||||
new_contentVar = (content[var])[1:-1].split(', ')
|
|
||||||
xnew_contentVar = []
|
|
||||||
for x in new_contentVar:
|
|
||||||
xnew_contentVar.append(x[1:-1])
|
|
||||||
content[var] = xnew_contentVar
|
|
||||||
else:
|
|
||||||
return [False, 'Brak danych - klucz: %s' % var]
|
|
||||||
functions = functions()
|
|
||||||
functions.string('secret')
|
|
||||||
functions.array('allowedCharactersInSeparator')
|
|
||||||
return [True, content]
|
|
||||||
|
|
||||||
def R(self):
|
# Funkcje sprawdzające poprawność recordu
|
||||||
self.__checkInstance(False)
|
def __checkSCA(self, write, record, var):
|
||||||
|
if write:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
var = var[1:-2].split(', ')
|
||||||
|
var = [x[1:-1] for x in var]
|
||||||
|
except:
|
||||||
|
return (False, 'Niepoprawne dane - klucz: %s' % record)
|
||||||
|
for x in var:
|
||||||
|
if len(x) != 1:
|
||||||
|
return (False, 'Niepoprawne dane - klucz: %s' % record)
|
||||||
|
return [True, var]
|
||||||
|
|
||||||
|
def __checkI(self, write, record, var):
|
||||||
|
if write:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
var = int(var)
|
||||||
|
except:
|
||||||
|
return (False, 'Niepoprawne dane - klucz: %s' % record)
|
||||||
|
return [True, var]
|
||||||
|
|
||||||
|
def __checkD(self, write, record, var):
|
||||||
|
if write:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
varToReturn = {}
|
||||||
|
var = var.split(' ')
|
||||||
|
try:
|
||||||
|
var[0] = var[0].split('.')
|
||||||
|
var[1] = var[1].split(':')
|
||||||
|
var = var[0] + var[1]
|
||||||
|
dateLabels = ['D', 'M', 'Y', 'h', 'm', 's']
|
||||||
|
if len(var) != len(dateLabels):
|
||||||
|
return (False, 'Niepoprawne dane - klucz: %s' % record)
|
||||||
|
index = 0
|
||||||
|
for x in var:
|
||||||
|
if x != '*':
|
||||||
|
varToReturn[dateLabels[index]] = int(x)
|
||||||
|
else:
|
||||||
|
varToReturn[dateLabels[index]] = None
|
||||||
|
index += 1
|
||||||
|
except:
|
||||||
|
return (False, 'Niepoprawne dane - klucz: %s' % record)
|
||||||
|
var = varToReturn
|
||||||
|
return [True, var]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def R(self, record):
|
||||||
|
self.__checkIfConfigFileExist(False)
|
||||||
content = {}
|
content = {}
|
||||||
for x in CD.open((str(appdata) + '\Generator CSV\config.cfg'), 'r', 'utf-8').read().split('\n'):
|
for x in CD.open((str(appdata) + '\Generator CSV\config.cfg'), 'r', 'utf-8').read().split('\n'):
|
||||||
x = x.split(' = ')
|
x = x.split(' = ')
|
||||||
try:
|
try:
|
||||||
content[x[0]] = (x[1]).strip('\r')
|
name = x[0].split('(')[0]
|
||||||
|
var = x[1]
|
||||||
|
type = x[0].split('(')[1].strip(')')
|
||||||
|
content[name] = [var, type]
|
||||||
except:
|
except:
|
||||||
continue
|
continue
|
||||||
contentCheckingOutput = self.__checkContent(False, content)
|
checkingOutput = self.__checkIfRecordExist(content, record)
|
||||||
if contentCheckingOutput[0]:
|
if not checkingOutput[0]:
|
||||||
return contentCheckingOutput[1]
|
MSG('E0003', True, checkingOutput[1])
|
||||||
else:
|
var = content[record]
|
||||||
MSG('E0003', True, contentCheckingOutput[1])
|
if var[1] == 'S':
|
||||||
|
# String
|
||||||
def W(self, changes):
|
var = var[0]
|
||||||
content = self.R()
|
return var
|
||||||
for x in changes:
|
elif var[1] == 'SCA':
|
||||||
content[x] = changes[x]
|
# Single char array
|
||||||
contentCheckingOutput = self.__checkContent(True, content)
|
checkingOutput = self.__checkSCA(False, record, var[0])
|
||||||
if contentCheckingOutput[0]:
|
if checkingOutput[0]:
|
||||||
if self.__checkInstance(True):
|
return checkingOutput[1]
|
||||||
with CD.open((str(appdata) + '\Generator CSV\config.cfg'), 'w', 'utf-8') as file:
|
|
||||||
contentToSave = contentCheckingOutput[1]
|
|
||||||
for x in contentToSave:
|
|
||||||
file.write('%s = %s\n' % (x, str(contentToSave[x])))
|
|
||||||
else:
|
else:
|
||||||
return False
|
MSG('E0003', True, checkingOutput[1])
|
||||||
|
elif var[1] == 'I':
|
||||||
|
# Integer
|
||||||
|
checkingOutput = self.__checkI(False, record, var[0])
|
||||||
|
if checkingOutput[0]:
|
||||||
|
return checkingOutput[1]
|
||||||
|
else:
|
||||||
|
MSG('E0003', True, checkingOutput[1])
|
||||||
|
elif var[1] == 'D':
|
||||||
|
# Date (DD.MM.RRRR HH:MM:SS)
|
||||||
|
checkingOutput = self.__checkD(False, record, var[0])
|
||||||
|
if checkingOutput[0]:
|
||||||
|
return checkingOutput[1]
|
||||||
|
else:
|
||||||
|
MSG('E0003', True, checkingOutput[1])
|
||||||
else:
|
else:
|
||||||
MSG('E0004', False, contentCheckingOutput[1])
|
MSG('E0003', True, 'Nie można rozpoznać typu klucza %s' % record)
|
||||||
|
|
||||||
|
def W(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
CFG = CFG()
|
CFG = CFG()
|
||||||
checkInstance = CFG.R()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
print(CFG.R('allowedCharactersInSeparator'))
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------- # Ładowanie pliku stylu # ---------------------------------- #
|
# ---------------------------------- # Ładowanie pliku stylu # ---------------------------------- #
|
||||||
@@ -691,7 +747,7 @@ class FMT:
|
|||||||
return [False, 'Brak danych - klucz: %s' % var]
|
return [False, 'Brak danych - klucz: %s' % var]
|
||||||
def separator_string(self, var):
|
def separator_string(self, var):
|
||||||
if var in list(content.keys()):
|
if var in list(content.keys()):
|
||||||
allowedCharactersInSeparator = CFG.R()['allowedCharactersInSeparator']
|
allowedCharactersInSeparator = CFG.R('allowedCharactersInSeparator')
|
||||||
check = content[var]
|
check = content[var]
|
||||||
check = check.strip('<enter>')
|
check = check.strip('<enter>')
|
||||||
for x in check:
|
for x in check:
|
||||||
@@ -702,7 +758,7 @@ class FMT:
|
|||||||
return [False, 'Brak danych - klucz: %s' % var]
|
return [False, 'Brak danych - klucz: %s' % var]
|
||||||
def separator_array(self, var):
|
def separator_array(self, var):
|
||||||
if var in list(content.keys()):
|
if var in list(content.keys()):
|
||||||
allowedCharactersInSeparator = CFG.R()['allowedCharactersInSeparator']
|
allowedCharactersInSeparator = CFG.R('allowedCharactersInSeparator')
|
||||||
new_contentVar = (content[var])[2:-2].split("', '")
|
new_contentVar = (content[var])[2:-2].split("', '")
|
||||||
check = new_contentVar
|
check = new_contentVar
|
||||||
for x in check:
|
for x in check:
|
||||||
@@ -836,8 +892,80 @@ FMT = FMT()
|
|||||||
# ---------------------------------- # Przetwarzanie plików # ----------------------------------- #
|
# ---------------------------------- # Przetwarzanie plików # ----------------------------------- #
|
||||||
|
|
||||||
class dataProcess:
|
class dataProcess:
|
||||||
|
# Funkcje sprawdzające
|
||||||
|
def __checkIfAtLeastOneInputFileIsFilled(files):
|
||||||
|
filledFiles = []
|
||||||
|
index = 0
|
||||||
|
for x in files:
|
||||||
|
if not (x[0] == '' or x[1] == ''):
|
||||||
|
filledFiles.append(index)
|
||||||
|
index += 1
|
||||||
|
if len(filledFiles) != 0:
|
||||||
|
return (True, filledFiles)
|
||||||
|
else:
|
||||||
|
return (False)
|
||||||
|
|
||||||
|
def __checkIfInputFilesIsReadable(self, files, filledFiles):
|
||||||
|
for x in filledFiles:
|
||||||
|
try:
|
||||||
|
check = CD.open((files[x])[0], 'r', CFG.R('inputCoding'))
|
||||||
|
except:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
def __checkIfInputFilesFormatPresetsExist(self, files, filledFiles):
|
||||||
|
for x in filledFiles:
|
||||||
|
if (files[x])[1] not in FMT.getList():
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
def __checkIfCreateOutputFilesIsPossible(self, files):
|
||||||
|
for x in files:
|
||||||
|
try:
|
||||||
|
check = CD.open(x, 'w', CFG.R('outputCoding'))
|
||||||
|
except:
|
||||||
|
return False
|
||||||
|
return true
|
||||||
|
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def start(self, files):
|
def start(self, files):
|
||||||
pass
|
checkingOutput = []
|
||||||
|
|
||||||
|
testOutput = self.__checkIfAtLeastOneInputFileIsFilled(files[:-1])
|
||||||
|
checkingOutput.append(testOutput[0])
|
||||||
|
if not testOutput[0]:
|
||||||
|
return checkingOutput
|
||||||
|
filledFiles = testOutput[1]
|
||||||
|
|
||||||
|
testOutput = self.__checkIfInputFilesIsReadable(files[:-1], filledFiles)
|
||||||
|
checkingOutput.append(testOutput)
|
||||||
|
if not testOutput:
|
||||||
|
return checkingOutput
|
||||||
|
|
||||||
|
testOutput = self.__checkIfInputFilesFormatPresetsExist(files[:-1], filledFiles)
|
||||||
|
checkingOutput.append(testOutput)
|
||||||
|
if not testOutput:
|
||||||
|
return checkingOutput
|
||||||
|
|
||||||
|
testOutput = self.__checkIfInputFilesFormatPresetsExist(files[-1])
|
||||||
|
checkingOutput.append(testOutput)
|
||||||
|
if not testOutput:
|
||||||
|
return checkingOutput
|
||||||
|
|
||||||
|
input = []
|
||||||
|
for x in filledFiles:
|
||||||
|
input.append(files[x])
|
||||||
|
output = files[-1]
|
||||||
|
|
||||||
|
testOutput = self.__checkIfCreateOutputFilesIsPossible(files[-1])
|
||||||
|
checkingOutput.append(testOutput)
|
||||||
|
if not testOutput:
|
||||||
|
return checkingOutput
|
||||||
|
|
||||||
|
|
||||||
dataProcess = dataProcess()
|
dataProcess = dataProcess()
|
||||||
|
|
||||||
|
|
||||||
@@ -1916,7 +2044,15 @@ class mainWindow:
|
|||||||
filesList = (GIF1, GIF2, GIF3, GIF4, GOF)
|
filesList = (GIF1, GIF2, GIF3, GIF4, GOF)
|
||||||
output = dataProcess.start(filesList)
|
output = dataProcess.start(filesList)
|
||||||
if not output[0]:
|
if not output[0]:
|
||||||
print('x')
|
MSG('E0007', False)
|
||||||
|
else:
|
||||||
|
if not output[1]:
|
||||||
|
MSG('E0008', False)
|
||||||
|
else:
|
||||||
|
if not output[2]:
|
||||||
|
MSG('E0009', False)
|
||||||
|
else:
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user