"modulefinder" --- 스크립트에서 사용되는 모듈 찾기
**************************************************

**소스 코드:** Lib/modulefinder.py

======================================================================

이 모듈은 스크립트가 임포트 한 모듈 집합을 판단하는 데 사용할 수 있는
"ModuleFinder" 클래스를 제공합니다. "modulefinder.py"는 스크립트로 실
행될 수도 있습니다, 인자로 파이썬 스크립트의 파일 이름을 지정하면, 임
포트 된 모듈의 보고서가 인쇄됩니다.

modulefinder.AddPackagePath(pkg_name, path)

   지정된 *path*에서 *pkg_name* 패키지를 찾을 수 있음을 기록합니다.

modulefinder.ReplacePackage(oldname, newname)

   *oldname* 라는 이름의 모듈이 실제로는 *newname*라는 이름의 패키지라
   는 것을 지정할 수 있도록 합니다.

class modulefinder.ModuleFinder(path=None, debug=0, excludes=[], replace_paths=[])

   이 클래스는 스크립트가 임포트하는 모듈 집합을 판단하는
   "run_script()" 와 "report()" 메서드를 제공합니다. *path*는 모듈을
   검색할 디렉터리 리스트일 수 있습니다; 지정되지 않으면, "sys.path"가
   사용됩니다. *debug*는 디버깅 수준을 설정합니다; 값이 크면 클래스가
   수행 중인 작업에 대한 디버깅 메시지를 인쇄합니다. *excludes*는 분석
   에서 제외할 모듈 이름 리스트입니다. *replace_paths*는 모듈 경로에서
   교체될 "(oldpath, newpath)" 튜플의 리스트입니다.

   report()

      빠지거나 빠진 것으로 보이는 모듈뿐 아니라, 스크립트가 임포트하는
      모듈과 그들의 경로의 목록에 관한 보고서를 표준 출력으로 인쇄합니
      다.

   run_script(pathname)

      파이썬 코드를 포함하는, *pathname* 파일의 내용을 분석합니다.

   modules

      모듈 이름을 모듈에 매핑하는 딕셔너리. ModuleFinder의 사용 예를
      참조하십시오.


"ModuleFinder"의 사용 예
========================

나중에 분석할 스크립트 (bacon.py):

   import re, itertools

   try:
       import baconhameggs
   except ImportError:
       pass

   try:
       import guido.python.ham
   except ImportError:
       pass

bacon.py의 보고서를 출력하는 스크립트:

   from modulefinder import ModuleFinder

   finder = ModuleFinder()
   finder.run_script('bacon.py')

   print('Loaded modules:')
   for name, mod in finder.modules.items():
       print('%s: ' % name, end='')
       print(','.join(list(mod.globalnames.keys())[:3]))

   print('-'*50)
   print('Modules not imported:')
   print('\n'.join(finder.badmodules.keys()))

표본 출력(아키텍처에 따라 다를 수 있습니다):

   Loaded modules:
   _types:
   copyreg:  _inverted_registry,_slotnames,__all__
   re._compiler:  isstring,_sre,_optimize_unicode
   _sre:
   re._constants:  REPEAT_ONE,makedict,AT_END_LINE
   sys:
   re:  __module__,finditer,_expand
   itertools:
   __main__:  re,itertools,baconhameggs
   re._parser:  _PATTERNENDERS,SRE_FLAG_UNICODE
   array:
   types:  __module__,IntType,TypeType
   ---------------------------------------------------
   Modules not imported:
   guido.python.ham
   baconhameggs
