more python3 compat
This commit is contained in:
parent
635ea1d3d1
commit
a2e37e3389
2 changed files with 18 additions and 26 deletions
|
@ -2,6 +2,7 @@ from . import CatalogItem
|
|||
from pandac.PandaModules import *
|
||||
from direct.distributed.PyDatagram import PyDatagram
|
||||
from direct.distributed.PyDatagramIterator import PyDatagramIterator
|
||||
import functools
|
||||
|
||||
class CatalogItemList:
|
||||
|
||||
|
@ -9,7 +10,7 @@ class CatalogItemList:
|
|||
self.store = store
|
||||
self.__blob = None
|
||||
self.__list = None
|
||||
if isinstance(source, str):
|
||||
if isinstance(source, bytes):
|
||||
self.__blob = source
|
||||
elif isinstance(source, list):
|
||||
self.__list = source[:]
|
||||
|
@ -156,7 +157,7 @@ class CatalogItemList:
|
|||
if cmpfunc == None:
|
||||
self.__list.sort()
|
||||
else:
|
||||
self.__list.sort(cmpfunc)
|
||||
self.__list.sort(key=functools.cmp_to_key(cmpfunc))
|
||||
self.__blob = None
|
||||
return
|
||||
|
||||
|
@ -166,6 +167,10 @@ class CatalogItemList:
|
|||
return len(self.__list)
|
||||
|
||||
def __getitem__(self, index):
|
||||
if isinstance(index, slice):
|
||||
if self.__list == None:
|
||||
self.__decodeList()
|
||||
return CatalogItemList(self.__list[index.start:index.stop], store=self.store)
|
||||
if self.__list == None:
|
||||
self.__decodeList()
|
||||
return self.__list[index]
|
||||
|
@ -173,36 +178,23 @@ class CatalogItemList:
|
|||
def __setitem__(self, index, item):
|
||||
if self.__list == None:
|
||||
self.__decodeList()
|
||||
self.__list[index] = item
|
||||
if isinstance(index, slice):
|
||||
if isinstance(item, CatalogItemList):
|
||||
self.__list[index.start:index.stop] = item.__list
|
||||
else:
|
||||
self.__list[index.start:index.stop] = item
|
||||
else:
|
||||
self.__list[index] = item
|
||||
self.__blob = None
|
||||
return
|
||||
|
||||
def __delitem__(self, index):
|
||||
if self.__list == None:
|
||||
self.__decodeList()
|
||||
del self.__list[index]
|
||||
self.__blob = None
|
||||
return
|
||||
|
||||
def __getslice__(self, i, j):
|
||||
if self.__list == None:
|
||||
self.__decodeList()
|
||||
return CatalogItemList(self.__list[i:j], store=self.store)
|
||||
|
||||
def __setslice__(self, i, j, s):
|
||||
if self.__list == None:
|
||||
self.__decodeList()
|
||||
if isinstance(s, CatalogItemList):
|
||||
self.__list[i:j] = s.__list
|
||||
if isinstance(index, slice):
|
||||
del self.__list[index.start:index.stop]
|
||||
else:
|
||||
self.__list[i:j] = s
|
||||
self.__blob = None
|
||||
return
|
||||
|
||||
def __delslice__(self, i, j):
|
||||
if self.__list == None:
|
||||
self.__decodeList()
|
||||
del self.__list[i:j]
|
||||
del self.__list[index]
|
||||
self.__blob = None
|
||||
return
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ class DistributedHouseInterior(DistributedObject.DistributedObject):
|
|||
|
||||
return
|
||||
numSurfaceTypes = CatalogSurfaceItem.NUM_ST_TYPES
|
||||
numRooms = min(len(self.wallpaper) / numSurfaceTypes, len(RoomNames))
|
||||
numRooms = min(len(self.wallpaper) // numSurfaceTypes, len(RoomNames))
|
||||
for room in range(numRooms):
|
||||
roomName = RoomNames[room]
|
||||
roomNode = self.interior.find(roomName)
|
||||
|
|
Loading…
Reference in a new issue