コード例 #1
0
    def parser(value):
        if not value:
            raise GlomError("Value was not defined")

        split = value.split(spliton)
        if len(split) < 2:
            raise GlomError("Value did not have 2 or more elements")

        return split[-1] if last else split[0]
コード例 #2
0
    def parser(value):
        if not value:
            raise GlomError("Value was not defined")

        try:
            parsed = validate_email(value,
                                    check_deliverability=False,
                                    allow_empty_local=True)

            if selector == "domain":
                return parsed["domain"]

            return (first_name(parsed["local"]) if selector == "first_name"
                    else last_name(parsed["local"])).capitalize()
        except EmailNotValidError as e:
            raise GlomError(str(e))
コード例 #3
0
ファイル: test_error.py プロジェクト: justinvanwinkle/glom
def test_unfinalized_glomerror_repr():
    assert 'GlomError()' in repr(GlomError())
コード例 #4
0
def required(value):
    if not value:
        raise GlomError("Value was not defined")

    return value