Пример #1
0
 def __genson_eval__(self, context):
     size = resolve(self.size, context)
     if size != 1:
         return self.random.lognormal(resolve(self.mean, context),
                                      resolve(self.stdev, context),
                                      size=size)
     else:
         return self.random.lognormal(resolve(self.mean, context),
                                      resolve(self.stdev, context))
Пример #2
0
 def __genson_eval__(self, context):
     size = resolve(self.size, context)
     if size != 1:
         return self.random.uniform(resolve(self.min, context),
                                resolve(self.max, context),
                                size=size)
     else:
         return self.random.uniform(resolve(self.min, context),
                                    resolve(self.max, context))
Пример #3
0
    def __genson_eval__(self, context):
        resolved_args = []
        for a in self.args:
            resolved_args.append(resolve(a, context))

        resolved_kwargs = {}
        for k, v in self.kwargs.items():
            resolved_kwargs[k] = resolve(v, context)

        return self.fun(*resolved_args, **resolved_kwargs)
Пример #4
0
    def __genson_eval__(self, context):

        res_a = resolve(self.a, context)
        res_b = resolve(self.b, context)

        if self.op is '+':
            return res_a + res_b
        elif self.op is '-':
            return res_a - res_b
        elif self.op is '*':
            return res_a * res_b
        elif self.op is '/':
            return res_a / res_b
        elif self.op is '**':
            return res_a / res_b
Пример #5
0
    def __genson_eval__(self, context):

        res_a = resolve(self.a, context)
        if self.op is '+':
            return res_a
        if self.op is '-':
            return -res_a
Пример #6
0
def buildSources(cp):
    result = []
    for name in cp.sections():
        if name in ['common', 'global']:
            continue
        if not cp.has_option(name, 'class'):
            logger.warning(u'无效的歌曲源 %s ,没有配置 class', name)
            continue
        cla = cp.get(name, 'class')
        logger.debug(u'创建歌曲源 %s ,class = %s', name, cla)
        cla = util.resolve(cla)
        config = Config(name, cp)
        source = cla(config)
        result.append(source)
    return result
Пример #7
0
def init():
    config.init()
    cp = config.load()
    if cp.has_option('global', 'source_manager'):
        cla = cp.get('global', 'source_manager')
        logger.debug(cla)
        cla = resolve(cla)
    else:
        cla = source.SimpleSourceManager
    sm = cla(cp) 
    global player
    player = Player(sm)
    player.start()
    saveCookieThread = config.SaveCookie()
    saveCookieThread.start()
Пример #8
0
    def __genson_eval__(self, context):
        size = resolve(self.size, context)
        if size != 1:
            val = self.random.lognormal(resolve(self.mean, context),
                                        resolve(self.stdev, context),
                                        size=size)
        else:
            val = self.random.lognormal(resolve(self.mean, context),
                                        resolve(self.stdev, context))

        round = resolve(self.round, context)
        val = (np.ceil(val) // round).astype(np.int64) * round

        return val
Пример #9
0
        self.prioritary_plugins = []
        self.plugins_map = {}
        self.normal_plugins = []
        self.game = None
        for plugin in conf["plugins"]:
            self.add_plugin(plugin, reload=reload)

    def on_switch_in(self):
        if self.game:
            self.prioritary_plugins.remove(self.game)
            self.game.integrated = False
            self.game.enabled = True
            self.game = None

    def add_plugin(self, (name, module_name, enabled, integrated, prioritary), reload=False):
        module = util.resolve(module_name, reload=reload)
        loc = os.path.join(self.loc, name)
        try:
            os.makedirs(loc)
        except (IOError, OSError):
            pass
        cls = module.__fluostart__
        with util.indir(loc):
            inst = cls(self, name, loc)
        inst.integrated = integrated
        inst.enabled = enabled
        if prioritary:
            self.prioritary_plugins.append(inst)
        else:
            self.normal_plugins.append(inst)
        self.plugins_map[name] = (module_name, enabled, integrated, prioritary, inst)
Пример #10
0
 def __genson_eval__(self, context):
     return self.random.uniform(resolve(self.min, context),
                                resolve(self.max, context))
Пример #11
0
 def __genson_eval__(self, context):
     return self.random.normal(resolve(self.mean, context),
                               resolve(self.stdev, context))
Пример #12
0
 def __init__(self, conf):
     self.bots = []
     self.conf = conf
     self.protocol = util.resolve(conf['protocol'])