from .ClusterFile import ClusterFile
from .RawFile import RawFile
from pathlib import Path


def open_file(fname):
    """Convenience function to open files"""
    fname = Path(fname)
    if fname.suffix == '.clust':
        return ClusterFile(fname)
    elif fname.suffix == '.json':
        return RawFile(fname)
    else:
        raise ValueError('unsupported file type')