equal
deleted
inserted
replaced
238 |
238 |
239 def _cube_pkgname(cube): |
239 def _cube_pkgname(cube): |
240 if not cube.startswith('cubicweb_'): |
240 if not cube.startswith('cubicweb_'): |
241 return 'cubicweb_' + cube |
241 return 'cubicweb_' + cube |
242 return cube |
242 return cube |
243 |
|
244 |
|
245 def _cube_modname(cube): |
|
246 modname = _cube_pkgname(cube) |
|
247 loader = pkgutil.find_loader(modname) |
|
248 if loader: |
|
249 return modname |
|
250 else: |
|
251 return 'cubes.' + cube |
|
252 |
243 |
253 |
244 |
254 def _expand_modname(modname, recursive=True): |
245 def _expand_modname(modname, recursive=True): |
255 """expand modules names `modname` if exists by recursively walking |
246 """expand modules names `modname` if exists by recursively walking |
256 submodules and subpackages and yield (submodname, filepath) including |
247 submodules and subpackages and yield (submodname, filepath) including |
764 modnames = [] |
755 modnames = [] |
765 for name in ('bootstrap', 'base', 'workflow', 'Bookmark'): |
756 for name in ('bootstrap', 'base', 'workflow', 'Bookmark'): |
766 modnames.append(('cubicweb', 'cubicweb.schemas.' + name)) |
757 modnames.append(('cubicweb', 'cubicweb.schemas.' + name)) |
767 for cube in reversed(self.cubes()): |
758 for cube in reversed(self.cubes()): |
768 for modname, filepath in _expand_modname( |
759 for modname, filepath in _expand_modname( |
769 '{0}.schema'.format(_cube_modname(cube)), |
760 '{0}.schema'.format(_cube_pkgname(cube)), |
770 recursive=False): |
761 recursive=False): |
771 modnames.append((cube, modname)) |
762 modnames.append((cube, modname)) |
772 if self.apphome: |
763 if self.apphome: |
773 apphome = realpath(self.apphome) |
764 apphome = realpath(self.apphome) |
774 for modname, filepath in _expand_modname( |
765 for modname, filepath in _expand_modname( |
1282 appobjects.insert(0, appobjects.pop(index)) |
1273 appobjects.insert(0, appobjects.pop(index)) |
1283 return appobjects |
1274 return appobjects |
1284 |
1275 |
1285 def appobjects_cube_modnames(self, cube): |
1276 def appobjects_cube_modnames(self, cube): |
1286 modnames = [] |
1277 modnames = [] |
1287 cube_modname = _cube_modname(cube) |
1278 cube_modname = _cube_pkgname(cube) |
1288 cube_submodnames = self._sorted_appobjects(self.cube_appobject_path) |
1279 cube_submodnames = self._sorted_appobjects(self.cube_appobject_path) |
1289 for name in cube_submodnames: |
1280 for name in cube_submodnames: |
1290 for modname, filepath in _expand_modname('.'.join([cube_modname, name])): |
1281 for modname, filepath in _expand_modname('.'.join([cube_modname, name])): |
1291 modnames.append(modname) |
1282 modnames.append(modname) |
1292 return modnames |
1283 return modnames |