1.1 --- a/classhook.py Sun Nov 14 01:02:55 2004 +0100
1.2 +++ b/classhook.py Sun Nov 14 01:59:23 2004 +0100
1.3 @@ -6,6 +6,7 @@
1.4 import classfile, bytecode
1.5 import new
1.6
1.7 +"""
1.8 class ClassHooks(ihooks.Hooks):
1.9
1.10 "A filesystem hooks class providing information about supported files."
1.11 @@ -15,6 +16,7 @@
1.12 "Return the recognised suffixes."
1.13
1.14 return ihooks.Hooks.get_suffixes(self) + [(os.extsep + "class", "r", PY_SOURCE)]
1.15 +"""
1.16
1.17 class ClassLoader(ihooks.ModuleLoader):
1.18
1.19 @@ -26,7 +28,7 @@
1.20 return ihooks.ModuleLoader.find_module(self, name, path)
1.21 """
1.22
1.23 - def find_module_in_dir(self, name, dir):
1.24 + def find_module_in_dir(self, name, dir, allow_packages=1):
1.25
1.26 """
1.27 Find the module with the given 'name' in the given directory 'dir'.
1.28 @@ -35,12 +37,16 @@
1.29 from 'dir' and 'name' refers to a directory containing class files.
1.30 """
1.31
1.32 - dir = dir or "."
1.33 + result = ihooks.ModuleLoader.find_module_in_dir(self, name, dir, allow_packages)
1.34 + if result is not None:
1.35 + return result
1.36
1.37 # Provide a special name for the current directory.
1.38
1.39 if name == "__this__":
1.40 - path = dir
1.41 + path = "."
1.42 + elif dir is None:
1.43 + return None
1.44 else:
1.45 path = os.path.join(dir, name)
1.46
1.47 @@ -78,10 +84,15 @@
1.48 problem occurred in the import operation.
1.49 """
1.50
1.51 + #result = ihooks.ModuleLoader.load_module(self, name, stuff)
1.52 + #if result is not None:
1.53 + # return result
1.54 +
1.55 # Just go into the directory and find the class files.
1.56
1.57 file, filename, info = stuff
1.58 - print "*", file, filename, info
1.59 +
1.60 + print "Loading", file, filename, info
1.61
1.62 # Prepare a dictionary of globals.
1.63
1.64 @@ -124,7 +135,7 @@
1.65 )
1.66 """
1.67
1.68 -importer = ihooks.ModuleImporter(loader=ClassLoader(hooks=ClassHooks()))
1.69 +importer = ihooks.ModuleImporter(loader=ClassLoader(hooks=ihooks.Hooks()))
1.70 importer.install()
1.71
1.72 # vim: tabstop=4 expandtab shiftwidth=4