# 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
# class AbstractTable(object):
# 
#     """抽象的Table接口
#        在构建新的Table结构和依赖Table的插件时,应尽量依赖于此约定展开工作
#     """
# 
#     __metaclass__ = ABCMeta
# 
#     def __init__(self):
#         pass
# 
#     @abstractproperty
#     def name(self):
#         """表格的名称
#         """
#         pass
# 
#     @abstractproperty
#     def titles(self):
#         """以可迭代对象的形式返回表格的列名
#         """
#         pass
# 
#     @abstractproperty
#     def row_num(self):
#         """表格行数
#         """
#         pass
# 
#     @abstractproperty
#     def column_num(self):
#         """表格列数
#         """
#         pass
# 
#     def __len__(self):
#         """表格的长度默认为行数
#         """
#         return self.row_num
# 
#     @abstractmethod
#     def row(self, index):
#         """获取某一行
#         """
#         pass
# 
#     @abstractmethod
#     def __getitem__(self, index):
#         """根据索引获取某一行
#         """
#         pass
# 
#     @abstractmethod
#     def append(self, row):
#         """添加行
#         """
#         pass
# 
#     @abstractmethod
#     def __iter__(self):
#         pass
# 
# Path: girlfriend/plugin/data.py
# class AbstractDataReader(AbstractDataHandler):
# 
#     __metaclass__ = ABCMeta
# 
#     def _handle_result(self, context, result):
#         """对最终结果进行包装
#         """
#         if self._result_wrapper is not None:
#             result = self._result_wrapper(result)
#         if self._variable:
#             context[self._variable] = result
#         return result


import xlrd
import time
import random
import types
import xlsxwriter
from StringIO import StringIO
from girlfriend.util.lang import (
    args2fields,
    SequenceCollectionType
)
from girlfriend.data.table import AbstractTable
from girlfriend.plugin.data import AbstractDataReader
            return workbook.add_worksheet(sheet_name)


class CellStyle(object):

    """单元格样式"""

    def __init__(self, selector, style_dict):
        self._selector = selector
        self._style_dict = style_dict
        self._formatter = None

    def match(self, row_index, column_index):
        if isinstance(self._selector, types.FunctionType):
            return self._selector(row_index, column_index)
        elif isinstance(self._selector, int):
            return row_index == self._selector
        elif isinstance(self._selector, SequenceCollectionType):
            row_condition, column_condition = self._selector
            row_matched, column_matched = (
                self._match(row_index, row_condition),
                self._match(column_index, column_condition)
            )
            return row_matched and column_matched

    def _match(self, index, condition):
        if condition is None:
            return True
        if isinstance(condition, int):
            return index == condition

# 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
# class AbstractTable(object):
# 
#     """抽象的Table接口
#        在构建新的Table结构和依赖Table的插件时,应尽量依赖于此约定展开工作
#     """
# 
#     __metaclass__ = ABCMeta
# 
#     def __init__(self):
#         pass
# 
#     @abstractproperty
#     def name(self):
#         """表格的名称
#         """
#         pass
# 
#     @abstractproperty
#     def titles(self):
#         """以可迭代对象的形式返回表格的列名
#         """
#         pass
# 
#     @abstractproperty
#     def row_num(self):
#         """表格行数
#         """
#         pass
# 
#     @abstractproperty
#     def column_num(self):
#         """表格列数
#         """
#         pass
# 
#     def __len__(self):
#         """表格的长度默认为行数
#         """
#         return self.row_num
# 
#     @abstractmethod
#     def row(self, index):
#         """获取某一行
#         """
#         pass
# 
#     @abstractmethod
#     def __getitem__(self, index):
#         """根据索引获取某一行
#         """
#         pass
# 
#     @abstractmethod
#     def append(self, row):
#         """添加行
#         """
#         pass
# 
#     @abstractmethod
#     def __iter__(self):
#         pass
# 
# Path: girlfriend/plugin/data.py
# class AbstractDataReader(AbstractDataHandler):
# 
#     __metaclass__ = ABCMeta
# 
#     def _handle_result(self, context, result):
#         """对最终结果进行包装
#         """
#         if self._result_wrapper is not None:
#             result = self._result_wrapper(result)
#         if self._variable:
#             context[self._variable] = result
#         return result


# Path: girlfriend/plugin/excel.py
import xlrd
import time
import random
import types
import xlsxwriter
from StringIO import StringIO
from girlfriend.util.lang import (
    args2fields,
    SequenceCollectionType
)
from girlfriend.data.table import AbstractTable
from girlfriend.plugin.data import AbstractDataReader

            return workbook.add_worksheet(sheet_name)


class CellStyle(object):

    """单元格样式"""

    def __init__(self, selector, style_dict):
        self._selector = selector
        self._style_dict = style_dict
        self._formatter = None

    def match(self, row_index, column_index):
        if isinstance(self._selector, types.FunctionType):
            return self._selector(row_index, column_index)
        elif isinstance(self._selector, int):
            return row_index == self._selector
        elif isinstance(self._selector, SequenceCollectionType):
            row_condition, column_condition = self._selector
            row_matched, column_matched = (
                self._match(row_index, row_condition),
                self._match(column_index, column_condition)
            )
            return row_matched and column_matched

    def _match(self, index, condition):
        if condition is None:
            return True
        if isinstance(condition, int):
            return index == condition

        elif isinstance(condition, SequenceCollectionType):