Ir al contenido
Menú
Se marcó esta pregunta
3 Respuestas
11603 Vistas

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
Descartar

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

Autor

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

Mejor respuesta

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
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
3
jul 25
1979
3
may 25
3458
2
jun 25
4011
0
jun 21
2326
1
ago 24
3383