INNER CODE UNIT · Python

save_db

skarndev/umodel_tools · umodel_tools/asset_db.py:74

    def save_db(self) -> None:
        """Save changes in the data base to disk.
        """
        if not os.path.exists(self._db_cats_path):
            os.makedirs(os.path.dirname(self._db_cats_path), exist_ok=True)

        with open(self._db_cats_path, mode='w', encoding='utf-8') as f:
            f.write(f"VERSION {self._version}\n")

            for uid, (full_path, simple_path) in self._catalogs.items():
                f.write(f"{uid}:{full_path}:{simple_path}\n")

        # write backup copy (required for Blender to not consider changes temporary)
        shutil.copyfile(self._db_cats_path, f"{self._db_cats_path}~")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…