home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 1.5)
-
- '''macmodulefinder - Find modules used in a script. Only slightly
- mac-specific, really.'''
- import sys
- import os
- import directives
-
- try:
- import modulefinder
- except ImportError:
- _FREEZEDIR = os.path.join(sys.prefix, ':Tools:freeze')
- sys.path.insert(0, _FREEZEDIR)
- import modulefinder
-
- MAC_INCLUDE_MODULES = [
- 'site',
- 'exceptions']
- MAC_MAYMISS_MODULES = [
- 'posix',
- 'os2',
- 'nt',
- 'ntpath',
- 'dos',
- 'dospath',
- 'win32api',
- 'nturl2path',
- 'pwd',
- 'sitecustomize']
- Missing = 'macmodulefinder.Missing'
-
- class Module(modulefinder.Module):
-
- def gettype(self):
- '''Return type of module'''
- if self.__path__:
- return 'package'
-
- if self.__code__:
- return 'module'
-
- if self.__file__:
- return 'dynamic'
-
- return 'builtin'
-
-
-
- class ModuleFinder(modulefinder.ModuleFinder):
-
- def add_module(self, fqname):
- if self.modules.has_key(fqname):
- return self.modules[fqname]
-
- self.modules[fqname] = m = Module(fqname)
- return m
-
-
-
- def process(program, modules = [], module_files = [], debug = 0):
- error = []
- modules = modules + MAC_INCLUDE_MODULES
- (extra_modules, exclude_modules, extra_path) = directives.findfreezedirectives(program)
- for m in extra_modules:
- pass
-
- path = sys.path[:]
- dir = os.path.dirname(program)
- path[0] = dir
- path = extra_path + path
- modfinder = ModuleFinder(path, excludes = exclude_modules, debug = debug)
- for m in modules:
- modfinder.import_hook(m)
-
- for m in module_files:
- modfinder.load_file(m)
-
- modfinder.run_script(program)
- module_dict = modfinder.modules
- maymiss = exclude_modules + MAC_MAYMISS_MODULES
- for m in modfinder.badmodules.keys():
- pass
-
- for m in sys.builtin_module_names:
- if m in ('__main__', '__builtin__'):
- pass
- elif not module_dict.has_key(m):
- if debug > 0:
- print 'Unused', m
-
- elif module_dict[m].gettype() != 'builtin':
- if debug > 0:
- print 'Conflict', m
-
-
-
- if error:
- raise Missing, error
-
- return module_dict
-
-