# 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
    def __getattr__(self, key):
        return getattr(self._row, key)

    def __iter__(self):
        for i in xrange(0, len(self._mapping)):
            yield getattr(self._row, self._mapping[i])


class DictTable(BaseLocalTable):

    """DictTable的每一行都是一个字典对象
    """

    def __init__(self, name, titles, data=None):
        BaseLocalTable.__init__(self, name, titles, data, DictRow)

    def _gen_mapping(self):
        return [title.name for title in self._titles]

    def cell(self, row_index, column_index):
        self._check_row_index(row_index)
        self._check_col_index(column_index)
        row = self._data[row_index]
        key = self._mapping(column_index)
        return row[key]

    def append(self, row):
        if not isinstance(row, types.DictType):
            raise InvalidTypeException(u"DictTable只能接受字典类型的行对象")
        if len(row) != self.column_num:

# 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

    def __getattr__(self, key):
        return getattr(self._row, key)

    def __iter__(self):
        for i in xrange(0, len(self._mapping)):
            yield getattr(self._row, self._mapping[i])


class DictTable(BaseLocalTable):

    """DictTable的每一行都是一个字典对象
    """

    def __init__(self, name, titles, data=None):
        BaseLocalTable.__init__(self, name, titles, data, DictRow)

    def _gen_mapping(self):
        return [title.name for title in self._titles]

    def cell(self, row_index, column_index):
        self._check_row_index(row_index)
        self._check_col_index(column_index)
        row = self._data[row_index]
        key = self._mapping(column_index)
        return row[key]

    def append(self, row):
        if not isinstance(row, types.DictType):
            raise InvalidTypeException(u"DictTable只能接受字典类型的行对象")
        if len(row) != self.column_num:

            raise InvalidSizeException(