Kaynağa Gözat

Multiple statement per line problem fixed (Issue #125).

jpcaram 10 yıl önce
ebeveyn
işleme
31ddb9cf7c
1 değiştirilmiş dosya ile 13 ekleme ve 1 silme
  1. 13 1
      camlib.py

+ 13 - 1
camlib.py

@@ -1429,7 +1429,14 @@ class Gerber (Geometry):
     def parse_file(self, filename, follow=False):
     def parse_file(self, filename, follow=False):
         """
         """
         Calls Gerber.parse_lines() with generator of lines
         Calls Gerber.parse_lines() with generator of lines
-        read from the given file.
+        read from the given file. Will split the lines if multiple
+        statements are found in a single original line.
+
+        The following line is split into two::
+
+            G54D11*G36*
+
+        First is ``G54D11*`` and seconds is ``G36*``.
 
 
         :param filename: Gerber file to parse.
         :param filename: Gerber file to parse.
         :type filename: str
         :type filename: str
@@ -1445,15 +1452,20 @@ class Gerber (Geometry):
                 for line in gfile:
                 for line in gfile:
                     line = line.strip(' \r\n')
                     line = line.strip(' \r\n')
                     while len(line) > 0:
                     while len(line) > 0:
+
+                        # If ends with '%' leave as is.
                         if line[-1] == '%':
                         if line[-1] == '%':
                             yield line
                             yield line
                             break
                             break
 
 
+                        # Split after '*' if any.
                         starpos = line.find('*')
                         starpos = line.find('*')
                         if starpos > -1:
                         if starpos > -1:
                             cleanline = line[:starpos + 1]
                             cleanline = line[:starpos + 1]
                             yield cleanline
                             yield cleanline
                             line = line[starpos + 1:]
                             line = line[starpos + 1:]
+
+                        # Otherwise leave as is.
                         else:
                         else:
                             yield cleanline
                             yield cleanline
                             break
                             break