2009-12-02 10:06:58 +00:00
|
|
|
#!/usr/bin/env python
|
2009-10-20 10:52:23 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2008-06-16 07:24:04 +00:00
|
|
|
##############################################################################
|
2010-03-11 08:49:41 +00:00
|
|
|
#
|
2009-10-14 12:32:15 +00:00
|
|
|
# OpenERP, Open Source Management Solution
|
|
|
|
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
2008-06-16 07:24:04 +00:00
|
|
|
#
|
2008-11-03 18:27:16 +00:00
|
|
|
# This program is free software: you can redistribute it and/or modify
|
2009-10-14 12:32:15 +00:00
|
|
|
# it under the terms of the GNU Affero General Public License as
|
|
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
|
|
# License, or (at your option) any later version.
|
2008-06-16 07:24:04 +00:00
|
|
|
#
|
2008-11-03 18:27:16 +00:00
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2009-10-14 12:32:15 +00:00
|
|
|
# GNU Affero General Public License for more details.
|
2008-06-16 07:24:04 +00:00
|
|
|
#
|
2009-10-14 12:32:15 +00:00
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
2010-03-11 08:49:41 +00:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2008-06-16 07:24:04 +00:00
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
2009-01-20 10:42:02 +00:00
|
|
|
# TODO handle the case of zip modules
|
2006-12-07 13:41:40 +00:00
|
|
|
|
|
|
|
import os
|
2010-05-20 14:37:04 +00:00
|
|
|
import optparse
|
2007-08-02 12:09:30 +00:00
|
|
|
import sys
|
2008-05-29 05:25:36 +00:00
|
|
|
import glob
|
2007-08-02 12:09:30 +00:00
|
|
|
|
2011-05-11 10:34:55 +00:00
|
|
|
# TODO use the same function provided in openerp.modules
|
2010-04-27 08:22:52 +00:00
|
|
|
def load_information_from_description_file(module):
|
|
|
|
"""
|
|
|
|
:param module: The name of the module (sale, purchase, ...)
|
|
|
|
"""
|
|
|
|
for filename in ['__openerp__.py', '__terp__.py']:
|
|
|
|
description_file = os.path.join(module, filename)
|
|
|
|
if os.path.isfile(description_file):
|
|
|
|
return eval(file(description_file).read())
|
|
|
|
|
|
|
|
return {}
|
|
|
|
|
2010-05-20 14:37:04 +00:00
|
|
|
def get_valid_path(paths, module):
|
|
|
|
for path in paths:
|
|
|
|
full = os.path.join(path, module)
|
|
|
|
if os.path.exists(full):
|
|
|
|
return full
|
|
|
|
return None
|
2007-08-02 12:09:30 +00:00
|
|
|
|
2010-05-20 14:37:04 +00:00
|
|
|
parser = optparse.OptionParser(usage="%prog [options] [module1 [module2 ...]]")
|
|
|
|
parser.add_option("-p", "--addons-path", dest="path", help="addons directory", action="append")
|
|
|
|
(opt, args) = parser.parse_args()
|
2008-05-29 05:25:36 +00:00
|
|
|
|
2010-05-20 14:37:04 +00:00
|
|
|
modules = []
|
|
|
|
if not opt.path:
|
|
|
|
opt.path = ["."]
|
2006-12-07 13:41:40 +00:00
|
|
|
|
2010-05-20 14:37:04 +00:00
|
|
|
if not args:
|
|
|
|
for path in opt.path:
|
|
|
|
modules += map(os.path.dirname, glob.glob(os.path.join(path, '*', '__openerp__.py')))
|
|
|
|
modules += map(os.path.dirname, glob.glob(os.path.join(path, '*', '__terp__.py')))
|
|
|
|
else:
|
|
|
|
for module in args:
|
|
|
|
valid_path = get_valid_path(opt.path, module)
|
|
|
|
if valid_path:
|
|
|
|
modules.append(valid_path)
|
|
|
|
|
|
|
|
all_modules = set(map(os.path.basename, modules))
|
2006-12-07 13:41:40 +00:00
|
|
|
print 'digraph G {'
|
2007-08-02 12:09:30 +00:00
|
|
|
while len(modules):
|
2008-07-22 14:24:36 +00:00
|
|
|
f = modules.pop(0)
|
2010-05-20 14:37:04 +00:00
|
|
|
module_name = os.path.basename(f)
|
|
|
|
all_modules.add(module_name)
|
2010-04-27 08:22:52 +00:00
|
|
|
info = load_information_from_description_file(f)
|
2010-03-12 06:15:00 +00:00
|
|
|
if info.get('installable', True):
|
2010-05-20 14:37:04 +00:00
|
|
|
for name in info.get('depends',[]):
|
|
|
|
valid_path = get_valid_path(opt.path, name)
|
|
|
|
if name not in all_modules:
|
|
|
|
if valid_path:
|
|
|
|
modules.append(valid_path)
|
|
|
|
else:
|
|
|
|
all_modules.add(name)
|
|
|
|
print '\t%s [color=red]' % (name,)
|
|
|
|
print '\t%s -> %s;' % (module_name, name)
|
2006-12-07 13:41:40 +00:00
|
|
|
print '}'
|
2008-07-23 15:01:27 +00:00
|
|
|
|
|
|
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
|
|
|