diff options
| author | 2018-09-30 17:29:09 +0100 | |
|---|---|---|
| committer | 2018-09-30 17:29:09 +0100 | |
| commit | 10ef985a8a849a6bbfa8cbb63c2548e42ffb3957 (patch) | |
| tree | 4da29ff0462ca69820d81aa95afb4b261ab3213c /src/Utils.py | |
| parent | received.command takes a final [command] part (diff) | |
| signature | ||
Switch to using docstring for usage, permission and require_mode
Diffstat (limited to 'src/Utils.py')
| -rw-r--r-- | src/Utils.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/Utils.py b/src/Utils.py index b5fa8452..e87330c2 100644 --- a/src/Utils.py +++ b/src/Utils.py @@ -313,3 +313,35 @@ def get_hashflags(filename): value = line_split[1] hashflags[hashflag] = value return hashflags.items() + +class Docstring(object): + def __init__(self, description, items): + self.description = description + self.items = items + +def parse_docstring(s): + description = "" + last_item = None + items = {} + if s: + for line in s.split("\n"): + line = line.strip() + + if line: + if line[0] == ":": + line_split = line.split(": ", 1) + + value = None + if len(line_split) > 1: + value = line_split[1] + + last_item = line_split[0][1:].lower() + items[last_item] = value + else: + if last_item: + items[last_item] += " %s" % line + else: + if description: + description += " " + description += line + return Docstring(description, items) |
