#!/usr/bin/env python """ capture.py Captures interaction from Inkscape into files in the temp directory """ import sys, tempfile, shutil outdir = tempfile.gettempdir() #capture the arguments f_args = open(outdir + '/ink_capture_args.txt', 'w') f_args.write(" ".join(sys.argv) + '\n') f_args.close() ''' #capture STDIN #notice STDIN is empty, I wasn't expecting this f_in = open(outdir + '/ink_capture_stdin.txt', 'w') for line in sys.stdin: f_in.write(line) f_in.close() ''' #the final argument is the path of a temporary file #that contains the SVG document #capture that file svgfile = sys.argv[-1:][0] shutil.copy(svgfile, outdir + '/ink_capture_svgfile.svg') #write the svgfile back to stdout for Inkscape f_svg = open(svgfile, 'r') for line in f_svg: sys.stdout.write(line) f_svg.close()