Update atlas_builder.py and store.py
This commit is contained in:
parent
b19a52d1aa
commit
9410726f07
@ -28,6 +28,8 @@ class AtlasBuilder:
|
||||
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}')
|
||||
|
@ -30,6 +30,20 @@ class Store:
|
||||
data['store'] = self
|
||||
obj.__dict__ = data
|
||||
|
||||
def get_file(self, typ, path):
|
||||
if not isfile(path):
|
||||
return None
|
||||
with open(path) as f:
|
||||
data = json.load(f)
|
||||
symbol = mg(data, 'symbol')
|
||||
oid = f'{symbol}.{typ.ext()}'
|
||||
if oid in self.data:
|
||||
return self.data[oid]
|
||||
obj = typ(symbol, self)
|
||||
self.load(obj)
|
||||
self.data[oid] = obj
|
||||
return obj
|
||||
|
||||
def store(self, obj):
|
||||
path = self.path(obj)
|
||||
path_dir = dirname(path)
|
||||
@ -69,8 +83,7 @@ class Store:
|
||||
continue
|
||||
if not fil.endswith(ext):
|
||||
continue
|
||||
symbol = f[:-len(ext)]
|
||||
yield self.get(typ, symbol)
|
||||
yield self.get_file(typ, fil)
|
||||
|
||||
|
||||
def flush(self):
|
||||
@ -81,4 +94,4 @@ class Store:
|
||||
self.store(obj)
|
||||
self.dirty_objects = set()
|
||||
dur = time() - start_time
|
||||
print(f'flush done {it} items {dur:.2f}')
|
||||
# print(f'flush done {it} items {dur:.2f}')
|
||||
|
Loading…
Reference in New Issue
Block a user