import os
import os.path
import sys
-import string
import re
rulesDir = "rules"
s = "<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 {
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."""
# 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]
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
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+")