-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrdw.py
More file actions
951 lines (857 loc) · 35.9 KB
/
rdw.py
File metadata and controls
951 lines (857 loc) · 35.9 KB
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
"""rdw.py"""
import datetime
import filecmp
import json
import os
import re
import sys
from rdw_utils import (
arg_has,
get_kentekens,
fill_prices,
get_variant,
my_die,
safe_get_key,
print_import_separate,
)
sys.stdout.flush() # Disable output buffering
D = arg_has("debug")
def dbg(line: str) -> bool:
"""print line if debugging"""
if D:
print(line)
return D # just to make a lazy evaluation expression possible
def rename_with_timestamp(filename: str) -> str:
"""rename with timestamp"""
new_filename = ""
if os.path.isfile(filename):
file_extension = os.path.splitext(filename)[1]
yyyymmdd_hhmmss = datetime.datetime.now().strftime("%Y.%m.%d_%H.%M.%S")
new_filename = f"{filename}.{yyyymmdd_hhmmss}{file_extension}"
os.rename(filename, new_filename)
print(f"INFO: Creating {filename}, backup={new_filename}")
return new_filename
def delete_second_file_if_content_same(filename1: str, filename2: str):
"""delete second file if content same"""
if filename2 != "" and filecmp.cmp(filename1, filename2, shallow=False):
print(f"INFO: Deleting {filename2}")
os.remove(filename2)
# ===============================================================================
# get_print_line
# parameter 1: line
# format:
# 1 2 3 4 5 6 7 8 9 # noqa
# 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
# NDHN146DH 20210917 GRIJS 55600 F5E32;E11A11;e9*2018/858*11054*01; prijs: 55600 GRIJS 73 kWh Lounge # noqa
# return printLine
# ===============================================================================
def get_print_line(line):
"""get_print_line"""
_ = D and dbg(f"getPrintLine({line})")
new = line[3:19] + line[39:93] + line[97:]
new = re.sub(r";e9\*2018\/858\*11054\*0[13456789];", "", new)
new = new.replace("prijs: ", "E")
# Kleuren:
# GEEL Gravity Gold (Mat)
# ZWART Phantom Black (Mica Parelmoer), Abyss Black (Mica Parelmoer)
# GROEN Digital Teal (Mica Parelmoer), Mystic Olive (Mica)
# BLAUW Lucid Blue (Mica Parelmoer)
# BRUIN Mystic Olive (Mica)
# GRIJS Shooting Star (Mat), Cyber Grey (Metal.), Galactic Gray (Metal.)
# WIT Atlas White (Solid) Atlas White Matte
# ROOD Ultimate Red Metallic
new = new.replace("GEEL ", "Gravity Gold ")
if "model 2025" in new:
new = new.replace("ZWART ", "Abyss Black ")
else:
new = new.replace("ZWART ", "Phantom Black ")
new = new.replace("ROOD ", "Red Metallic ")
if "GROEN " in new and " (Olive)" in new:
new = new.replace(" (Olive)", "")
new = new.replace("GROEN ", "Mystic Olive ")
if "GROEN " in new and "Olive" not in new:
new = new.replace("GROEN ", "Digital Teal ")
new = new.replace("GROEN ", "GROEN ")
new = new.replace("BLAUW ", "Lucid Blue ")
new = new.replace("BRUIN ", "Mystic Olive ")
if "GRIJS " in new and (" (Shooting Star)" in new or "PROJECT45" in new):
new = new.replace(" (Shooting Star)", "")
new = new.replace("GRIJS ", "Shooting Star ")
new = new.replace("GRIJS ", "Cyber/Galactic ")
if "WIT " in new and " (Atlas White Matte)" in new:
new = new.replace("WIT ", "White Matte ")
else:
new = new.replace("WIT ", "Atlas White ")
# get rid of internal information too, not interesting for end user
new = re.sub(r"F5E..;E11.11 ", "", new)
new = re.sub(r"A5E..;E11.11 ", "", new)
_ = D and dbg(f"getPrintLine RESULT: [{new}]")
return new
def main():
"""main"""
# this contains the pricelist per date and kWh battery and AWD
pricelists_dates = [
"20250701",
"20250401",
"20250101",
"20240701",
"20231001",
"20230501",
"20230101",
"20220901",
"20220501",
"20220301",
"20210501",
]
pricelists = fill_prices(D)
variantscount = {}
variantscountnognietopnaam = {}
counttaxi = 0
taxi = "Nee"
export = "Nee"
count19inch = 0
count20inch = 0
countlounge19inch = 0
countlounge20inch = 0
colormatte = 0
colormetallic = 0
colormica = 0
colorsolid = 0
colormicapearl = 0
# totals kleuren en andere statistieken
count = 0
colors = {}
dates = {}
# statistics
longrangebattery = 0
rwd = 0
v2l = 0
warmtepomp = 0
panoramadak = 0
solardak = 0
project45 = 0
lounge = 0
connectplus = 0
connect = 0
style = 0
nline = 0
nlineedition = 0
model2022 = 0
model2022_5 = 0
model2023 = 0
model2025 = 0
months = {
"01": "januari",
"02": "februari",
"03": "maart",
"04": "april",
"05": "mei",
"06": "juni",
"07": "juli",
"08": "augustus",
"09": "september",
"10": "oktober",
"11": "november",
"12": "december",
}
summary = arg_has("summary")
overview = arg_has("overview")
alle_kentekens = []
nieuw_export_list = []
gekend_op_naam_list = []
nieuw_op_naam_list = []
nieuw_nog_niet_op_naam_list = []
geimporteerd = 0
count_nog_niet_op_naam = 0
nognietopnaam = []
opnaam = []
nognietopnaam_dict = {}
if os.path.isfile("nognietopnaam.txt"):
with open("nognietopnaam.txt", "r", encoding="utf8") as nognietopnaamfile:
for line in nognietopnaamfile:
mstr = line.rstrip("\n")
k = mstr[:6]
if k != "":
_ = D and dbg(f"Adding nognietopnaam: [{k}]")
nognietopnaam_dict[k] = mstr
opnaam_dict = {}
if os.path.isfile("opnaam.txt"):
with open("opnaam.txt", "r", encoding="utf8") as opnaamfile:
for line in opnaamfile:
mstr = line.rstrip("\n")
k = mstr[:6]
if k != "":
_ = D and dbg(f"Adding opnaam: [{k}]")
opnaam_dict[k] = mstr
exported_dict = {}
if os.path.isfile("exported.txt"):
with open("exported.txt", "r", encoding="utf8") as exportedfile:
for line in exportedfile:
mstr = line.rstrip("\n")
k = mstr[:6]
if k != "":
_ = D and dbg(f"Adding exported: [{k}]")
exported_dict[k] = mstr
xkentekensfilename = "x.kentekens"
if not summary and not overview:
print("Getting IONIQ5 kentekens")
if os.path.exists(xkentekensfilename):
os.remove(xkentekensfilename)
with open(xkentekensfilename, "w", encoding="utf8"):
pass
get_kentekens()
print("Processing IONIQ5 kentekens")
with open(xkentekensfilename, encoding="utf8") as json_file:
json_data = json.load(json_file)
aantal_kentekens = len(json_data)
print(f"Aantal kentekens: {aantal_kentekens}")
for hash_ in json_data:
k = hash_["kenteken"]
_ = D and dbg(f"kenteken = [{k}]")
gekend_op_naam = False
nieuw_op_naam = False
gekend_niet_op_naam = False
nieuw_niet_op_naam = False
taxi = hash_["taxi_indicator"]
if taxi == "Ja":
counttaxi += 1
export = hash_["export_indicator"]
kenteken = safe_get_key(hash_, "kenteken")
if len(kenteken) != 6:
my_die(f"{k} Kenteken lengte fout: [{kenteken}] {hash_}")
date = safe_get_key(
hash_, "datum_eerste_afgifte_nederland"
) # niet gevuld wanneer kenteken nog niet op naam
if date == "":
date = safe_get_key(
hash_, "datum_eerste_tenaamstelling_in_nederland"
) # changed 31 maart 2022, niet gevuld wanneer kenteken nog niet op naam
date_bpm = safe_get_key(
hash_, "registratie_datum_goedkeuring_afschrijvingsmoment_bpm_dt"
) # gevuld wanneer kenteken nog niet op naam
if date_bpm != "":
if len(date_bpm) == 23 and date_bpm[:2] == "20":
date_bpm = date_bpm[:4] + date_bpm[5:7] + date_bpm[8:10]
if date == date_bpm:
date_bpm = ""
else:
_ = D and dbg(f"{k} dateBPM: [{date_bpm}]")
else:
print(f"WARNING: {k} dateBPM: [{date_bpm}]")
if date == "" and date_bpm != "":
date = date_bpm
if k not in nognietopnaam_dict:
nieuw_niet_op_naam = True
print(
f"{k} Nieuw kenteken nog niet op naam {date_bpm}: [{date}]" # noqa
)
else:
gekend_niet_op_naam = True
if D:
print(
f"{k} Gekend kenteken nog niet op naam {date_bpm}: [{date}]" # noqa
)
nognietopnaam_dict[k] = k
else:
if k not in nognietopnaam_dict and k not in opnaam_dict:
nieuw_op_naam = True
print(f"{k} Nieuw kenteken op naam {date_bpm}: [{date}]") # noqa
else:
gekend_op_naam = True
_ = D and dbg(
f"{k} Gekend kenteken op naam {date_bpm}: [{date}]" # noqa
)
if len(date) != 8:
my_die(f"{k} Date lengte fout: [{date}]")
date_toelating = safe_get_key(hash_, "datum_eerste_toelating")
if date_toelating == "":
date_toelating = date
if D:
print(
f"{k} datetoelating overruled with {date}: [{date}]"
) # niet gevuld wanneer kenteken nog niet op naam
if len(date_toelating) != 8:
my_die(f"{k} Date lengte fout: [{date_toelating}] {hash_}")
if date != date_toelating:
_ = D and dbg(f"Import {kenteken}: [{date_toelating}] [{date}]")
geimporteerd += 1
kleur = safe_get_key(hash_, "eerste_kleur")
if kleur == "":
my_die(f"{k} Kleur leeg: [{kleur}]")
if kleur not in [
"GROEN",
"WIT",
"ZWART",
"GEEL",
"GRIJS",
"BLAUW",
"BRUIN",
"ROOD",
]:
my_die(f"{k} Kleur onbekend: [{kleur}]")
kleur = kleur.ljust(10)
prijs = safe_get_key(hash_, "catalogusprijs")
if not prijs and kenteken != "R296FL":
my_die(f"{k} Prijs leeg: [{prijs}]")
if len(prijs) > 7 and kenteken not in ["N770TS", "R296FL", "R303XF"]:
my_die(f"{k} Prijs verkeerd: [{prijs}]")
variant = safe_get_key(hash_, "variant")
uitvoering = safe_get_key(hash_, "uitvoering")
typegoedkeuring = safe_get_key(hash_, "typegoedkeuringsnummer")
if kenteken == "N331SH":
variant = "F5E14"
uitvoering = "E11B11"
typegoedkeuring = "e9*2018/858*11054*01"
elif kenteken == "P085GJ":
variant = "F5E14"
uitvoering = "E11B11"
typegoedkeuring = "e9*2018/858*11054*01"
elif kenteken == "N688DR":
variant = "F5E32"
uitvoering = "E11B11"
typegoedkeuring = "e9*2018/858*11054*01"
elif kenteken == "P380DR":
variant = "F5E14"
elif kenteken == "N770TS":
prijs = 72300
elif kenteken == "R296FL":
variant = "F5E32"
uitvoering = "E11B11"
typegoedkeuring = "e9*2018/858*11054*01"
prijs = 55600
elif kenteken == "R303XF":
variant = "F5E42"
uitvoering = "E11A11"
typegoedkeuring = "e9*2018/858*11054*01"
prijs = 52426
elif kenteken == "R818ZL":
variant = "F5E42"
uitvoering = "E11A11"
typegoedkeuring = "e9*2018/858*11054*01"
elif kenteken == "R494RB":
variant = "F5E42"
uitvoering = "E11A11"
typegoedkeuring = "e9*2018/858*11054*04"
if variant == "":
my_die(f"{k} Variant leeg: [{variant}] {hash_}")
if variant not in [
"F5E24",
"F5E14",
"F5E32",
"F5E42",
"F5E54",
"F5E62",
"F5E22",
"F5E12",
"A5E22",
"F5E34",
"A5E34",
"F5E74",
]:
my_die(f"WARNING: {k} Variant verkeerd: [{variant}] {hash_}")
if uitvoering == "":
my_die(f"{k} Uitvoering leeg: [{uitvoering}] {hash_}")
if uitvoering not in ["E11A11", "E11B11"]:
my_die(f"{k} Uitvoering onbekend: [{uitvoering}] {hash_}")
if typegoedkeuring == "":
my_die(f"{k} Typegoedkeuring leeg: [{typegoedkeuring}] {hash_}")
if typegoedkeuring not in [
"e9*2018/858*11054*01",
"e9*2018/858*11054*03",
"e9*2018/858*11054*04",
"e9*2018/858*11054*05",
"e9*2018/858*11054*06",
"e9*2018/858*11054*07",
"e9*2018/858*11054*08",
"e9*2018/858*11054*09",
]:
my_die(f"ERROR: {k} Typegoedkeuring verkeerd: [{typegoedkeuring}] {hash_}")
cartype = f"{variant};{uitvoering};{typegoedkeuring}; prijs: {prijs} {kleur}"
date20 = date_toelating.replace(
"??", "20"
) # nog niet op naam date can start with ??
if date_bpm and int(date_bpm) < int(date_toelating):
date20 = date_bpm
if D:
print(
f"Overruled {kenteken} met dateBPM: dateToelating: {date_toelating} with dateBPM {date_bpm}" # noqa
)
date20 = date20.replace("??", "20") # nog niet op naam date can start with ??
if date20[:3] != "202":
print(f"Invalid toelating date: {date20}")
date20 = date20[6:10] + date20[3:5] + date20[0:2]
print(f"Corrected toelating date: {date20}")
if D and kenteken == "R059VH":
print(
f"{kenteken}, date: {date}, datetoelating: {date_toelating}, date20: {date20}, dateBPM: {date_bpm}" # noqa
)
tuple_parameter = (
taxi,
export,
count20inch,
countlounge20inch,
count19inch,
countlounge19inch,
colormatte,
colormica,
colorsolid,
colormicapearl,
colormetallic,
variantscount,
variantscountnognietopnaam,
)
(
value,
taxi,
export,
count20inch,
countlounge20inch,
count19inch,
countlounge19inch,
colormatte,
colormica,
colorsolid,
colormicapearl,
colormetallic,
variantscount,
variantscountnognietopnaam,
) = get_variant(
pricelists, pricelists_dates, D, tuple_parameter, cartype, True, k, date20
)
if value == "ERROR":
my_die(f"{k} ERROR occurred")
cartype += value
if date != date_toelating:
cartype += f" ({date_toelating} geimporteerd {date})"
elif date_bpm != "":
cartype += f" (aanvraag kenteken {date_bpm})"
if gekend_niet_op_naam or nieuw_niet_op_naam:
cartype += " (nog niet op naam)"
special_kenteken = f"{kenteken[0]}{kenteken[4:6]}{kenteken} {date} {kleur} {prijs} {cartype}" # noqa
_ = D and print(special_kenteken)
tmp = get_print_line(special_kenteken)
if export == "Ja":
if k not in exported_dict:
nieuw_export_list.append(tmp)
exported_dict[k] = tmp
if gekend_niet_op_naam:
_ = D and dbg(f"Gekend kenteken niet op naam: {k} {tmp}")
nognietopnaam.append(tmp)
count_nog_niet_op_naam += 1
if nieuw_niet_op_naam:
print(f"Nieuw kenteken niet op naam: {k} {tmp}")
nognietopnaam.append(tmp)
nieuw_nog_niet_op_naam_list.append(tmp)
count_nog_niet_op_naam += 1
if gekend_op_naam:
opnaam.append(tmp)
if k in nognietopnaam_dict:
del nognietopnaam_dict[k]
gekend_op_naam_list.append(f"{tmp}")
print(f"Gekend kenteken op naam gezet: {k} {tmp}")
if nieuw_op_naam:
opnaam.append(tmp)
print(f"Nieuw kenteken op naam: {k} {tmp}")
nieuw_op_naam_list.append(f"{tmp}")
alle_kentekens.append(special_kenteken)
countexport = 0
sorted_exported = sorted(
exported_dict.values(),
key=lambda s: (s[7:], s[0:1], s[4:6], s[1:]),
reverse=True,
)
for values in sorted_exported:
countexport += 1
if not summary and not overview:
new_filename = rename_with_timestamp("exported.txt")
with open("exported.txt", "x", encoding="utf8") as exportedtxtfile:
for values in sorted_exported:
exportedtxtfile.write(f"{values}\n")
delete_second_file_if_content_same("exported.txt", new_filename)
importnietopnaam = 0
sorted_nog_niet_op_naam = sorted(
nognietopnaam, key=lambda s: (s[7:], s[0:1], s[4:6], s[1:]), reverse=True
)
for string in sorted_nog_niet_op_naam:
if "geimporteerd" in string:
importnietopnaam += 1
if not summary and not overview:
new_filename = rename_with_timestamp("nognietopnaam.txt")
with open("nognietopnaam.txt", "x", encoding="utf8") as nognietopnaamtxtfile:
for string in sorted_nog_niet_op_naam:
string = string.replace(" (nog niet op naam)", "")
nognietopnaamtxtfile.write(f"{string}\n")
delete_second_file_if_content_same("nognietopnaam.txt", new_filename)
if not summary and not overview:
new_filename = rename_with_timestamp("opnaam.txt")
with open("opnaam.txt", "x", encoding="utf8") as opnaamtxtfile:
sorted_op_naam = sorted(
opnaam, key=lambda s: (s[7:], s[0:1], s[4:6], s[1:]), reverse=True
)
for string in sorted_op_naam:
opnaamtxtfile.write(f"{string}\n")
delete_second_file_if_content_same("opnaam.txt", new_filename)
if summary:
print(
"\n\n"
+ "[h1]Kentekens gesorteerd met tenaamstelling datum, prijs, kleur, uitvoering[/h1]" # noqa
)
print("[code]")
alle_kentekens_print = []
for k in sorted(alle_kentekens, reverse=True):
count += 1
print_line = get_print_line(k)
alle_kentekens_print.append(print_line)
for k in sorted(alle_kentekens, reverse=True):
print_line = get_print_line(k)
if summary:
print(f"{print_line}")
if not re.search(r"AWD", print_line, re.IGNORECASE) and not re.search(
r"PROJECT45", print_line, re.IGNORECASE
):
rwd += 1
if re.search(r"Model 2025", print_line, re.IGNORECASE):
model2025 += 1
elif re.search(r"Model 2023", print_line, re.IGNORECASE):
model2023 += 1
elif re.search(r"Model 2022\.5", print_line, re.IGNORECASE):
model2022_5 += 1
else:
model2022 += 1
if not re.search(r"58 kWh", print_line, re.IGNORECASE) and not re.search(
r"63 kWh", print_line, re.IGNORECASE
):
longrangebattery += 1
if re.search(r"V2L|PROJECT45|Lounge|Connect", print_line, re.IGNORECASE):
v2l += 1
if re.search(r"WP|PROJECT45|Lounge|Connect\+", print_line, re.IGNORECASE):
warmtepomp += 1
if re.search(r"Panoramadak", print_line, re.IGNORECASE) and not re.search(
r"Olive", print_line
):
panoramadak += 1
if re.search(r"PROJECT45", print_line, re.IGNORECASE):
solardak += 1
project45 += 1
elif re.search(r"Zonnepanelen", print_line, re.IGNORECASE):
solardak += 1
elif re.search(r"LOUNGE", print_line, re.IGNORECASE):
lounge += 1
elif re.search(r"CONNECT\+", print_line, re.IGNORECASE):
connectplus += 1
elif re.search(r"CONNECT", print_line, re.IGNORECASE):
connect += 1
elif re.search(r"STYLE", print_line, re.IGNORECASE):
style += 1
elif re.search(r"N LINE EDITION", print_line, re.IGNORECASE):
nlineedition += 1
elif re.search(r"N LINE", print_line, re.IGNORECASE):
nline += 1
else:
my_die(f"ERROR: Model niet gevonden: [{k}][{print_line}]")
if "(nog niet op naam)" not in print_line:
date = k[10:16]
if date.startswith("2"):
if date in dates:
dates[date] += 1
else:
dates[date] = 1
color = k[19:29].rstrip()
_ = D and dbg(f"KLEUR=[{color}]")
if color in colors:
colors[color] += 1
else:
colors[color] = 1
if summary:
print("[/code]\n")
if overview:
print("\n\n[h1]Kentekens gesorteerd op kleur/uitvoering/datum[/h1]\n[code]")
op_all = []
for print_line in alle_kentekens_print:
op_all.append(print_line)
sorted_all = sorted(op_all, key=lambda x: (x[23:], x[7:], x[0], x[4:6], x[1:]))
for string in sorted_all:
print(string)
print("[/code]\n")
print("\n\n[h1]Taxi's gesorteerd op kleur/uitvoering/datum[/h1]\n[code]")
op_taxi = []
for print_line in alle_kentekens_print:
if "(Taxi)" in print_line:
op_taxi.append(print_line)
sorted_taxi = sorted(
op_taxi, key=lambda x: (x[23:], x[7:9], x[0], x[4:6], x[1:])
)
for string in sorted_taxi:
print(string)
print("[/code]\n")
print("\n\n[h1]geexporteerd gesorteerd op kleur/uitvoering/datum[/h1]")
print("[code]")
op_export = []
for print_line in alle_kentekens_print:
if "(geexporteerd)" in print_line:
op_export.append(print_line)
sorted_export = sorted(
op_export, key=lambda a: (a[23:], a[7:10], a[0], a[4:6], a[1:])
)
for string in sorted_export:
print(string)
print("[/code]\n")
# overview of kentekens per month
for key in sorted(dates.keys()):
jaar = key[:4]
maand = key[4:6]
if overview:
continue
if not summary:
print(f"Skipping maand: {maand} in mode without parameters")
continue
# if jaar <= 2021 or maand <= 1: # do not give overviews after this month
# print(f"Skipping maand: {maand}")
# continue
maandstring = months[maand]
print(
f"\n\n[h1]Kentekens op naam in {maandstring} {jaar}, kleur/uitvoering[/h1]" # noqa
)
print("[code]")
op_naam = []
for print_line in alle_kentekens_print:
kenteken = print_line[0:6]
_ = D and dbg(f"kenteken={kenteken} print_line=[{print_line}]")
if kenteken not in nognietopnaam_dict:
date = print_line[7:13]
if date == key:
_ = D and dbg(print_line)
op_naam.append(print_line)
sorted_opnaam = sorted(op_naam, key=lambda a: a[23:])
for string in sorted_opnaam:
print(string)
print("[/code]\n")
print()
if not overview and not summary:
sorted_nog_niet_op_naam = sorted(nognietopnaam, key=lambda s: s[23:])
print("\n\n")
print_import_separate(
sorted_nog_niet_op_naam,
"[anchor=nietgeimporteerd]\n[h1]Kentekens nog niet op naam (geen import) gesorteerd op kleur/uitvoering (datum is registratiedatum)[/h1]", # noqa
"[anchor=geimporteerd][h1]Kentekens nog niet op naam (geimporteerd) gesorteerd op kleur/uitvoering (datum is registratiedatum)[/h1]", # noqa
True,
)
if len(gekend_op_naam_list) > 0:
sorted_gekend_op_naam = sorted(
gekend_op_naam_list, key=lambda x: (x[23:], x[7:10], x[0], x[4:6], x[1:])
)
print_import_separate(
sorted_gekend_op_naam,
"Eerder gevonden kenteken (geen import) op naam gezet:",
"Eerder gevonden kenteken (geimporteerd) op naam gezet:",
)
if len(nieuw_op_naam_list) > 0:
sorted_nieuw_op_naam = sorted(
nieuw_op_naam_list, key=lambda x: (x[23:], x[7:10], x[0], x[4:6], x[1:])
)
print_import_separate(
sorted_nieuw_op_naam,
"Nieuw kenteken (geen import) op naam gezet:",
"Nieuw kenteken (geimporteerd) op naam gezet:",
)
if len(nieuw_nog_niet_op_naam_list) > 0:
sorted_nieuw_nog_niet_op_naam_list = sorted(
nieuw_nog_niet_op_naam_list,
key=lambda x: (x[23:], x[7:10], x[0], x[4:6], x[1:]),
)
print_import_separate(
sorted_nieuw_nog_niet_op_naam_list,
"Nieuw kenteken (geen import) nog niet op naam:",
"Nieuw kenteken (geimporteerd) nog niet op naam:",
)
if len(nieuw_export_list) > 0:
sorted_nieuw_export_list = sorted(
nieuw_export_list,
key=lambda x: (x[23:], x[7:10], x[0], x[4:6], x[1:]),
)
print_import_separate(
sorted_nieuw_export_list,
"Nieuw kenteken (geen import) geexporteerd:",
"Nieuw kenteken (geimporteerd) geexporteerd:",
)
print(f"Totaal aantal IONIQ5 op gekend kenteken: {count}")
if count_nog_niet_op_naam > 0:
opnaamcount = len(opnaam)
print(f"Op naam: {opnaamcount}")
nietimportnietopnaam = count_nog_niet_op_naam - importnietopnaam
print(
f"[url=https://gathering.tweakers.net/forum/list_message/69802884#69802884]Nog niet op naam: {count_nog_niet_op_naam}[/url], [url=https://gathering.tweakers.net/forum/list_message/69802884#nietgeimporteerd]{nietimportnietopnaam} geen import[/url], [url=https://gathering.tweakers.net/forum/list_message/69802884#geimporteerd]{importnietopnaam} geimporteerd[/url]" # noqa
)
print(f"Geimporteerd: {geimporteerd}")
print(f"Geexporteerd: {countexport}")
print()
pmodel2022 = model2022 / count * 100
pmodel2022_5 = model2022_5 / count * 100
pmodel2023 = model2023 / count * 100
pmodel2025 = model2025 / count * 100
print(f"{pmodel2025:4.1f} % model 2025 ({model2025} maal)")
print(f"{pmodel2023:4.1f} % model 2023 ({model2023} maal)")
print(f"{pmodel2022_5:4.1f} % model 2022.5 ({model2022_5} maal)")
print(f"{pmodel2022:4.1f} % model 2022 ({model2022} maal)")
print()
if overview or summary:
print("Kentekens op naam gezet per maand:")
href = {
"juni 2021": "https://gathering.tweakers.net/forum/list_message/69800422#69800422", # noqa
"juli 2021": "https://gathering.tweakers.net/forum/list_message/69800430#69800430", # noqa
"augustus 2021": "https://gathering.tweakers.net/forum/list_message/69800436#69800436", # noqa
"september 2021": "https://gathering.tweakers.net/forum/list_message/69800444#69800444", # noqa
"oktober 2021": "https://gathering.tweakers.net/forum/list_message/69800446#69800446", # noqa
"november 2021": "https://gathering.tweakers.net/forum/list_message/69800456#69800456", # noqa
"december 2021": "https://gathering.tweakers.net/forum/list_message/69800460#69800460", # noqa
"januari 2022": "https://gathering.tweakers.net/forum/list_message/70090920#70090920", # noqa
"februari 2022": "https://gathering.tweakers.net/forum/list_message/70788736#70788736", # noqa
"maart 2022": "https://gathering.tweakers.net/forum/list_message/71123634#71123634", # noqa
"april 2022": "https://gathering.tweakers.net/forum/list_message/71393214#71393214", # noqa
"mei 2022": "https://gathering.tweakers.net/forum/list_message/71723406#71723406", # noqa
"juni 2022": "https://gathering.tweakers.net/forum/list_message/72031366#72031366", # noqa
"juli 2022": "https://gathering.tweakers.net/forum/list_message/72300528#72300528", # noqa
"augustus 2022": "https://gathering.tweakers.net/forum/list_message/72624024#72624024", # noqa
"september 2022": "https://gathering.tweakers.net/forum/list_message/72989402#72989402", # noqa
"oktober 2022": "https://gathering.tweakers.net/forum/list_message/73324494#73324494", # noqa
"november 2022": "https://gathering.tweakers.net/forum/list_message/73660348#73660348", # noqa
"december 2022": "https://gathering.tweakers.net/forum/list_message/73984554#73984554", # noqa
"januari 2023": "https://gathering.tweakers.net/forum/list_message/74335278#74335278", # noqa
"februari 2023": "https://gathering.tweakers.net/forum/list_message/74650990#74650990", # noqa
"maart 2023": "https://gathering.tweakers.net/forum/list_message/74966656#74966656", # noqa
"april 2023": "https://gathering.tweakers.net/forum/list_message/75525182#75525182", # noqa
"mei 2023": "https://gathering.tweakers.net/forum/list_message/75524932#75524932", # noqa
"juni 2023": "https://gathering.tweakers.net/forum/list_message/75814390#75814390", # noqa
"juli 2023": "https://gathering.tweakers.net/forum/list_message/76101516#76101516", # noqa
"augustus 2023": "https://gathering.tweakers.net/forum/list_message/76397426#76397426", # noqa
"september 2023": "https://gathering.tweakers.net/forum/list_message/76722044#76722044", # noqa
"oktober 2023": "https://gathering.tweakers.net/forum/list_message/77060150#77060150", # noqa
"november 2023": "https://gathering.tweakers.net/forum/list_message/77380106#77380106", # noqa
"december 2023": "https://gathering.tweakers.net/forum/list_message/77691524#77691524", # noqa
"januari 2024": "https://gathering.tweakers.net/forum/list_message/78011736#78011736", # noqa
"februari 2024": "https://gathering.tweakers.net/forum/list_message/78319598#783195980", # noqa
}
# jaren
years = {}
for key in sorted(dates.keys()):
count_date = dates[key]
countstring = f"{count_date:3d}"
jaar = key[:4]
if jaar in years:
years[jaar] = count_date + years[jaar]
else:
years[jaar] = count_date
maand = key[4:6]
maandjaarstring = f"{months[maand]} {jaar}"
if maandjaarstring in href:
print(
f"[url={href[maandjaarstring]}]{countstring} op naam gezet in {maandjaarstring}[/url]" # noqa
)
else:
print(f"{countstring} op naam gezet in {maandjaarstring}")
print()
for key in sorted(years.keys()):
count_year = years[key]
print(f"{count_year} op naam gezet in {key}")
print()
print(f"Statistieken van totaal {count} maal IONIQ 5:")
plongrangebattery = longrangebattery / count * 100
prwd = rwd / count * 100
pv2l = v2l / count * 100
pwp = warmtepomp / count * 100
ppanoramadak = panoramadak / count * 100
psolardak = solardak / count * 100
pproject45 = project45 / count * 100
plounge = lounge / count * 100
pconnectplus = connectplus / count * 100
pconnect = connect / count * 100
pstyle = style / count * 100
pnline = nline / count * 100
pnlineedition = nlineedition / count * 100
print(f"{pwp:4.1f} % warmtepomp (standaard vanaf Connect+, {warmtepomp} maal)")
print(f"{plongrangebattery:4.1f} % grote batterij ({longrangebattery} maal)")
print(f"{pv2l:4.1f} % vehicle to load (standaard vanaf Connect, {v2l} maal)")
print(f"{prwd:4.1f} % achterwielaandrijving ({rwd} maal)")
print(f"{ppanoramadak:4.1f} % panoramadak ({panoramadak} maal)")
print(
f"{psolardak:4.1f} % zonnepanelendak (in principe alleen op PROJECT45 geleverd in Nederland, {solardak} maal)\n" # noqa
)
print(f"{pnline:4.1f} % N Line ({nline} maal)")
print(f"{pnlineedition:4.1f} % N Line Edition ({nlineedition} maal)")
print(f"{plounge:4.1f} % Lounge ({lounge} maal)")
print(f"{pstyle:4.1f} % Style ({style} maal)")
print(f"{pconnectplus:4.1f} % Connect+ ({connectplus} maal)")
print(f"{pconnect:4.1f} % Connect ({connect} maal)")
print(f"{pproject45:4.1f} % Project45 ({project45} maal)\n")
pexport = countexport / count * 100
print(f"{pexport:4.1f} % geexporteerd ({countexport} maal)")
print()
ptaxi = counttaxi / count * 100
print(f"{ptaxi:4.1f} % Taxi ({counttaxi} maal)")
print()
p19 = count19inch / count * 100
p20 = count20inch / count * 100
lounge_count = countlounge19inch + countlounge20inch
plounge19 = countlounge19inch / lounge_count * 100
plounge20 = countlounge20inch / lounge_count * 100
print(f"{p19:4.1f} % 19 inch banden ({count19inch} maal)")
print(f"{p20:4.1f} % 20 inch banden ({count20inch} maal)")
print(f"{plounge20:4.1f} % Lounge 20 inch banden ({countlounge20inch} maal)")
print(f"{plounge19:4.1f} % Lounge 19 inch banden ({countlounge19inch} maal)")
print()
leganda = {
"WIT": "Atlas White (Solid), Atlas White (Mat)",
"GRIJS": "Shooting Star (Mat), Cyber Grey (Metal.), Galactic Gray (Metal.)",
"GROEN": "Digital Teal (Mica Parelmoer), Mystic Olive (Mica)",
"ZWART": "Phantom Black (Mica Parelmoer), Abyss Black (Mica Parelmoer)",
"BLAUW": "Lucid Blue (Mica Parelmoer)",
"GEEL": "Gravity Gold (Mat)",
"BRUIN": "Mystic Olive (Mica)",
"ROOD": "Red Metallic",
}
colorsoutput = []
for key in sorted(colors.keys()):
number = colors[key]
perc = int((number / count * 100) + 0.5)
legenda = leganda[key]
percstr = f"{perc:2d}"
cstr = f"{key:>6s}"
cnt = f"{number:3d}"
colorsoutput.append(f"{percstr}% {cstr} ({cnt} maal) {legenda}\n")
print("[code]")
sorted_output = sorted(colorsoutput, reverse=True)
print("".join(sorted_output))
pcolormatte = colormatte / count * 100
pcolormetallic = colormetallic / count * 100
pcolormica = colormica / count * 100
pcolorsolid = colorsolid / count * 100
pcolormicapearl = colormicapearl / count * 100
print(f"{pcolormicapearl:4.1f} % Mica Parelmoer kleur ({colormicapearl} maal)")
print(f"{pcolormatte:4.1f} % Mat kleur ({colormatte} maal)")
print(f"{pcolormetallic:4.1f} % Metallic kleur ({colormetallic} maal)")
print(f"{pcolormica:4.1f} % Mica Kleur ({colormica} maal)")
print(f"{pcolorsolid:4.1f} % Solid kleur ({colorsolid} maal)")
print("[/code]\n")
for k, count in sorted(
variantscount.items(),
key=lambda x: (
x[1],
(
format(-int(x[0].split(" ")[0]), "05d")
if x[0].split(" ")[0].isdigit()
else x[0]
),
),
reverse=True,
):
_ = D and dbg(f"key: [{k}]")
# count = variantscount[k]
print(f"{count} maal op gekend kenteken variant: {k}")
if k in variantscountnognietopnaam:
count_nog_niet_op_naam = variantscountnognietopnaam[k]
if count_nog_niet_op_naam > 0:
print(
f"waarvan {count_nog_niet_op_naam} maal kenteken nog niet op naam" # noqa
)
print()
main()