Datastore: add a method to create a new empty tree
This commit is contained in:
parent
4d7d1ccab2
commit
418ff4f519
@ -142,7 +142,7 @@ def main():
|
||||
"the prompt.")
|
||||
|
||||
context.quit()
|
||||
print("\nWaiting for other threads shuts down...")
|
||||
print("Waiting for other threads shuts down...")
|
||||
sys.exit(0)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -19,6 +19,13 @@ class Abstract:
|
||||
"""Abstract implementation of a module data store, that always return an
|
||||
empty set"""
|
||||
|
||||
def new(self):
|
||||
"""Initialize a new empty storage tree
|
||||
"""
|
||||
|
||||
from nemubot.tools.xmlparser import module_state
|
||||
return module_state.ModuleState("nemubotstate")
|
||||
|
||||
def open(self):
|
||||
return
|
||||
|
||||
@ -35,8 +42,7 @@ class Abstract:
|
||||
The loaded data
|
||||
"""
|
||||
|
||||
from nemubot.tools.xmlparser import module_state
|
||||
return module_state.ModuleState("nemubotstate")
|
||||
return self.new()
|
||||
|
||||
def save(self, module, data):
|
||||
"""Load data for the given module
|
||||
|
@ -80,9 +80,8 @@ class ModuleContext:
|
||||
module.logger.error("Try to send a message to the unknown server: %s", server)
|
||||
return False
|
||||
|
||||
else:
|
||||
else: # Used when using outside of nemubot
|
||||
from nemubot.tools.xmlparser import module_state
|
||||
|
||||
self.data = module_state.ModuleState("nemubotstate")
|
||||
|
||||
def add_hook(store, hook):
|
||||
|
Loading…
x
Reference in New Issue
Block a user