def py2dep(target, **kw):
log.info("<STR_LIT>", target)<EOL>dummy = DummyModule(target, **kw)<EOL>kw['<STR_LIT>'] = dummy.fname<EOL>syspath = sys.path[:]<EOL>syspath.insert(<NUM_LIT:0>, target.syspath_dir)<EOL>exclude = ['<STR_LIT>'] + kw.pop('<STR_LIT>', [])<EOL>log.debug("<STR_LIT>", exclude)<EOL>log.debug("<STR_LIT>", kw)<EOL>if '<STR_LIT>' in kw:<EOL><INDENT>del kw['<STR_LIT>']<EOL><DEDENT>mf = MyModuleFinder(<EOL>syspath,                <EOL>excludes=exclude,       <EOL>**kw<EOL>)<EOL>mf.debug = max(mf.debug, kw.get('<STR_LIT>', <NUM_LIT:0>))<EOL>log.debug("<STR_LIT>", os.getcwd())<EOL>log.debug("<STR_LIT>", dummy.fname, dummy.text())<EOL>mf.run_script(dummy.fname)<EOL>log.info("<STR_LIT>", json.dumps(dict(mf._depgraph), indent=<NUM_LIT:4>))<EOL>log.info("<STR_LIT>", json.dumps(mf.badmodules, indent=<NUM_LIT:4>))<EOL>if kw.get('<STR_LIT>'):<EOL><INDENT>for k, vdict in list(mf.badmodules.items()):<EOL><INDENT>if k not in mf._depgraph:<EOL><INDENT>mf._depgraph[k] = {}<EOL><DEDENT>for v in vdict:<EOL><INDENT>if v not in mf._depgraph['<STR_LIT:__main__>']:<EOL><INDENT>mf._depgraph['<STR_LIT:__main__>'][v] = None<EOL><DEDENT>if v in mf._depgraph:<EOL><INDENT>mf._depgraph[v][k] = None<EOL><DEDENT>else:<EOL><INDENT>mf._depgraph[v] = {k:None}<EOL><DEDENT><DEDENT><DEDENT><DEDENT>log.info("<STR_LIT>", json.dumps(dict(mf._depgraph), indent=<NUM_LIT:4>))<EOL>kw['<STR_LIT>'] = exclude<EOL>if kw.get('<STR_LIT>'):<EOL><INDENT>mf_depgraph = mf._depgraph<EOL>for k, v in list(mf._depgraph.items()):<EOL><INDENT>log.debug('<STR_LIT>', k, v)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>pylib = pystdlib()<EOL>mf_depgraph = {}<EOL>for k, v in list(mf._depgraph.items()):<EOL><INDENT>log.debug('<STR_LIT>', k, v)<EOL>if k in pylib:<EOL><INDENT>continue<EOL><DEDENT>vals = {vk: vv for vk, vv in list(v.items()) if vk not in pylib}<EOL>mf_depgraph[k] = vals<EOL><DEDENT><DEDENT>try:<EOL><INDENT>import yaml<EOL>log.info("<STR_LIT>",<EOL>yaml.dump(dict(mf_depgraph), default_flow_style=False))<EOL><DEDENT>except ImportError:<EOL><INDENT>log.info("<STR_LIT>", json.dumps(dict(mf_depgraph), indent=<NUM_LIT:4>))<EOL><DEDENT>return depgraph.DepGraph(mf_depgraph, mf._types, **kw)<EOL>
Calculate dependencies for ``pattern`` and return a DepGraph.