|
@@ -10,14 +10,14 @@ from pycs.database.base import NamedBaseModel
|
|
from pycs.interfaces.LabelProvider import LabelProvider as LabelProviderInterface
|
|
from pycs.interfaces.LabelProvider import LabelProvider as LabelProviderInterface
|
|
|
|
|
|
|
|
|
|
-def __find_files(root: str, config_regex=re.compile(r'^configuration(\d+)?\.json$')):
|
|
|
|
|
|
+def _find_files(root: str, config_regex=re.compile(r'^configuration(\d+)?\.json$')):
|
|
# list folders in labels/
|
|
# list folders in labels/
|
|
for folder in Path(root).glob('*'):
|
|
for folder in Path(root).glob('*'):
|
|
# list files
|
|
# list files
|
|
for file_path in folder.iterdir():
|
|
for file_path in folder.iterdir():
|
|
|
|
|
|
# filter configuration files
|
|
# filter configuration files
|
|
- if not file_path.isfile():
|
|
|
|
|
|
+ if not file_path.is_file():
|
|
continue
|
|
continue
|
|
|
|
|
|
if config_regex.match(file_path.name) is None:
|
|
if config_regex.match(file_path.name) is None:
|
|
@@ -53,7 +53,7 @@ class LabelProvider(NamedBaseModel):
|
|
@classmethod
|
|
@classmethod
|
|
def discover(cls, root: Path):
|
|
def discover(cls, root: Path):
|
|
|
|
|
|
- for folder, conf_path in __find_files(root):
|
|
|
|
|
|
+ for folder, conf_path in _find_files(root):
|
|
with open(conf_path) as f:
|
|
with open(conf_path) as f:
|
|
config = json.load(f)
|
|
config = json.load(f)
|
|
|
|
|
|
@@ -84,7 +84,7 @@ class LabelProvider(NamedBaseModel):
|
|
configuration = json.load(configuration_file)
|
|
configuration = json.load(configuration_file)
|
|
|
|
|
|
# load code
|
|
# load code
|
|
- code_path = Path(self.root_folder, configuration['code']['module']).resolve()
|
|
|
|
|
|
+ code_path = str(Path(self.root_folder, configuration['code']['module']))
|
|
module_name = code_path.replace('/', '.').replace('\\', '.')
|
|
module_name = code_path.replace('/', '.').replace('\\', '.')
|
|
class_name = configuration['code']['class']
|
|
class_name = configuration['code']['class']
|
|
|
|
|