1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Add serializer/deserializer to plugin base object (v2)

Fixes #10923
This commit is contained in:
James Cammarata 2015-05-06 01:31:02 -05:00
parent d34b586eb6
commit 8214ac7841

View file

@ -77,6 +77,36 @@ class PluginLoader:
self._extra_dirs = [] self._extra_dirs = []
self._searched_paths = set() self._searched_paths = set()
def __setstate__(self, data):
'''
Deserializer.
'''
class_name = data.get('class_name')
package = data.get('package')
config = data.get('config')
subdir = data.get('subdir')
aliases = data.get('aliases')
self.__init__(class_name, package, config, subdir, aliases)
self._extra_dirs = data.get('_extra_dirs', [])
self._searched_paths = data.get('_searched_paths', set())
def __getstate__(self):
'''
Serializer.
'''
return dict(
class_name = self.class_name,
package = self.package,
config = self.config,
subdir = self.subdir,
aliases = self.aliases,
_extra_dirs = self._extra_dirs,
_searched_paths = self._searched_paths,
)
def print_paths(self): def print_paths(self):
''' Returns a string suitable for printing of the search path ''' ''' Returns a string suitable for printing of the search path '''