# Path: girlfriend/exception.py
# class InvalidTypeException(GirlFriendSysException):
# 
#     """当接受的参数对象类型不符合预期时抛出此异常
#     """
#     pass
# 
# Path: girlfriend/data/exception.py
# class IndexOutOfBoundsException(GirlFriendSysException):
#     """索引越界时抛出此异常
#     """
#     pass
# 
# class MissingKeyException(GirlFriendSysException):
#     """在key-value的结构中，当key所引用的数据不存在时抛出此异常
#     """
#     pass
# 
# class InvalidSizeException(GirlFriendSysException):
#     """当目标集合的尺寸不符合要求时抛出此异常
#     """
#     pass
# 
# Path: girlfriend/util/lang.py
# def singleton(clazz):
#     def constructor(*args, **kws):
#     def __new__(cls, name, bases, attrs):
#         def getter(self, method_name):
#             def method(*args, **kws):
#     def register_delegates(delegate_methods, attrs):
#             def make_method(method_name):
#                 def method(self, *args, **kws):
# def args2fields(private=True):
#     def _field_name(arg_name):
#     def _args2fields(constructor):
#         def _wrapped_constuctor(self, *args, **kws):
# def get_default_args(o):
# def parse_context_var(context, variable_name):
#     def __getattr__(self, name):
#     def __setattr__(self, name, value):
#     def __getitem__(self, name):
#     def __setitem__(self, name, value):
#     def __init__(self, obj):
#     def __getattr__(self, attrname):
#     def __setattr__(self, attrname, value):
#     def __call__(self, *args, **kwds):
# class DelegateMeta(type):
#     class UnknownAttrError(GirlFriendSysException):
# class ObjDictModel(object):
# class SafeOperation(object):


import types
import prettytable
from abc import (
    ABCMeta,
    abstractproperty,
    abstractmethod
)
from girlfriend.exception import InvalidTypeException
from girlfriend.data.exception import (
    IndexOutOfBoundsException,
    MissingKeyException,
    InvalidSizeException
)
from girlfriend.util.lang import SequenceCollectionType
        """添加新的一行
        """
        if not isinstance(row, SequenceCollectionType):
            raise InvalidTypeException(u"新行的类型必须是list或者tuple类型")
        if len(row) > self.column_num:
            raise InvalidSizeException(
                u"新行的列数为{0}，表格的列数为{1}，两者不一致".format(
                    len(row),
                    self.column_num
                ))
        self._data.append(row)


class ListRow(BaseLocalRow):

    """基于List/Tuple实现的行对象
    """

    def __init__(self, row_list, mapping):
        BaseLocalRow.__init__(self, row_list, mapping)

    def __getitem__(self, key):
        if isinstance(key, (types.IntType, types.LongType)):
            return self._row[key]
        elif isinstance(key, (types.StringType)):
            index = self._mapping.get(key, None)
            if index is None:
                raise MissingKeyException(
                    u"找不到与key={}相关联的值".format(key))
            return self._row[index]

# Path: girlfriend/exception.py
# class InvalidTypeException(GirlFriendSysException):
# 
#     """当接受的参数对象类型不符合预期时抛出此异常
#     """
#     pass
# 
# Path: girlfriend/data/exception.py
# class IndexOutOfBoundsException(GirlFriendSysException):
#     """索引越界时抛出此异常
#     """
#     pass
# 
# class MissingKeyException(GirlFriendSysException):
#     """在key-value的结构中，当key所引用的数据不存在时抛出此异常
#     """
#     pass
# 
# class InvalidSizeException(GirlFriendSysException):
#     """当目标集合的尺寸不符合要求时抛出此异常
#     """
#     pass
# 
# Path: girlfriend/util/lang.py
# def singleton(clazz):
#     def constructor(*args, **kws):
#     def __new__(cls, name, bases, attrs):
#         def getter(self, method_name):
#             def method(*args, **kws):
#     def register_delegates(delegate_methods, attrs):
#             def make_method(method_name):
#                 def method(self, *args, **kws):
# def args2fields(private=True):
#     def _field_name(arg_name):
#     def _args2fields(constructor):
#         def _wrapped_constuctor(self, *args, **kws):
# def get_default_args(o):
# def parse_context_var(context, variable_name):
#     def __getattr__(self, name):
#     def __setattr__(self, name, value):
#     def __getitem__(self, name):
#     def __setitem__(self, name, value):
#     def __init__(self, obj):
#     def __getattr__(self, attrname):
#     def __setattr__(self, attrname, value):
#     def __call__(self, *args, **kwds):
# class DelegateMeta(type):
#     class UnknownAttrError(GirlFriendSysException):
# class ObjDictModel(object):
# class SafeOperation(object):


# Path: girlfriend/data/table.py
import types
import prettytable
from abc import (
    ABCMeta,
    abstractproperty,
    abstractmethod
)
from girlfriend.exception import InvalidTypeException
from girlfriend.data.exception import (
    IndexOutOfBoundsException,
    MissingKeyException,
    InvalidSizeException
)
from girlfriend.util.lang import SequenceCollectionType

        """添加新的一行
        """
        if not isinstance(row, SequenceCollectionType):
            raise InvalidTypeException(u"新行的类型必须是list或者tuple类型")
        if len(row) > self.column_num:
            raise InvalidSizeException(
                u"新行的列数为{0}，表格的列数为{1}，两者不一致".format(
                    len(row),
                    self.column_num
                ))
        self._data.append(row)


class ListRow(BaseLocalRow):

    """基于List/Tuple实现的行对象
    """

    def __init__(self, row_list, mapping):
        BaseLocalRow.__init__(self, row_list, mapping)

    def __getitem__(self, key):
        if isinstance(key, (types.IntType, types.LongType)):
            return self._row[key]
        elif isinstance(key, (types.StringType)):
            index = self._mapping.get(key, None)
            if index is None:
                raise MissingKeyException(
                    u"找不到与key={}相关联的值".format(key))
            return self._row[index]

        elif isinstance(key, SequenceCollectionType):