-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathget-package-list-diff-from-index
executable file
·65 lines (49 loc) · 1.47 KB
/
get-package-list-diff-from-index
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/python
# -*- coding: utf-8 -*-
import piksemel
import bz2
import sys
import os
def getXmlData(_file):
if os.path.exists(_file):
return piksemel.parse(_file)
elif os.path.exists("%s.bz2" % _file):
indexdata = bz2.decompress(file("%s.bz2" % _file).read())
return piksemel.parseString(indexdata)
else:
print "%s not found" % indexfile
sys.exit(1)
def parseXmlData(_index):
pkglist = []
hasSpecFile = _index.getTag("SpecFile")
if hasSpecFile:
for i in _index.tags("SpecFile"):
parent = i.getTag("Source")
pkglist.append(parent.getTagData("Name"))
else:
for parent in _index.tags("Package"):
pkglist.append(parent.getTagData("Name"))
pkglist.sort()
return pkglist
def getPackageList(indexfile):
xmldata = getXmlData(indexfile)
packages = parseXmlData(xmldata)
return packages
def printListDifference(list1, list2):
listdiff = filter(lambda x:x not in list1,list2)
for i in listdiff:
print i
def usage():
print "prints package differences in pisi index files"
print "usage: %s <old-index> <new-index>" % sys.argv[0]
print
sys.exit(0)
if __name__ == "__main__":
try:
indexOld = sys.argv[1]
indexNew = sys.argv[2]
except IndexError:
usage()
oldpackages = getPackageList(indexOld)
newpackages = getPackageList(indexNew)
printListDifference(oldpackages, newpackages)