From 167d4df40b55f2e8b559a797bb93b09554a871d0 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Tue, 9 Nov 2010 16:10:52 +0000 Subject: Update Python scripts to work in Python 3. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2162 --- data/convert-icon | 7 ++----- man/docgen | 25 +++++++++++-------------- pkg/wince/wince-cabgen | 40 ++++++++++++++++++---------------------- 3 files changed, 31 insertions(+), 41 deletions(-) diff --git a/data/convert-icon b/data/convert-icon index c651bc7f..30fade20 100755 --- a/data/convert-icon +++ b/data/convert-icon @@ -1,6 +1,4 @@ -#!/usr/bin/python -# -# $Id: convert-icon 704 2006-10-18 00:51:11Z fraggle $ +#!/usr/bin/env python # # Copyright(C) 2005 Simon Howard # @@ -29,7 +27,7 @@ import re try: import Image except ImportError: - print "WARNING: Could not update %s. Please install the Python Imaging library." % sys.argv[2] + print("WARNING: Could not update %s. Please install the Python Imaging library." % sys.argv[2]) sys.exit(0) @@ -71,4 +69,3 @@ def convert_image(filename, output_filename): convert_image(sys.argv[1], sys.argv[2]) - diff --git a/man/docgen b/man/docgen index 73e8c852..bfde7aef 100755 --- a/man/docgen +++ b/man/docgen @@ -150,11 +150,8 @@ config_files = {} show_vanilla_options = True class Parameter: - def __cmp__(self, other): - if self.name < other.name: - return -1 - else: - return 1 + def __lt__(self, other): + return self.name < other.name def __init__(self): self.text = "" @@ -389,7 +386,7 @@ def print_template(template_file, content): try: for line in f: line = line.replace("@content", content) - print line.rstrip() + print(line.rstrip()) finally: f.close() @@ -407,7 +404,7 @@ def wiki_output(targets, template): read_wikipages() for t in targets: - print t.wiki_output() + print(t.wiki_output()) def plaintext_output(targets, template_file): @@ -419,13 +416,13 @@ def plaintext_output(targets, template_file): print_template(template_file, content) def usage(): - print "Usage: %s [-V] [-c filename ]( -m | -w | -p ) " \ - % sys.argv[0] - print " -c : Provide documentation for the specified configuration file" - print " -m : Manpage output" - print " -w : Wikitext output" - print " -p : Plaintext output" - print " -V : Don't show Vanilla Doom options" + print("Usage: %s [-V] [-c filename ]( -m | -w | -p ) " \ + % sys.argv[0]) + print(" -c : Provide documentation for the specified configuration file") + print(" -m : Manpage output") + print(" -w : Wikitext output") + print(" -p : Plaintext output") + print(" -V : Don't show Vanilla Doom options") sys.exit(0) # Parse command line diff --git a/pkg/wince/wince-cabgen b/pkg/wince/wince-cabgen index 97cba132..76845cf9 100755 --- a/pkg/wince/wince-cabgen +++ b/pkg/wince/wince-cabgen @@ -3,10 +3,11 @@ import os import re import shutil +import struct import sys import tempfile -CAB_HEADER = "MSCE" +CAB_HEADER = "MSCE".encode("ascii") ARCHITECTURES = { "shx-sh3": 103, @@ -58,16 +59,10 @@ DIR_VARIABLES = { } def write_int16(f, value): - b1 = value & 0xff - b2 = (value >> 8) & 0xff - f.write("%c%c" % (b1, b2)) + f.write(struct.pack("> 8) & 0xff - b3 = (value >> 16) & 0xff - b4 = (value >> 24) & 0xff - f.write("%c%c%c%c" % (b1, b2, b3, b4)) + f.write(struct.pack(" " % sys.argv[0] + print("Usage: %s " % sys.argv[0]) sys.exit(0) if sys.argv[1] == "-d": -- cgit v1.2.3