Skip to content

Commit

Permalink
Fix raise
Browse files Browse the repository at this point in the history
  • Loading branch information
tukiains committed Apr 23, 2024
1 parent 58bc005 commit a68a146
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
3 changes: 2 additions & 1 deletion rpgpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"RPGFileError",
]

from rpgpy.data import RPGFileError, read_rpg
from rpgpy.data import read_rpg
from rpgpy.utils import RPGFileError

from .nc import rpg2nc, rpg2nc_multi, spectra2nc
from .spcutil import spectra2moments
7 changes: 1 addition & 6 deletions rpgpy/data.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@ from rpgpy import header as head
from rpgpy import utils
from rpgpy.metadata import METADATA


class RPGFileError(Exception):
"""Base class for exceptions in this module."""
def __init__(self, msg: str = "Problem with reading file"):
self.message = msg
super().__init__(self.message)
from rpgpy.utils import RPGFileError


def read_rpg(file_name: Path | str, rpg_names: bool = True) -> tuple[dict, dict]:
Expand Down
10 changes: 9 additions & 1 deletion rpgpy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
from numpy import ma


class RPGFileError(Exception):
"""Base class for exceptions in this module."""

def __init__(self, msg: str = "Problem with reading file"):
self.message = msg
super().__init__(self.message)


def get_current_time() -> str:
"""Returns current UTC time."""
return datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S")
Expand Down Expand Up @@ -100,7 +108,7 @@ def get_rpg_file_type(header: dict) -> tuple[int, float]:
if file_code == 889348:
return 1, 4.0
msg = f"Unknown file type. File code: {file_code}"
raise RuntimeError(msg)
raise RPGFileError(msg)


def isscalar(array) -> bool:
Expand Down

0 comments on commit a68a146

Please sign in to comment.