Last active
October 6, 2022 20:12
-
-
Save capjamesg/ac5ce5b0743819f7a0d80c151d62555e to your computer and use it in GitHub Desktop.
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
# Code to advance discussion around url_summary implementation | |
# Still in development | |
from urllib.parse import urlparse | |
url = "https://github.com/capjamesg/indieweb-utils/pulls/1" | |
callbacks = { | |
"github.com": [ | |
lambda path: "A comment on pull request " + path[1] if len(path) > 2 and path[2] == "pulls" else "", | |
lambda path: "A comment on GitHub project " + path[1] if len(path) > 1 else "" | |
] | |
} | |
parsed_url = urlparse(url) | |
domain = parsed_url.netloc | |
path = parsed_url.path.split("/") | |
path.remove("") | |
functions = callbacks[domain] | |
for f in functions: | |
if f(path) != "": | |
print(f(path)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment