spansh.py: now takes minimum age of data as argument

Still defaults to 1 year.

fixes #6
This commit is contained in:
alterNERDtive 2020-07-10 14:19:37 +02:00
parent ceccb497dd
commit 0176f70c86
3 changed files with 19 additions and 2 deletions

View file

@ -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) # 0.5 (2020-07-01)
Changed Changelog format. Should be even clearer now at a glance! Changed Changelog format. Should be even clearer now at a glance!

View file

@ -199,13 +199,15 @@ optional arguments:
``` ```
usage: spansh.py oldstations [-h] [--system [SYSTEM]] [--count [COUNT]] usage: spansh.py oldstations [-h] [--system [SYSTEM]] [--count [COUNT]]
[--short] [--minage [MINAGE]] [--short]
optional arguments: optional arguments:
-h, --help show this help message and exit -h, --help show this help message and exit
--system [SYSTEM] a single system to query. If not present, get the oldest --system [SYSTEM] a single system to query. If not present, get the oldest
stations overall. stations overall.
--count [COUNT] how many stations to output. Defaults to 50. --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 (= 1year).
--short short output format (system/station names only) --short short output format (system/station names only)
``` ```

View file

@ -141,6 +141,9 @@ parser_oldstations.add_argument("--system", nargs="?",
+ "overall.") + "overall.")
parser_oldstations.add_argument("--count", nargs="?", type=int, default=50, parser_oldstations.add_argument("--count", nargs="?", type=int, default=50,
help="how many stations to output. Defaults to 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 (= 1year).")
parser_oldstations.add_argument("--short", action='store_true', parser_oldstations.add_argument("--short", action='store_true',
help="short output format (system/station names only)") help="short output format (system/station names only)")
@ -164,7 +167,7 @@ FILTERS = {
{ {
"value": [ "value": [
"2017-11-06", "2017-11-06",
(datetime.now() - timedelta(days=365)).strftime("%Y-%m-%d") (datetime.now() - timedelta(days=args.minage)).strftime("%Y-%m-%d")
], ],
"comparison": "<=>" "comparison": "<=>"
} }