def read_by_file_suffix()

in python/dpu_utils/utils/richpath.py [0:0]


    def read_by_file_suffix(self) -> Any:
        if self.path.endswith('.json.gz') or self.path.endswith('.json'):
            return self.read_as_json()
        if self.path.endswith('.jsonl.gz') or self.path.endswith('.jsonl'):
            return self.read_as_jsonl()
        if self.path.endswith('.pkl.gz') or self.path.endswith('.pkl'):
            return self.read_as_pickle()
        if self.path.endswith('.msgpack.gz') or self.path.endswith('.msgpack'):
            return self.read_as_msgpack()
        if self.path.endswith('.msgpack.l.gz') or self.path.endswith('.msgpack.l'):
            return self.read_as_msgpack_l()
        if self.path.endswith('.npy') or self.path.endswith('.npz'):
            return self.read_as_numpy()
        raise ValueError('File suffix must be .json, .json.gz, .pkl, .pkl.gz, .npy or .npz: %s' % self.path)