Removed UPX for faster loading. Fixed non existing region value interpretation. Fixed crash on Windows lock. Fixed race condition on number interpretation.
This commit is contained in:
parent
dfd7dfa5f0
commit
2af98808e0
Binary file not shown.
@ -1,5 +1,5 @@
|
||||
@echo off
|
||||
pyinstaller --clean --splash logo_s.png --onefile --upx-dir=c:\tools\upx-4.2.2-win64 .\makkelijk_rapport.py
|
||||
pyinstaller --clean --splash logo_s.png --onefile .\makkelijk_rapport.py
|
||||
rd /S /Q build
|
||||
del /F /Q makkelijk_rapport.spec
|
||||
pause
|
@ -1,5 +1,7 @@
|
||||
import pyperclip
|
||||
import pyi_splash
|
||||
from time import sleep
|
||||
from sys import exit
|
||||
|
||||
gebied = ['FUS', 'BLK', 'DBP', 'DKW', 'KKP', 'PAL'] # positioning matters for excel sheet!
|
||||
|
||||
@ -11,29 +13,32 @@ def check_correct_copy(clip):
|
||||
# check if copied correctly
|
||||
if clip[0:3] == '000':
|
||||
return True
|
||||
print('!!! You copied the menu incorrectly. See https://git.ventilaar.nl/ventilaar/random-scripts/src/branch/master/makkelijk_uurlijks_rapport/kopie_voorbeeld.png for an example !!!')
|
||||
print('!!! Incorrect copy, please start at 000 and finish at PAL colli !!!')
|
||||
return False
|
||||
|
||||
def nested_list_from_bare_copy(clip):
|
||||
# create nested list with values based on position
|
||||
cliplines = []
|
||||
|
||||
for x in clip.split('\r\n'): # voor elke nieuwe regel
|
||||
line = [] # lege regel aanmaken
|
||||
|
||||
for i in x.split(' '): #
|
||||
if i: # positie is niet leeg
|
||||
count = 0
|
||||
line.append(i)
|
||||
elif count == 12: # te veel lege posities ontvangen, kolom is leeg en dus 0
|
||||
count = 0
|
||||
line.append('0')
|
||||
else: # positie is leeg
|
||||
count = count + 1
|
||||
|
||||
cliplines.append(line) # regel is compleet toevoegen aan geneste lijst
|
||||
|
||||
return cliplines # geneste lijst teruggeven
|
||||
try:
|
||||
for x in clip.split('\r\n'): # voor elke nieuwe regel
|
||||
line = [] # lege regel aanmaken
|
||||
|
||||
for i in x.split(' '): #
|
||||
if i: # positie is niet leeg
|
||||
count = 0
|
||||
line.append(i)
|
||||
elif count == 12: # te veel lege posities ontvangen, kolom is leeg en dus 0
|
||||
count = 0
|
||||
line.append('0')
|
||||
else: # positie is leeg
|
||||
count = count + 1
|
||||
|
||||
cliplines.append(line) # regel is compleet toevoegen aan geneste lijst
|
||||
|
||||
return cliplines # geneste lijst teruggeven
|
||||
except IndexError:
|
||||
print('!!! Incorrect copy, please start at 000 and finish at PAL colli !!!')
|
||||
return False
|
||||
|
||||
def nested_list_to_dict(clip):
|
||||
# create dictionary based on gebied for a better overview of the data
|
||||
@ -41,51 +46,72 @@ def nested_list_to_dict(clip):
|
||||
data['totaal_colli'] = 0
|
||||
colli = 0
|
||||
|
||||
for x in clip: # voor elke gebied
|
||||
if x[2] in gebied: # als gebied van ons is
|
||||
if len(x) != 8: # totaal aantal colomen kloppen niet iets is fout gegeaan in nested_list_from_bare_copy()
|
||||
print('!!! Something went wrong with assuming the empty rows. Please double check manually !!!')
|
||||
|
||||
data[x[2]] = {} # genereer het verzamelgebied
|
||||
data[x[2]]['totaal'] = int(x[3]) # kopieer totaal regels kolom
|
||||
data[x[2]]['gedaan'] = int(x[4]) # kopieer ingenomen regels kolom
|
||||
data[x[2]]['tedoen'] = int(x[5]) + int(x[6]) # tel te plannen en gepland kolomen bijelkaar op
|
||||
data['totaal_colli'] = data['totaal_colli'] + int(x[-1]) # tel de collis van alle gebieden bijelkaar op
|
||||
try:
|
||||
for x in clip: # voor elke gebied
|
||||
if x[2] in gebied: # als gebied van ons is
|
||||
if len(x) != 8: # totaal aantal colomen kloppen niet iets is fout gegeaan in nested_list_from_bare_copy()
|
||||
print('!!! Something went wrong with assuming the empty rows. Please double check manually !!!')
|
||||
|
||||
data[x[2]] = {} # genereer het verzamelgebied
|
||||
data[x[2]]['totaal'] = int(x[3]) # kopieer totaal regels kolom
|
||||
data[x[2]]['gedaan'] = int(x[4]) # kopieer ingenomen regels kolom
|
||||
data[x[2]]['tedoen'] = int(x[5]) + int(x[6]) # tel te plannen en gepland kolomen bijelkaar op
|
||||
data['totaal_colli'] = data['totaal_colli'] + int(x[-1]) # tel de collis van alle gebieden bijelkaar op
|
||||
|
||||
return data
|
||||
return data
|
||||
|
||||
except IndexError:
|
||||
print('!!! Incorrect copy, please start at 000 and finish at PAL colli !!!')
|
||||
return False
|
||||
|
||||
def generate_clipboard(data):
|
||||
# generate clipboard
|
||||
copyhand = '' # start met een leeg hand
|
||||
|
||||
for x in gebied: # voor elk gebied
|
||||
if x not in data and x == 'PAL': # Pallet gebied komt vandaag (nog) niet voor
|
||||
copyhand = f"{copyhand}0\t0\t" # Zet hand bij pallet gebied op 0
|
||||
if x not in data: # Gebied komt morgen (nog) niet voor
|
||||
copyhand = f"{copyhand}0\t0\t" # Zet hand bij (nog) niet voorkomend gebied op 0
|
||||
else:
|
||||
copyhand = f"{copyhand}{data[x]['gedaan']}\t{data[x]['tedoen']}\t" # voeg de juiste data toe in de hand
|
||||
|
||||
return f"{copyhand}{data['totaal_colli']}" # compleet ingevuld regel
|
||||
return f"{copyhand}{data['totaal_colli']}" # hand afsluiten met totaal colli
|
||||
|
||||
def main():
|
||||
try:
|
||||
paste = pyperclip.waitForNewPaste()
|
||||
if not check_correct_copy(paste):
|
||||
return
|
||||
|
||||
nested_list = nested_list_from_bare_copy(paste)
|
||||
if not nested_list:
|
||||
return
|
||||
|
||||
nested_dict = nested_list_to_dict(nested_list)
|
||||
if not nested_dict:
|
||||
return
|
||||
|
||||
copyhand = generate_clipboard(nested_dict)
|
||||
|
||||
print(copyhand)
|
||||
pyperclip.copy(copyhand)
|
||||
ring_the_bell()
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print('Exiting')
|
||||
exit(0)
|
||||
|
||||
if __name__ == '__main__':
|
||||
print('Listening for new clipboard updates. When you hear a bell you copied correctly, the resulting conversion has replaced your clipboard')
|
||||
print('Welcome to the easy copy tool version 2.1!')
|
||||
print('Listening for copy events, when you copy correctly a bell will ring.')
|
||||
print('')
|
||||
print('Copy example: https://git.ventilaar.nl/ventilaar/random-scripts/src/branch/master/makkelijk_uurlijks_rapport/kopie_voorbeeld.png')
|
||||
print('Source code: https://git.ventilaar.nl/ventilaar/random-scripts/src/branch/master/makkelijk_uurlijks_rapport')
|
||||
print('-'*79)
|
||||
|
||||
pyi_splash.close()
|
||||
while True:
|
||||
try:
|
||||
paste = pyperclip.waitForNewPaste()
|
||||
if not check_correct_copy(paste):
|
||||
continue
|
||||
|
||||
copyhand = generate_clipboard(nested_list_to_dict(nested_list_from_bare_copy(paste)))
|
||||
|
||||
print(copyhand)
|
||||
pyperclip.copy(copyhand)
|
||||
ring_the_bell()
|
||||
except KeyboardInterrupt:
|
||||
print('Exiting')
|
||||
exit(0)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
main()
|
||||
except pyperclip.PyperclipWindowsException:
|
||||
print('Windows is locked, retrying clipboard monitoring in 6 seconds')
|
||||
sleep(6)
|
Loading…
Reference in New Issue
Block a user