From 559bcdc8d76600b6970b50c62629f781409f0034 Mon Sep 17 00:00:00 2001 From: yzqzss Date: Tue, 16 Apr 2024 15:02:16 +0800 Subject: [PATCH] DROP `--stdout-log-file` OPTION --- wikiteam3/dumpgenerator/cli/cli.py | 4 ---- wikiteam3/dumpgenerator/config.py | 1 - wikiteam3/dumpgenerator/dump/generator.py | 24 +---------------------- 3 files changed, 1 insertion(+), 28 deletions(-) diff --git a/wikiteam3/dumpgenerator/cli/cli.py b/wikiteam3/dumpgenerator/cli/cli.py index 6e29b4bd..cff864bd 100644 --- a/wikiteam3/dumpgenerator/cli/cli.py +++ b/wikiteam3/dumpgenerator/cli/cli.py @@ -82,9 +82,6 @@ def getArgumentParser(): parser.add_argument( "--verbose", action="store_true", help="" ) - parser.add_argument( - "--stdout-log-file", dest="stdout_log_path", default=None, help="Path to copy stdout to", - ) parser.add_argument( "--api_chunksize", metavar="50", default=50, help="Chunk size for MediaWiki API (arvlimit, ailimit, etc.)" ) @@ -542,7 +539,6 @@ def sleep(self, response=None): resume = args.resume, force = args.force, session = session, - stdout_log_path = args.stdout_log_path, bypass_cdn_image_compression = args.bypass_cdn_image_compression, add_referer_header = args.add_referer_header, image_timestamp_interval = args.image_timestamp_interval, diff --git a/wikiteam3/dumpgenerator/config.py b/wikiteam3/dumpgenerator/config.py index 7cc74977..7fa77ff2 100644 --- a/wikiteam3/dumpgenerator/config.py +++ b/wikiteam3/dumpgenerator/config.py @@ -100,7 +100,6 @@ class OtherConfig: resume: bool force: bool session: requests.Session - stdout_log_path: Optional[str] bypass_cdn_image_compression: bool add_referer_header: Optional[str] '''None, "auto", {URL}''' diff --git a/wikiteam3/dumpgenerator/dump/generator.py b/wikiteam3/dumpgenerator/dump/generator.py index 7430d0af..a549cf61 100644 --- a/wikiteam3/dumpgenerator/dump/generator.py +++ b/wikiteam3/dumpgenerator/dump/generator.py @@ -23,28 +23,6 @@ from wikiteam3.utils.ia_checker import any_recent_ia_item_exists from wikiteam3.utils.util import ALL_DUMPED_MARK, int_or_zero, mark_as_done, underscore -# From https://stackoverflow.com/a/57008707 -class Tee(object): - def __init__(self, filename): - self.file = open(filename, 'w', encoding="utf-8") - self.stdout = sys.stdout - - def __enter__(self): - sys.stdout = self - - def __exit__(self, exc_type, exc_value, tb): - sys.stdout = self.stdout - if exc_type is not None: - self.file.write(traceback.format_exc()) - self.file.close() - - def write(self, data): - self.file.write(data) - self.stdout.write(data) - - def flush(self): - self.file.flush() - self.stdout.flush() class DumpGenerator: configfilename = "config.json" @@ -56,7 +34,7 @@ def __init__(params=None): config, other = get_parameters(params=params) avoid_WikiMedia_projects(config=config, other=other) - with (Tee(other.stdout_log_path) if other.stdout_log_path else contextlib.nullcontext()): + with contextlib.nullcontext(): print(welcome()) print("Analysing %s" % (config.api if config.api else config.index))