-#!/usr/bin/python
+#!/usr/bin/python3
# arekm, 2008
# remove
from __future__ import print_function
+import functools
import os
import re
import time
os.close(fd1)
os.close(fd2)
- l1 = rpm.versionCompare(h1, h2)
- l2 = rpm.versionCompare(h2, h1)
+ try:
+ l1 = rpm.versionCompare(h1, h2)
+ except ValueError:
+ l1 = -1
+ try:
+ l2 = rpm.versionCompare(h2, h1)
+ except ValueError:
+ l2 = -1
if l1 > 0 and l2 > 0:
return 0
def find_old(files):
- return sorted(files, compare)
+ return sorted(files, key=functools.cmp_to_key(compare))
files = {}
dupes = {}
name = m.group(1)
- if files.has_key(name):
- if dupes.has_key(name):
+ if name in files:
+ if name in dupes:
dupes[name].append(file)
else:
dupes[name] = [ files[name] ]