diff --git a/apple410/__init__.py b/apple410/__init__.py index 58cffe5..1404c00 100755 --- a/apple410/__init__.py +++ b/apple410/__init__.py @@ -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""" diff --git a/apple410/plot_to_svg.py b/apple410/plot_to_svg.py index 861f426..eb35c02 100755 --- a/apple410/plot_to_svg.py +++ b/apple410/plot_to_svg.py @@ -158,10 +158,13 @@ class Plotter: except AttributeError: sys.stderr.write("Unrecognized command code {}\n".format(cmd_code)) -p = Plotter() + def read(self,inf): + for line in inf.readlines(): + line = line.strip() + p.process_cmd(line) -for line in sys.stdin.readlines(): - line = line.strip() - p.process_cmd(line) +if __name__=='__main__': + p = Plotter() + p.read(sys.stdin) + p.write(sys.stdout) -p.write(sys.stdout)