インストールしたプログラムについて readme changelog 等の ドキュメント を 捜す。
頂きもの ”http://www.tuxcomputing.com/cookbook/finddoc.py”
#!/usr/bin/env python
# doc-find:
# Search for documentation related to the given strings.
# Relies on "locate" and assumes that the locate database is current.
#
# Copyright 2003 by Akkana Peck.
# You may use, distribute or modify this program under the terms of the GPL.
import sys, os, string, re
# Some filenames we consider to be documentation-related.
# If you add to this list, add only lowercase!
# We will lowercase the filenames being compared
# (to make comparisons case insensitive).
docfilenames = [ \
"changelog", \
"readme", \
"install", \
"howto", \
"authors", \
"news", \
"todo", \
"config", \
"sample", \
"samples", \
"example", \
"examples", \
"ref", \
"guide", \
"manual", \
"quickstart", \
"thanks", \
"notes", \
"features", \
"faq", \
"acknowledgement", \
"bugs", \
"problems" \
]
def system_out (cmdstr) :
retlist = []
fp = os.popen(cmdstr)
while 1:
s = fp.readline()
if not s : break
retlist.append(s)
fp.close()
return retlist
# main()
for arg in sys.argv :
#print string.split(arg, " \t./")
files = system_out("locate " + arg + " | grep -w " + arg);
for path in files :
#print path
# Special case for anything with "man", "doc", or "info" in the path:
if (string.find(path, "/man") >= 0) \
or (string.find(path, "/doc") >= 0) \
or (string.find(path, "/info") >= 0) :
print path,
#print "Basename is", os.path.basename(path)
continue
# Now see if it matches any of the docfilenames:
base = os.path.basename(path)
for nam in docfilenames :
if base == "" : continue
# Non full word search would use this:
#if (string.find(string.lower(base), nam) >= 0) :
# Full word search:
# Make a regexp to search for nam as full-word only
pat = "^" + nam + "$"
if (re.compile(nam).search(base, 1)) :
print path,
base = ""
continue
残念でした locate を 作成していないと 美味く 動作しない。
$ which python /usr/bin/python $ /usr/bin/python doc-find.py locate: /var/locate/locatedb: そのようなファイルやディレクトリはありません
使いかた このファイルの 名前と ドキュメントを 捜したいプログラムの 名 前 を 入力する。
$ usr/bin/python doc-find.py grep or chmod +x doc-find.py ./doc-find.py grep
後 ”mass_passwd”、”mass_useradd”等も 頂いた 又後で ゆっくり 見て ゆこう
にゃんたろう 拝!
2006年 1月30日 (月) 20:56:02 JST 作成