Fix for multiple statements per line. Tests pending.
This commit is contained in:
27
camlib.py
27
camlib.py
@@ -1428,7 +1428,7 @@ class Gerber (Geometry):
|
|||||||
|
|
||||||
def parse_file(self, filename, follow=False):
|
def parse_file(self, filename, follow=False):
|
||||||
"""
|
"""
|
||||||
Calls Gerber.parse_lines() with array of lines
|
Calls Gerber.parse_lines() with generator of lines
|
||||||
read from the given file.
|
read from the given file.
|
||||||
|
|
||||||
:param filename: Gerber file to parse.
|
:param filename: Gerber file to parse.
|
||||||
@@ -1438,10 +1438,27 @@ class Gerber (Geometry):
|
|||||||
:type follow: bool
|
:type follow: bool
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
gfile = open(filename, 'r')
|
|
||||||
gstr = gfile.readlines()
|
with open(filename, 'r') as gfile:
|
||||||
gfile.close()
|
|
||||||
self.parse_lines(gstr, follow=follow)
|
def line_generator():
|
||||||
|
for line in gfile:
|
||||||
|
line = line.strip(' \r\n')
|
||||||
|
while len(line) > 0:
|
||||||
|
if line[-1] == '%':
|
||||||
|
yield line
|
||||||
|
break
|
||||||
|
|
||||||
|
starpos = line.find('*')
|
||||||
|
if starpos > -1:
|
||||||
|
cleanline = line[:starpos + 1]
|
||||||
|
yield cleanline
|
||||||
|
line = line[starpos + 1:]
|
||||||
|
else:
|
||||||
|
yield cleanline
|
||||||
|
break
|
||||||
|
|
||||||
|
self.parse_lines(line_generator(), follow=follow)
|
||||||
|
|
||||||
#@profile
|
#@profile
|
||||||
def parse_lines(self, glines, follow=False):
|
def parse_lines(self, glines, follow=False):
|
||||||
|
|||||||
Reference in New Issue
Block a user