def update_events(self, dt, event): if event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: self.end_state() if event.key == pygame.K_1: self.tile_color = constants.BLACK if event.key == pygame.K_2: self.tile_color = constants.RED if event.key == pygame.K_3: self.tile_color = constants.GREEN if event.key == pygame.K_4: self.tile_color = constants.BLUE if event.key == pygame.K_5: self.tile_color = constants.LIGHT_RED if event.key == pygame.K_6: self.tile_color = constants.LIGHT_GREEN if event.key == pygame.K_7: self.tile_color = constants.LIGHT_YELLOW if event.key == pygame.K_8: self.tile_color = constants.GREY if event.key == pygame.K_c: self.tiles.empty() if event.key == pygame.K_s: with open("data", "wb") as f: dill.load_types(unpickleable=True) print(dill.detect.badobjects(self.selected_tile)) dill.dump(self.selected_tile, f)
# Copyright (c) 2008-2016 California Institute of Technology. # Copyright (c) 2016-2017 The Uncertainty Quantification Foundation. # License: 3-clause BSD. The full license text is available at: # - http://trac.mystic.cacr.caltech.edu/project/pathos/browser/dill/LICENSE """ use objgraph to plot the reference paths for types found in dill.types """ #XXX: useful if could read .pkl file and generate the graph... ? import dill as pickle #pickle.debug.trace(True) #import pickle # get all objects for testing from dill import load_types load_types(pickleable=True, unpickleable=True) from dill import objects if __name__ == "__main__": import sys if len(sys.argv) != 2: print("Please provide exactly one type name (e.g. 'IntType')") msg = "\n" for objtype in list(objects.keys())[:40]: msg += objtype + ', ' print(msg + "...") else: objtype = str(sys.argv[-1]) obj = objects[objtype] try: import objgraph
# Copyright (c) 2008-2016 California Institute of Technology. # License: 3-clause BSD. The full license text is available at: # - http://trac.mystic.cacr.caltech.edu/project/pathos/browser/dill/LICENSE """ demonstrate dill's ability to pickle different python types test pickling of all Python Standard Library objects (currently: CH 1-14 @ 2.7) """ import dill as pickle pickle.settings['recurse'] = True #pickle.debug.trace(True) #import pickle # get all objects for testing from dill import load_types, objects, extend load_types(pickleable=True, unpickleable=False) #FIXME: pypy # Traceback (most recent call last): # File "dill/_objects.py", line 264, in <module> # a['MemberDescriptorType'] = type.__dict__['__weakrefoffset__'] # KeyError: '__weakrefoffset__' #load_types(pickleable=True,unpickleable=True) # uncomment the next two lines to test cloudpickle #extend(False) #import cloudpickle as pickle # helper objects class _class: def _method(self):
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation) # Copyright (c) 2008-2015 California Institute of Technology. # License: 3-clause BSD. The full license text is available at: # - http://trac.mystic.cacr.caltech.edu/project/pathos/browser/dill/LICENSE """ demonstrate dill's ability to pickle different python types test pickling of all Python Standard Library objects (currently: CH 1-14 @ 2.7) """ import dill as pickle #pickle.debug.trace(True) #import pickle # get all objects for testing from dill import load_types load_types(pickleable=True,unpickleable=False) #load_types(pickleable=True,unpickleable=True) from dill import objects # helper objects class _class: def _method(self): pass # objects that *fail* if imported special = {} special['LambdaType'] = _lambda = lambda x: lambda y: x special['MethodType'] = _method = _class()._method special['UnboundMethodType'] = _class._method objects.update(special) def pickles(name, exact=False):
# Copyright (c) 2008-2016 California Institute of Technology. # License: 3-clause BSD. The full license text is available at: # - http://trac.mystic.cacr.caltech.edu/project/pathos/browser/dill/LICENSE """ demonstrate dill's ability to pickle different python types test pickling of all Python Standard Library objects (currently: CH 1-14 @ 2.7) """ import dill as pickle pickle.settings['recurse'] = True #pickle.debug.trace(True) #import pickle # get all objects for testing from dill import load_types, objects, extend load_types(pickleable=True,unpickleable=False) #FIXME: pypy # Traceback (most recent call last): # File "dill/_objects.py", line 264, in <module> # a['MemberDescriptorType'] = type.__dict__['__weakrefoffset__'] # KeyError: '__weakrefoffset__' #load_types(pickleable=True,unpickleable=True) # uncomment the next two lines to test cloudpickle #extend(False) #import cloudpickle as pickle # helper objects class _class: def _method(self): pass