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 # TODO use the same function provided in openerp.modules
31 def load_information_from_description_file(module):
33 :param module: The name of the module (sale, purchase, ...)
35 for filename in ['__openerp__.py', '__terp__.py']:
36 description_file = os.path.join(module, filename)
37 if os.path.isfile(description_file):
38 return eval(file(description_file).read())
42 def get_valid_path(paths, module):
44 full = os.path.join(path, module)
45 if os.path.exists(full):
49 parser = optparse.OptionParser(usage="%prog [options] [module1 [module2 ...]]")
50 parser.add_option("-p", "--addons-path", dest="path", help="addons directory", action="append")
51 (opt, args) = parser.parse_args()
59 modules += map(os.path.dirname, glob.glob(os.path.join(path, '*', '__openerp__.py')))
60 modules += map(os.path.dirname, glob.glob(os.path.join(path, '*', '__terp__.py')))
63 valid_path = get_valid_path(opt.path, module)
65 modules.append(valid_path)
67 all_modules = set(map(os.path.basename, modules))
71 module_name = os.path.basename(f)
72 all_modules.add(module_name)
73 info = load_information_from_description_file(f)
74 if info.get('installable', True):
75 for name in info.get('depends',[]):
76 valid_path = get_valid_path(opt.path, name)
77 if name not in all_modules:
79 modules.append(valid_path)
82 print '\t%s [color=red]' % (name,)
83 print '\t%s -> %s;' % (module_name, name)
86 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: