From c2a1f787a2f3cc01b96e6011f71c0aef0ffcf8b7 Mon Sep 17 00:00:00 2001 From: Richard Bronkhorst Date: Sat, 17 Jun 2023 23:07:53 +0200 Subject: [PATCH] Update api.py, commander.py and one other file --- nullptr/api.py | 4 ++-- nullptr/commander.py | 13 ++++++++++++- nullptr/models/survey.py | 6 +++++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/nullptr/api.py b/nullptr/api.py index 3f12edb..1289ca5 100644 --- a/nullptr/api.py +++ b/nullptr/api.py @@ -244,11 +244,11 @@ class Api: else: raise e ship.update(data) - return ship + return data def survey(self, ship): data = self.request('post', f'my/ships/{ship}/survey') ship.update(data) result = self.store.update_list('Survey', mg(data, 'surveys')) return result - \ No newline at end of file + diff --git a/nullptr/commander.py b/nullptr/commander.py index 503b289..9750838 100644 --- a/nullptr/commander.py +++ b/nullptr/commander.py @@ -261,4 +261,15 @@ class Commander(CommandLine): def do_survey(self): if not self.has_ship(): return r = self.api.survey(self.ship) - pprint(r) \ No newline at end of file + pprint(r) + + def do_extract(self, survey_str=''): + if not self.has_ship(): return + survey = None + if survey_str != '': + survey = self.resolve('Survey', survey_str) + result = self.api.extract(self.ship, survey) + + symbol = mg(result,'extraction.yield.symbol') + units = mg(result,'extraction.yield.units') + print(units, symbol) diff --git a/nullptr/models/survey.py b/nullptr/models/survey.py index e776c1e..0c42d14 100644 --- a/nullptr/models/survey.py +++ b/nullptr/models/survey.py @@ -25,10 +25,14 @@ class Survey(SystemMember): def is_expired(self): return time() > self.expires or self.exhausted + def waypoint(self): + p = self.symbol.split('-') + return '-'.join(p[:3]) + def api_dict(self): return { 'signature': self.symbol, - 'symbol': str(self.waypoint), + 'symbol': self.waypoint(), 'deposits': [{'symbol': d} for d in self.deposits], 'expiration': self.expires_str, 'size': size_names[self.size]