- 【入門】Common Lisp その11【質問よろず】
283 :282[]:2015/10/06(火) 16:16:19.87 ID:QezNm1t4 - localリファレンス用のzshコマンドのために書いた
#!/usr/bin/env python3 import urllib.request import re import os import subprocess import sys # USAGE: this-script.py or this-script.py [Symbol] ref_dir = os.environ["HOME"] + "/lib/HyperSpec/" ref_top_dir = ref_dir + "/Front/X_AllSym.htm" if len(sys.argv) == 1: to_Symbol_list = "w3m " + ref_top_dir subprocess.call(to_Symbol_list, shell=True) elif len(sys.argv) == 2: top_as_html = "file://" + ref_top_dir with urllib.request.urlopen(top_as_html) as res: html = res.read() is_Symbol = 'Body/.+?#' + sys.argv[1] + '"' url_suffix = re.sub("#.*", "", "".join(re.findall(is_Symbol, html.decode()))) if url_suffix: do_w3m = "w3m " + ref_dir + url_suffix subprocess.call(do_w3m, shell=True) else: print("The symbol was not found.") else: print("Please input 0 or 1 Symbol of Lisp.")
|
|