/
ilya.petrash
/
SimplePyScripts
Обзор
Документация
Войти
/
ilya.petrash
/
SimplePyScripts
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
github_io_git_repo_url.py
26 строк
670 B
gil9red
Refactoring. Using f-strings
26 июн 2023, 12:42
26 июн 2023, 12:42
fec522a
Код
Авторство
О чём код?
#!/usr/bin/env python3 # -*- coding: utf-8 -*- __author__ = "ipetrash" import re # Convertor github pages url to github repo url # http://nemilya.github.io/coffeescript-game-life/html/game.html # https://github.com/nemilya/coffeescript-game-life def github_io_git_repo_url(github_io_url: str) -> str | None: match = re.search(r"https?://(.+)\.github\.io/(.+)", github_io_url) if match: user = match.group(1) repo = match.group(2).split("/")[0] return f"https://github.com/{user}/{repo}" if __name__ == "__main__": url = "http://nemilya.github.io/coffeescript-game-life/html/game.html" print(github_io_git_repo_url(url))