diff options
author | Paulo Henrique Silva <ph.silva@gmail.com> | 2015-05-21 16:15:55 -0300 |
---|---|---|
committer | Paulo Henrique Silva <ph.silva@gmail.com> | 2015-05-21 16:15:55 -0300 |
commit | aff36a4dca0d2d06b00c5f1e1a0703400fbe3b6b (patch) | |
tree | 72c356d57627e5523b417aff44df5d9dca16ab88 /gerber | |
parent | 2fe5f36db233e6c45e0d6b2443b025baf173211e (diff) | |
download | gerbonara-aff36a4dca0d2d06b00c5f1e1a0703400fbe3b6b.tar.gz gerbonara-aff36a4dca0d2d06b00c5f1e1a0703400fbe3b6b.tar.bz2 gerbonara-aff36a4dca0d2d06b00c5f1e1a0703400fbe3b6b.zip |
Fix multiline read of mixed statements (%XXX*% followed by DNN*)
We now check if there is a %XXX*% command inside the line before
considering it a multiline statement.
Diffstat (limited to 'gerber')
-rw-r--r-- | gerber/rs274x.py | 4 | ||||
-rw-r--r-- | gerber/tests/resources/multiline_read.ger | 9 | ||||
-rw-r--r-- | gerber/tests/test_rs274x.py | 8 |
3 files changed, 20 insertions, 1 deletions
diff --git a/gerber/rs274x.py b/gerber/rs274x.py index 5d1f5fe..2af3ed6 100644 --- a/gerber/rs274x.py +++ b/gerber/rs274x.py @@ -241,10 +241,11 @@ class GerberParser(object): continue # deal with multi-line parameters - if line.startswith("%") and not line.endswith("%"): + if line.startswith("%") and not line.endswith("%") and not "%" in line[1:]: oldline = line continue + did_something = True # make sure we do at least one loop while did_something and len(line) > 0: did_something = False @@ -292,6 +293,7 @@ class GerberParser(object): # parameter (param, r) = _match_one_from_many(self.PARAM_STMT, line) + if param: if param["param"] == "FS": stmt = FSParamStmt.from_dict(param) diff --git a/gerber/tests/resources/multiline_read.ger b/gerber/tests/resources/multiline_read.ger new file mode 100644 index 0000000..02242e4 --- /dev/null +++ b/gerber/tests/resources/multiline_read.ger @@ -0,0 +1,9 @@ +G75* +G71* +%OFA0B0*% +%FSLAX23Y23*% +%IPPOS*% +%LPD*% +%ADD10C,0.1*% +%LPD*%D10* +M02*
\ No newline at end of file diff --git a/gerber/tests/test_rs274x.py b/gerber/tests/test_rs274x.py index a3d20ed..c084e80 100644 --- a/gerber/tests/test_rs274x.py +++ b/gerber/tests/test_rs274x.py @@ -11,11 +11,19 @@ from .tests import * TOP_COPPER_FILE = os.path.join(os.path.dirname(__file__), 'resources/top_copper.GTL') +MULTILINE_READ_FILE = os.path.join(os.path.dirname(__file__), + 'resources/multiline_read.ger') + def test_read(): top_copper = read(TOP_COPPER_FILE) assert(isinstance(top_copper, GerberFile)) +def test_multiline_read(): + multiline = read(MULTILINE_READ_FILE) + assert(isinstance(multiline, GerberFile)) + assert_equal(10, len(multiline.statements)) + def test_comments_parameter(): top_copper = read(TOP_COPPER_FILE) assert_equal(top_copper.comments[0], 'This is a comment,:') |