From 795a20b8947a97e74d4c48796c0c83491249cc23 Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Tue, 9 Sep 2014 00:48:51 +0200 Subject: [PATCH] Make omkbuild Python 3 compatible --- omkbuild.py | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/omkbuild.py b/omkbuild.py index f409563..b1c0a12 100755 --- a/omkbuild.py +++ b/omkbuild.py @@ -39,7 +39,6 @@ from optparse import OptionParser import os import os.path import sys -import string import re rulesDir = "rules" @@ -136,15 +135,15 @@ class Snippet: s = "" % self.name return s - def __cmp__(self, other): - ret = cmp(self.name, other.name) - if ret != 0: return ret - ret = cmp(self.legal, other.legal) - if ret != 0: return ret - ret = cmp(self.doc, other.doc) - if ret != 0: return ret - ret = cmp(self.code, other.code) - return ret + def __eq__(self, other): + return \ + self.name == other.name and \ + self.legal == other.legal and \ + self.doc == other.doc and \ + self.code == other.code + + def __ne__(self, other): + return not self == other def __getitem__(self, key): return { @@ -179,8 +178,11 @@ class Snippets: def __iter__(self): return iter(self._order) - def __cmp__(self, other): - return cmp(self._snippets, other._snippets) + def __eq__(self, other): + return self._snippets == other._snippets + + def __ne__(self, other): + return not self == other def loadFromFiles(self, fnames): """Reads the snippets from several files and adds them to itself.""" @@ -241,9 +243,9 @@ class MakefileRules(LineList): # Add this line to rules if addMarker: if addMarker==1: - line = string.rstrip(line).ljust(80)+" #OMK:%s@%s\n"%(filename,baseFileName) + line = line.rstrip().ljust(80)+" #OMK:%s@%s\n"%(filename,baseFileName) elif addMarker==2: - line = string.rstrip(line).ljust(80)+" #OMK:%s\n"%(filename) + line = line.rstrip().ljust(80)+" #OMK:%s\n"%(filename) addMarker = 0 if not onlyLoadSnippets: self.rules += [line] @@ -261,7 +263,7 @@ class MakefileRules(LineList): for snip in self.snippets: lines = snip[type] if len(lines) == 0: continue - firstLine = string.rstrip(lines[0]) + firstLine = lines[0].rstrip() self.rules += [firstLine.ljust(80)+" #OMK:%s\n"%snip.name] self.rules += lines[1:] #self.rules += ['a'] # test error @@ -371,7 +373,7 @@ def splitRules(rulesFN, output): for snip in rules.snippets: if snip.name[0:2] == "__": continue - print snip.name + print(snip.name) f = None if output == "-": f = sys.stdout else: f = open(snip.name, "w+") -- 2.39.2