Coverage for sparkle/instance/__init__.py: 100%
8 statements
« prev ^ index » next coverage.py v7.6.4, created at 2024-11-05 14:48 +0000
« prev ^ index » next coverage.py v7.6.4, created at 2024-11-05 14:48 +0000
1"""This package provides instance set support for Sparkle."""
2from sparkle.instance.instances import \
3 MultiFileInstanceSet, FileInstanceSet, IterableFileInstanceSet, InstanceSet
4from pathlib import Path
7def Instance_Set(target: any) -> InstanceSet:
8 """The combined interface for all instance set types."""
9 if ((isinstance(target, Path)
10 and (target / MultiFileInstanceSet.instance_csv).exists())
11 or isinstance(target, list)):
12 return MultiFileInstanceSet(target)
13 elif (isinstance(target, Path) and target.is_dir()
14 and all([p.suffix in IterableFileInstanceSet.supported_filetypes
15 for p in target.iterdir()])):
16 return IterableFileInstanceSet(target)
17 return FileInstanceSet(target)