本文整理汇总了Python中ids_generators.SequenceIDGenerator类的典型用法代码示例。如果您正苦于以下问题:Python SequenceIDGenerator类的具体用法?Python SequenceIDGenerator怎么用?Python SequenceIDGenerator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SequenceIDGenerator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: EquipmentsPlugin
class EquipmentsPlugin(common.IntervalPlugin):
__slots__ = ('__generator',)
def __init__(self, parent):
super(EquipmentsPlugin, self).__init__(parent)
self.__generator = SequenceIDGenerator()
def start(self):
super(EquipmentsPlugin, self).start()
ctrl = g_sessionProvider.shared.equipments
if ctrl is not None:
ctrl.onEquipmentMarkerShown += self.__onEquipmentMarkerShown
return
def stop(self):
ctrl = g_sessionProvider.shared.equipments
if ctrl is not None:
ctrl.onEquipmentMarkerShown -= self.__onEquipmentMarkerShown
super(EquipmentsPlugin, self).stop()
return
def __onEquipmentMarkerShown(self, equipment, position, _, interval):
uniqueID = self.__generator.next()
marker = equipment.getMarker()
if marker in settings.EQ_MARKER_TO_SYMBOL:
symbol = settings.EQ_MARKER_TO_SYMBOL[marker]
else:
LOG_ERROR('Symbol is not found for equipment', equipment)
return
matrix = minimap_utils.makePositionMatrix(position)
model = self._addEntryEx(uniqueID, symbol, _C_NAME.EQUIPMENTS, matrix=matrix, active=True)
if model is not None:
self._setCallback(uniqueID, int(interval))
return
示例2: __init__
def __init__(self):
super(BWChatProvider, self).__init__()
self.__handlers = defaultdict(set)
self.__msgFilters = None
self.__coolDown = _ChatCooldownManager()
self.__idGen = SequenceIDGenerator()
self.__isEnabled = False
self.__queue = []
示例3: __init__
def __init__(self, controller):
self.__controller = weakref.proxy(controller)
self.__idGen = SequenceIDGenerator()
self.__cache = {}
self.__idToIndex = {}
self.__indexToID = {}
self.__selectedUnit = None
self.__isRequestInProcess = False
示例4: __init__
def __init__(self, proxy):
super(BrowserController, self).__init__(proxy)
self.__browsers = {}
self.__browsersCallbacks = {}
self.__browserIDGenerator = SequenceIDGenerator()
self.__eventMgr = Event.EventManager()
self.onBrowserAdded = Event.Event(self.__eventMgr)
self.onBrowserDeleted = Event.Event(self.__eventMgr)
self.__urlMacros = URLMarcos()
示例5: _SquadInvitationsRecorder
class _SquadInvitationsRecorder(_SquadInvitationsHandler):
""" This class wraps _SquadInvitationsHandler in order to record player's
actions with dyn squads during replay recording."""
__slots__ = ("__idGen",)
def __init__(self, setup):
super(_SquadInvitationsRecorder, self).__init__(setup)
self.__idGen = SequenceIDGenerator()
def send(self, playerID):
BattleReplay.g_replayCtrl.serializeCallbackData(_SEND_ACTION_NAME, (self.__idGen.next(), playerID))
super(_SquadInvitationsRecorder, self).send(playerID)
def accept(self, playerID):
BattleReplay.g_replayCtrl.serializeCallbackData(_ACCEPT_ACTION_NAME, (self.__idGen.next(), playerID))
super(_SquadInvitationsRecorder, self).accept(playerID)
def reject(self, playerID):
BattleReplay.g_replayCtrl.serializeCallbackData(_REJECT_ACTION_NAME, (self.__idGen.next(), playerID))
super(_SquadInvitationsRecorder, self).reject(playerID)
示例6: __init__
def __init__(self, loader):
self.__loader = loader
self._IDGen = SequenceIDGenerator()
self._IDMap = {'inviteIDs': {},
'prbIDs': {}}
self.__receivedInvites = {}
self.__unreadInvitesCount = 0
self.__eventManager = Event.EventManager()
self.__acceptChain = None
self.onReceivedInviteListInited = Event.Event(self.__eventManager)
self.onReceivedInviteListModified = Event.Event(self.__eventManager)
return
示例7: __init__
def __init__(self, loader):
super(InvitesManager, self).__init__()
self.__loader = loader
self._IDGen = SequenceIDGenerator()
self._IDMap = {}
self.__invites = {}
self.__unreadInvitesCount = 0
self.__eventManager = Event.EventManager()
self.__acceptChain = None
self.onInvitesListInited = Event.Event(self.__eventManager)
self.onReceivedInviteListModified = Event.Event(self.__eventManager)
self.onSentInviteListModified = Event.Event(self.__eventManager)
self.__isInBattle = False
示例8: __init__
def __init__(self):
from gui.prb_control.formatters.invites import PrbInviteLinkFormatter
self.__linkFormatter = PrbInviteLinkFormatter()
self._IDGen = SequenceIDGenerator()
self._IDMap = {'inviteIDs': {},
'prbIDs': {}}
self.__receivedInvites = {}
self.__unreadInvitesCount = 0
self.__eventManager = Event.EventManager()
self.__acceptChain = None
self.onReceivedInviteListInited = Event.Event(self.__eventManager)
self.onReceivedInviteListModified = Event.Event(self.__eventManager)
return
示例9: __init__
def __init__(self, proxy):
super(BrowserController, self).__init__(proxy)
self.__browsers = {}
self.__browsersCallbacks = {}
self.__browserIDGenerator = SequenceIDGenerator()
self.__eventMgr = Event.EventManager()
self.onBrowserAdded = Event.Event(self.__eventMgr)
self.onBrowserDeleted = Event.Event(self.__eventMgr)
self.__urlMacros = URLMarcos()
self.__pendingBrowsers = {}
self.__creatingBrowserID = None
self.__filters = _getGlobalFilters()
return
示例10: __init__
def __init__(self):
self.__client = BigWorld.XmppClient()
self.__currentUser = None
self.__xmppRoster = None
self.__usersMgr = None
self.__model = None
self.__bwRoster = None
self.__reconnectCount = 0
self.__reconnectCallbackId = None
self.__bwConnected = False
self.__isEnabled = False
self.__idsGen = SequenceIDGenerator()
self.__pendingBattleMode = None
self.__databaseID = None
return
示例11: _InvitesIDsManager
class _InvitesIDsManager(object):
def __init__(self):
self.clear()
def clear(self):
self.__idsGen = SequenceIDGenerator()
self.__idsMap = {'inviteIDs': {},
'clubIDs': {}}
def getInviteID(self, clubDbID, userDbID, creationTime):
uniqueID = (clubDbID, userDbID, creationTime)
if uniqueID not in self.__idsMap['clubIDs']:
inviteID, showAt = self.__idsGen.next(), None
self.__idsMap['inviteIDs'][inviteID] = uniqueID
self.__idsMap['clubIDs'][uniqueID] = (inviteID, showAt)
else:
inviteID, showAt = self.__idsMap['clubIDs'][uniqueID]
return (inviteID, showAt)
def setShowTime(self, inviteID, showAt):
uniqueID = self.__idsMap['inviteIDs'][inviteID]
self.__idsMap['clubIDs'][uniqueID] = (inviteID, showAt)
示例12: _generateUserName
def _generateUserName():
global _g_namesGenerator
if _g_namesGenerator is None:
_g_namesGenerator = SequenceIDGenerator()
return '%s %d' % (USER_DEFAULT_NAME_PREFIX, _g_namesGenerator.next())
示例13: BrowserController
class BrowserController(Controller):
_BROWSER_TEXTURE = 'BrowserBg'
_ALT_BROWSER_TEXTURE = 'AltBrowserBg'
def __init__(self, proxy):
super(BrowserController, self).__init__(proxy)
self.__browsers = {}
self.__browsersCallbacks = {}
self.__browserIDGenerator = SequenceIDGenerator()
self.__eventMgr = Event.EventManager()
self.onBrowserAdded = Event.Event(self.__eventMgr)
self.onBrowserDeleted = Event.Event(self.__eventMgr)
self.__urlMacros = URLMarcos()
self.__pendingBrowsers = {}
self.__creatingBrowserID = None
self.__filters = _getGlobalFilters()
return
def fini(self):
self.__filters = None
self.__eventMgr.clear()
self.__eventMgr = None
self.__urlMacros.clear()
self.__urlMacros = None
self.__browserIDGenerator = None
super(BrowserController, self).fini()
return
def onAvatarBecomePlayer(self):
self.__stop()
def onDisconnected(self):
self.__stop()
def addFilterHandler(self, handler):
""" Adds given @handler to the browser urls filter chain. Calls
it if there is a @tag in url onto opened browser page.
Handler should receive url and list of client-specific tags,
return bool as flag that routine have to stop
"""
self.__filters.add(handler)
def removeFilterHandler(self, handler):
""" Remove given @handler from filtering chain. Handler description
can be seen in addFilterhandler method doc-string
"""
self.__filters.discard(handler)
@async
@process
def load(self, url = None, title = None, showActionBtn = True, showWaiting = True, browserID = None, isAsync = False, browserSize = None, isDefault = True, callback = None, showCloseBtn = False, useBrowserWindow = True):
url = yield self.__urlMacros.parse(url or GUI_SETTINGS.browser.url)
suffix = yield self.__urlMacros.parse(GUI_SETTINGS.browser.params)
concatenator = '&' if '?' in url else '?'
if suffix not in url:
url = concatenator.join([url, suffix])
size = browserSize or BROWSER.SIZE
webBrowserID = browserID
if browserID is None:
browserID = self.__browserIDGenerator.next()
webBrowserID = browserID
elif type(browserID) is not int:
webBrowserID = self.__browserIDGenerator.next()
ctx = {'url': url,
'title': title,
'showActionBtn': showActionBtn,
'showWaiting': showWaiting,
'browserID': browserID,
'size': size,
'isAsync': isAsync,
'showCloseBtn': showCloseBtn,
'showWindow': useBrowserWindow}
texture = browserID not in self.__browsers and browserID not in self.__pendingBrowsers and self._BROWSER_TEXTURE
app = g_appLoader.getApp()
if not app:
raise AssertionError('Application can not be None')
browser = WebBrowser(webBrowserID, app, texture, size, url, handlers=self.__filters)
self.__browsers[browserID] = browser
if self.__isCreatingBrowser():
self.__pendingBrowsers[browserID] = ctx
else:
self.__createBrowser(ctx)
elif browserID in self.__pendingBrowsers:
self.__pendingBrowsers[browserID] = ctx
elif browserID in self.__browsers:
self.__browsers[browserID].navigate(url)
callback(browserID)
return
def getBrowser(self, browserID):
return self.__browsers.get(browserID)
def delBrowser(self, browserID):
if browserID in self.__browsers:
browser = self.__browsers.pop(browserID)
loadStart, loadEnd = self.__browsersCallbacks.pop(browserID, (None, None))
if loadStart is not None:
browser.onLoadStart -= loadStart
if loadEnd is not None:
browser.onLoadEnd -= loadEnd
#.........这里部分代码省略.........
示例14: InvitesManager
class InvitesManager(UsersInfoHelper):
__clanInfo = None
def __init__(self, loader):
super(InvitesManager, self).__init__()
self.__loader = loader
self._IDGen = SequenceIDGenerator()
self._IDMap = {}
self.__invites = {}
self.__unreadInvitesCount = 0
self.__eventManager = Event.EventManager()
self.__acceptChain = None
self.onInvitesListInited = Event.Event(self.__eventManager)
self.onReceivedInviteListModified = Event.Event(self.__eventManager)
self.onSentInviteListModified = Event.Event(self.__eventManager)
self.__isInBattle = False
return
def __del__(self):
LOG_DEBUG('InvitesManager deleted')
super(InvitesManager, self).__del__()
def init(self):
self.__inited = PRB_INVITES_INIT_STEP.UNDEFINED
g_messengerEvents.users.onUsersListReceived += self.__me_onUsersListReceived
g_playerEvents.onPrebattleInvitesChanged += self.__pe_onPrebattleInvitesChanged
g_playerEvents.onPrebattleInvitationsChanged += self.__pe_onPrebattleInvitationsChanged
g_playerEvents.onPrebattleInvitesStatus += self.__pe_onPrebattleInvitesStatus
def fini(self):
self.__clearAcceptChain()
self.__inited = PRB_INVITES_INIT_STEP.UNDEFINED
self.__loader = None
g_messengerEvents.users.onUsersListReceived -= self.__me_onUsersListReceived
g_playerEvents.onPrebattleInvitationsChanged -= self.__pe_onPrebattleInvitationsChanged
g_playerEvents.onPrebattleInvitesChanged -= self.__pe_onPrebattleInvitesChanged
g_playerEvents.onPrebattleInvitesStatus -= self.__pe_onPrebattleInvitesStatus
self.clear()
return
def start(self):
self.__isInBattle = False
if self.__inited & PRB_INVITES_INIT_STEP.STARTED == 0:
self.__inited |= PRB_INVITES_INIT_STEP.STARTED
if self.__inited == PRB_INVITES_INIT_STEP.INITED:
self.onInvitesListInited()
def clear(self):
self.__inited = PRB_INVITES_INIT_STEP.UNDEFINED
self.__clearInvites()
self._IDMap = {}
self.__eventManager.clear()
def onAvatarBecomePlayer(self):
self.__isInBattle = True
self.__clearAcceptChain()
@storage_getter('users')
def users(self):
return None
def isInited(self):
return self.__inited == PRB_INVITES_INIT_STEP.INITED
def acceptInvite(self, inviteID, postActions = None):
try:
invite = self.__invites[inviteID]
except KeyError:
LOG_ERROR('Invite ID is invalid', inviteID, self._IDMap)
return
self.__clearAcceptChain()
if not postActions:
invite.accept()
else:
self.__acceptChain = _AcceptInvitesPostActions(invite, postActions)
self.__acceptChain.onStopped += self.__accept_onPostActionsStopped
self.__acceptChain.start()
if self.__unreadInvitesCount > 0:
self.__unreadInvitesCount -= 1
def declineInvite(self, inviteID):
try:
invite = self.__invites[inviteID]
except KeyError:
LOG_ERROR('Invite ID is invalid', inviteID, self._IDMap)
return
invite.decline()
if self.__unreadInvitesCount > 0:
self.__unreadInvitesCount -= 1
def revokeInvite(self, inviteID):
try:
invite = self.__invites[inviteID]
except KeyError:
LOG_ERROR('Invite ID is invalid', inviteID, self._IDMap)
return
invite.revoke()
#.........这里部分代码省略.........
示例15: __init__
def __init__(self):
raise isinstance(self, BigWorld.Entity) or AssertionError
self.__chatActionCallbacks = {}
self._idGen = SequenceIDGenerator()