def __init__(self, name, postNames, callback, removeNames=None): self.notify.debug('__init__: %s, %s, %s' % (name, postNames, callback)) if removeNames is None: removeNames = [] self.name = name self.postNames = makeList(postNames) self.removeNames = makeList(removeNames) self.callback = callback self.waitingOn = set() for name in self.postNames: if not bboard.has(name): eventName = bboard.getEvent(name) self.waitingOn.add(eventName) self.acceptOnce(eventName, Functor(self._handleEvent, eventName)) continue for name in self.removeNames: if bboard.has(name): eventName = bboard.getRemoveEvent(name) self.waitingOn.add(eventName) self.acceptOnce(eventName, Functor(self._handleEvent, eventName)) continue self._checkDone()
def addExclObjs(cls, *objs): for obj in makeList(objs): if id(obj) not in cls._ExclObjIds: cls._ExclObjs.append(obj) cls._ExclObjIds.setdefault(id(obj), 0) cls._ExclObjIds[id(obj)] += 1 cls._SyncMaster.change()
def removeExclObjs(cls, *objs): for obj in makeList(objs): assert id(obj) in cls._ExclObjIds cls._ExclObjIds[id(obj)] -= 1 if cls._ExclObjIds[id(obj)] == 0: del cls._ExclObjIds[id(obj)] cls._ExclObjs.remove(obj) cls._SyncMaster.change()
def removeExclObjs(cls, *objs): for obj in makeList(objs): cls._ExclObjIds[id(obj)] -= 1 if cls._ExclObjIds[id(obj)] == 0: del cls._ExclObjIds[id(obj)] cls._ExclObjs.remove(obj) cls._SyncMaster.change()
def removeExclObjs(cls, *objs): for obj in makeList(objs): cls._ExclObjIds[id(obj)] -= 1 if cls._ExclObjIds[id(obj)] == 0: del cls._ExclObjIds[id(obj)] cls._ExclObjs.remove(obj) continue cls._SyncMaster.change()
def typeFreqStr(self): s = 'Object Pool: Type Frequencies' s += '\n=============================' counts = list(set(self._count2types.keys())) counts.sort() counts.reverse() for count in counts: types = makeList(self._count2types[count]) for typ in types: s += '\n%s\t%s' % (count, typ) return s
def __init__(self, name, postNames, callback, removeNames=None): self.notify.debug('__init__: %s, %s, %s' % (name, postNames, callback)) if removeNames is None: removeNames = [] self.name = name self.postNames = makeList(postNames) self.removeNames = makeList(removeNames) self.callback = callback self.waitingOn = set() for name in self.postNames: if not bboard.has(name): eventName = bboard.getEvent(name) self.waitingOn.add(eventName) self.acceptOnce(eventName, Functor(self._handleEvent, eventName)) for name in self.removeNames: if bboard.has(name): eventName = bboard.getRemoveEvent(name) self.waitingOn.add(eventName) self.acceptOnce(eventName, Functor(self._handleEvent, eventName)) self._checkDone()
def printObjsByType(self): print('Object Pool: Objects By Type') print('\n============================') counts = list(set(self._count2types.keys())) counts.sort() # print types with the smallest number of instances first, in case # there's a large group that waits a long time before printing #counts.reverse() for count in counts: types = makeList(self._count2types[count]) for typ in types: print('TYPE: %s, %s objects' % (repr(typ), len(self._type2objs[typ]))) print(getNumberedTypedSortedString(self._type2objs[typ]))
def printObjsByType(self, printReferrers = False): print 'Object Pool: Objects By Type' print '\n============================' counts = list(set(self._count2types.keys())) counts.sort() for count in counts: types = makeList(self._count2types[count]) for typ in types: print 'TYPE: %s, %s objects' % (repr(typ), len(self._type2objs[typ])) if printReferrers: for line in getNumberedTypedSortedStringWithReferrersGen(self._type2objs[typ]): print line print getNumberedTypedSortedString(self._type2objs[typ])
def printObjsByType(self, printReferrers=False): print 'Object Pool: Objects By Type' print '\n============================' counts = list(set(self._count2types.keys())) counts.sort() counts.reverse() for count in counts: types = makeList(self._count2types[count]) for typ in types: print 'TYPE: %s, %s objects' % (repr(typ), len(self._type2objs[typ])) if printReferrers: for line in getNumberedTypedSortedStringWithReferrersGen(self._type2objs[typ]): print line else: print getNumberedTypedSortedString(self._type2objs[typ])
def printReferrers(self, numEach = 3): counts = list(set(self._count2types.keys())) counts.sort() counts.reverse() for count in counts: types = makeList(self._count2types[count]) for typ in types: print '\n\nTYPE: %s' % repr(typ) for i in xrange(min(numEach, len(self._type2objs[typ]))): obj = self._type2objs[typ][i] print '\nOBJ: %s\n' % safeRepr(obj) referrers = gc.get_referrers(obj) print '%s REFERRERS:\n' % len(referrers) if len(referrers): print getNumberedTypedString(referrers, maxLen = 80, numPrefix = 'REF') continue print '<No Referrers>'
def printObjsByType(self, printReferrers=False): print 'Object Pool: Objects By Type' print '\n============================' counts = list(set(self._count2types.keys())) counts.sort() # print types with the smallest number of instances first, in case # there's a large group that waits a long time before printing #counts.reverse() for count in counts: types = makeList(self._count2types[count]) for typ in types: print 'TYPE: %s, %s objects' % (repr(typ), len(self._type2objs[typ])) if printReferrers: for line in getNumberedTypedSortedStringWithReferrersGen(self._type2objs[typ]): print line else: print getNumberedTypedSortedString(self._type2objs[typ])
def printReferrers(self, numEach=3): """referrers of the first few of each type of object""" counts = list(set(self._count2types.keys())) counts.sort() counts.reverse() for count in counts: types = makeList(self._count2types[count]) for typ in types: print "\n\nTYPE: %s" % repr(typ) for i in xrange(min(numEach, len(self._type2objs[typ]))): obj = self._type2objs[typ][i] print "\nOBJ: %s\n" % safeRepr(obj) referrers = gc.get_referrers(obj) print "%s REFERRERS:\n" % len(referrers) if len(referrers): print getNumberedTypedString(referrers, maxLen=80, numPrefix="REF") else: print "<No Referrers>"
def printReferrers(self, numEach=3): """referrers of the first few of each type of object""" counts = list(set(self._count2types.keys())) counts.sort() counts.reverse() for count in counts: types = makeList(self._count2types[count]) for typ in types: print('\n\nTYPE: %s' % repr(typ)) for i in range(min(numEach, len(self._type2objs[typ]))): obj = self._type2objs[typ][i] print('\nOBJ: %s\n' % safeRepr(obj)) referrers = gc.get_referrers(obj) print('%s REFERRERS:\n' % len(referrers)) if len(referrers): print(getNumberedTypedString(referrers, maxLen=80, numPrefix='REF')) else: print('<No Referrers>')
def printObjsByType(self, printReferrers=False): print 'Object Pool: Objects By Type' print '\n============================' counts = list(set(self._count2types.keys())) counts.sort() # print types with the smallest number of instances first, in case # there's a large group that waits a long time before printing #counts.reverse() for count in counts: types = makeList(self._count2types[count]) for typ in types: print 'TYPE: %s, %s objects' % (repr(typ), len(self._type2objs[typ])) if printReferrers: for line in getNumberedTypedSortedStringWithReferrersGen( self._type2objs[typ]): print line else: print getNumberedTypedSortedString(self._type2objs[typ])
def _loadSound(self): self._sounds = [] for soundFile in makeList(self._data.soundFile): self._sounds.append(loader.loadSfx(soundFile))
def _getMsgName(self, msgId): # we might get a list of message names, use the first one return makeList(MsgId2Names.get(msgId, 'UNKNOWN MESSAGE: %s' % msgId))[0]