<filename>src/mrsimulator/utils/importer.py
# -*- coding: utf-8 -*-
"""Utility function module."""
import json
from urllib.parse import urlparse

from csdmpy.dependent_variable.download import download_file_from_url


__author__ = "<NAME>"
__email__ = "<EMAIL>"


def import_json(filename):
    res = urlparse(filename)
    if res[0] not in ["file", ""]:
        filename = download_file_from_url(filename)
    with open(filename, "rb") as f:
        content = f.read()
        return json.loads(str(content, encoding="UTF-8"))

<filename>src/mrsimulator/utils/importer.py
# -*- coding: utf-8 -*-
"""Utility function module."""
import json
from urllib.parse import urlparse

from csdmpy.dependent_variable.download import download_file_from_url


__author__ = "<NAME>"
__email__ = "<EMAIL>"


def import_json(filename):
    res = urlparse(filename)
    if res[0] not in ["file", ""]:
        filename = download_file_from_url(filename)
    with open(filename, "rb") as f:
        content = f.read()
        return json.loads(str(content, encoding="UTF-8"))

# -*- coding: utf-8 -*- Utility function module.