aboutsummaryrefslogtreecommitdiffstats
path: root/rdps.py
diff options
context:
space:
mode:
authorJaap Keuter <jaap.keuter@xs4all.nl>2009-03-12 07:04:46 +0000
committerJaap Keuter <jaap.keuter@xs4all.nl>2009-03-12 07:04:46 +0000
commit07b76038497488dd3e289c1a01cdd983070d387b (patch)
tree4f4bc231de53565eca37b30bfc16115b5e8d9739 /rdps.py
parent5f1b7e8f279bccd0a59cc53bec3c8a1a17c86c2e (diff)
Fix the output header, error reporting. Remove use of deprecated function.
svn path=/trunk/; revision=27708
Diffstat (limited to 'rdps.py')
-rw-r--r--rdps.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/rdps.py b/rdps.py
index 4c4ac04dc9..0ff2e55d8a 100644
--- a/rdps.py
+++ b/rdps.py
@@ -25,7 +25,7 @@
'''\
takes the file listed as the first argument and creates the file listed
-as the second argument. It takes a PostScript file and creates a C program
+as the second argument. It takes a PostScript file and creates a C source
with 2 functions:
print_ps_preamble()
print_ps_finale()
@@ -54,7 +54,6 @@ def start_code(fd, func):
fd.write("/* Created by %s. Do not edit! */\n" % script_name)
fd.write("void print_ps_%s(FILE *fd) {\n" % func)
-
def write_code(fd, raw_str):
ps_str = ps_clean_string(raw_str)
fd.write("\tfprintf(fd, \"%s\");\n" % ps_str)
@@ -62,9 +61,9 @@ def write_code(fd, raw_str):
def end_code(fd):
fd.write("}\n\n\n")
-def exit_err(msg=None):
+def exit_err(msg=None, *param):
if msg is not None:
- sys.stderr.write(msg)
+ sys.stderr.write(msg % param)
sys.exit(1)
# Globals
@@ -81,16 +80,18 @@ def main():
input = open(sys.argv[1], 'r')
output = open(sys.argv[2], 'w')
+ script_name = os.path.split(__file__)[-1]
+
output.write('''\
-/* Created by rdps.c. Do not edit! */
+/* Created by %s. Do not edit! */
#include <stdio.h>
#include "ps.h"
-''')
+''' % script_name)
- for line in input.xreadlines():
+ for line in input:
#line = line.rstrip()
if state is STATE_NULL:
if line.startswith("% ---- wireshark preamble start ---- %"):