linetypes.py

changeset 0
55b4c97d44c5
child 1
5411a25cfca7
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/linetypes.py	Sun Dec 10 15:37:26 2017 +0200
@@ -0,0 +1,46 @@
+class EmptyLine:
+    def __repr__(self):
+        return 'linetypes.EmptyLine()'
+
+class Comment:
+    def __init__(self, text, style = 'old'):
+        if style == 'old' and text.startswith('//'):
+            self.text = text[3:].strip()
+            self.style = 'new'
+        else:
+            self.text = text
+            self.style = style
+    def __repr__(self):
+        return str.format('linetypes.Comment({text!r}, {style!r})',
+            text = self.text,
+            style = self.style,
+        )
+
+class SubfileReference:
+    def __init__(self, *, color, subfile_path, anchor, matrix):
+        self.color, self.subfile_path, = color, subfile_path
+        self.anchor, self.matrix = anchor, matrix
+    def __repr__(self):
+        return str.format('linetypes.SubfileReference(' \
+            'color = {color!r}, ' \
+            'subfile_path = {subfile_path!r}, ' \
+            'anchor = {anchor!r}, ' \
+            'matrix = {matrix!r})', **self.__dict__)
+
+class LineSegment:
+    def __init__(self, *, color, geometry):
+        self.color, self.geometry = color, geometry
+    def __repr__(self):
+        return str.format('linetypes.{typename}(' \
+            'color = {color!r}, ' \
+            'geometry = {geometry!r})',
+            typename = type(self).__name__,
+            color = self.color,
+            geometry = self.geometry,
+        )
+
+class Triangle(LineSegment):
+    pass
+
+class Quadrilateral(LineSegment):
+    pass

mercurial