aboutsummaryrefslogtreecommitdiffstats
path: root/todoist
diff options
context:
space:
mode:
authorGravatar Robin Obůrka <r.oburka@gmail.com> 2016-02-28 20:24:38 +0100
committerGravatar Robin Obůrka <r.oburka@gmail.com> 2016-02-28 20:24:38 +0100
commita571d929a3d082005c48476055a4cd4663a85a40 (patch)
tree1ce9824bd52405f2f10c6ef78be792878ac7f57b /todoist
parentMake "assign to person" process more careful (diff)
downloadtodoist-a571d929a3d082005c48476055a4cd4663a85a40.tar.xz
Make refactoring of assign_to_person to common reusable code
Diffstat (limited to 'todoist')
-rwxr-xr-xtodoist10
1 files changed, 5 insertions, 5 deletions
diff --git a/todoist b/todoist
index 92867d5..cd469c3 100755
--- a/todoist
+++ b/todoist
@@ -92,16 +92,16 @@ def build_collaborators_list(data):
collaborators = { col["full_name"].lower(): col["id"] for col in data["Collaborators"] }
return collaborators
-def assign_to_person(name, collaborators):
+def find_candidate(name, storage):
candidates = []
- for k, v in collaborators.items():
+ for k, v in storage.items():
if k.find(name) != -1:
candidates.append((k, v))
if len(candidates) == 0:
return None, "No candidate found"
elif len(candidates) > 1:
clist = [ item[0] for item in candidates ]
- clist.insert(0, "Multiple candidates found. Make better specification of one of them:")
+ clist.insert(0, "Multiple candidates found. Pick one of them:")
return None, "\n".join(clist)
else:
return candidates[0][1], None
@@ -164,9 +164,9 @@ def main():
## Assign to person
if args.assign:
- aid, err = assign_to_person(args.assign.lower(), collaborators)
+ aid, err = find_candidate(args.assign.lower(), collaborators)
if not aid:
- print(err, file=sys.stderr)
+ print("Assign to person error:", err, file=sys.stderr)
sys.exit(1)
kwargs["responsible_uid"] = aid