示例#1
0
 def check(Pickler):
     for proto in range(pickle.HIGHEST_PROTOCOL + 1):
         f = io.BytesIO()
         pickler = Pickler(f, proto)
         pickler.dump('abc')
         self.assertEqual(self.loads(f.getvalue()), 'abc')
     pickler = Pickler(io.BytesIO())
     self.assertEqual(pickler.persistent_id('def'), 'def')
     r = weakref.ref(pickler)
     del pickler
     self.assertIsNone(r())
示例#2
0
 def check(Pickler):
     for proto in range(pickle.HIGHEST_PROTOCOL + 1):
         f = io.BytesIO()
         pickler = Pickler(f, proto)
         pickler.dump('abc')
         self.assertEqual(self.loads(f.getvalue()), 'abc')
     pickler = Pickler(io.BytesIO())
     self.assertEqual(pickler.persistent_id('def'), 'def')
     r = weakref.ref(pickler)
     del pickler
     self.assertIsNone(r())
示例#3
0
 def __setitem__(self, key, value):
     if type(value) is dict:
         blue = Blue_dict(key, value, self, self)
         self.__vars__[key] = blue
         self.__blues__[key] = blue
         with open(f'{self.name}.blue', 'wb') as fp:
             p = Pickler(fp)
             p.dump(self)
     else:
         self.__vars__[key] = value
         with open(f'{self.name}.blue', 'wb') as fp:
             p = Pickler(fp)
             p.dump(self)
     self.__base_reload__()
示例#4
0
 def dump(self, obj):
     try:
         return Pickler.dump(self, obj)
     except RuntimeError as e:
         if "recursion" in e.args[0]:
             msg = ("Could not pickle object as excessively deep recursion "
                    "required.")
             raise pickle.PicklingError(msg)
         else:
             raise
示例#5
0
def saveturn():
	filename = 'lastturn'
	if lexists(filename):
		file = open(filename, 'wb')
	else:
		file = open(filename, 'xb')

	saver = Pickler(file)
	saver.dump(summoners)
	saver.dump(teams)
	saver.dump(board)
	saver.dump(boardwidth)
	saver.dump(boardheight)
	saver.dump(modifiers)
	saver.dump(gamemods)
	saver.dump(whoseturn)
	saver.dump(phase)
	saver.dump(subphase)
	#cannot save action, because will give error with inner methods (like render).
	file.close()
示例#6
0
 def __delitem__(self, key):
     del self.__vars__[key]
     with open(f'{self.name}.blue', 'wb') as thing:
         p = Pickler(thing)
         p.dump(self)
     self.__base_reload__()