Skip to content
Snippets Groups Projects
Commit bf926512 authored by Simon Grasse's avatar Simon Grasse
Browse files

follow EM102 convention

parent 446ba0ce
Branches
Tags
2 merge requests!11Creation of first beta release version,!10change in metadata of notebook
...@@ -46,7 +46,8 @@ class toargridding_defaultLogging: ...@@ -46,7 +46,8 @@ class toargridding_defaultLogging:
Throws an exception if the name of the handler is already known. Throws an exception if the name of the handler is already known.
""" """
if name in self.registeredHandlers: if name in self.registeredHandlers:
raise ValueError(f"There is already a registered handler with the name {name}.") msg = f"There is already a registered handler with the name {name}."
raise ValueError(msg)
if formatter is not None: if formatter is not None:
handler.setFormatter(formatter) handler.setFormatter(formatter)
self.logger.addHandler(handler) self.logger.addHandler(handler)
...@@ -128,7 +129,8 @@ class toargridding_defaultLogging: ...@@ -128,7 +129,8 @@ class toargridding_defaultLogging:
""" """
sn = Path(scriptName) sn = Path(scriptName)
if not sn.is_file: if not sn.is_file:
raise ValueError(f"Expecting name to a script. {sn} is not a file.") msg = f"Expecting name to a script. {sn} is not a file."
raise ValueError(msg)
path = sn.parent / "log" path = sn.parent / "log"
path.mkdir(exist_ok=True) path.mkdir(exist_ok=True)
fn = path / f"{sn.stem}.log" fn = path / f"{sn.stem}.log"
......
...@@ -57,9 +57,8 @@ class TimeSample: ...@@ -57,9 +57,8 @@ class TimeSample:
@sampling.setter @sampling.setter
def sampling(self, sampling: str): def sampling(self, sampling: str):
if sampling not in ALLOWED_SAMPLING_VALUES: if sampling not in ALLOWED_SAMPLING_VALUES:
raise ValueError( msg = f"sampling: {sampling} is not in the list of supported samplings for toargridding: {ALLOWED_SAMPLING_VALUES}"
f"sampling: {sampling} is not in the list of supported samplings for toargridding: {ALLOWED_SAMPLING_VALUES}" raise ValueError(msg)
)
self._sampling = sampling self._sampling = sampling
def as_datetime_index(self) -> pd.DatetimeIndex: def as_datetime_index(self) -> pd.DatetimeIndex:
...@@ -145,7 +144,8 @@ class Metadata: ...@@ -145,7 +144,8 @@ class Metadata:
@statistic.setter @statistic.setter
def statistic(self, stat: str): def statistic(self, stat: str):
if stat not in STATISTICS_LIST: if stat not in STATISTICS_LIST:
raise ValueError(f"invalid statistic: {stat}") msg = f"invalid statistic: {stat}"
raise ValueError(msg)
self._statistic = stat self._statistic = stat
def get_id(self) -> str: def get_id(self) -> str:
...@@ -225,9 +225,8 @@ def get_global_attributes(metadata: Metadata) -> dict: ...@@ -225,9 +225,8 @@ def get_global_attributes(metadata: Metadata) -> dict:
if key not in dynamic_cf_attributes: if key not in dynamic_cf_attributes:
dynamic_cf_attributes[key] = value dynamic_cf_attributes[key] = value
else: else:
raise ValueError( msg = f'{key} is already has the value {dynamic_cf_attributes[key]}. Prohibited overriding with "{value}"!'
f'{key} is already has the value {dynamic_cf_attributes[key]}. Prohibited overriding with "{value}"!' raise ValueError(msg)
)
cf_attributes = dynamic_cf_attributes | global_cf_attributes cf_attributes = dynamic_cf_attributes | global_cf_attributes
return cf_attributes return cf_attributes
......
...@@ -70,7 +70,8 @@ class TOARVariable: ...@@ -70,7 +70,8 @@ class TOARVariable:
try: try:
return cls.get_from_name(name=name) return cls.get_from_name(name=name)
except ValueError: except ValueError:
raise ValueError(f"TOAR Database contains no variable with cf_standardname or name '{name}'") msg = f"TOAR Database contains no variable with cf_standardname or name '{name}'"
raise ValueError(msg)
@classmethod @classmethod
def get_from_cf_standardname(cls, standard_name: str) -> "TOARVariable": def get_from_cf_standardname(cls, standard_name: str) -> "TOARVariable":
...@@ -89,7 +90,8 @@ class TOARVariable: ...@@ -89,7 +90,8 @@ class TOARVariable:
for var in cls.vars: for var in cls.vars:
if var.standard_name == standard_name: if var.standard_name == standard_name:
return var return var
raise ValueError(f"TOAR Database contains no variable with cf_standardname {standard_name}") msg = f"TOAR Database contains no variable with cf_standardname {standard_name}"
raise ValueError(msg)
@classmethod @classmethod
def get_from_name(cls, name: str) -> "TOARVariable": def get_from_name(cls, name: str) -> "TOARVariable":
...@@ -108,7 +110,8 @@ class TOARVariable: ...@@ -108,7 +110,8 @@ class TOARVariable:
for var in cls.vars: for var in cls.vars:
if var.name == name: if var.name == name:
return var return var
raise ValueError(f"TOAR Database contains no variable {name}") msg = f"TOAR Database contains no variable {name}"
raise ValueError(msg)
@property @property
def toar_id(self): def toar_id(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment