diff options
author | Paulo Henrique Silva <ph.silva@gmail.com> | 2013-12-18 03:01:03 -0200 |
---|---|---|
committer | Paulo Henrique Silva <ph.silva@gmail.com> | 2013-12-18 03:01:03 -0200 |
commit | 560a68eeb929a3f9310a7aab0656dbc9b307e417 (patch) | |
tree | e0e24cf26fdf8d43cf9acdf2d9e2038cf0258da2 /gerber | |
parent | 6b8f0470e9460dfc70ae8b7714f6e2659dedcdc2 (diff) | |
download | gerbonara-560a68eeb929a3f9310a7aab0656dbc9b307e417.tar.gz gerbonara-560a68eeb929a3f9310a7aab0656dbc9b307e417.tar.bz2 gerbonara-560a68eeb929a3f9310a7aab0656dbc9b307e417.zip |
Make PEP-8 clean.
Diffstat (limited to 'gerber')
-rw-r--r-- | gerber/gerber.py | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/gerber/gerber.py b/gerber/gerber.py index 74da114..d3f1ff1 100644 --- a/gerber/gerber.py +++ b/gerber/gerber.py @@ -3,38 +3,47 @@ import re + def red(s): return '\033[1;31m{0}\033[0;m'.format(s) + class Statement: - pass + def __init__(self): + pass + class ParamStmt(Statement): - pass + def __init__(self): + pass + class CoordStmt(Statement): - pass + def __init__(self): + pass + class ApertureStmt(Statement): - pass + def __init__(self): + pass + class CommentStmt(Statement): def __init__(self, comment): self.comment = comment + class EofStmt(Statement): pass + class UnexpectedStmt(Statement): def __init__(self, line): self.line = line -class GerberContext: - x = 0 - y = 0 class Gerber: - NUMBER = r"[\+-]?\d+" + NUMBER = r"[\+-]?\d+" FUNCTION = r"G\d{2}" STRING = r"[a-zA-Z0-9_+-/!?<>”’(){}.\|&@# :]+" @@ -55,20 +64,17 @@ class Gerber: EOF_STMT = re.compile(r"M02\*") def __init__(self): - self.apertures = {} - self.ctx = GerberContext() + self.tokens = [] def parse(self, filename): - fp = open(filename, "r") data = fp.readlines() self.tokens = list(self.tokenize(data)) + for token in self.tokens: if isinstance(token, UnexpectedStmt): - print filename print red("[UNEXPECTED TOKEN]") - print self.COORD_STMT.pattern print token.line def tokenize(self, data): |