def reloadConf(self, conf): qqGroup = conf.get('qqGroup', '') if not isstring(qqGroup): raise TYBizConfException(conf, 'qqGroup must be string') instruction = conf.get('instruction', '') if not isstring(instruction): raise TYBizConfException(conf, 'instruction must be string') mailWhenCanExchange = conf.get('mailWhenCanExchange', '') if not isstring(mailWhenCanExchange): raise TYBizConfException(conf, 'mailWhenCanExchange must be string') items = conf.get('items', []) if not isinstance(items, list): raise TYBizConfException(conf, 'items must be list') couponItemList = [] couponItemMap = {} for item in items: couponItem = CouponItem().decodeFromDict(item) if couponItem.couponId in couponItemMap: raise TYBizConfException(item, 'Duplicate couponId %s' % (couponItem.couponId)) couponItemList.append(couponItem) couponItemMap[couponItem.couponId] = couponItem self._couponItemList = couponItemList self._couponItemMap = couponItemMap self._qqGroup = qqGroup self._instruction = instruction self._mailWhenCanExchange = mailWhenCanExchange ftlog.debug('CouponService.reloadConf successed gameId=', self.gameId, 'couponItems=', self._couponItemMap.keys(), 'qqGroup=', self._qqGroup, 'instruction=', self._instruction, 'mailWhenCanExchange=', self._mailWhenCanExchange)
def decodeFromDict(self, d): self.conf = d self.level = d.get('level') if not isinstance(self.level, int): raise TYVipConfException(d, 'VipLevel.level must be int') self.name = d.get('name') if not isstring(self.name) or not self.name: raise TYVipConfException(d, 'VipLevel.name must be valid string') self.vipExp = d.get('exp') if not isinstance(self.vipExp, int): raise TYVipConfException(d, 'VipLevel.vipExt must be int') self.pic = d.get('pic', '') if not isstring(self.pic): raise TYVipConfException(d, 'VipLevel.pic must be string') self.desc = d.get('desc', []) if not isinstance(self.desc, list): raise TYVipConfException(d, 'VipLevel.desc must be list') if self.desc: for subDesc in self.desc: if not isstring(subDesc): raise TYVipConfException(d, 'VipLevel.desc.item must be string') rewardContent = d.get('rewardContent') if rewardContent: self.rewardContent = TYContentRegister.decodeFromDict(rewardContent) giftContent = d.get('giftContent') if giftContent: self.giftContent = TYContentRegister.decodeFromDict(giftContent) self.expDesc = d.get('expDesc', '') if not isstring(self.expDesc): raise TYVipConfException(d, 'VipLevel.expDesc must be string') self.nextVipLevelValue = d.get('nextLevel') if (self.nextVipLevelValue is not None and not isinstance(self.nextVipLevelValue, int)): raise TYVipConfException(d, 'VipLevel.nextVipLevelValue must be int') return self
def decodeFromDict(self, d): self.desc = d.get('desc', '') if not isstring(self.desc): raise TYBizConfException(d, 'FlipableCard.desc must be string') self.tips = d.get('tips', '') if not isstring(self.tips): raise TYBizConfException(d, 'FlipableCard.tips must be string') self._decodeFromDictImpl(d) return self
def decodeFromDict(self, d): self.name = d.get('name') if not isstring(self.name) or not self.name: raise TYBenefitsConfException(d, 'Privilege.name must be valid string') self.desc = d.get('desc', '') if not isstring(self.desc): raise TYBenefitsConfException(d, 'Privilege.desc must be string') self.sortValue = d.get('sort', 0) self._decodeFromDictImpl(d) return self
def decodeFromDict(self, d): self.conf = d self.kindId = d.get('kindId') if not isinstance(self.kindId, int): raise TYTaskConfException(d, 'task.kindId must be int') self.name = d.get('name') if not isstring(self.name): raise TYTaskConfException(d, 'task.name must be string') self.count = d.get('count') if not isinstance(self.count, int): raise TYTaskConfException(d, 'task.count must be int') self.totalLimit = d.get('totalLimit', 0) if not isinstance(self.totalLimit, int): raise TYTaskConfException(d, 'task.totalLimit must be int') self.desc = d.get('desc', '') if not isstring(self.desc): raise TYTaskConfException(d, 'task.desc must be string') self.pic = d.get('pic', '') if not isstring(self.pic): raise TYTaskConfException(d, 'task.pic must be string') self.inheritPrevTaskProgress = d.get('inheritPrevTaskProgress', 0) if self.inheritPrevTaskProgress not in (0, 1): raise TYTaskConfException(d, 'task.inheritPrevTaskProgress must be int in (0, 1)') self.star = d.get('star', 0) if not isinstance(self.star, int): raise TYTaskConfException(d, 'task.star must be int') self.shareUrl = d.get('shareUrl', 0) if self.shareUrl not in (0, 1): raise TYTaskConfException(d, 'task.shareUrl must be in (0,1)') rewardContent = d.get('rewardContent') if rewardContent: self.rewardContent = TYContentRegister.decodeFromDict(rewardContent) self.autoSendReward = d.get('autoSendReward', 0) if self.autoSendReward not in (0, 1): raise TYTaskConfException(d, 'task.n must be int int (0, 1)') self.rewardMail = d.get('rewardMail', '') if not isstring(self.rewardMail): raise TYTaskConfException(d, 'task.rewardMail must be string') if 'inspector' in d: inspector = TYTaskInspectorRegister.decodeFromDict(d.get('inspector')) self.inspectors.append(inspector) elif 'inspectors' in d: self.inspectors = TYTaskInspectorRegister.decodeList(d.get('inspectors')) self._decodeFromDictImpl(d) return self
def reloadConf(self, conf): vipLevelMap = {} assistanceChip = conf.get('assistanceChip') if not isinstance(assistanceChip, int) or assistanceChip <= 0: raise TYVipConfException(conf, 'assistanceChip must be int > 0') assistanceChipUpperLimit = conf.get('assistanceChipUpperLimit') if not isinstance(assistanceChipUpperLimit, int) or assistanceChipUpperLimit < 0: raise TYVipConfException(conf, 'assistanceChip must be int >= 0') levelUpDesc = conf.get('levelUpDesc', '') if not isstring(levelUpDesc): raise TYVipConfException(conf, 'levelUpDesc must be string') levelUpPayOrder = conf.get('levelUpPayOrder') if not isinstance(levelUpPayOrder, dict): raise TYVipConfException(conf, 'levelUpPayOrder must be dict') gotGiftDesc = conf.get('gotGiftDesc', '') if not isstring(gotGiftDesc): raise TYVipConfException(conf, 'gotGiftDesc must be string') gotAssistanceDesc = conf.get('gotAssistanceDesc', '') if not isstring(gotAssistanceDesc): raise TYVipConfException(conf, 'gotAssistanceDesc must be string') levelsConf = conf.get('levels') if not isinstance(levelsConf, list) or not levelsConf: raise TYVipConfException(conf, 'vip levels must be list') for levelConf in levelsConf: vipLevel = TYVipLevel() vipLevel.decodeFromDict(levelConf) if vipLevel.level in vipLevelMap: raise TYVipConfException(conf, 'duplicate vip level' % (vipLevel.level)) vipLevelMap[vipLevel.level] = vipLevel for vipLevel in vipLevelMap.values(): vipLevel.initWhenLoaded(vipLevelMap) vipLevelList = sorted(vipLevelMap.values(), cmp=lambda x, y: cmp(x.vipExp, y.vipExp)) # 判读是否循环配置 for vipLevel in vipLevelList: nextVipLevel = vipLevel.nextVipLevel while (nextVipLevel): if nextVipLevel == vipLevel: raise TYVipConfException(conf, 'Loop vip level %s' % (vipLevel.level)) nextVipLevel = nextVipLevel.nextVipLevel self._vipLevelMap = vipLevelMap self._vipLevelList = vipLevelList self._assistanceChip = assistanceChip self._assistanceChipUpperLimit = assistanceChipUpperLimit self._levelUpDesc = levelUpDesc self._gotGiftDesc = gotGiftDesc self._gotAssistanceDesc = gotAssistanceDesc self._levelUpPayOrder = levelUpPayOrder ftlog.debug('TYVipSystemImpl.reloadConf successed allLevels=', self._vipLevelMap.keys(), 'list=', [l.level for l in vipLevelList])
def decodeFromDict(self, d): # itemId self.itemId = d.get('itemId') if not isstring(self.itemId): raise TYBizConfException(d, 'TYRedEnvelopeLimit.itemId must be string') # minValue self.minValue = d.get('minValue', 1) if not isinstance(self.minValue, int): raise TYBizConfException(d, 'TYRedEnvelopeLimit.minValue must be int') # maxValue self.maxValue = d.get('maxValue', 1) if not isinstance(self.maxValue, int): raise TYBizConfException(d, 'TYRedEnvelopeLimit.maxValue must be int') if self.minValue > self.maxValue: raise TYBizConfException(d, 'TYRedEnvelopeLimit minValue > maxValue !!!') self.minCount = d.get('minCount', 1) if not isinstance(self.minCount, int): raise TYBizConfException(d, 'TYRedEnvelopeLimit.minCount must be int') self.maxCount = d.get('maxCount', 1) if not isinstance(self.maxCount, int): raise TYBizConfException(d, 'TYRedEnvelopeLimit.maxCount must be int') return self
def decodeFromDict(self, d): startTimeStr = d.get('startTime') endTimeStr = d.get('endTime') if startTimeStr: self.startDT = datetime.strptime(startTimeStr, '%Y-%m-%d %H:%M:%S').timetuple() if endTimeStr: self.endDT = datetime.strptime(endTimeStr, '%Y-%m-%d %H:%M:%S').timetuple() if self.endDT and self.startDT and self.endDT < self.startDT: raise TYBizConfException(d, 'BuyCountLimit.endTime must >= BuyCountLimit.startTime') periods = d.get('periods', []) if not periods: raise TYBizConfException(d, 'BuyCountLimit.periods must not empty list') for period in periods: limit = TimePeriodLimit().decodeFromDict(period) if limit.periodId in self.periodLimitMap: raise TYBizConfException(d, 'Duplicate BuyCountLimit period %s' % (limit.periodId)) self.periodLimitList.append(limit) self.periodLimitMap[limit.periodId] = limit self.outTimeFailure = d.get('outTimeFailure', '') if not isstring(self.outTimeFailure) or not self.outTimeFailure: raise TYBizConfException(d, 'BuyCountLimit.outTimeFailure must be not empty string') return self
def decodeFromDict(self, d): self.conf = d self.type = d.get('type') if not isstring(self.type): raise TYBizConfException(d, 'HallGameNode.type must be string') self._decodeFromDictImpl(d) return self
def getParamsByPlayer(player, timestamp): try: m360kpParams = player.getSigninParam('m360kp') if not m360kpParams: return None gkey = m360kpParams.get('gkey') if not gkey or not isstring(gkey): return None snsId = player.snsId if not snsId or not snsId.startswith('360:'): return None return { 'time': timestamp, 'gkey': gkey, 'uid': snsId[4:], 'matchid': player.matchId, 'skey': 1 } except: ftlog.error('match360kp.getParamsByPlayer userId=', player.userId, 'signinParams=', player.signinParams, 'snsId=', player.snsId) return None
def addKeyword(self, keyword): '''添加一个关键词''' if not isstring(keyword): return False keyword = self.__ensureUnicode(keyword) if keyword in self.__keywords: return False self.__keywords.add(keyword) keyword += unichr(11) q = {} k = u'' d = self.__d for uchar in keyword: uchar = uchar.lower() if d == '': q[k] = {} d = q[k] if not (uchar in d): d[uchar] = '' q = d k = uchar d = d[uchar] return True
def _compile(pattern, flags): # internal: compile pattern if isinstance(flags, RegexFlag): flags = flags.value try: return _cache[type(pattern), pattern, flags] except KeyError: pass if isinstance(pattern, Pattern): if flags: raise ValueError( "cannot process flags argument with a compiled pattern") return pattern if not sre_compile.isstring(pattern): raise TypeError("first argument must be string or compiled pattern") p = sre_compile.compile(pattern, flags) if not (flags & DEBUG): if len(_cache) >= _MAXCACHE: # Drop the oldest item try: del _cache[next(iter(_cache))] except (StopIteration, RuntimeError, KeyError): pass _cache[type(pattern), pattern, flags] = p return p
def _compile(pattern, flags): # internal: compile pattern try: p, loc = _cache[type(pattern), pattern, flags] if loc is None or loc == _locale.setlocale(_locale.LC_CTYPE): return p except KeyError: pass if isinstance(pattern, _pattern_type): if flags: raise ValueError( "cannot process flags argument with a compiled pattern") return pattern if not sre_compile.isstring(pattern): raise TypeError("first argument must be string or compiled pattern") p = sre_compile.compile(pattern, flags) if not (flags & DEBUG): if len(_cache) >= _MAXCACHE: _cache.clear() if p.flags & LOCALE: if not _locale: return p loc = _locale.setlocale(_locale.LC_CTYPE) else: loc = None _cache[type(pattern), pattern, flags] = p, loc return p
def load_namespaces (root, graph): with open (join (root, 'data', 'context.jsonld'), "rb") as f: context = json.loads (f.read ()) for prefix, url in context["@context"].items (): if isstring (url): graph.namespace_manager.bind (prefix, url)
def _check_param_orderId(self, msg, key, params): orderId = msg.getParam(key) if (isstring(orderId) and (orderid.is_valid_orderid_str(orderId) or orderId in ('ios_compensate', 'momo_compensate'))): return None, orderId return 'ERROR of orderId !' + str(orderId), None
def _compile(*key): pattern, flags = key bypass_cache = flags & DEBUG if not bypass_cache: cachekey = (type(key[0]),) + key p = _cache.get(cachekey) if p is not None: return p if isinstance(pattern, _pattern_type): if flags: raise ValueError("Cannot process flags argument with a compiled pattern") return pattern else: if not sre_compile.isstring(pattern): raise TypeError, "first argument must be string or compiled pattern" try: p = sre_compile.compile(pattern, flags) except error as v: raise error, v if not bypass_cache: if len(_cache) >= _MAXCACHE: _cache.clear() _cache[cachekey] = p return p
def checkValid(self): if not isstring(self.name): raise MatchConfException('Stage.name must be string') if not AnimationType.isValid(self.animationType): raise MatchConfException('Stage.animationType must in:' + str(AnimationType.VALID_TYPES)) if not SeatQueuingType.isValid(self.seatQueuing): raise MatchConfException('Stage.seat.principles must in:' + str(SeatQueuingType.VALID_TYPES)) if (not isinstance(self.cardCount, int) or self.cardCount <= 0 or self.cardCount > MAX_CARD_COUNT): raise MatchConfException('Stage.card.count must in:' + str((1, MAX_CARD_COUNT))) if (not isinstance(self.riseUserCount, int) or self.riseUserCount <= 0): raise MatchConfException('Stage.raise.user.count must be integer >= 0') if not isinstance(self.chipBase, int): raise MatchConfException('Stage.chip.base must be integer') if not GroupingType.isValid(self.groupingType): raise MatchConfException('Stage.grouping.type must in:' + str(GroupingType.VALID_TYPES)) if self.groupingType == GroupingType.TYPE_GROUP_COUNT: if not isinstance(self.groupingGroupCount, int) or self.groupingGroupCount <= 0: raise MatchConfException('Stage.grouping.group.count must be integer > 0') elif self.groupingType == GroupingType.TYPE_USER_COUNT: if not isinstance(self.groupingUserCount, int) or self.groupingUserCount <= 0: raise MatchConfException('Stage.grouping.user.count must be integer > 0') return self
def _compile(*key): # internal: compile pattern taint = _get_taint(key[0]) if taint is not None: # can't hash the set taint = tuple(taint) cachekey = (type(key[0]), key, taint) p = re._cache.get(cachekey) if p is not None: return p pattern, flags = key if isinstance(pattern, re._pattern_type): if flags: raise ValueError("Cannot process flags argument with" " a compiled pattern") return pattern if not sre_compile.isstring(pattern): raise TypeError("first argument must be string or compiled" " pattern") p = sre_compile.compile(pattern, flags) if len(re._cache) >= re._MAXCACHE: re._cache.clear() re._cache[cachekey] = p return p
def replaceParams(string, params): if string: for k, v in params.iteritems(): k = '${%s}' % (k) if not isstring(v): v = str(v) string = string.replace(k, v) return string
def decodeFromDict(self, d): from hall.entity.hallusercond import UserConditionRegister self.value = d.get('value', '') if not isstring(self.value): raise TYBizConfException(d, 'hallshare.HallShareConfigItem.value must be string') self.conditions = UserConditionRegister.decodeList(d.get('conditions', [])) return self
def _decodeFromDictImpl(self, d): self.type = d.get('type') if not isstring(self.type): raise TYBizConfException(d, 'HallGameNode.type must be string') self.params = d.get('params', {}) self.conditions = UserConditionRegister.decodeList(d.get('conditions', []))
def decodeFromDict(self, d): self.name = d.get('name') if not isstring(self.name) or not self.name: raise TYBizConfException(d, 'TipModule.name must be not empty string') self.type = d.get('type', 0) if not isinstance(self.type, int): raise TYBizConfException(d, 'TipModule.type must be int') self.needReport = d.get('needReport', 1) if not isinstance(self.needReport, int): raise TYBizConfException(d, 'TipModule.needReport must be int') self.hallType = d.get('hallType') if not isstring(self.hallType) or not self.hallType: raise TYBizConfException(d, 'TipModule.hallType must be not empty string') return self
def checkResponse(conf, response): d = strutil.loads(response) status = d.get('status', 0) if status == 0: password = d.get('data', {}).get('hongbao_code') if not password or not isstring(password): return -1, conf.get('errorInfo', '红包系统忙,请稍后再试') return 0, password return status, d.get('info') or conf.get('errorInfo', '红包系统忙,请稍后再试')
def decodeFromDict(self, d): self.shareId = d.get('shareId', '') if not isinstance(self.shareId, int): raise TYBizConfException(d, 'HallShare.shareId must be int') self.type = d.get('type', '') if not isstring(self.type): raise TYBizConfException(d, 'HallShare.type must be string') self.subType = d.get('subType', '') if not isstring(self.subType): raise TYBizConfException(d, 'HallShare.subType must be string') self.desc = HallShareConfigs().decodeFromDict(d.get('desc', [])) self.smsDesc = d.get('smsDesc', '') if not isstring(self.smsDesc): raise TYBizConfException(d, 'HallShare.smsDesc must be string') self.tips = d.get('tips', '') if not isstring(self.tips): raise TYBizConfException(d, 'HallShare.tips must be string') self.title = HallShareConfigs().decodeFromDict(d.get('title', [])) self.url = HallShareConfigs().decodeFromDict(d.get('url', [])) self.maxRewardCount = d.get('maxRewardCount') if not isinstance(self.maxRewardCount, int): raise TYBizConfException(d, 'HallShare.maxRewardCount must be int') self.rewardContent = None rewardContent = d.get('rewardContent') if rewardContent: self.rewardContent = TYContentRegister.decodeFromDict(rewardContent) self.mail = d.get('mail', '') if not isstring(self.mail): raise TYBizConfException(d, 'HallShare.mail must be string') self.shareIcon = HallShareConfigs().decodeFromDict(d.get('shareIcon', [])) self._decodeFromDictImpl(d) return self
def checkValid(self): if not self.gameId in MatchConfig.VALID_GAMEIDS: raise MatchConfException('gameId must in:' + str(MatchConfig.VALID_GAMEIDS)) if not isinstance(self.matchId, int): raise MatchConfException('matchId must be int') if self.matchId3 and not isstring(self.matchId3): raise MatchConfException('matchId3 must be string') if not isinstance(self.tableSeatCount, int) or self.tableSeatCount <= 0: raise MatchConfException('table.seat.count must be int > 0') return self
def checkValid(self): if not isinstance(self.infos, list): raise ConfigException('tips.infos must be array') for info in self.infos: if not isstring(info): raise ConfigException('tips.infos.item must be string') if not isinstance(self.interval, int) or self.interval <= 0: raise ConfigException('tips.interval must be int > 0') return self
def decodeFromDict(self, d, freeItemMap): self.name = d.get('name') if not isstring(self.name) or not self.name: raise TYBizConfException(d, 'HallFreeTemplate.name must be not empty string') self.freeItems = [] for itemId in d.get('freeItems', []): if freeItemMap.has_key(itemId): self.freeItems.append(freeItemMap[itemId]) return self
def _decodeFromDictImpl(self, d): self.shelvesName = d.get('shelves') if not isstring(self.shelvesName): raise TYBizConfException(d, 'FlipableCardProduct.shelves must be string') self.number = d.get('number', 0) if not isinstance(self.number, int): raise TYBizConfException(d, 'FlipableCardProduct.number must be int') self.minChip = d.get('minChip', 0) if not isinstance(self.minChip, int): raise TYBizConfException(d, 'FlipableCardProduct.minChip must be int')
def where(self, data): comm = " where " if isstring(data): return comm + data for key in data: if str(data[key]).isdigit(): comm += "%s=%s and " % (key, data[key]) else: comm += "%s='%s' and " % (key, data[key]) return comm[0:-4]
def _compile_typed(text_bytes_type, pattern, flags): # internal: compile pattern if isinstance(pattern, _pattern_type): if flags: raise ValueError( "Cannot process flags argument with a compiled pattern") return pattern if not sre_compile.isstring(pattern): raise TypeError("first argument must be string or compiled pattern") return sre_compile.compile(pattern, flags)
def decodeFromDict(self, d): self.inspector = TYTaskInspectorRegister.decodeFromDict(d['inspector']) reward_content = d.get('rewardContent') reward_multi_rate = d.get("multiReward", {}).get("rewardMultiRate", 0) if not isinstance(reward_multi_rate, (int, float)): raise TYBizConfException(d, 'task.rewardMultiRate must be number') self.totalLimit = d.get('total', 0) if not isinstance(self.totalLimit, int): raise TYBizConfException(d, 'task.totalLimit must be int') if reward_content: multi_reward_content = copy.deepcopy(reward_content) if reward_multi_rate > 0: for item in multi_reward_content.get("items", []): if "count" not in item: continue item["count"] += int(item["count"] * reward_multi_rate) self.reward_content = TYContentRegister.decodeFromDict( reward_content) self.multi_reward_content = TYContentRegister.decodeFromDict( multi_reward_content) self.reward_mail = d.get('rewardMail', '') if not isstring(self.reward_mail): raise TYBizConfException(d, 'task.rewardMail must be string') return self
def parse(cls, conf): ret = cls() ret.conf = conf ret.startRank = conf['ranking']['start'] ret.endRank = conf['ranking']['end'] rewards = conf.get('rewards', []) ret.rewards = [] for reward in rewards: if not isinstance(reward, dict): raise ConfigException('reward item must dict') itemId = reward.get('itemId', None) if not isstring(itemId) or not itemId: raise ConfigException( 'reward item.name must be not empty string') count = reward.get('count', None) if not isinstance(count, int) or count < 0: raise ConfigException('reward item.count must be int >= 0') if count > 0: ret.rewards.append(reward) ret.desc = conf['desc'] ret.message = conf.get('message', None) return ret.checkValid()
def _compile(pattern, flags): # internal: compile pattern if isinstance(flags, RegexFlag): flags = flags.value try: return _cache[type(pattern), pattern, flags] except KeyError: pass if isinstance(pattern, Pattern): if flags: raise ValueError( "cannot process flags argument with a compiled pattern") return pattern if not sre_compile.isstring(pattern): raise TypeError("first argument must be string or compiled pattern") p = sre_compile.compile(pattern, flags) if not (flags & DEBUG): if len(_cache) >= _MAXCACHE: try: _cache.popitem(last=False) except KeyError: pass _cache[type(pattern), pattern, flags] = p return p
def _compile(pattern, flags): # internal: compile pattern try: #fixme brython #return _cache[type(pattern), pattern, flags] return _cache["%s:%s:%s" % (type(pattern), pattern, flags)] except KeyError: pass #print(pattern) if isinstance(pattern, _pattern_type): if flags: raise ValueError( "Cannot process flags argument with a compiled pattern") return pattern if not sre_compile.isstring(pattern): raise TypeError("first argument must be string or compiled pattern") p = sre_compile.compile(pattern, flags) #print('_compile', p) if len(_cache) >= _MAXCACHE: _cache.clear() #fix me brython #_cache[type(pattern), pattern, flags] = p _cache["%s:%s:%s" % (type(pattern), pattern, flags)]= p return p
def makeClientConf(self, clientconf, gameId, userId, clientId): ''' 构造客户端的活动协议配置 ''' conf = strutil.cloneData(clientconf) activateconf = conf.get("config", {}).get("activate", {}) subconf = conf.get('config', {}) task = self._taskWrapper # New: 要统计的房间列表 roomid_tocount = activateconf.get('countRoomId', []) roomids_tocount = [roomid_tocount] if isstring(roomid_tocount) else roomid_tocount key_tocount = activateconf.get('countByKey') finish_taskcount = task.getFinishTaskCount(gameId, userId, clientconf) gain_taskcount = task.getRecvTaskCount(gameId, userId) total_tablecount = task.getTablePlayCount(userId) # New: 统计多个房间的数量 roomid_tablecount = 0 for roomid in roomids_tocount: roomid_tablecount += task.getRoomTablePlayCount(userId, roomid) is_activited = ActivityDdzFund.loadFundStatus(userId).isActivated ftlog.debug("TYActivityFund.makeClientConf: userId=", userId, "roomids_tocount=",roomids_tocount, "total_tablecount=", total_tablecount, "finish_taskcount=", finish_taskcount, "roomid_tablecount=", roomid_tablecount, "gain_taskcount=", gain_taskcount, "is_activited=",is_activited, 'key_tocount=', key_tocount) # subconf['overCnt'] = finish_taskcount # 已经完成的任务数量 if key_tocount: subconf['overCnt'] = task.getPlayCountByKey(userId, key_tocount) elif len(roomids_tocount) > 0: subconf['overCnt'] = roomid_tablecount # 已经完成的局数 else: subconf['overCnt'] = total_tablecount # 已经完成的局数 subconf['getRewardYetCnt'] = gain_taskcount # 已经领取的任务数量 subconf['isActive'] = is_activited # 是否已经激活基金活动 subconf['activeYetHint'] = strutil.replaceParams(subconf.get("activeYetHint",""), { "finishcount":subconf['overCnt'], "finishcount_room": str(roomid_tablecount), }) reward_btn_map = subconf.get('rewardButton', {}) normal_tip = reward_btn_map.get('normalTip', '') activate_map = subconf.get('activate', {}) reward_list = activate_map.get('reward', []) if len(reward_list)>gain_taskcount: desc = reward_list[gain_taskcount].get('desc', '') reward_btn_map['normalTip'] = strutil.replaceParams(normal_tip, {"assets":desc}) # TodoTask activatebtn_map = subconf.get("activateButton", {}) todotask = activatebtn_map.get("todoTask", {}) payOrder = todotask.get("payOrder") ftlog.debug("TYActivityFund.makeClientConf: userId=", userId, "payOrder=", payOrder) if payOrder: product, _ = hallstore.findProductByPayOrder(gameId, userId, clientId, payOrder) ftlog.debug("TYActivityFund.makeClientConf: userId=", userId, "product=", product) payOrder = TodoTaskPayOrder(product) ftlog.debug("TYActivityFund.makeClientConf: userId=", userId, "params=", payOrder) activatebtn_map["todoTask"] = payOrder.toDict() # 激活日期限制 ok = self.checkCanActivateDate(conf) activateconf['isOutdate'] = not ok if ok: activateconf['outdateTip'] = None ftlog.debug("TYActivityFund.makeClientConf: userId=", userId, "isOutdate", activateconf['isOutdate']) ftlog.debug("TYActivityFund.makeClientConf: userId=", userId, "conf=", conf) return conf
def _check_param_whereToShare(self, key, params): value = runhttp.getParamStr(key) if not value or not isstring(value): return 'whereToShare必须是字符串', None return None, value
def _check_param_newName(self, msg, key, params): newName = msg.getParam(key) if not newName or not isstring(newName): return 'Error param newName', None return None, newName
def _check_param_roundId(self, msg, key, params): roundId = msg.getParam(key) if not roundId or not isstring(roundId): return 'ERROR of roundId !' + str(roundId), None return None, roundId
def _check_param_videoId(self, msg, key, params): videoId = msg.getParam(key) if not videoId or not isstring(videoId) : return 'ERROR of videoId !' + str(videoId), None return None, videoId
def _check_param_chargeType(self, msg, key, params): chargeType = msg.getParam(key) if chargeType and not isstring(chargeType): return 'ERROR of chargeType !' + str(chargeType), None return None, chargeType or ''
raise TYBizConfException( d, 'DizhuMatchConf.startTime must be time HH:MM %s' % startTime) try: stopTime = d.get('stopTime') stopTime = datetime.strptime(stopTime, '%H:%M').time() except Exception, e: raise TYBizConfException( d, 'DizhuMatchConf.stopTime must be time HH:MM %s' % stopTime) self.startTime = startTime self.stopTime = stopTime self.tipsForNotSignin = d.get('tipsForNotSignin') if not isstring(self.tipsForNotSignin) or not self.tipsForNotSignin: raise TYBizConfException( d, 'DizhuMatchConf.tipsForNotSignin must not empty string') self.tipsForWillStopInfo = d.get('tipsForWillStopInfo') if not isstring( self.tipsForWillStopInfo) or not self.tipsForWillStopInfo: raise TYBizConfException( d, 'DizhuMatchConf.tipsForWillStopInfo must not empty string') self.lifeSafeCount = d.get('lifeSafeCount', 0) if not isinstance(self.lifeSafeCount, (int, float)): raise TYBizConfException( d, 'DizhuMatchConf.lifeSafeCount must be int or float') self.dailySafeCount = d.get('dailySafeCount', 0) if not isinstance(self.dailySafeCount, (int, float)):
def _check_param_rewardId(self, msg, key, params): rewardId = msg.getParam(key) if isstring(rewardId): return None, rewardId return None, {}
def _check_param_msg(self, msg, key, params): msgstr = msg.getParam(key) if not msgstr or not isstring(msgstr): return 'Error param msg', None return None, msgstr
def _check_param_configKey(self, msg, key, params): configKey = msg.getParam(key) if not configKey or not isstring(configKey): return None, None return None, configKey
def _check_param_scope(self, msg, key, params): scope = msg.getParam(key) if not scope or not isstring(scope): return None, 'hall' return None, scope
def reloadConf(self, conf): vipLevelMap = {} assistanceChip = conf.get('assistanceChip') if not isinstance(assistanceChip, int) or assistanceChip <= 0: raise TYVipConfException(conf, 'assistanceChip must be int > 0') assistanceChipUpperLimit = conf.get('assistanceChipUpperLimit') if not isinstance(assistanceChipUpperLimit, int) or assistanceChipUpperLimit < 0: raise TYVipConfException(conf, 'assistanceChip must be int >= 0') levelUpDesc = conf.get('levelUpDesc', '') if not isstring(levelUpDesc): raise TYVipConfException(conf, 'levelUpDesc must be string') levelUpErrorGameIds = conf.get('levelUpErrorGameIds', []) if not isinstance(levelUpErrorGameIds, list): raise TYVipConfException(conf, 'levelUpErrorGameIds must be list') levelUpPayOrder = conf.get('levelUpPayOrder') if not isinstance(levelUpPayOrder, dict): raise TYVipConfException(conf, 'levelUpPayOrder must be dict') gotGiftDesc = conf.get('gotGiftDesc', '') if not isstring(gotGiftDesc): raise TYVipConfException(conf, 'gotGiftDesc must be string') gotAssistanceDesc = conf.get('gotAssistanceDesc', '') if not isstring(gotAssistanceDesc): raise TYVipConfException(conf, 'gotAssistanceDesc must be string') levelsConf = conf.get('levels') if not isinstance(levelsConf, list) or not levelsConf: raise TYVipConfException(conf, 'vip levels must be list') for levelConf in levelsConf: vipLevel = TYVipLevel() vipLevel.decodeFromDict(levelConf) if vipLevel.level in vipLevelMap: raise TYVipConfException( conf, 'duplicate vip level' % (vipLevel.level)) vipLevelMap[vipLevel.level] = vipLevel for vipLevel in vipLevelMap.values(): vipLevel.initWhenLoaded(vipLevelMap) vipLevelList = sorted(vipLevelMap.values(), cmp=lambda x, y: cmp(x.vipExp, y.vipExp)) # 判读是否循环配置 for vipLevel in vipLevelList: nextVipLevel = vipLevel.nextVipLevel while (nextVipLevel): if nextVipLevel == vipLevel: raise TYVipConfException( conf, 'Loop vip level %s' % (vipLevel.level)) nextVipLevel = nextVipLevel.nextVipLevel self._vipLevelMap = vipLevelMap self._vipLevelList = vipLevelList self._assistanceChip = assistanceChip self._assistanceChipUpperLimit = assistanceChipUpperLimit self._levelUpDesc = levelUpDesc self._levelUpErrorGameIds = levelUpErrorGameIds self._gotGiftDesc = gotGiftDesc self._gotAssistanceDesc = gotAssistanceDesc self._levelUpPayOrder = levelUpPayOrder ftlog.debug('TYVipSystemImpl.reloadConf successed allLevels=', self._vipLevelMap.keys(), 'list=', [l.level for l in vipLevelList])
def checkValid(self): if not StageType.isValid(self.type): raise ConfigException('Stage.type must in:' + str(StageType.VALID_TYPES)) if not isstring(self.name): raise ConfigException('Stage.name must be string') if not AnimationType.isValid(self.animationType): raise ConfigException('Stage.animationType must in:' + str(AnimationType.VALID_TYPES)) if not SeatQueuingType.isValid(self.seatQueuing): raise ConfigException('Stage.seat.principles must in:' + str(SeatQueuingType.VALID_TYPES)) if (not isinstance(self.cardCount, int) or self.cardCount <= 0 or self.cardCount > MAX_CARD_COUNT): raise ConfigException('Stage.card.count must in:' + str((1, MAX_CARD_COUNT))) if (not isinstance(self.riseUserCount, int) or self.riseUserCount <= 0): raise ConfigException('Stage.raise.user.count must be integer >= 0') if not isinstance(self.chipBase, int): raise ConfigException('Stage.chip.base must be integer') if not isinstance(self.chipTimes, int): raise ConfigException('Stage.chip.times must be integer') if (not isinstance(self.chipGrow, (int, float)) or not self.chipGrow >= 0): raise ConfigException('Stage.chip.grow must be int or float >= 0.0') if not isinstance(self.chipUser, int): raise ConfigException('Stage.chip.user must be integer') if self.chipUser == ScoreCalcType.BAI_FEN_BI: if (not isinstance(self.chipUserRate, float) or not self.chipUserRate > 0): raise ConfigException('Stage.chip.user.2.rate must be float > 0.0') elif self.chipUser == ScoreCalcType.KAI_FANG_FANG_DA: if (not isinstance(self.chipUserBase, int) or not self.chipUserBase > 0): raise ConfigException('Stage.chip.user.3.base must be integer > 0.0') if self.type == StageType.ASS: if (not isinstance(self.riseUserRefer, int) or self.riseUserRefer < self.riseUserCount): raise ConfigException('Stage.raise.user.refer must be integer >= raise.user.count') if (not isinstance(self.loseUserChip, (int, float))): raise ConfigException('Stage.lose.user.chip must be integer or float') if (not isinstance(self.chipGrowBase, (int, float))): raise ConfigException('Stage.chip.grow.base must be integer or float') if (not isinstance(self.chipGrowIncr, (int, float))): raise ConfigException('Stage.chip.grow.incr must be integer or float') if not GroupingType.isValid(self.groupingType): raise ConfigException('Stage.grouping.type must in:' + str(GroupingType.VALID_TYPES)) if self.groupingType == GroupingType.TYPE_GROUP_COUNT: if not isinstance(self.groupingGroupCount, int) or self.groupingGroupCount <= 0: raise ConfigException('Stage.grouping.group.count must be integer > 0') elif self.groupingType == GroupingType.TYPE_USER_COUNT: if not isinstance(self.groupingUserCount, int) or self.groupingUserCount <= 0: raise ConfigException('Stage.grouping.user.count must be integer > 0') return self
def stringVerifier(elem): if not elem or not isstring(elem) or re.search("^[^a-zA-Z0-9 ]*$", elem): return False # Will become error message else: return True
def isContains(self, content): if not isstring(content): return False for _ in self._matchIter(content): return True return False
str(int(workSheet.cell(j, 0).value)) + "th from " + workSheet.cell(1, 2).value + " " + workSheet.cell(1, 5).value + " Loft: " + workSheet.cell(j, 1).value) found = True for i in range(0, 6): fileName = "" + str(i) + ".xlsx" # Opening the file as workbook workbook = xlrd.open_workbook(fileName) # Opening worksheet by its index workSheet = workbook.sheet_by_index(0) for j in range(1, workSheet.nrows): currentRing2 = workSheet.cell(j, 2).value if isstring(currentRing2): pass else: currentRing2 = str(int(currentRing2)) #print(currentRing2) currentRing2 = re.sub("C", "", currentRing2) currentRing2 = re.sub("H", "", currentRing2) currentRing2 = re.sub("\+", "", currentRing2) #print(currentRing2) if currentRing2 == ringNo: print( str(int(workSheet.cell(j, 0).value)) + "th from " + str(workSheet.cell(1, 2).value) + " " + str(workSheet.cell(1, 5).value) + " Loft: " + str(workSheet.cell(j, 1).value))
def _check_param_prodId(self, msg, key, params): productId = msg.getParam(key) if isstring(productId) and productId: return None, productId return 'ERROR of prodId !' + str(productId), None
def _check_param_rankId(self, msg, key, params): rankId = msg.getParam(key) if isstring(rankId): return None, rankId return 'ERROR of rankId !' + str(rankId), None
def _check_param_shareType(self, msg, key, params): shareType = msg.getParam('shareType', msg.getParam('type')) if not shareType or not isstring(shareType) : return 'ERROR of shareType !' + str(shareType), None return None, shareType
def _check_param_rankKey(self, msg, key, params): rankKey = msg.getParam('rankKey') if not isstring(rankKey): return 'must be set rankKey', None return None, rankKey
def _check_param_shelvesName(self, msg, key, params): value = msg.getParam(key) if not isstring(value) or not value: return 'ERROR of shelvesName !' + str(value), None return None, value
def decodeFromDict(self, d): self.type = d.get('type') if not MatchStartType.isValid(self.type): raise TYBizConfException( d, 'MatchStartConf.type must in %s' % (MatchStartType.VALID_TYPES)) self.feeType = d.get('fee.type') if not MatchFeeType.isValid(self.feeType): raise TYBizConfException( d, 'MatchStartConf.fee.type must in %s' % (MatchFeeType.VALID_TYPES)) self.maxPlayTime = d.get('maxplaytime') if not isinstance(self.maxPlayTime, int) or self.maxPlayTime <= 0: raise TYBizConfException( d, 'MatchStartConf.maxplaytime must int > 0') self.tableTimes = d.get('table.times', 400) if not isinstance(self.tableTimes, int) or self.tableTimes <= 0: raise TYBizConfException( d, 'MatchStartConf.table.times must int > 0') self.tableAvgTimes = d.get('table.avg.times', 400) if not isinstance(self.tableAvgTimes, int) or self.tableAvgTimes <= 0: raise TYBizConfException( d, 'MatchStartConf.table.avg.times must int > 0') if self.isUserCountType(): # 人满开赛的配置 self.userCount = d.get('user.size', None) if not isinstance(self.userCount, int) or self.userCount <= 0: raise TYBizConfException( d, 'MatchStartConf.user.size must int > 0') else: self.userMinCount = d.get('user.minsize') if not isinstance(self.userMinCount, int) or self.userMinCount <= 0: raise TYBizConfException( 'MatchStartConf.user.minsize must be int > 0') self.userMaxCount = d.get('user.maxsize') if not isinstance(self.userMaxCount, int) or self.userMaxCount <= 0: raise TYBizConfException( 'MatchStartConf.user.maxsize must be int > 0') self.signinMaxCount = d.get('signin.maxsize', self.userMaxCount) if not isinstance(self.signinMaxCount, int) or self.signinMaxCount <= 0: raise TYBizConfException( 'MatchStartConf.signin.maxsize must be int > 0') self.userMaxCountPerMatch = self.userMaxCount self.signinMaxCountPerMatch = self.signinMaxCount self.signinTimes = d.get('signin.times') if not isinstance(self.signinTimes, int) or self.signinTimes < 0: raise TYBizConfException( 'MatchStartConf.signin.times must be int >= 0') self.signinTimesStr = d.get('signinTimesStr', '') if not isstring(self.signinTimesStr): raise TYBizConfException( 'MatchStartConf.signinTimesStr must be string') self.prepareTimes = d.get('prepare.times', 5) if not isinstance(self.prepareTimes, int) or self.prepareTimes < 0: raise TYBizConfException( 'MatchStartConf.prepare.times must be int >= 0') self.userNextGroup = d.get('user.next.group') if not isinstance(self.userNextGroup, (int, float)): raise TYBizConfException( 'MatchStartConf.user.next.group must be float') self.selectFirstStage = d.get('selectFirstStage', 0) if self.selectFirstStage not in (0, 1): raise TYBizConfException( 'MatchStartConf.selectFirstStage must in (0, 1)') self._cron = FTCron(d.get('times')) return self
def _check_param_pointId(self, msg, key, params): value = msg.getParam(key) if isinstance(value, int) or isstring(value): return None, int(value) return 'ERROR of pointId !' + str(value), None
def _check_param_exchangeId(self, msg, key, params): value = msg.getParam(key) if not isstring(value) or not value: return 'ERROR of exchangeId !' + str(value), None return None, value
def _check_param_burialId(self, msg, key, params): burialId = msg.getParam(key) if burialId and isstring(burialId): return None, burialId return 'ERROR of burialId !' + str(burialId), None
def _check_param_issueNum(self, msg, key, params): issueNum = msg.getParam('issn') if isstring(issueNum): return None, issueNum return 'ERROR of issueNum !' + str(issueNum), None