wrapping up plot_to_svg.

This commit is contained in:
Adam Mayer 2017-12-15 13:04:47 -05:00
parent 91a055cc5a
commit 28b99686fb
2 changed files with 15 additions and 5 deletions

View File

@ -1,6 +1,13 @@
#!/usr/bin/python3
import serial
import time
from plot_to_svg import Plotter
def plot_to_svg(instream, outstream):
"Convert a set of plot instructions to an SVG. Works mininmally."
p = Plotter()
p.read(instream)
p.write(outstream)
class Apple410:
"""A simple class for queing up commands for the Apple 410"""

View File

@ -158,10 +158,13 @@ class Plotter:
except AttributeError:
sys.stderr.write("Unrecognized command code {}\n".format(cmd_code))
p = Plotter()
for line in sys.stdin.readlines():
def read(self,inf):
for line in inf.readlines():
line = line.strip()
p.process_cmd(line)
p.write(sys.stdout)
if __name__=='__main__':
p = Plotter()
p.read(sys.stdin)
p.write(sys.stdout)