How to use the signac.common.configobj.__init__.ConfigObjError function in signac

To help you get started, we’ve selected a few signac 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 glotzerlab / signac / signac / common / configobj / __init__.py View on Github external
break

        assert all(isinstance(line, str) for line in content), repr(content)
        content = [line.rstrip('\r\n') for line in content]

        self._parse(content)
        # if we had any errors, now is the time to raise them
        if self._errors:
            if len(self._errors) > 1:
                msg = ["Parsing failed with {} errors.".format(len(self._errors))]
                for error in self._errors[:self.MAX_PARSE_ERROR_DETAILS]:
                    msg.append(str(error))
                if len(self._errors) > self.MAX_PARSE_ERROR_DETAILS:
                    msg.append("{} more error(s)!"
                               .format(len(self._errors) - self.MAX_PARSE_ERROR_DETAILS))
                error = ConfigObjError('\n    '.join(msg))
            else:
                error = self._errors[0]
            # set the errors attribute; it's a list of tuples:
            # (error_type, message, line_number)
            error.errors = self._errors
            # set the config attribute
            error.config = self
            raise error
        # delete private attributes
        del self._errors

        if configspec is None:
            self.configspec = None
        else:
            self._handle_configspec(configspec)
github glotzerlab / signac / signac / common / configobj / __init__.py View on Github external
IOError.__init__(self, 'reload failed, filename is not set.')


class DuplicateError(ConfigObjError):
    """
    The keyword or section specified already exists.
    """


class ConfigspecError(ConfigObjError):
    """
    An error occured whilst parsing a configspec.
    """


class InterpolationError(ConfigObjError):
    """Base class for the two interpolation errors."""


class InterpolationLoopError(InterpolationError):
    """Maximum interpolation depth exceeded in string interpolation."""

    def __init__(self, option):
        InterpolationError.__init__(
            self,
            'interpolation loop detected in value "%s".' % option)


class RepeatSectionError(ConfigObjError):
    """
    This error indicates additional sections in a section with a
    ``__many__`` (repeated) section.
github glotzerlab / signac / signac / common / configobj / __init__.py View on Github external
It is a subclass of SyntaxError.
    """

    def __init__(self, message='', line_number=None, line=''):
        self.line = line
        self.line_number = line_number
        SyntaxError.__init__(self, message)


class NestingError(ConfigObjError):
    """
    This error indicates a level of nesting that doesn't match.
    """


class ParseError(ConfigObjError):
    """
    This error indicates that a line is badly written.
    It is neither a valid ``key = value`` line,
    nor a valid section marker line.
    """


class ReloadError(IOError):
    """
    A 'reload' operation failed.
    This exception is a subclass of ``IOError``.
    """

    def __init__(self):
        IOError.__init__(self, 'reload failed, filename is not set.')
github glotzerlab / signac / signac / common / configobj / __init__.py View on Github external
def _get_single_quote(self, value):
        if ("'" in value) and ('"' in value):
            raise ConfigObjError('Value cannot be safely quoted: {!r}'.format(value))
        elif '"' in value:
            quot = squot
        else:
            quot = dquot
        return quot
github glotzerlab / signac / signac / common / configobj / __init__.py View on Github external
def _get_triple_quote(value):
    """Helper for triple-quoting round-trips."""
    if ('"""' in value) and ("'''" in value):
        raise ConfigObjError('Value cannot be safely quoted: {!r}'.format(value))

    return tsquot if "'''" in value else tdquot
github glotzerlab / signac / signac / common / configobj / __init__.py View on Github external
class InterpolationError(ConfigObjError):
    """Base class for the two interpolation errors."""


class InterpolationLoopError(InterpolationError):
    """Maximum interpolation depth exceeded in string interpolation."""

    def __init__(self, option):
        InterpolationError.__init__(
            self,
            'interpolation loop detected in value "%s".' % option)


class RepeatSectionError(ConfigObjError):
    """
    This error indicates additional sections in a section with a
    ``__many__`` (repeated) section.
    """


class MissingInterpolationOption(InterpolationError):
    """A value specified for interpolation was missing."""

    def __init__(self, option):
        msg = 'missing option "%s" in interpolation.' % option
        InterpolationError.__init__(self, msg)


class UnreprError(ConfigObjError):
    """An error parsing in unrepr mode."""
github glotzerlab / signac / signac / common / configobj / __init__.py View on Github external
It is neither a valid ``key = value`` line,
    nor a valid section marker line.
    """


class ReloadError(IOError):
    """
    A 'reload' operation failed.
    This exception is a subclass of ``IOError``.
    """

    def __init__(self):
        IOError.__init__(self, 'reload failed, filename is not set.')


class DuplicateError(ConfigObjError):
    """
    The keyword or section specified already exists.
    """


class ConfigspecError(ConfigObjError):
    """
    An error occured whilst parsing a configspec.
    """


class InterpolationError(ConfigObjError):
    """Base class for the two interpolation errors."""


class InterpolationLoopError(InterpolationError):