Skip to content

Commit

Permalink
initial commit to fix F541, E501, F841, and E721, not sure on E501 in…
Browse files Browse the repository at this point in the history
… line 77 and 125 when it is in print statement. Also not sure about E722 in line 132 where try and except actually in pairs.
  • Loading branch information
stevenhua0320 committed Jul 4, 2024
1 parent ef6f614 commit de7f7b9
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions regolith/helpers/l_todohelper.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Helper for listing the to-do tasks. Tasks are gathered from people.yml, milestones, and group meeting actions."""
"""Helper for listing the to-do tasks.
Tasks are gathered from people.yml, milestones, and group meeting actions."""

import datetime as dt
import dateutil.parser as date_parser
Expand Down Expand Up @@ -40,8 +41,8 @@ def subparser(subpi):
nargs="?",
const=30,
help="Filter for tasks of short duration. "
"All items with a duration <= # mins, will be returned "
"if the number # is specified.",
"All items with a duration <= # mins, will be returned "
"if the number # is specified.",
)
subpi.add_argument(
"-t",
Expand All @@ -54,7 +55,7 @@ def subparser(subpi):
"--stati",
nargs="+",
choices=TODO_STATI,
help=f"Filter tasks with specific stati",
help="Filter tasks with specific stati",
default=["started"],
**listbox_kwargs,
)
Expand All @@ -73,21 +74,24 @@ def subparser(subpi):
)
subpi.add_argument(
"--date",
help="Enter a date such that the helper can calculate how many days are left from that date to the due-date. Default is today.",
help="Enter a date such that the helper can calculate how many days are left from that date to the due-date. "
"Default is today.",
**date_kwargs,
)
subpi.add_argument(
"-f",
"--filter",
nargs="+",
help="Search this collection by giving key element pairs. '-f description paper' will return tasks with description containing 'paper' ",
help="Search this collection by giving key element pairs. '-f description paper' will return tasks "
"with description containing 'paper' ",
)

return subpi


class TodoListerHelper(SoutHelperBase):
"""Helper for listing the to-do tasks. Tasks are gathered from people.yml, milestones, and group meeting actions."""
"""Helper for listing the to-do tasks.
Tasks are gathered from people.yml, milestones, and group meeting actions."""

# btype must be the same as helper target in helper.py
btype = HELPER_TARGET
Expand Down Expand Up @@ -134,7 +138,6 @@ def sout(self):
today = date_parser.parse(rc.date).date()
if rc.stati == ["started"]:
rc.stati = PROJECTUM_ACTIVE_STATI
running_index = 0
if rc.filter:
gather_todos = key_value_pair_filter(gather_todos, rc.filter)
if rc.short:
Expand Down Expand Up @@ -176,7 +179,8 @@ def sout(self):
gather_todos[len_of_tasks:], key=lambda k: (k["status"], k["order"], -k.get("duration", 10000))
)
print(
"If the indices are far from being in numerical order, please renumber them by running regolith helper u_todo -r"
"If the indices are far from being in numerical order, please renumber them "
"by running regolith helper u_todo -r"
)
print("(index) action (days to due date|importance|expected duration (mins)|tags|assigned by)")
print("-" * 80)
Expand Down Expand Up @@ -241,9 +245,9 @@ def _format_todos(todo, today):
nothing
"""
if type(todo["due_date"]) == str:
if isinstance(todo["due_date"], str):
todo["due_date"] = date_parser.parse(todo["due_date"]).date()
if type(todo.get("end_date")) == str:
if isinstance(todo.get("end_date"), str):
todo["end_date"] = date_parser.parse(todo["end_date"]).date()
todo["days_to_due"] = (todo.get("due_date") - today).days
todo["sort_finished"] = (todo.get("end_date", dt.date(1900, 1, 1)) - dt.date(1900, 1, 1)).days
Expand Down

0 comments on commit de7f7b9

Please sign in to comment.