-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
617 additions
and
803 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,28 @@ | ||
from collections import OrderedDict | ||
|
||
from malcolm.core.notifier import Notifier | ||
from malcolm.compat import base_string | ||
|
||
|
||
class Meta(Notifier): | ||
"""Meta base class""" | ||
|
||
endpoints = ["description", "tags"] | ||
|
||
def __init__(self, name, description, *args): | ||
super(Meta, self).__init__(name, *args) | ||
def __init__(self, name, description=""): | ||
super(Meta, self).__init__(name) | ||
self.description = description | ||
self.tags = [] | ||
|
||
def set_description(self, description, notify=True): | ||
self.description = description | ||
self.on_changed([["description"], description], notify) | ||
"""Set the description string""" | ||
assert isinstance(description, base_string), \ | ||
"Expected descroption to be a string, got %s" % (description,) | ||
self.set_endpoint("description", description, notify) | ||
|
||
def set_tags(self, tags, notify=True): | ||
self.tags = tags | ||
self.on_changed([["tags"], tags], notify) | ||
|
||
@classmethod | ||
def from_dict(cls, name, d, *args): | ||
meta = cls(name, d["description"], *args) | ||
meta.tags = d["tags"] | ||
return meta | ||
"""Set the tags list""" | ||
assert isinstance(tags, list), \ | ||
"Expected tags to be a list, got %s" % (tags,) | ||
for tag in tags: | ||
assert isinstance(tag, base_string), \ | ||
"Expected tag to be string, got %s" % (tag,) | ||
self.set_endpoint("tags", tags, notify) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.