(self, root, conf, paths=None)
| 171 | } |
| 172 | |
| 173 | def __init__(self, root, conf, paths=None): |
| 174 | self.conf = conf = SimpleNamespace(**{**self.default_conf, **conf}) |
| 175 | self.root = root |
| 176 | |
| 177 | if paths is None: |
| 178 | paths = [] |
| 179 | for g in conf.globs: |
| 180 | paths += glob.glob( |
| 181 | (Path(root) / '**' / g).as_posix(), recursive=True) |
| 182 | if len(paths) == 0: |
| 183 | raise ValueError(f'Could not find any image in root: {root}.') |
| 184 | paths = sorted(set(paths)) |
| 185 | self.names = [Path(p).relative_to(root).as_posix() for p in paths] |
| 186 | logger.info(f'Found {len(self.names)} images in root {root}.') |
| 187 | else: |
| 188 | if isinstance(paths, (Path, str)): |
| 189 | self.names = parse_image_lists(paths) |
| 190 | elif isinstance(paths, collections.Iterable): |
| 191 | self.names = [p.as_posix() if isinstance(p, Path) else p |
| 192 | for p in paths] |
| 193 | else: |
| 194 | raise ValueError(f'Unknown format for path argument {paths}.') |
| 195 | |
| 196 | for name in self.names: |
| 197 | if not (root / name).exists(): |
| 198 | raise ValueError( |
| 199 | f'Image {name} does not exists in root: {root}.') |
| 200 | |
| 201 | def __getitem__(self, idx): |
| 202 | name = self.names[idx] |
nothing calls this directly
no test coverage detected