Changeset 14424 for lang/python
- Timestamp:
- 06/22/08 21:52:46 (5 months ago)
- Files:
-
- 1 modified
-
lang/python/incsearch/incsearch/indexer.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/python/incsearch/incsearch/indexer.py
r14401 r14424 30 30 yield f 31 31 32 def createindex(dbfile, globber, outdirbase, extractor=extractor ):32 def createindex(dbfile, globber, outdirbase, extractor=extractor, removepath=""): 33 33 u""" 34 34 extractor ファイル内の情報列を返す。dict(pos=出現文字位置, title=タイトル) 35 35 """ 36 36 db = DocDbWriter(dbfile) 37 if not removepath.endswith("/"): 38 removepath += "/" 39 37 40 for fname in globber: 38 41 #内容を読み込む 39 print "fname", fname40 42 fp = file(fname) 41 43 whole = fp.read() 42 44 fp.close() 45 46 if removepath: 47 if fname.startswith(removepath): 48 fname = fname[len(removepath):] 49 print "fname", fname, 43 50 44 51 outdir = os.path.join(outdirbase, os.path.dirname(fname)) 52 print " -> outdir", outdir 45 53 if not os.path.exists(outdir): 46 54 os.mkdir(outdir) … … 69 77 createindex("testdb", globber("data/lib/*"), "data/index") 70 78 71 def main(): 72 pass 73 79 def main(dbname, indir, outdir, removepath=""): 80 createindex(dbname, globber(os.path.join(indir, "*")), outdir, removepath=removepath) 74 81 75 82 if __name__ == "__main__": … … 77 84 78 85 parser = optparse.OptionParser(u""" 79 86 DBファイルを作成します。 80 87 """) 81 parser.add_option("-o", "--opt", dest="opt", help=u"", default=None) 88 parser.add_option("-d", "--database", dest="database", help=u"出力するDBファイル名", default=None) 89 parser.add_option("-i", "--input-dir", dest="inputdir", help=u"入力ファイルのあるデリレクトリ名", default=None) 90 parser.add_option("-o", "--output-dir", dest="outputdir", help=u"リンクタグ付きhtmlを出力するディレクトリ名", default=None) 91 parser.add_option("-r", "--remove-path", dest="rmpath", help=u"削除対象とする先頭パス名", default="") 92 82 93 (options, args) = parser.parse_args() 83 94 84 test()85 #main()95 #test() 96 main(options.database, options.inputdir, options.outputdir, removepath=options.rmpath) 86 97 87 98
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)