import re
import glob
mod_path = 'modular/'
D = DiGraph()
all_py = glob.glob(mod_path+'*/all.py')
Vs = [x.split('/')[-2] for x in all_py]
for V in Vs:
D.add_vertex(V)
for V in Vs:
for s in glob.glob(mod_path+V+'/*'):
with open(s,'r') as f:
for l in f:
if re.match('from sage.modular', l):
B = l.split(' ')[1].split('.')[2]
if B in Vs:
D.add_edge(V, B)
show(D)
D.plot()