diff options
| author | 2018-10-28 11:43:41 +0000 | |
|---|---|---|
| committer | 2018-10-28 11:43:41 +0000 | |
| commit | 857761a653bade7a2021f78a5975d5ff48b20edb (patch) | |
| tree | 10ebfbd5ad1b767808d51e146c1da8cd42a0432a | |
| parent | Github won't highlight ircs:// urls, grumble. (diff) | |
| signature | ||
Support multiple items for docstring kwargs in utils.parse_docstring
| -rw-r--r-- | src/utils/__init__.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/utils/__init__.py b/src/utils/__init__.py index 658a434d..f2e1355c 100644 --- a/src/utils/__init__.py +++ b/src/utils/__init__.py @@ -178,14 +178,16 @@ def get_hashflags(filename): return hashflags.items() class Docstring(object): - def __init__(self, description, items): + def __init__(self, description, items, var_items): self.description = description self.items = items + self.var_items = var_items def parse_docstring(s): description = "" last_item = None items = {} + var_items = {} if s: for line in s.split("\n"): line = line.strip() @@ -194,7 +196,13 @@ def parse_docstring(s): if line[0] == ":": key, _, value = line[1:].partition(": ") last_item = key - items[key] = value + + if key in multiple_items: + var_items[key].append(value) + elif key in items: + var_items[key] = [items.pop(key), value] + else: + items[key] = value else: if last_item: items[last_item] += " %s" % line @@ -202,7 +210,7 @@ def parse_docstring(s): if description: description += " " description += line - return Docstring(description, items) + return Docstring(description, items, var_items) def top_10(items, convert_key=lambda x: x, value_format=lambda x: x): top_10 = sorted(items.keys()) |
