-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
498 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
"""Helper functions for FutureX Open edX Extensions.""" | ||
from __future__ import annotations | ||
|
||
import re | ||
from typing import List | ||
from urllib.parse import urlparse | ||
|
||
from futurex_openedx_extensions.helpers.constants import COURSE_ID_REGX | ||
|
||
|
||
def get_course_id_from_uri(uri: str) -> str | None: | ||
"""Extract the course_id from the URI.""" | ||
path_parts = urlparse(uri).path.split("/") | ||
|
||
for part in path_parts: | ||
result = re.search(r"^" + COURSE_ID_REGX, part) | ||
if result: | ||
return result.groupdict().get('course_id') | ||
|
||
return None | ||
|
||
|
||
def get_first_not_empty_item(items: List, default=None) -> any: | ||
"""Return the first item in the list that is not empty.""" | ||
return next((item for item in items if item), default) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.