Skip to content

Instantly share code, notes, and snippets.

@klightspeed
Last active January 25, 2019 09:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save klightspeed/4dbc2ee8ccd0866cb58bddfcccddaf5a to your computer and use it in GitHub Desktop.
Save klightspeed/4dbc2ee8ccd0866cb58bddfcccddaf5a to your computer and use it in GitHub Desktop.
#!/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