- fixed a decoding error in the Excellon parser

This commit is contained in:
Marius Stanciu
2023-01-16 13:02:47 +02:00
parent d6ebcef38d
commit 6c5a468418
2 changed files with 18 additions and 3 deletions

View File

@@ -7,6 +7,10 @@ CHANGELOG for FlatCAM Evo beta
=================================================
16.01.2023
- fixed a decoding error in the Excellon parser
15.01.2023
- PEP8 changes

View File

@@ -230,9 +230,20 @@ class Excellon(Geometry):
else:
if filename is None:
return "fail"
efile = open(filename, 'r')
estr = efile.readlines()
efile.close()
estr = ""
decoded = False
encodings_types = ('cp1252', 'cp850', 'utf-8', 'utf8')
for enc in encodings_types:
try:
with open(filename, 'r', encoding=enc) as efile:
estr = efile.readlines()
decoded = True
break
except UnicodeDecodeError:
pass
if decoded is False:
return 'fail'
try:
self.parse_lines(estr)