How to use the omas.exceptions.CannotReadMEIException function in omas

To help you get started, we’ve selected a few omas examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github umd-mith / ema / Omas / omas / meiinfo.py View on Github external
"""Parse MEI file from text content using pymei / libmei."""
    try:
        parsed_mei = documentFromText(meitext)
    except ElementNotRegisteredException as ex:
        raise CannotReadMEIException(
            "The MEI File could not be read with this version of libmei. {0}"
            .format(ex.message))
    except FileReadFailureException as ex:
        raise CannotReadMEIException(
            "The MEI File was malformed and could not be read. {0}"
            .format(ex.message))
    except NoVersionFoundException as ex:
        raise CannotReadMEIException(
            "The MEI File could not be read: MEI version not specified.")
    except:
        raise CannotReadMEIException(
            "The MEI File could not be read for unknown reasons.")

    return parsed_mei
github umd-mith / ema / Omas / omas / meiinfo.py View on Github external
def read_MEI(meitext):
    """Parse MEI file from text content using pymei / libmei."""
    try:
        parsed_mei = documentFromText(meitext)
    except ElementNotRegisteredException as ex:
        raise CannotReadMEIException(
            "The MEI File could not be read with this version of libmei. {0}"
            .format(ex.message))
    except FileReadFailureException as ex:
        raise CannotReadMEIException(
            "The MEI File was malformed and could not be read. {0}"
            .format(ex.message))
    except NoVersionFoundException as ex:
        raise CannotReadMEIException(
            "The MEI File could not be read: MEI version not specified.")
    except:
        raise CannotReadMEIException(
            "The MEI File could not be read for unknown reasons.")

    return parsed_mei
github umd-mith / ema / Omas / omas / meiinfo.py View on Github external
def read_MEI(meitext):
    """Parse MEI file from text content using pymei / libmei."""
    try:
        parsed_mei = documentFromText(meitext)
    except ElementNotRegisteredException as ex:
        raise CannotReadMEIException(
            "The MEI File could not be read with this version of libmei. {0}"
            .format(ex.message))
    except FileReadFailureException as ex:
        raise CannotReadMEIException(
            "The MEI File was malformed and could not be read. {0}"
            .format(ex.message))
    except NoVersionFoundException as ex:
        raise CannotReadMEIException(
            "The MEI File could not be read: MEI version not specified.")
    except:
        raise CannotReadMEIException(
            "The MEI File could not be read for unknown reasons.")

    return parsed_mei
github umd-mith / ema / Omas / api.py View on Github external
def information(meipath):
    try:
        mei_as_text = get_external_mei(meipath)
    except CannotAccessRemoteMEIException as ex:
        return {"message": ex.message}, status.HTTP_400_BAD_REQUEST
    except UnknownMEIReadException as ex:
        return {"message": ex.message}, status.HTTP_500_INTERNAL_SERVER_ERROR

    try:
        parsed_mei = meiinfo.read_MEI(mei_as_text).getMeiDocument()
    except CannotReadMEIException as ex:
        # return a 500 server error with the exception message
        return {"message": ex.message}, status.HTTP_500_INTERNAL_SERVER_ERROR

    # it's possible that this will raise some exceptions too, so break it out.
    try:
        mus_doc_info = meiinfo.MusDocInfo(parsed_mei).get()
    except BadApiRequest as ex:
        return {"message": ex.message}, status.HTTP_500_INTERNAL_SERVER_ERROR

    return mus_doc_info