~dosage-dev/dosage/test-mode

« back to all changes in this revision

Viewing changes to admin/checksubmodules.py

  • Committer: ns
  • Date: 2009-12-01 06:47:33 UTC
  • Revision ID: ns@ww1aviationlinks.cjb.net-20091201064733-wqy9o7lggwhd36o3
repairĀ forĀ Lint

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
import sys, os
 
3
if os.sep + 'dosage' in os.path.abspath(sys.argv[0]):
 
4
    sys.path.insert(0, os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), os.pardir, os.pardir)))
 
5
 
 
6
import dosage.modules
 
7
from sets import Set as set
 
8
 
 
9
'''
 
10
Iterates through all the available comic modules, that implement a 'fetchSubmodules'
 
11
classmethod and a 'submodules' sequence, to determine what comics have been added or removed.
 
12
'''
 
13
 
 
14
def reprset(modulename, s):
 
15
    if not s:
 
16
        return ''
 
17
    return ',\n'.join(['  ' + repr(module) for module in s])
 
18
 
 
19
def main():
 
20
    done = []
 
21
 
 
22
    for moduleName in dosage.modules.items(dosage.modules.__path__[0]):
 
23
        module = dosage.modules.get(moduleName)
 
24
        parentModuleName = moduleName.split('/')[0]
 
25
        if parentModuleName not in done and hasattr(module, 'fetchSubmodules') and hasattr(module, 'submodules'):
 
26
            done.append(parentModuleName)
 
27
            existing = set(module.submodules)
 
28
            new = set(module.fetchSubmodules())
 
29
            print 'Added to %r:' % (parentModuleName,)
 
30
            print reprset(parentModuleName, new - existing)
 
31
            print 'Removed from %r:' % (parentModuleName,)
 
32
            print reprset(parentModuleName, existing - new)
 
33
 
 
34
if __name__ == '__main__':
 
35
    main()