class ImposcActions: def __init__(self): self._cache = ImageCache() self._actions = ActionCollection() self._imposclib = ImposcIF() self._actions.add_functions(self._imposclib) def info(self) -> dict: return self._actions.info() def validate( self, args: Dict[str, str] ) -> Tuple[Dict[str, Optional[Union[int, float, str]]], List[str]]: validated = dict( map( lambda pair: (pair[0], self._actions.validate(pair[0], pair[1])), args.items())) outcome = list( map( lambda elem: f"Parameter {elem[0]} was supplied with an invalid value {args[elem[0]]}", filter(lambda pair: pair is None, validated.items()))) return validated, outcome def impacts(self, **kwargs) -> Path: errors = LibErrors() try: outfile = str(self._cache.offer_new_file()) if self._imposclib.impacts( outfile=outfile.encode('utf-8'), errorfile=errors.errorFile.encode('utf-8'), **kwargs): return outfile else: return errors.errorPath except TypeError as e: errors.put(f"{e}") return errors.errorPath def singularity_set(self, **kwargs) -> Path: errors = LibErrors() try: outfile = str(self._cache.offer_new_file()) if self._imposclib.singularity_set( outfile=outfile.encode('utf-8'), errorfile=errors.errorFile.encode('utf-8'), **kwargs): return outfile else: return errors.errorPath except TypeError as e: errors.put(f"{e}") return errors.errorPath def doa(self, **kwargs) -> Path: errors = LibErrors() try: outfile = str(self._cache.offer_new_file()) if self._imposclib.doa(outfile=outfile.encode('utf-8'), errorfile=errors.errorFile.encode('utf-8'), **kwargs): return outfile else: return errors.errorPath except TypeError as e: errors.put(f"{e}") return errors.errorPath
def add_to_cache(self, cache: ImageCache, file_size: int) -> str: file_name = cache.offer_new_file(extension='dat') self.fs.create_file(file_name, st_size=file_size) return file_name