4.0 Alpha (Build 19353)
This commit is contained in:
@@ -40,82 +40,142 @@ except ModuleNotFoundError:
|
||||
# --------------------------------------------------- # Funkcje # ---------------------------------------------------- #
|
||||
|
||||
# Wewnętrzna funkcja sprawdzająca błędy pliku formatu
|
||||
def CheckFormat(format):
|
||||
uczniowiefmt = ''
|
||||
for x in format[0]:
|
||||
uczniowiefmt += x
|
||||
def CheckFormat(Read, format):
|
||||
poprawne = True
|
||||
check = True
|
||||
while check:
|
||||
uczniowiefmt = ''
|
||||
for x in format[0]:
|
||||
uczniowiefmt += x
|
||||
|
||||
try:
|
||||
if format[0].count('') > 0:
|
||||
error = int('x')
|
||||
except ValueError:
|
||||
MDdlg.err(11)
|
||||
|
||||
try:
|
||||
if uczniowiefmt.count('K') != 1:
|
||||
error = int('x')
|
||||
except ValueError:
|
||||
MDdlg.err(6)
|
||||
|
||||
try:
|
||||
if uczniowiefmt.count('O') != 1:
|
||||
error = int('x')
|
||||
except ValueError:
|
||||
MDdlg.err(7)
|
||||
|
||||
try:
|
||||
if uczniowiefmt.count('N') != 1:
|
||||
error = int('x')
|
||||
except ValueError:
|
||||
MDdlg.err(8)
|
||||
|
||||
try:
|
||||
if uczniowiefmt.count('I') != 1:
|
||||
error = int('x')
|
||||
except ValueError:
|
||||
MDdlg.err(9)
|
||||
|
||||
try:
|
||||
if uczniowiefmt.count('L') != 1:
|
||||
error = int('x')
|
||||
except ValueError:
|
||||
MDdlg.err(10)
|
||||
|
||||
try:
|
||||
if format[1].count('') > 0:
|
||||
error = int('x')
|
||||
except ValueError:
|
||||
MDdlg.err(12)
|
||||
|
||||
nauczycielefmt = ''
|
||||
for x in format[1]:
|
||||
nauczycielefmt += x
|
||||
|
||||
try:
|
||||
if nauczycielefmt.count('N') != 1:
|
||||
error = int('x')
|
||||
except ValueError:
|
||||
MDdlg.err(13)
|
||||
|
||||
try:
|
||||
if nauczycielefmt.count('I') != 1:
|
||||
error = int('x')
|
||||
except ValueError:
|
||||
MDdlg.err(14)
|
||||
|
||||
try:
|
||||
if nauczycielefmt.count('L') != 1:
|
||||
error = int('x')
|
||||
except ValueError:
|
||||
MDdlg.err(15)
|
||||
|
||||
NiedozwoloneZnaki = ['1','2','3','4','5','6','7','8','9','0','W','E','R','T','Y','U','P','A','S','D','F','G','H','J','Z','C','V','B','M']
|
||||
try:
|
||||
for x in NiedozwoloneZnaki:
|
||||
if x in nauczycielefmt+uczniowiefmt:
|
||||
try:
|
||||
if format[0].count('') > 0:
|
||||
error = int('x')
|
||||
except ValueError:
|
||||
MDdlg.err(16)
|
||||
except ValueError:
|
||||
MDdlg.err(11)
|
||||
if Read:
|
||||
SS.exit(0)
|
||||
else:
|
||||
poprawne = False
|
||||
break
|
||||
|
||||
try:
|
||||
if uczniowiefmt.count('K') != 1:
|
||||
error = int('x')
|
||||
except ValueError:
|
||||
MDdlg.err(6)
|
||||
if Read:
|
||||
SS.exit(0)
|
||||
else:
|
||||
poprawne = False
|
||||
break
|
||||
|
||||
try:
|
||||
if uczniowiefmt.count('O') != 1:
|
||||
error = int('x')
|
||||
except ValueError:
|
||||
MDdlg.err(7)
|
||||
if Read:
|
||||
SS.exit(0)
|
||||
else:
|
||||
poprawne = False
|
||||
break
|
||||
|
||||
try:
|
||||
if uczniowiefmt.count('N') != 1:
|
||||
error = int('x')
|
||||
except ValueError:
|
||||
MDdlg.err(8)
|
||||
if Read:
|
||||
SS.exit(0)
|
||||
else:
|
||||
poprawne = False
|
||||
break
|
||||
|
||||
try:
|
||||
if uczniowiefmt.count('I') != 1:
|
||||
error = int('x')
|
||||
except ValueError:
|
||||
MDdlg.err(9)
|
||||
if Read:
|
||||
SS.exit(0)
|
||||
else:
|
||||
poprawne = False
|
||||
break
|
||||
|
||||
try:
|
||||
if uczniowiefmt.count('L') != 1:
|
||||
error = int('x')
|
||||
except ValueError:
|
||||
MDdlg.err(10)
|
||||
if Read:
|
||||
SS.exit(0)
|
||||
else:
|
||||
poprawne = False
|
||||
break
|
||||
|
||||
try:
|
||||
if format[1].count('') > 0:
|
||||
error = int('x')
|
||||
except ValueError:
|
||||
MDdlg.err(12)
|
||||
if Read:
|
||||
SS.exit(0)
|
||||
else:
|
||||
poprawne = False
|
||||
break
|
||||
|
||||
nauczycielefmt = ''
|
||||
for x in format[1]:
|
||||
nauczycielefmt += x
|
||||
|
||||
try:
|
||||
if nauczycielefmt.count('N') != 1:
|
||||
error = int('x')
|
||||
except ValueError:
|
||||
MDdlg.err(13)
|
||||
if Read:
|
||||
SS.exit(0)
|
||||
else:
|
||||
poprawne = False
|
||||
break
|
||||
|
||||
try:
|
||||
if nauczycielefmt.count('I') != 1:
|
||||
error = int('x')
|
||||
except ValueError:
|
||||
MDdlg.err(14)
|
||||
if Read:
|
||||
SS.exit(0)
|
||||
else:
|
||||
poprawne = False
|
||||
break
|
||||
|
||||
try:
|
||||
if nauczycielefmt.count('L') != 1:
|
||||
error = int('x')
|
||||
except ValueError:
|
||||
MDdlg.err(15)
|
||||
if Read:
|
||||
SS.exit(0)
|
||||
else:
|
||||
poprawne = False
|
||||
break
|
||||
|
||||
NiedozwoloneZnaki = ['1','2','3','4','5','6','7','8','9','0','W','E','R','T','Y','U','P','A','S','D','F','G','H','J','Z','C','V','B','M']
|
||||
try:
|
||||
for x in NiedozwoloneZnaki:
|
||||
if x in nauczycielefmt+uczniowiefmt:
|
||||
error = int('x')
|
||||
except ValueError:
|
||||
MDdlg.err(16)
|
||||
if Read:
|
||||
SS.exit(0)
|
||||
else:
|
||||
poprawne = False
|
||||
break
|
||||
check = False
|
||||
return poprawne
|
||||
|
||||
|
||||
|
||||
@@ -131,22 +191,28 @@ def read():
|
||||
format = []
|
||||
for x in fmt:
|
||||
format.append(x.split('\n'))
|
||||
CheckFormat(format)
|
||||
CheckFormat(True, format)
|
||||
return format
|
||||
|
||||
|
||||
|
||||
# Zapis ustawień do pliku formatu
|
||||
def edit(format):
|
||||
CheckFormat(format)
|
||||
try:
|
||||
check = open(r'.\format.fmt')
|
||||
except FileNotFoundError:
|
||||
MDdlg.err(5)
|
||||
xformat = []
|
||||
for x in format:
|
||||
xformat.append(x.split('\n')[:-1])
|
||||
if CheckFormat(False, xformat):
|
||||
try:
|
||||
check = open(r'.\format.fmt')
|
||||
except FileNotFoundError:
|
||||
MDdlg.err(5)
|
||||
else:
|
||||
FormatToSaveX = []
|
||||
for x in xformat:
|
||||
FormatToSaveX.append('\n'.join(x))
|
||||
FormatToSave = FormatToSaveX[0] + '\n<separator>\n' + FormatToSaveX[1]
|
||||
with open(r'.\format.fmt', 'w') as fmt:
|
||||
fmt.write(FormatToSave)
|
||||
return True
|
||||
else:
|
||||
FormatToSaveX = []
|
||||
for x in format:
|
||||
FormatToSaveX.append('\n'.join(x))
|
||||
FormatToSave = FormatToSaveX[0] + '\n<separator>\n' + FormatToSaveX[1]
|
||||
with open(r'.\format.fmt', 'w') as fmt:
|
||||
fmt.write(FormatToSave)
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user