How to use the asn1tools.errors.Error function in asn1tools

To help you get started, we’ve selected a few asn1tools 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 eerimoq / asn1tools / asn1tools / errors.py View on Github external
"""Various exceptions/errors.

"""


class Error(Exception):
    """Base exception of all asn1tools exceptions.

    """


class CompileError(Error):
    """General ASN.1 compile error.

    """


class EncodeError(Error):
    """General ASN.1 encode error.

    """


class DecodeError(Error):
    """General ASN.1 decode error.

    """
github eerimoq / asn1tools / asn1tools / source / c / utils.py View on Github external
def get_member_checker(self, checker, name):
        for member in checker.members:
            if member.name == name:
                return member

        raise Error('No member checker found for {}.'.format(name))
github eerimoq / asn1tools / asn1tools / source / c / utils.py View on Github external
def error(self, message):
        return Error('{}: {}'.format(self.location_error(), message))
github eerimoq / asn1tools / asn1tools / source / rust / utils.py View on Github external
def error(self, message):
        return Error('{}: {}'.format(self.location_error(), message))
github eerimoq / asn1tools / asn1tools / codecs / __init__.py View on Github external
def restricted_utc_time_to_datetime(string):
    """Convert given restricted ASN.1 UTC time string `string` to a
    ``datetime.datetime`` object.

    """

    try:
        if string[-1] != 'Z':
            raise ValueError

        if len(string) != 13:
            raise ValueError

        return datetime.strptime(string[:-1], '%y%m%d%H%M%S')
    except (ValueError, IndexError):
        raise Error(
            "Expected a restricted UTC time string, but got '{}'.".format(
                string))
github eerimoq / asn1tools / asn1tools / parser.py View on Github external
from pyparsing import NotAny
from pyparsing import NoMatch
from pyparsing import QuotedString
from pyparsing import Combine
from pyparsing import ParseResults
from pyparsing import lineno

from .errors import Error


LOGGER = logging.getLogger(__name__)

EXTENSION_MARKER = None


class ParseError(Error):
    pass


class InternalParserError(Error):
    pass


class Tokens(object):

    def __init__(self, tag, tokens):
        self.tag = tag
        self.tokens = tokens

    def __getitem__(self, index):
        return self.tokens[index]
github eerimoq / asn1tools / asn1tools / source / rust / utils.py View on Github external
def get_member_checker(self, checker, name):
        for member in checker.members:
            if member.name == name:
                return member

        raise Error('No member checker found for {}.'.format(name))