rclabels2text.py

来自「用python实现的邮件过滤器」· Python 代码 · 共 48 行

PY
48
字号
# rclabels2text.py# This module is part of the spambayes project, which is Copyright 2003# The Python Software Foundation and is covered by the Python Software# Foundation license.__author__="Adam Walker"__doc__=""""Pulls labels and captions out of a windows resource fileand writes them into a text file for spell checking purposes."""import sys, os, reimport rcparseranti_and = re.compile(r"([^\\]*)&([^&]*)");anti_nl = re.compile(r"([^\\]*)\\n([^\\])");def extract(inputFilename = None, outputFilename = None):    """See the module doc string"""    if inputFilename is None:        inputFilename = "dialogs.rc"    if outputFilename is None:        outputFilename = "spellcheck.txt"    rcp = rcparser.ParseDialogs(inputFilename)    out = open(outputFilename, "wt")    for dlg_id in rcp._dialogs:        print dlg_id        dlg = rcp._dialogs[dlg_id]        out.write("\n================================================\n")        out.write("In Dialog: "+str(dlg_id)+" Title: "+str(dlg.caption)+"\n\n")        for ctrl in dlg.controls:            if len(ctrl.label)>0:                out.write(ctrl.id)                out.write("\n")                s = ctrl.label                s = anti_and.sub(r"\g<1>\g<2>", s)                s = anti_nl.sub("\\g<1>\n\\g<2>",s)                out.write(s)                out.write("\n\n")    out.close()    os.startfile(outputFilename);if __name__=="__main__":    if len(sys.argv)>1:        extract(sys.argv[1], sys.argv[2])    else:        extract()

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?