Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import logging
import os
from functools import reduce
from pathlib import Path
from typing import Union
import metview
import numpy as np
logger = logging.getLogger(__name__)
class Fieldset(metview.Fieldset):
def __init__(self, path):
raise PermissionError("Initilizing this class directly is not allowed.")
@property
def units(self):
return metview.grib_get_string(self, "units")
@classmethod
def from_path(cls, path: Union[Path, str]):
if isinstance(path, Path):
path = str(path)
if not os.path.exists(path):
raise IOError(f"File does not exist: {path}")
obj = metview.read(path)