From 0176f70c86b0737f395c5bda82f823a6d840d28a Mon Sep 17 00:00:00 2001 From: alterNERDtive Date: Fri, 10 Jul 2020 14:19:37 +0200 Subject: [PATCH] spansh.py: now takes minimum age of data as argument MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Still defaults to 1 year. fixes #6 --- CHANGELOG.md | 12 ++++++++++++ README.md | 4 +++- spansh.py | 5 ++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 808bcf8..c799881 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ +# devel + +## Added + +* `spansh.py` old station snearch now takes a `--minage` (in days) argument for + what you would consider “outdated” data. + +## Changed + +* `spansh.py` old station search now outputs an age in days for the last update + instead of a time stamp. + # 0.5 (2020-07-01) Changed Changelog format. Should be even clearer now at a glance! diff --git a/README.md b/README.md index cf0e0b0..d75cf51 100644 --- a/README.md +++ b/README.md @@ -199,13 +199,15 @@ optional arguments: ``` usage: spansh.py oldstations [-h] [--system [SYSTEM]] [--count [COUNT]] - [--short] + [--minage [MINAGE]] [--short] optional arguments: -h, --help show this help message and exit --system [SYSTEM] a single system to query. If not present, get the oldest stations overall. --count [COUNT] how many stations to output. Defaults to 50. + --minage [MINAGE] minimum age of data (in days) to be considered + “outdated”. Defaults to 365 (= 1 year). --short short output format (system/station names only) ``` diff --git a/spansh.py b/spansh.py index 6f01233..14f399d 100755 --- a/spansh.py +++ b/spansh.py @@ -141,6 +141,9 @@ parser_oldstations.add_argument("--system", nargs="?", + "overall.") parser_oldstations.add_argument("--count", nargs="?", type=int, default=50, help="how many stations to output. Defaults to 50.") +parser_oldstations.add_argument("--minage", nargs="?", type=int, default=365, + help="minimum age of data (in days) to be considered “outdated”. Defaults to " + + "365 (= 1 year).") parser_oldstations.add_argument("--short", action='store_true', help="short output format (system/station names only)") @@ -164,7 +167,7 @@ FILTERS = { { "value": [ "2017-11-06", - (datetime.now() - timedelta(days=365)).strftime("%Y-%m-%d") + (datetime.now() - timedelta(days=args.minage)).strftime("%Y-%m-%d") ], "comparison": "<=>" }