2 # -*- coding: utf-8 -*-
3 ##############################################################################
5 # OpenERP, Open Source Management Solution
6 # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
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.
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.
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/>.
21 ##############################################################################
23 # TODO handle the case of zip modules
30 def load_information_from_description_file(module):
32 :param module: The name of the module (sale, purchase, ...)
34 for filename in ['__openerp__.py', '__terp__.py']:
35 description_file = os.path.join(module, filename)
36 if os.path.isfile(description_file):
37 return eval(file(description_file).read())
41 def get_valid_path(paths, module):
43 full = os.path.join(path, module)
44 if os.path.exists(full):
48 parser = optparse.OptionParser(usage="%prog [options] [module1 [module2 ...]]")
49 parser.add_option("-p", "--addons-path", dest="path", help="addons directory", action="append")
50 (opt, args) = parser.parse_args()
58 modules += map(os.path.dirname, glob.glob(os.path.join(path, '*', '__openerp__.py')))
59 modules += map(os.path.dirname, glob.glob(os.path.join(path, '*', '__terp__.py')))
62 valid_path = get_valid_path(opt.path, module)
64 modules.append(valid_path)
66 all_modules = set(map(os.path.basename, modules))
70 module_name = os.path.basename(f)
71 all_modules.add(module_name)
72 info = load_information_from_description_file(f)
73 if info.get('installable', True):
74 for name in info.get('depends',[]):
75 valid_path = get_valid_path(opt.path, name)
76 if name not in all_modules:
78 modules.append(valid_path)
81 print '\t%s [color=red]' % (name,)
82 print '\t%s -> %s;' % (module_name, name)
85 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: