- fixed an encoding error in the Excellon parser
This commit is contained in:
@@ -7,6 +7,10 @@ CHANGELOG for FlatCAM Evo beta
|
|||||||
|
|
||||||
=================================================
|
=================================================
|
||||||
|
|
||||||
|
16.01.2023
|
||||||
|
|
||||||
|
- fixed an encoding error in the Excellon parser
|
||||||
|
|
||||||
20.05.2022
|
20.05.2022
|
||||||
|
|
||||||
- small fix for a bug that interfere with running the 2D graphic mode
|
- small fix for a bug that interfere with running the 2D graphic mode
|
||||||
|
|||||||
@@ -230,9 +230,20 @@ class Excellon(Geometry):
|
|||||||
else:
|
else:
|
||||||
if filename is None:
|
if filename is None:
|
||||||
return "fail"
|
return "fail"
|
||||||
efile = open(filename, 'r')
|
|
||||||
|
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()
|
estr = efile.readlines()
|
||||||
efile.close()
|
decoded = True
|
||||||
|
break
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
pass
|
||||||
|
if decoded is False:
|
||||||
|
return 'fail'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.parse_lines(estr)
|
self.parse_lines(estr)
|
||||||
|
|||||||
Reference in New Issue
Block a user