~marrakis/openobject-server/python-lib

« back to all changes in this revision

Viewing changes to openobject/server/addons/module_graph.py

  • Committer: Mathieu Leduc-Hamel
  • Date: 2010-02-11 20:36:24 UTC
  • Revision ID: mlhamel@arak4-20100211203624-4331pfj1xb8qtzw8
[IMP] New pythonic way to organise the code. Everything is under the package openobject.server and everything is refering to that. Now needed to clean again setup.py

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
# -*- coding: utf-8 -*-
 
3
##############################################################################
 
4
#    
 
5
#    OpenERP, Open Source Management Solution
 
6
#    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
 
7
#
 
8
#    This program is free software: you can redistribute it and/or modify
 
9
#    it under the terms of the GNU Affero General Public License as
 
10
#    published by the Free Software Foundation, either version 3 of the
 
11
#    License, or (at your option) any later version.
 
12
#
 
13
#    This program is distributed in the hope that it will be useful,
 
14
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
#    GNU Affero General Public License for more details.
 
17
#
 
18
#    You should have received a copy of the GNU Affero General Public License
 
19
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.     
 
20
#
 
21
##############################################################################
 
22
 
 
23
# TODO handle the case of zip modules
 
24
 
 
25
import os
 
26
import sys
 
27
import glob
 
28
 
 
29
if len(sys.argv) == 2 and (sys.argv[1] in ['-h', '--help']):
 
30
    print >>sys.stderr, 'Usage: module_graph.py [module1 module2 module3]\n\tWhen no module is specified, all modules in current directory are used'
 
31
    sys.exit(1)
 
32
 
 
33
modules = sys.argv[1:]
 
34
if not len(modules):
 
35
    modules = map(os.path.dirname, glob.glob(os.path.join('*', '__terp__.py')))
 
36
 
 
37
done = []
 
38
 
 
39
print 'digraph G {'
 
40
while len(modules):
 
41
    f = modules.pop(0)
 
42
    done.append(f)
 
43
    if os.path.isfile(os.path.join(f,"__terp__.py")):
 
44
        info=eval(file(os.path.join(f,"__terp__.py")).read())
 
45
        if info.get('installable', True):
 
46
            for name in info['depends']:
 
47
                if name not in done+modules:
 
48
                    modules.append(name)
 
49
                if not os.path.exists(name):
 
50
                    print '\t%s [color=red]' % (name,)
 
51
                print '\t%s -> %s;' % (f, name)
 
52
print '}'
 
53
 
 
54
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
 
55