online-judge-tools でテストケースDL済のディレクトリから問題ページを開く
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
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
"""oj d したディレクトリから起動すると対応する問題ページを開く。""" | |
import sys | |
from typing import * | |
import webbrowser | |
from onlinejudge._implementation.download_history import DownloadHistory | |
def WARN(msg: str) -> None: | |
print(msg, file=sys.stderr) | |
def ERROR(msg: str) -> NoReturn: | |
WARN(msg) | |
sys.exit(1) | |
def main() -> None: | |
dh = DownloadHistory() | |
urls = dh.get() | |
if not urls: ERROR("no URL found") | |
if len(urls) >= 2: WARN(f"multiple URLs found: {urls}") | |
webbrowser.open_new_tab(urls[0]) | |
if __name__ == "__main__": main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment