mirror of
https://github.com/m-labs/artiq.git
synced 2024-12-19 16:36:29 +08:00
25 lines
693 B
Python
25 lines
693 B
Python
from artiq.protocols.sync_struct import Notifier
|
|
from artiq.protocols import pyon
|
|
|
|
|
|
class DDB:
|
|
def __init__(self, backing_file):
|
|
self.backing_file = backing_file
|
|
self.data = Notifier(pyon.load_file(self.backing_file))
|
|
|
|
def scan(self):
|
|
new_data = pyon.load_file(self.backing_file)
|
|
|
|
for k in list(self.data.read.keys()):
|
|
if k not in new_data:
|
|
del self.data[k]
|
|
for k in new_data.keys():
|
|
if k not in self.data.read or self.data.read[k] != new_data[k]:
|
|
self.data[k] = new_data[k]
|
|
|
|
def get_ddb(self):
|
|
return self.data.read
|
|
|
|
def get(self, key):
|
|
return self.data.read[key]
|