def get_dynamic_link_map(for_delete=False):
 if ((getattr(frappe.local, 'dynamic_link_map', None) == None) or frappe.flags.in_test):
  dynamic_link_map = {}
  for df in get_dynamic_links():
   meta = frappe.get_meta(df.parent)
   if meta.issingle:
    dynamic_link_map.setdefault(meta.name, []).append(df)
   else:
    links = frappe.db.sql_list('select distinct {options} from `tab{parent}`'.format(**df))
    for doctype in links:
     dynamic_link_map.setdefault(doctype, []).append(df)
  frappe.local.dynamic_link_map = dynamic_link_map
 return frappe.local.dynamic_link_map

def get_dynamic_link_map ( for_delete = False ) : if ( ( getattr ( frappe . local , 'dynamic_link_map' , None ) == None ) or frappe . flags . in_test ) : dynamic_link_map = { } for df in get_dynamic_links ( ) : meta = frappe . get_meta ( df . parent ) if meta . issingle : dynamic_link_map . setdefault ( meta . name , [ ] ) . append ( df ) else : links = frappe . db . sql_list ( 'select distinct {options} from `tab{parent}`' . format ( ** df ) ) for doctype in links : dynamic_link_map . setdefault ( doctype , [ ] ) . append ( df ) frappe . local . dynamic_link_map = dynamic_link_map return frappe . local . dynamic_link_map
build a map of all dynamically linked tables .