Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/users/genadmins.py
blob: a70d9b6e3a582219753548ece501543463fbc572 (plain)
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
#!/usr/bin/env python

import os, sys
import os.path
from stat import *

from jToolkit import prefs
from teampagegenerator import TeamPageGenerator

users = prefs.PrefsParser('/etc/pootle/users.prefs')
pootleprefs = prefs.PrefsParser('/etc/pootle/pootle.prefs')


def walktree(top, callback):
    '''recursively descend the directory tree rooted at top,
       calling the callback function for each regular file'''

    for f in os.listdir(top):
        pathname = os.path.join(top, f)
        mode = os.stat(pathname)[ST_MODE]
        if S_ISDIR(mode):
            # It's a directory, recurse into it
            walktree(pathname, callback)
        elif S_ISREG(mode):
            # It's a file, call the callback function
            callback(pathname)
        else:
            # Unknown file type, print a message
            print 'Skipping %s' % pathname

def visitfile(file):
    if file.endswith('prefs'):
        print '\n\n'
        langname = os.path.basename(os.path.dirname(file))
        fulllangname = getattr(pootleprefs.Pootle.languages, langname + '.fullname')
        print fulllangname + ':'

        f = prefs.PrefsParser(file)

        found_admin = 0
        if f.__hasattr__('rights'):
            for i in f.rights.iteritems():
                if i[1].find('admin') > -1:
                    print '\t' + getattr(users, i[0] + '.name').encode('utf-8')
                    found_admin = 1

        if found_admin == 0:
            print '\t' + 'NO ADMIN'


if __name__ == '__main__':
    walktree(sys.argv[1], visitfile)