From 5718099d5a6b7e1708dfe88b1eb3f62796c7a770 Mon Sep 17 00:00:00 2001 From: alterNERDtive Date: Mon, 5 Sep 2022 16:17:08 +0200 Subject: [PATCH] spansh.py: added `--nofeet` option to `outdatedstations` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … which excludes Odyssey settlements from the outdated stations search. fixes #10 Also now excluding carriers / settlements _from the search itself_ instead of removing returned results. So now the `--count` will be properly respected. Will need updating if/when new station types are introduced. --- CHANGELOG.md | 20 +++++++++++++++++--- README.md | 32 +++++++++++++++++--------------- spansh.py | 28 +++++++++++++++++++++------- 3 files changed, 55 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3210840..d77856f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,15 +1,29 @@ +# devel + +## Added + +* `spansh.py`: `--raw` option. Prints the raw JSON returned from a query. +* `spansh.py`: `--nofeet` option for `outdatedstations`. Excludes Odyssey + settlements from the result set. + +## Changed + +* `spansh.py`: Now uses instead of . + +----- + # 0.7 (2021-01-28) ## Changed -* spansh.py: Fleet carriers are now explicitly excluded from the outdated +* `spansh.py`: Fleet carriers are now explicitly excluded from the outdated stations list. ## Fixed -* explorationtools.py: Searching for a CMDR with public profile, but hidden +* `explorationtools.py`: Searching for a CMDR with public profile, but hidden activity will no longer error out. -* explorationtools.py: Searching for a CMDR with public profile, but hidden +* `explorationtools.py`: Searching for a CMDR with public profile, but hidden flight log will no longer error out. ----- diff --git a/README.md b/README.md index d75cf51..58b7a84 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ positional arguments: CMDR a list of CMDR names (must have their location public on EDSM!) -optional arguments: +options: -h, --help show this help message and exit --system SYSTEM the target system (must be in EDDN!) --short short output (only makes sense with `--text`) @@ -51,7 +51,7 @@ usage: edts.py [-h] {coords} ... Script for interfacing with Alot’s hosted EDTS API. -optional arguments: +options: -h, --help show this help message and exit subcommands: @@ -66,7 +66,7 @@ usage: edts.py coords [-h] [--maxuncertainty [MAXUNCERTAINTY]] system positional arguments: system the system name to get coordinates for -optional arguments: +options: -h, --help show this help message and exit --maxuncertainty [MAXUNCERTAINTY] maximum accepted uncertainty, if any @@ -81,7 +81,7 @@ usage: explorationtools.py [-h] A collection of tools useful for exploration. -optional arguments: +options: -h, --help show this help message and exit subcommands: @@ -111,7 +111,7 @@ usage: explorationtools.py bodycount [-h] system positional arguments: system system to query -optional arguments: +options: -h, --help show this help message and exit ``` @@ -122,7 +122,7 @@ usage: explorationtools.py distancebetween [-h] [--roundto [ROUNDTO]] positional arguments: system the systems to measure -optional arguments: +options: -h, --help show this help message and exit --roundto [ROUNDTO] the number of digits to round to (default: 2) ``` @@ -135,7 +135,7 @@ positional arguments: name the commander in question apikey the commander’s EDSM API key. Can be empty for public profiles. -optional arguments: +options: -h, --help show this help message and exit --system output the commander’s last known system (default) --coords output the commander’s last known position in {x,y,z} @@ -149,7 +149,7 @@ usage: explorationtools.py findsystem [-h] system positional arguments: system the system in question -optional arguments: +options: -h, --help show this help message and exit ``` @@ -159,19 +159,20 @@ usage: explorationtools.py systemlist [-h] partialsystem positional arguments: partialsystem the partial system name to query against -optional arguments: +options: -h, --help show this help message and exit ``` ### spansh.py ### ``` -usage: spansh.py [-h] {nearestsystem,oldstations,systemexists} ... +usage: spansh.py [-h] [--raw] {nearestsystem,oldstations,systemexists} ... Script for interfacing with Spansh’s API. -optional arguments: +options: -h, --help show this help message and exit + --raw output raw json (mostly for debugging) subcommands: {nearestsystem,oldstations,systemexists} @@ -191,7 +192,7 @@ usage: spansh.py nearestsystem [-h] [--short | --parsable] positional arguments: coordinate the coordinates to search for (order: x, y, z) -optional arguments: +options: -h, --help show this help message and exit --short short output format (system name only) --parsable parsable output format (|,,|) @@ -199,9 +200,9 @@ optional arguments: ``` usage: spansh.py oldstations [-h] [--system [SYSTEM]] [--count [COUNT]] - [--minage [MINAGE]] [--short] + [--minage [MINAGE]] [--short] [--nofeet] -optional arguments: +options: -h, --help show this help message and exit --system [SYSTEM] a single system to query. If not present, get the oldest stations overall. @@ -209,6 +210,7 @@ optional arguments: --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) + --nofeet omit Odyssey settlements ``` ``` @@ -217,7 +219,7 @@ usage: spansh.py systemexists [-h] system positional arguments: system the system to search for -optional arguments: +options: -h, --help show this help message and exit ``` diff --git a/spansh.py b/spansh.py index e501a5d..bec0092 100755 --- a/spansh.py +++ b/spansh.py @@ -86,11 +86,9 @@ def getOldStationsInSystem(system, raw=False): if raw: return json ret = "" - # exclude carriers - stations = list(filter(lambda station: not station["type"] == "Drake-Class Carrier", json["results"])) - if len(stations) == 0: + if len(json["results"]) == 0: raise NotFoundError() - for station in stations: + for station in json["results"]: # systems including the given name as a word will also trigger; # looking for e.g. “Mari” will also give you stuff in “Mac Mari”! if station["system_name"] == system: @@ -161,6 +159,8 @@ parser_oldstations.add_argument("--minage", nargs="?", type=int, default=365, + "365 (= 1 year).") parser_oldstations.add_argument("--short", action='store_true', help="short output format (system/station names only)") +parser_oldstations.add_argument("--nofeet", action='store_true', + help="omit Odyssey settlements") parser_systemexists = subparsers.add_parser("systemexists", help="Checks if a given system exists in the search database.") @@ -188,15 +188,29 @@ try: "value": [ "2017-11-06", (datetime.now() - timedelta(days=args.minage)).strftime("%Y-%m-%d") - ], + ], "comparison": "<=>" - } + }, + "type": + { + "value": [ + "Asteroid base", + "Coriolis Starport", + "Mega ship", + "Ocellus Starport", + "Orbis Starport", + "Outpost", + "Planetary Outpost", + "Planetary Port", + "Settlement" if not args.nofeet else "" + ] } + } SORT = { "updated_at": { "direction": "asc" - } } + } if args.system: out = getOldStationsInSystem(args.system, args.raw) else: