Skip to Content
Menu
This question has been flagged
3 Replies
10471 Views

Hi,

I needed to get the modules dependecies showing all levels

I wrote the following code that shows only the first level, assuming that I have the list of modules in the list 'modules'

I tried to show all dependencies using a recursive function with no success, could anyone help me accomplishing this

Here is my code

def get_dep(m):
    fl = main_path+m+'\\__openerp__.py'
    ret = []
    with open(fl,'r') as f:
        ret = eval(f.read())['depends']
    return ret

main_path = 'D:\\openerp-7.0-latest\\openerp-7.0-20140804-231303\\openerp\\addons\\'
modules = [
    'account_budget',
    'base',
    'purchase',   
]


for m in modules:
    print m
    for f in get_dep(m):
        print '         '+f

 

Avatar
Discard

The above code works fine it shows all the depends modules.

Author

It gave me the result : account_budget account base purchase stock process procurement but the 'stock' module depends on 'product', I need a help in tweaking the code so it prints all levels

Best Answer

Try the below code:-

ret = []

def get_dep(m):
global ret
fl = main_path+m+'\\__openerp__.py'
with open(fl,'r') as f:
ret = eval(f.read())['depends']
return ret

main_path = 'D:\\openerp-7.0-latest\\openerp-7.0-20140804-231303\\openerp\\addons\\'

modules = [
'account_budget',
'base',
'purchase',
]

def display(module):
for m in module:
print m
for f in get_dep(m):
print ' '+f
display(modules)



vals = [display(ret) for _ in range(3)] # It prints 3 level based on your need increase the value

Avatar
Discard
Related Posts Replies Views Activity
1
Jul 24
325
3
Jun 24
1248
2
Sep 23
1925
0
Jun 21
1121
1
Aug 24
1851