include nuoveXT icon theme in our project.
[lxde/lxde-common.git] / icon-theme / prevent-dup.py
CommitLineData
ecc608a0
HJYP
1#!/usr/bin/env python
2import os, sys
3os.system( 'fdupes -r nuoveXT2 > dups.txt' )
4
5excludes=['gnome', 'redhat', 'xfce', 'mozilla', 'thunderbird', 'evolution', 'rythmbox', 'stock', 'gtk']
6
7def is_not_generic( file ):
8 for exclude in excludes:
9 if file.find( exclude ) != -1:
10 return True
11
12 if os.path.basename(file).startswith('k'): # don't use kde icon
13 return True
14
15 return False
16
17def get_common_dir( path1, path2 ):
18
19 while path1 != '' and path2 != '':
20 path1 = os.path.dirname(path1)
21 path2 = os.path.dirname(path2)
22 if path1 == path2:
23 return path1+'/'
24
25 return ''
26
27def get_relative_path( file, relative_to ):
28 prefix = get_common_dir( file, relative_to )
29 prefix_len = len(prefix)
30 rest = relative_to[ prefix_len : ]
31 n = rest.count( '/' )
32 prefix=''
33 while n > 0:
34 prefix += '../'
35 n = n - 1
36 return prefix + relative_to[ prefix_len : ]
37
38
39files=[]
40f = open( 'dups.txt', 'r' )
41generic=''
42for line in f:
43 file = line.rstrip()
44 if file != '':
45 if generic != '' or is_not_generic( file ):
46 files.append( file )
47 else:
48 generic = file
49 else:
50 if generic == '':
51 generic = files[0]
52 del files[0]
53 for file in files:
54 print'rm -f %s' % file
55 print 'ln -s %s %s' % (get_relative_path(file, generic), file)
56 print
57 files=[]
58 generic=''
59
60f.close()