Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@taotao54321
Created February 14, 2020 01:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taotao54321/2942b86a38142f6092bde38db86b03f7 to your computer and use it in GitHub Desktop.
Save taotao54321/2942b86a38142f6092bde38db86b03f7 to your computer and use it in GitHub Desktop.
online-judge-tools でテストケースDL済のディレクトリから問題ページを開く
#!/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