# Path: pgp/exceptions.py
# class RegexValueError(InvalidSignatureSubpacket):
#     """This regular expression signature subpacket contains an invalid
#     expression.
#     """
# 
#     def __init__(self, position, string, unterminated=False):
#         if unterminated:
#             position -= 1
#         self.position = position
#         self.string = string
# 
#     def __str__(self):
#         return 'Invalid character at position {0}\n{1}\n{2}^'.format(
#                     self.position, self.string, ' ' * self.position
#                     )


import re
from pgp.exceptions import RegexValueError
                piece.atom = current
            elif isinstance(current, Atom):
                if current.complete:
                    current.piece.complete = True
                    branch = current.piece.branch
                    piece = Piece(branch)
                    branch.pieces.append(piece)
                    current = Atom(piece)
                    piece.atom = current

            current.content += (tok)

    if (
            valid and
            (isinstance(current, Range) or isinstance(current, Group))
            and not current.complete
        ):

        unterminated = True

    if not valid:
        tokens.insert(0, tok)
    return unterminated, valid, str(root)


def validate_subpacket_regex(re_str):
    tokens = re_tokenizer.findall(re_str)
    unterminated, valid, valid_portion = \
        validate_partial_subpacket_regex(tokens)
    if unterminated:

# Path: pgp/exceptions.py
# class RegexValueError(InvalidSignatureSubpacket):
#     """This regular expression signature subpacket contains an invalid
#     expression.
#     """
# 
#     def __init__(self, position, string, unterminated=False):
#         if unterminated:
#             position -= 1
#         self.position = position
#         self.string = string
# 
#     def __str__(self):
#         return 'Invalid character at position {0}\n{1}\n{2}^'.format(
#                     self.position, self.string, ' ' * self.position
#                     )


# Path: pgp/regex.py
import re
from pgp.exceptions import RegexValueError

                piece.atom = current
            elif isinstance(current, Atom):
                if current.complete:
                    current.piece.complete = True
                    branch = current.piece.branch
                    piece = Piece(branch)
                    branch.pieces.append(piece)
                    current = Atom(piece)
                    piece.atom = current

            current.content += (tok)

    if (
            valid and
            (isinstance(current, Range) or isinstance(current, Group))
            and not current.complete
        ):

        unterminated = True

    if not valid:
        tokens.insert(0, tok)
    return unterminated, valid, str(root)


def validate_subpacket_regex(re_str):
    tokens = re_tokenizer.findall(re_str)
    unterminated, valid, valid_portion = \
        validate_partial_subpacket_regex(tokens)
    if unterminated:

        raise RegexValueError(len(valid_portion), re_str, unterminated=True)