Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3 ตอบกลับ
11780 มุมมอง

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

 

อวตาร
ละทิ้ง

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

ผู้เขียน

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

คำตอบที่ดีที่สุด

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

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
3
ก.ค. 25
2127
3
พ.ค. 25
3721
2
มิ.ย. 25
4196
0
มิ.ย. 21
2427
1
ส.ค. 24
3579