Fix the resources load issue

The resources cannot be loaded correctly if the command
is not issued at the top level of the package.

Bug report: https://bugs.launchpad.net/ospurge/+bug/1693409

Change-Id: I14dd2b62b1c30de8aee451b851af02577ad61957
This commit is contained in:
rocky 2017-09-04 17:39:13 +10:00
parent 57481bc598
commit 36cf3d9c29
1 changed files with 3 additions and 1 deletions

View File

@ -13,6 +13,7 @@ import copy
import functools
import importlib
import logging
import os
import pkgutil
import re
@ -37,7 +38,8 @@ def get_resource_classes(resources: Optional[Iterable[str]]=None) -> List:
`resources` dir.
"""
iter_modules = pkgutil.iter_modules(
['ospurge/resources'], prefix='ospurge.resources.'
[os.path.join(os.path.dirname(__file__), 'resources')],
prefix='ospurge.resources.'
)
for (_, name, ispkg) in iter_modules:
if not ispkg: