46 for fileordir in path: |
46 for fileordir in path: |
47 if isdir(fileordir) and exists(join(fileordir, '__init__.py')): |
47 if isdir(fileordir) and exists(join(fileordir, '__init__.py')): |
48 subfiles = [join(fileordir, fname) for fname in listdir(fileordir)] |
48 subfiles = [join(fileordir, fname) for fname in listdir(fileordir)] |
49 _toload_info(subfiles, extrapath, _toload) |
49 _toload_info(subfiles, extrapath, _toload) |
50 elif fileordir[-3:] == '.py': |
50 elif fileordir[-3:] == '.py': |
51 modname = '.'.join(modpath_from_file(fileordir, extrapath)) |
51 modpath = modpath_from_file(fileordir, extrapath) |
|
52 # omit '__init__' from package's name to avoid loading that module |
|
53 # once for each name when it is imported by some other appobject |
|
54 # module. This supposes import in modules are done as:: |
|
55 # |
|
56 # from package import something |
|
57 # |
|
58 # not:: |
|
59 # |
|
60 # from package.__init__ import something |
|
61 # |
|
62 # which seems quite correct. |
|
63 if modpath[-1] == '__init__': |
|
64 modpath.pop() |
|
65 modname = '.'.join(modpath) |
52 _toload[0][modname] = fileordir |
66 _toload[0][modname] = fileordir |
53 _toload[1].append((fileordir, modname)) |
67 _toload[1].append((fileordir, modname)) |
54 return _toload |
68 return _toload |
55 |
69 |
56 |
70 |