diff --git a/cosima_cookbook/__init__.py b/cosima_cookbook/__init__.py index f034d57..1c3cd75 100644 --- a/cosima_cookbook/__init__.py +++ b/cosima_cookbook/__init__.py @@ -3,13 +3,13 @@ Common tools for working with COSIMA model output """ -import pkg_resources - from . import database from . import querying from . import explore +from importlib.metadata import version, PackageNotFoundError + try: - __version__ = pkg_resources.get_distribution("cosima-cookbook").version -except Exception: - __version__ = "999" + __version__ = version("cosima-cookbook") +except PackageNotFoundError: + pass diff --git a/cosima_cookbook/database.py b/cosima_cookbook/database.py index 55999ce..4767b71 100644 --- a/cosima_cookbook/database.py +++ b/cosima_cookbook/database.py @@ -42,8 +42,6 @@ from .database_utils import * from .date_utils import format_datetime -logging.captureWarnings(True) - __DB_VERSION__ = 3 __DEFAULT_DB__ = "/g/data/ik11/databases/cosima_master.db" @@ -731,7 +729,8 @@ def find_files(searchdir, matchstring="*.nc", followsymlinks=False): ) if proc.returncode != 0: warnings.warn( - "Some files or directories could not be read while finding output files: %s", + "Some files or directories could not be read " + f"while finding output files: {proc.stderr[:200]}", UserWarning, )