From 6c50793f81ed8b6ef1eee43e06ddb325c4aa047a Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Fri, 15 May 2020 17:37:10 +0200 Subject: remove deprecated pickle code --- allocbench/benchmark.py | 17 ++++------------- allocbench/facter.py | 5 ----- doc/Benchmarks.md | 2 +- merge.py | 9 ++------- 4 files changed, 7 insertions(+), 26 deletions(-) diff --git a/allocbench/benchmark.py b/allocbench/benchmark.py index afcb126..c4b3695 100644 --- a/allocbench/benchmark.py +++ b/allocbench/benchmark.py @@ -258,22 +258,13 @@ class Benchmark: def load(self, path=None): """Load benchmark results from file""" if not path: - filename = self.name - else: - if os.path.isdir(path): - filename = os.path.join(path, self.name) - else: - filename = os.path.splitext(path) + filename = f"{self.name}.json" + elif os.path.isdir(path): + filename = os.path.join(path, self.name) - if os.path.exists(filename + ".json"): - filename += ".json" + if os.path.exists(filename): with open(filename, "r") as load_file: self.results = json.load(load_file) - elif os.path.exists(filename + ".save"): - import pickle # pylint: disable=import-outside-toplevel - filename += ".save" - with open(filename, "rb") as load_file: - self.results = pickle.load(load_file) else: raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), filename) diff --git a/allocbench/facter.py b/allocbench/facter.py index afc1d02..374c881 100644 --- a/allocbench/facter.py +++ b/allocbench/facter.py @@ -82,11 +82,6 @@ def load_facts(path=None): filename += ".json" with open(filename, "r") as facts_file: loaded_facts = json.load(facts_file) - elif os.path.exists(filename + ".save"): - import pickle - filename += ".save" - with open(filename, "rb") as facts_file: - loaded_facts = pickle.load(facts_file) else: raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), filename) diff --git a/doc/Benchmarks.md b/doc/Benchmarks.md index e8add89..8e95a8c 100644 --- a/doc/Benchmarks.md +++ b/doc/Benchmarks.md @@ -131,7 +131,7 @@ loop = BenchmarkLoop() The class Benchmark defined in the allocbench/benchmark.py implements most common operations for a benchmark. -It provides load and save functions using pythons pickle module, +It provides load and save functions using pythons json module, helpers generating plots using matplotlib and most importantly a run method using the attributes `cmd` and `args` to execute your benchmark. To not enforce some output format hooks are available to parse the output of your benchmark yourself. diff --git a/merge.py b/merge.py index ca20092..185183f 100755 --- a/merge.py +++ b/merge.py @@ -21,7 +21,6 @@ import argparse import json import os -import pickle import sys import allocbench.facter as facter @@ -29,12 +28,8 @@ from allocbench.util import print_license_and_exit def load_file(filename): - if filename.endswith("json"): - with open(filename, "r") as json_file: - return json.load(json_file) - else: - with open(filename, "rb") as pickle_file: - return pickle.load(pickle_file) + with open(filename, "r") as json_file: + return json.load(json_file) def main(): -- cgit v1.2.3