From fc9671a8122bd085fa1d4ea74e2d4850abdf529f Mon Sep 17 00:00:00 2001 From: meejah Date: Tue, 30 Nov 2021 18:25:32 -0700 Subject: [PATCH] simplify, flake9 --- src/allmydata/scripts/admin.py | 2 +- src/allmydata/storage/crawler.py | 7 +------ src/allmydata/storage/expirer.py | 2 -- src/allmydata/test/test_storage_web.py | 1 - 4 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/allmydata/scripts/admin.py b/src/allmydata/scripts/admin.py index a6e826174..e0dcc8821 100644 --- a/src/allmydata/scripts/admin.py +++ b/src/allmydata/scripts/admin.py @@ -106,7 +106,7 @@ def migrate_crawler(options): for fp, converter in conversions: existed = fp.exists() - newfp = crawler._maybe_upgrade_pickle_to_json(fp, converter) + newfp = crawler._upgrade_pickle_to_json(fp, converter) if existed: print("Converted '{}' to '{}'".format(fp.path, newfp.path), file=out) else: diff --git a/src/allmydata/storage/crawler.py b/src/allmydata/storage/crawler.py index a1f70f4e5..dbf4b1300 100644 --- a/src/allmydata/storage/crawler.py +++ b/src/allmydata/storage/crawler.py @@ -101,7 +101,7 @@ def _convert_pickle_state_to_json(state): } -def _maybe_upgrade_pickle_to_json(state_path, convert_pickle): +def _upgrade_pickle_to_json(state_path, convert_pickle): """ :param FilePath state_path: the filepath to ensure is json @@ -110,14 +110,9 @@ def _maybe_upgrade_pickle_to_json(state_path, convert_pickle): :returns FilePath: the local path where the state is stored - If this state path is JSON, simply return it. - If this state is pickle, convert to the JSON format and return the JSON path. """ - if state_path.path.endswith(".json"): - return state_path - json_state_path = state_path.siblingExtension(".json") # if there's no file there at all, we're done because there's diff --git a/src/allmydata/storage/expirer.py b/src/allmydata/storage/expirer.py index cd0a9369a..abe3c37b6 100644 --- a/src/allmydata/storage/expirer.py +++ b/src/allmydata/storage/expirer.py @@ -12,9 +12,7 @@ import os import struct from allmydata.storage.crawler import ( ShareCrawler, - MigratePickleFileError, _confirm_json_format, - _maybe_upgrade_pickle_to_json, _convert_cycle_data, ) from allmydata.storage.shares import get_share_file diff --git a/src/allmydata/test/test_storage_web.py b/src/allmydata/test/test_storage_web.py index 86c2382f0..490a3f775 100644 --- a/src/allmydata/test/test_storage_web.py +++ b/src/allmydata/test/test_storage_web.py @@ -47,7 +47,6 @@ from allmydata.web.storage import ( remove_prefix ) from allmydata.scripts.admin import ( - MigrateCrawlerOptions, migrate_crawler, ) from allmydata.scripts.runner import (