1
0
mirror of https://github.com/bspeice/metrik synced 2024-09-28 13:41:31 -04:00
metrik/metrik/targets/pickle_target.py

13 lines
302 B
Python
Raw Normal View History

2016-08-12 20:18:12 -04:00
from pickle import dump, load
2016-08-07 16:25:04 -04:00
2016-08-12 20:18:12 -04:00
from metrik.targets.temp_file import TempFileTarget
2016-08-07 16:25:04 -04:00
2016-08-12 20:18:12 -04:00
class PickleTarget(TempFileTarget):
def write(self, obj):
2016-08-07 16:25:04 -04:00
with open(self.full_path(), 'w+b') as handle:
2016-08-12 20:18:12 -04:00
dump(obj, handle)
2016-08-07 16:25:04 -04:00
def read(self):
return load(open(self.full_path(), 'rb'))