pyEvents.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:Parallel.GAMIT 作者: demiangomez 项目源码 文件源码
def __init__(self, **kwargs):

        dict.__init__(self)

        self['EventDate'] = datetime.datetime.now()
        self['EventType'] = 'info'
        self['NetworkCode'] = None
        self['StationCode'] = None
        self['Year'] = None
        self['DOY'] = None
        self['Description'] = ''
        self['node'] = platform.node()
        self['stack'] = None

        module = inspect.getmodule(inspect.stack()[1][0])

        if module is None:
            self['module'] = inspect.stack()[1][3]  # just get the calling module
        else:
            self['module'] = module.__name__ + '.' + inspect.stack()[1][3]  # just get the calling module

        # initialize the dictionary based on the input
        for key in kwargs:
            if key not in self.keys():
                raise Exception('Provided key not in list of valid fields.')

            arg = kwargs[key]
            self[key] = arg

        if self['EventType'] == 'error':
            self['stack'] = ''.join(traceback.format_stack()[0:-1])  # print the traceback until just before this call
        else:
            self['stack'] = None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号