Last active
January 25, 2019 09:55
-
-
Save klightspeed/4dbc2ee8ccd0866cb58bddfcccddaf5a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import sys | |
import json | |
mindist = 2500 | |
binmoonparents = set() | |
gasgiants = {} | |
sysid64 = None | |
for line in sys.stdin: | |
line = line.strip() | |
if line[-1] == ',': | |
line = line[:-1] | |
if line[0] == '{' and line[-1] == '}': | |
body = json.loads(line) | |
id64 = body['systemId64'] | |
if id64 != sysid64: | |
for bid in binmoonparents: | |
if bid in gasgiants: | |
gg = gasgiants[bid] | |
if gg['distanceToArrival'] >= mindist: | |
print(json.dumps(gg)) | |
binmoonparents = set() | |
gasgiants = {} | |
sysid64 = id64 | |
if 'parents' in body and body['parents'] is not None and len(body['parents']) >= 3: | |
parents = body['parents'] | |
if 'Null' in parents[0] and 'Planet' in parents[1]: | |
binmoonparents.add(parents[1]['Planet']) | |
if 'bodyId' in body and body['bodyId'] is not None and body['subType'] is not None and 'gas giant' in body['subType'].lower(): | |
gasgiants[body['bodyId']] = body |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment