pysig.py
来自「The major functionality added in this re」· Python 代码 · 共 72 行
PY
72 行
import stringimport sysimport reens = ""bbreak = re.compile ("[^A-Z]*,?([A-Z_0-9]+)[^A-Z]*,?")def process(l): global ens ens = ens + l[:-1]processing = 0l = sys.stdin.readline ()while (l != ""): if (string.find (l, "//STOP") != -1): processing = 0 if (processing == 1): process(l) if (string.find (l, "//START") != -1): processing = 1 l = sys.stdin.readline ()#print ensparts1 = []parts2 = []parts1 = bbreak.split (ens)for x in range (len(parts1)): if (x & 1 == 1): parts2.append (parts1[x])print parts2print """/* XChat This file was generated by sigextract.py by Adam Langley agl@linuxpower.org It should *not* be edited by hand! AGL*/struct signalmapping{ char *name; int num;};static struct signalmapping signal_mapping[] = {"""# This is the start of the numbers, in this case the signals start at 1count = 1for x in parts2: print " {\"" + x + "\", " + str(count) + "}," count = count + 1print """ {NULL, 0}};#define NUM_SIGNALS_LOOKUP """,print str(count)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?