Ejemplo n.º 1
0
 def __getitem__(self, key):
     if key == 'data':
         return UserList.__getitem__(self, key)
     if type(key) is str and key != 'data':
         if len(self.data) > 1:
             warnings.warn("Results is of type list. Use results[i]['model'] instead of results['model'] ")
         return self.data[0][key]
     else:
         return(UserList.__getitem__(self,key))
     raise KeyError(key)
Ejemplo n.º 2
0
 def __getitem__(self, key):
     if key == 'data':
         return UserList.__getitem__(self, key)
     if isinstance(key, str):
         if len(self.data) > 1:
             from gillespy2.core import log
             msg = f"Results is of type list. Use results[i]['{key}'] instead of results['{key}']"
             log.warning(msg)
         return self.data[0][key]
     else:
         return (UserList.__getitem__(self, key))
     raise KeyError(key)
Ejemplo n.º 3
0
 def __getitem__(self, i, *args, **kwargs):
     length = len(self)
     if type(i) == int and i >= length:
         try:
             return self.extra_items[i]
         except KeyError:
             return 0
     elif type(i) == slice and i.stop and i.stop >= length:
         the_rest = i.indices(i.stop - length)
         return UserList.__getitem__(
             self, slice(i.start, length, i.step), *args, **
             kwargs) + [0 for _ in range(*the_rest)]
     else:
         # slice(1, 2, None)
         return UserList.__getitem__(self, i, *args, **kwargs)
Ejemplo n.º 4
0
	def __getitem__(self, i):
		if sys.version_info < (3, ):
			if isinstance(i, slice):
				# TODO Return just a list. Why?
				return [self[i] for i in range(*i.indices(len(self)))]
				# return UserList([self[i] for i in range(*i.indices(len(self)))])
		return UserList.__getitem__(self, i)
Ejemplo n.º 5
0
 def __getitem__(self, item):
     result = UserList.__getitem__(self, item)
     if type(result) is list:
         if len(result) > 1:
             return USBackItemList(self._usr, result)
     else:
         return result
Ejemplo n.º 6
0
 def __getitem__(self, item):
     result = UserList.__getitem__(self, item)
     if type(result) is list:
         if len(result) > 1:
             return SDBItemList(self._usr, result)
     else:
         return result
Ejemplo n.º 7
0
 def __getslice__(self, i, j):
     # fix UserList - don't return a new list of the same type but just the
     # normal list item
     if sys.version_info < (3, ):
         i = max(i, 0)
         j = max(j, 0)
         return self.data[i:j]
     return UserList.__getitem__(self, slice(i, j))
Ejemplo n.º 8
0
	def __getslice__(self, i, j):
		# fix UserList - don't return a new list of the same type but just the
		# normal list item
		if sys.version_info < (3, ):
			i = max(i, 0)
			j = max(j, 0)
			return self.data[i:j]
		return UserList.__getitem__(self, slice(i, j))
Ejemplo n.º 9
0
Archivo: Util.py Proyecto: billynip/map
 def __getitem__(self, i):
     self.__make_unique()
     return UserList.__getitem__(self, i)
Ejemplo n.º 10
0
 def __getitem__(self, i):
     self.__make_unique()
     return UserList.__getitem__(self, i)
Ejemplo n.º 11
0
 def __getitem__(self, n):
     res = UserList.__getitem__(self, n)
     if isinstance(n, slice):
         return self._init_subset(res)
     return res