Compare commits
11 commits
release/0.
...
master
Author | SHA1 | Date | |
---|---|---|---|
bf31991875 | |||
700df6e98f | |||
fbfaeac64f | |||
a7a44a34b2 | |||
baf0a69396 | |||
bf592168c1 | |||
ebfa86e163 | |||
9e52b9772f | |||
4b8bf96c1c | |||
0176f70c86 | |||
ceccb497dd |
6 changed files with 79 additions and 31 deletions
34
CHANGELOG.md
34
CHANGELOG.md
|
@ -1,3 +1,33 @@
|
|||
# 0.7 (2021-01-28)
|
||||
|
||||
## Changed
|
||||
|
||||
* 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
|
||||
activity will no longer error out.
|
||||
* explorationtools.py: Searching for a CMDR with public profile, but hidden
|
||||
flight log will no longer error out.
|
||||
|
||||
-----
|
||||
|
||||
# 0.6 (2020-07-18)
|
||||
|
||||
## 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!
|
||||
|
@ -10,10 +40,14 @@ See [KeepAChangelog](https://keepachangelog.com/en/1.0.0/).
|
|||
implemented thing is getting approximate coordinates for a given procedually
|
||||
generated system name.
|
||||
|
||||
-----
|
||||
|
||||
# 0.4.1 (2020-06-18)
|
||||
|
||||
* removed accidentally left over debug print code from `spansh.py`
|
||||
|
||||
-----
|
||||
|
||||
# 0.4 (2020-03-09)
|
||||
|
||||
Kind of a big one. Obviously because in addition to EDSM, I can now do some
|
||||
|
|
|
@ -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)
|
||||
```
|
||||
|
||||
|
|
|
@ -78,9 +78,6 @@ def outputText():
|
|||
except SystemNotFoundError as e:
|
||||
print(e)
|
||||
sys.exit(2)
|
||||
except EdsmApiException as e:
|
||||
print(e)
|
||||
sys.exit(1)
|
||||
nearestCmdr = min(distances,key=distances.get)
|
||||
if shortOutput:
|
||||
print('nearest commander: {} ({} ly).'.format(nearestCmdr.name,
|
||||
|
|
|
@ -22,18 +22,24 @@ def distanceBetween(system1, system2, roundTo=2):
|
|||
|
||||
def getCommanderPosition(name, apikey):
|
||||
coords = Commander(name, apikey).currentPosition
|
||||
ret = ""
|
||||
for k in coords:
|
||||
ret += "{}: {}, ".format(k, coords[k])
|
||||
return ret[:-2]
|
||||
ret = "hidden"
|
||||
if coords:
|
||||
ret = ""
|
||||
for k in coords:
|
||||
ret += "{}: {}, ".format(k, coords[k])
|
||||
ret = ret[:-2]
|
||||
return ret
|
||||
|
||||
def getCommanderProfileUrl(name, apikey):
|
||||
return Commander(name, apikey).profileUrl
|
||||
|
||||
def getCommanderSystem(name, apikey):
|
||||
cmdr = Commander(name, apikey)
|
||||
return "{} (last seen {})".format(cmdr.currentSystem,
|
||||
when(cmdr.lastActivity))
|
||||
if cmdr.lastActivity is None:
|
||||
return "{}".format(cmdr.currentSystem)
|
||||
else:
|
||||
return "{} (last seen {})".format(cmdr.currentSystem,
|
||||
when(cmdr.lastActivity))
|
||||
def when(date):
|
||||
diff = datetime.now() - date
|
||||
ret = ""
|
||||
|
|
2
pyEDSM
2
pyEDSM
|
@ -1 +1 @@
|
|||
Subproject commit 36a660f240c7e57cf524fe9640d13e56c7e42e79
|
||||
Subproject commit da044e918fe17cf18d2b2e18d60ce16a168ea70b
|
49
spansh.py
49
spansh.py
|
@ -5,7 +5,8 @@ import json as JSON
|
|||
import requests
|
||||
import sys
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from dateutil import parser as dtparser
|
||||
|
||||
from pyEDSM.edsm.exception import ServerError, NotFoundError
|
||||
|
||||
|
@ -63,8 +64,8 @@ def getOldStations():
|
|||
if args.short:
|
||||
ret += "{}\n".format(station["system_name"])
|
||||
else:
|
||||
ret += "{}: {} ({})\n".format(station["system_name"], station["name"],
|
||||
station["updated_at"])
|
||||
ret += "{}: {} ({} days ago)\n".format(station["system_name"], station["name"],
|
||||
(datetime.now(timezone.utc) - dtparser.parse(station["updated_at"])).days)
|
||||
|
||||
return ret[:-1]
|
||||
|
||||
|
@ -79,14 +80,19 @@ def getOldStationsInSystem(system):
|
|||
json = querystations(APIURLS["stations"], params)
|
||||
|
||||
ret = ""
|
||||
for station in json["results"]:
|
||||
# exclude carriers
|
||||
stations = list(filter(lambda station: not station["type"] == "Drake-Class Carrier", json["results"]))
|
||||
if len(stations) == 0:
|
||||
raise NotFoundError()
|
||||
for station in stations:
|
||||
# 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:
|
||||
if args.short:
|
||||
ret += "{}\n".format(station["name"])
|
||||
else:
|
||||
ret += "{} ({})\n".format(station["name"], station["updated_at"])
|
||||
ret += "{} ({} days ago)\n".format(station["name"],
|
||||
(datetime.now(timezone.utc) - dtparser.parse(station["updated_at"])).days)
|
||||
|
||||
return ret[:-1]
|
||||
|
||||
|
@ -139,6 +145,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)")
|
||||
|
||||
|
@ -157,26 +166,26 @@ APIURLS = {
|
|||
"stations": "https://spansh.co.uk/api/stations/search",
|
||||
"systems": "https://spansh.co.uk/api/systems/search",
|
||||
}
|
||||
FILTERS = {
|
||||
"updated_at":
|
||||
{
|
||||
"value": [
|
||||
"2017-11-06",
|
||||
(datetime.now() - timedelta(days=365)).strftime("%Y-%m-%d")
|
||||
],
|
||||
"comparison": "<=>"
|
||||
}
|
||||
}
|
||||
SORT = {
|
||||
"updated_at": {
|
||||
"direction": "asc"
|
||||
}
|
||||
}
|
||||
|
||||
try:
|
||||
if args.subcommand == "nearestsystem":
|
||||
out = getNearestSystem(args.coordinate)
|
||||
elif args.subcommand == "oldstations":
|
||||
FILTERS = {
|
||||
"updated_at":
|
||||
{
|
||||
"value": [
|
||||
"2017-11-06",
|
||||
(datetime.now() - timedelta(days=args.minage)).strftime("%Y-%m-%d")
|
||||
],
|
||||
"comparison": "<=>"
|
||||
}
|
||||
}
|
||||
SORT = {
|
||||
"updated_at": {
|
||||
"direction": "asc"
|
||||
}
|
||||
}
|
||||
if args.system:
|
||||
out = getOldStationsInSystem(args.system)
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue