Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions prpr/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ def configure_arg_parser():
)
filters.add_argument(
"-p",
"--problems",
"--projects",
type=int,
nargs="+",
help="the numbers of problems to be shown; multiple space-separated values are accepted",
help="the numbers of projects to be shown; multiple space-separated values are accepted",
)
filters.add_argument(
"-n",
Expand All @@ -39,7 +39,13 @@ def configure_arg_parser():
"--student",
help="the substring to be found in the student column, mail works best",
)
arg_parser.add_argument("-o", "--open", action="store_true", default=False, help="Open homework pages in browser")
arg_parser.add_argument(
"-o",
"--open",
action="store_true",
default=False,
help="Open the first homework in the list "
"in two tabs of default browser: tracker and reviewer")
arg_parser.add_argument(
"-v",
"--verbose",
Expand Down
6 changes: 3 additions & 3 deletions prpr/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def filter_homeworks(
homeworks: list[Homework],
*,
mode: Mode,
problems: Optional[list[int]] = None,
projects: Optional[list[int]] = None,
no: Optional[int] = None,
student: Optional[str] = None,
) -> list[Homework]:
Expand All @@ -57,8 +57,8 @@ def filter_homeworks(
elif mode == Mode.CLOSED:
result = _filter_homeworks_by_status(homeworks, CLOSED_STATUSES)

if problems:
result = [h for h in result if h.problem in problems]
if projects:
result = [h for h in result if h.project in projects]
if student:
result = [h for h in result if student in h.student]
return result
Expand Down
10 changes: 5 additions & 5 deletions prpr/homework.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def __init__(
self.number = number
self.status_updated = self._parse_datetime(status_updated)
self.description = description
self.problem, self.student = self._extract_problem_and_student(summary)
self.project, self.student = self._extract_project_and_student(summary)
self.status = Status.from_string(status)
self.issue_key = issue_key

Expand Down Expand Up @@ -130,12 +130,12 @@ def _compute_deadline(status_updated: Optional[datetime], status: Status) -> Opt
return status_updated + timedelta(days=1) if status in {Status.OPEN} else None

def __repr__(self) -> str:
return f"no {self.number}: {self.student} {self.problem} ({self.status})"
return f"no {self.number}: {self.student} {self.project} ({self.status})"

@staticmethod
def _extract_problem_and_student(summary) -> Tuple[int, str]:
if m := re.match(r"\[(?P<problem>\d+)( \(back_cohort_(?P<cohort>\d+)\))?\] (?P<student>.*)", summary):
return int(m.group("problem")), m.group("student")
def _extract_project_and_student(summary) -> Tuple[int, str]:
if m := re.match(r"\[(?P<project>\d+)( \(back_cohort_(?P<cohort>\d+)\))?\] (?P<student>.*)", summary):
return int(m.group("project")), m.group("student")
raise ValueError(f"Couldn't parse summary '{summary}' 😿")

@property
Expand Down
2 changes: 1 addition & 1 deletion prpr/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def main():
filtered_homeworks = filter_homeworks(
homeworks,
mode=args.mode,
problems=args.problems,
projects=args.projects,
no=args.no,
student=args.student,
)
Expand Down
2 changes: 1 addition & 1 deletion prpr/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def print_issue_table(homeworks: list[Homework], last=None):
str(table_number),
homework.issue_url,
str(homework.number),
str(homework.problem),
str(homework.project),
homework.student,
homework.pretty_status,
homework.deadline_string,
Expand Down