Ejemplo n.º 1
0
def write_config(config: str, path: str) -> bool:
    check = prompt(f"\n{config}\nDoes this look correct? y/N")
    if check is False:
        return False
    else:
        path = Path.cwd() / path
        with open(path, "w") as tomlfile:
            qtoml.dump(config, tomlfile)
        return True
Ejemplo n.º 2
0
def write_sample(sample, samplefiles):
    """ Write back sample data to disk according to samplefiles paths

    Arguments:
        sample (dict): a dictionary of np.ndarrays and dict
        samplefiles (dict): a dictionary of Path-objects corresponding to their respective
                            data in the sample dict
    """
    for part in sample:
        filepath = Path(samplefiles[part])
        part_type = part.split('_')[0]
        if part_type in {"image", "mask", "xyz"}:
            cv2.imwrite(str(filepath), sample[part])
        elif part_type in {"conf"}:
            with filepath.open('w') as fp:
                toml.dump(sample[part], fp)
        else:
            raise ValueError(f"{part} is either not a valid type or not yet implemented.")
Ejemplo n.º 3
0
def _save_toml(content: Any, output_filename: str = '-'):
    if output_filename == '-':
        qtoml.dump(content, sys.stdout)
    else:
        with open(output_filename, 'wt') as file_ptr:
            qtoml.dump(content, file_ptr, cls=_TomlDecoder)
Ejemplo n.º 4
0
 def dump_config(self):
     """ Dump current config, can be used for debugging.
     """
     with open(self.mod_cfg_path, "r+") as fp:
         qtoml.dump(self.cfg, fp)
         self.cfg = qtoml.load(fp)
Ejemplo n.º 5
0
Archivo: cfg.py Proyecto: snide/negi3wm
 def dump_config(self) -> None:
     """ Dump current config, can be used for debugging. """
     with open(self.i3_cfg_mod_path, "r+") as mod_cfg:
         print(self.cfg)
         qtoml.dump(self.cfg, mod_cfg)
         self.cfg = qtoml.load(mod_cfg)