# Path: docpie/error.py
# class DocpieError(Exception, DocpieException):
#     """Error in construction of usage-message by developer."""
# 
# class UnknownOptionExit(DocpieExit):
#     """Unknown options found in argv"""
# 
#     def __init__(self, message, option=None, inside=None):
#         super(UnknownOptionExit, self).__init__(message)
#         self.option = option
#         self.inside = inside
# 
# class AmbiguousPrefixExit(DocpieExit):
#     """Long option has an ambiguous prefix"""
#     def __init__(self, message, prefix=None, ambiguous=None):
#         super(AmbiguousPrefixExit, self).__init__(message)
#         self.prefix = prefix
#         self.ambiguous = ambiguous


import logging
from docpie.error import DocpieError, UnknownOptionExit, AmbiguousPrefixExit

    def current(self, offset=0):
        return self[offset] if len(self) > offset else None

    def insert(self, index, object, from_=None):
        if self.auto_dashes and '--' in self:
            dashes_index = self.index('--')
        else:
            dashes_index = float('inf')

        fine = True
        if (object != '-' and
                object.startswith('-') and
                not object.startswith('--')):
            if self.stdopt:
                flag = object[:2]
            else:
                flag = object
            fine = (flag in self.known)
            logger.debug('%s has flag %s, is known: %s', object, flag, fine)

        if (index <= dashes_index and fine or
                index > dashes_index or
                fine):
            logger.debug('insert %s into %s at %s', object, self, index)
            return super(Argv, self).insert(index, object)

        logger.debug('%s not in %s', flag, self.known)
        # self.error = 'Unknown option: %s.' % flag
        raise UnknownOptionExit('Unknown option: %s.' % flag,

# Path: docpie/error.py
# class DocpieError(Exception, DocpieException):
#     """Error in construction of usage-message by developer."""
# 
# class UnknownOptionExit(DocpieExit):
#     """Unknown options found in argv"""
# 
#     def __init__(self, message, option=None, inside=None):
#         super(UnknownOptionExit, self).__init__(message)
#         self.option = option
#         self.inside = inside
# 
# class AmbiguousPrefixExit(DocpieExit):
#     """Long option has an ambiguous prefix"""
#     def __init__(self, message, prefix=None, ambiguous=None):
#         super(AmbiguousPrefixExit, self).__init__(message)
#         self.prefix = prefix
#         self.ambiguous = ambiguous


# Path: docpie/tokens.py
import logging
from docpie.error import DocpieError, UnknownOptionExit, AmbiguousPrefixExit


    def current(self, offset=0):
        return self[offset] if len(self) > offset else None

    def insert(self, index, object, from_=None):
        if self.auto_dashes and '--' in self:
            dashes_index = self.index('--')
        else:
            dashes_index = float('inf')

        fine = True
        if (object != '-' and
                object.startswith('-') and
                not object.startswith('--')):
            if self.stdopt:
                flag = object[:2]
            else:
                flag = object
            fine = (flag in self.known)
            logger.debug('%s has flag %s, is known: %s', object, flag, fine)

        if (index <= dashes_index and fine or
                index > dashes_index or
                fine):
            logger.debug('insert %s into %s at %s', object, self, index)
            return super(Argv, self).insert(index, object)

        logger.debug('%s not in %s', flag, self.known)
        # self.error = 'Unknown option: %s.' % flag
        raise UnknownOptionExit('Unknown option: %s.' % flag,

                                option=flag,