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.")
|
"the prompt.")
|
||||||
|
|
||||||
context.quit()
|
context.quit()
|
||||||
print("\nWaiting for other threads shuts down...")
|
print("Waiting for other threads shuts down...")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -19,6 +19,13 @@ class Abstract:
|
|||||||
"""Abstract implementation of a module data store, that always return an
|
"""Abstract implementation of a module data store, that always return an
|
||||||
empty set"""
|
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):
|
def open(self):
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -35,8 +42,7 @@ class Abstract:
|
|||||||
The loaded data
|
The loaded data
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from nemubot.tools.xmlparser import module_state
|
return self.new()
|
||||||
return module_state.ModuleState("nemubotstate")
|
|
||||||
|
|
||||||
def save(self, module, data):
|
def save(self, module, data):
|
||||||
"""Load data for the given module
|
"""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)
|
module.logger.error("Try to send a message to the unknown server: %s", server)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
else:
|
else: # Used when using outside of nemubot
|
||||||
from nemubot.tools.xmlparser import module_state
|
from nemubot.tools.xmlparser import module_state
|
||||||
|
|
||||||
self.data = module_state.ModuleState("nemubotstate")
|
self.data = module_state.ModuleState("nemubotstate")
|
||||||
|
|
||||||
def add_hook(store, hook):
|
def add_hook(store, hook):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user