mirror of https://github.com/m-labs/artiq.git
file_db: support default data if file not present
This commit is contained in:
parent
9fb42e4952
commit
f983fdc985
|
@ -5,9 +5,16 @@ from artiq.protocols.sync_struct import Notifier
|
|||
|
||||
|
||||
class FlatFileDB:
|
||||
def __init__(self, filename):
|
||||
def __init__(self, filename, default_data=None):
|
||||
self.filename = filename
|
||||
self.data = Notifier(pyon.load_file(self.filename))
|
||||
try:
|
||||
data = pyon.load_file(self.filename)
|
||||
except FileNotFoundError:
|
||||
if default_data is None:
|
||||
raise
|
||||
else:
|
||||
data = default_data
|
||||
self.data = Notifier(data)
|
||||
self.hooks = []
|
||||
|
||||
def save(self):
|
||||
|
|
Loading…
Reference in New Issue