from time import sleep from nullptr.util import * from threading import Thread class AtlasBuilder: def __init__(self, store, api): self.store = store self.api = api self.stop_auto = False def wait_for_stop(self): try: input() except EOFError: pass self.stop_auto = True print('stopping...') def run(self, page=1): print('universe mode. hit enter to stop') t = Thread(target=self.wait_for_stop) t.daemon = True t.start() self.all_systems(int(page)) print('manual mode') def all_specials(self, waypoints): for w in waypoints: if self.stop_auto: break if 'UNCHARTED' in w.traits: continue if 'MARKETPLACE' in w.traits: self.api.marketplace(w) print(f'marketplace at {w}') sleep(0.5) if w.type == 'JUMP_GATE': self.api.jumps(w) print(f'jumpgate at {w}') def all_waypoints(self, systems): for s in systems: if self.stop_auto: break r = self.api.list_waypoints(s) self.all_specials(r) sleep(0.5) def all_systems(self, start_page): self.stop_auto = False data = self.api.list_systems(start_page) pages = total_pages(self.api.last_meta) print(f'{pages} pages of systems') print(f'page {1}: {len(data)} results') self.all_waypoints(data) self.store.flush() for p in range(start_page+1, pages+1): if self.stop_auto: break data = self.api.list_systems(p) print(f'page {p}: {len(data)} systems') self.all_waypoints(data) sleep(0.5) self.store.flush()