blob: db87484f15b1d2cd2c00b97fad069856083e80b0 (
plain) (
blame)
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
|
#!/usr/bin/env python
from xml.dom.minidom import parse, Node, Document, parseString
import xml.parsers.expat
import os
import sys
try:
base = sys.argv[1]
except IndexError:
print "\nYou shoud give the full path to freedesktop.org.xml file"
print "e.g /usr/share/mime/packages/freedesktop.org.xml\n"
sys.exit (1)
dbfile = os.path.join(os.path.dirname(base), "freedesktop.org.xml")
permissionfile = "mime-types-permissions.xml"
def PrintIfAbsent(elements, elem):
for elem2 in elements:
if (elem.attributes["type"].value == elem2.attributes["type"].value):
return;
print ("<mime-type type=\"" + elem.attributes["type"].value + "\"/>");
def ExtractTypes():
dbdom = parse(dbfile)
permissiondom = parse(permissionfile);
dbelements = dbdom.getElementsByTagName("mime-type");
permissionelements = permissiondom.getElementsByTagName("mime-type");
print ("New types:");
print ("----------\n");
for elem in dbelements:
PrintIfAbsent(permissionelements, elem)
print ("\nTypes removed:");
print ("--------------\n");
for elem in permissionelements:
PrintIfAbsent(dbelements, elem)
dbdom.unlink();
permissiondom.unlink();
ExtractTypes();
|