INNER CODE UNIT · Python

_open_db

skarndev/umodel_tools · umodel_tools/asset_db.py:25

    def _open_db(self, db_root_path: str) -> None:
        """Open the asset catalog database or create one on disk if does not exist.

        :param db_root_path: Asset root directory.
        :raises NotImplementedError: Raised when an unknown value is met while parsing the DB.
        """
        # create DB if not found
        if not os.path.exists(self._db_cats_path):
            os.makedirs(db_root_path, exist_ok=True)
            with open(self._db_cats_path, mode='w', encoding='utf-8') as f:
                f.writelines(f'VERSION {self._version}')

        # read DB from disk
        else:
            with open(self._db_cats_path, mode='r', encoding='utf-8') as f:
                for line in f.readlines():
                    # skip empty lines and comments
                    if not line or line.startswith('#') or line == '\n':

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…