Skip to content

Commit

Permalink
Merge pull request #51 from madeddie/small_fixes_39
Browse files Browse the repository at this point in the history
Small fixes 39
  • Loading branch information
madeddie authored May 23, 2024
2 parents a005a47 + b28bbb3 commit d7a8a4a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 39 deletions.
43 changes: 6 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,49 +16,18 @@ It provides a convenient way to view and submit tasks.

## Installation

1. Clone the repository to your local machine:

```bash
git clone https://github.com/madeddie/tyora.git
```

2. Navigate to the project directory:

```bash
cd tyora
```

3. Install the required dependencies:

```bash
pip install -r requirements.txt
pip install tyora
```

## Usage

1. Configure the script by running:

```bash
python tyora.py configure
```

Follow the prompts to enter your mooc.fi username and password. This information will be stored for future use.

2. List available exercises:

```bash
python tyora.py list
```

This will retrieve and display a list of exercises available on the CSES platform.

3. Submit a solution:

```bash
python tyora.py submit <exercise_id> <path_to_solution_file>
```
The script can be used from the command line. The following commands are available:

Replace `<exercise_id>` with the ID of the exercise you want to submit a solution for, and `<path_to_solution_file>` with the path to your solution file.
- `tyora login`: Stores your mooc.fi username and password and tests if we can log in with them.
- `tyora list`: Retrieves and displays a list of exercises available on the CSES platform.
- `tyora show <exercise_id>`: Displays the details of a specific exercise.
- `tyora submit <exercise_id> <path_to_solution_file>`: Submits a solution to a specific exercise.

## Origin of name

Expand Down
7 changes: 5 additions & 2 deletions src/tyora/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def parse_args(args: Optional[list[str]] = None) -> argparse.Namespace:
help="Don't store cookies or cache (they're used for faster access on the future runs)",
action="store_true",
)
subparsers = parser.add_subparsers(required=True, dest="cmd")
subparsers = parser.add_subparsers(required=True, title="commands", dest="cmd")

# login subparser
subparsers.add_parser("login", help="Login to mooc.fi CSES")
Expand Down Expand Up @@ -285,7 +285,10 @@ def parse_task_list(html: AnyStr) -> list[Task]:
item_name = item_link.text or ""
item_id = item_link.get("href", "").split("/")[-1]

item_span = item.find('span[@class!="detail"]')
item_spans = item.findall("span") or []
item_span = next(
(span for span in item_spans if span.get("class", "") != "detail"), None
)
if item_span is not None:
item_class = item_span.get("class", "")

Expand Down

0 comments on commit d7a8a4a

Please sign in to comment.