Update api.py, jumpgate.py and four other files

This commit is contained in:
Richard Bronkhorst 2023-06-12 22:36:58 +02:00
parent ffb35f3121
commit 6434ba8a6a
6 changed files with 16 additions and 8 deletions

View File

@ -79,7 +79,7 @@ class Api:
def list_waypoints(self, system): def list_waypoints(self, system):
data = self.request('get', f'systems/{system}/waypoints/') data = self.request('get', f'systems/{system}/waypoints/')
# pprintz(self.last_meta) # pprint(data)
return self.store.update_list(Waypoint, data) return self.store.update_list(Waypoint, data)
def marketplace(self, waypoint): def marketplace(self, waypoint):

View File

@ -16,5 +16,5 @@ class Jumpgate(Base):
return 'jmp' return 'jmp'
def path(self): def path(self):
sector, system, symbol = self.symbol.split('-') sector, system, _ = self.symbol.split('-')
return f'atlas/{sector}/{system[0:1]}/{system}/{symbol}.{self.ext()}' return f'atlas/{sector}/{system[0:1]}/{system}/{self.symbol}.{self.ext()}'

View File

@ -17,5 +17,5 @@ class Marketplace(Base):
return 'mkt' return 'mkt'
def path(self): def path(self):
sector, system, symbol = self.symbol.split('-') sector, system, _ = self.symbol.split('-')
return f'atlas/{sector}/{system[0:1]}/{system}/{symbol}.{self.ext()}' return f'atlas/{sector}/{system[0:1]}/{system}/{self.symbol}.{self.ext()}'

View File

@ -18,4 +18,4 @@ class System(Base):
def path(self): def path(self):
sector, symbol = self.symbol.split('-') sector, symbol = self.symbol.split('-')
return f'atlas/{sector}/{symbol[0:1]}/{symbol}.{self.ext()}' return f'atlas/{sector}/{symbol[0:1]}/{self.symbol}.{self.ext()}'

View File

@ -21,8 +21,8 @@ class Waypoint(Base):
return 'way' return 'way'
def path(self): def path(self):
sector, system, symbol = self.symbol.split('-') sector, system, _ = self.symbol.split('-')
return f'atlas/{sector}/{system[0:1]}/{system}/{symbol}.{self.ext()}' return f'atlas/{sector}/{system[0:1]}/{system}/{self.symbol}.{self.ext()}'
def system(self): def system(self):
p = self.symbol.split('-') p = self.symbol.split('-')

View File

@ -3,6 +3,8 @@ from nullptr.models.waypoint import Waypoint
from nullptr.models.sector import Sector from nullptr.models.sector import Sector
from nullptr.models.system import System from nullptr.models.system import System
from nullptr.models.agent import Agent from nullptr.models.agent import Agent
from nullptr.models.marketplace import Marketplace
from nullptr.models.jumpgate import Jumpgate
from os.path import isfile, dirname, isdir from os.path import isfile, dirname, isdir
import os import os
import json import json
@ -11,10 +13,16 @@ from time import time
class Store: class Store:
def __init__(self, data_dir): def __init__(self, data_dir):
self.init_models()
self.data_dir = data_dir self.data_dir = data_dir
self.data = {} self.data = {}
self.dirty_objects = set() self.dirty_objects = set()
def init_models(self):
self.models = Base.__subclasses__()
self.extensions = {c.ext(): c for c in self.models}
def dirty(self, obj): def dirty(self, obj):
self.dirty_objects.add(obj) self.dirty_objects.add(obj)