当前位置: 首页>>代码示例>>Python>>正文


Python Plugin.constructor方法代码示例

本文整理汇总了Python中Plugin.Plugin.constructor方法的典型用法代码示例。如果您正苦于以下问题:Python Plugin.constructor方法的具体用法?Python Plugin.constructor怎么用?Python Plugin.constructor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Plugin.Plugin的用法示例。


在下文中一共展示了Plugin.constructor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Backend

# 需要导入模块: from Plugin import Plugin [as 别名]
# 或者: from Plugin.Plugin import constructor [as 别名]
class Backend(object):
    def __init__(self, opt):
        if 'plugin' not in opt:
            raise ValueError("no plugin selected")
        self.params = opt;
        self.backend = Plugin().load("plugins/Backend_"+opt['plugin']+".py")
        self.backend.constructor(self.params)

    def alreadyExist(self, key):
        res = self.backend.alreadyExist(key);
        if not isinstance(res, bool):
            raise TypeError('issues with the plugin: '+self.params['plugin']);
        else:
            return res;

    def put(self, key, obj):
        self.backend.put(key, obj);
开发者ID:mickael-kerjean,项目名称:crawlr,代码行数:19,代码来源:Backend.py

示例2: Logger

# 需要导入模块: from Plugin import Plugin [as 别名]
# 或者: from Plugin.Plugin import constructor [as 别名]
class Logger(object):
    def __init__(self, opt):
        if "plugin" not in opt:
            raise ValueError("no plugin selected")
        self.botId = self._pickAName()
        self.params = opt
        self.logger = Plugin().load("plugins/Logger_" + opt["plugin"] + ".py")
        self.logger.constructor(self.params)

    def log(self, message, opt={}):
        opt["original_message"] = message
        opt["botId"] = self.botId
        opt["datetime"] = datetime.today()

        if "level" not in opt:
            opt["level"] = "INFO"

        if "exception" in opt:
            exc_type, exc_value, exc_traceback = opt["exception"]
            lines = format_exception(exc_type, exc_value, exc_traceback)
            error = "".join(" " + line for line in lines) + "\n\n   "
            message += error + "\n   "

        self.logger.log(message, opt)

    def _pickAName(self):
        # taken from docker
        names = [
            "albattani",
            "allen",
            "almeida",
            "archimedes",
            "ardinghelli",
            "aryabhata",
            "austin",
            "babbage",
            "banach",
            "bardeen",
            "bartik",
            "bassi",
            "bell",
            "bhabha",
            "bhaskara",
            "blackwell",
            "bohr",
            "booth",
            "borg",
            "bose",
            "boyd",
            "brahmagupta",
            "brattain",
            "brown",
            "carson",
            "chandrasekhar",
            "colden",
            "cori",
            "cray",
            "curie",
            "darwin",
            "davinci",
            "dijkstra",
            "dubinsky",
            "easley",
            "einstein",
            "elion",
            "engelbart",
            "euclid",
            "euler",
            "fermat",
            "fermi",
            "feynman",
            "franklin",
            "galileo",
            "gates",
            "goldberg",
            "goldstine",
            "goldwasser",
            "golick",
            "goodall",
            "hamilton",
            "hawking",
            "heisenberg",
            "heyrovsky",
            "hodgkin",
            "hoover",
            "hopper",
            "hugle",
            "hypatia",
            "jang",
            "jennings",
            "jepsen",
            "joliot",
            "jones",
            "kalam",
            "kare",
            "keller",
            "khorana",
            "kilby",
            "kirch",
            "knuth",
#.........这里部分代码省略.........
开发者ID:mickael-kerjean,项目名称:crawlr,代码行数:103,代码来源:Logger.py


注:本文中的Plugin.Plugin.constructor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。