mphelp_check.py
来自「君正早期ucos系统(只有早期的才不没有打包成库),MPLAYER,文件系统,图」· Python 代码 · 共 67 行
PY
67 行
#!/usr/bin/python# Tool to compare MPlayer translation files against a base file. Reports# conflicting arguments, extra strings not present in the base file and# (optionally) missing strings.# Written by Uoti Urpalaimport sysimport redef parse(filename): r = {} f = open(filename) it = iter(f) cur = '' for line in it: line = line.strip() if not line.startswith('#define'): while line and line[-1] == '\\': line = it.next().strip() continue _, name, value = line.split(None, 2) value = value.strip('"') while line[-1] == '\\': line = it.next().strip() value += line.rstrip('\\').strip('"') r[name] = value f.close() return rdef compare(base, other, show_missing=False): r = re.compile('%[^diouxXeEfFgGaAcspn%]*[diouxXeEfFgGaAcspn%]') missing = [] for key in base: if key not in other: missing.append(key) continue if re.findall(r, base[key]) != re.findall(r, other[key]): print 'Mismatch: ', key print base[key] print other[key] print del other[key] if other: extra = other.keys() extra.sort() print 'Extra: ', ' '.join(extra) if show_missing and missing: missing.sort() print 'Missing: ', ' '.join(missing)if len(sys.argv) < 3: print 'Usage:\n'+sys.argv[0]+' [--missing] base_helpfile otherfile1 '\ '[otherfile2 ...]' sys.exit(1)i = 1show_missing = Falseif sys.argv[i] in ( '--missing', '-missing' ): show_missing = True i = 2base = parse(sys.argv[i])for filename in sys.argv[i+1:]: print '*****', filename compare(base, parse(filename), show_missing) print '\n'
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?