资源简介
用于两个配置文件defconfig之间的比较,差分。当配置文件里面的CONFIG_XXXXXX=Y项因时间推移,乱序情况下,使用此工具,颇为方便。
代码片段和文件信息
#!/usr/bin/env python
import os
import sys
import optparse
def show_help(name):
print ““
print “Usage: %s [-d--diff-type][\“=\“\“ \“] [\“a-b\“\“b-a\“\“a&b\“\“a|b\“] defconf_file1 defconf_file2“ % (name)
print ““
parse = optparse.OptionParser(usage = “Usage: %prog [-d--diff-type][\“=\“ \“\ \“][\“a-b\“\“b-a\“\“a&b\“\“a|b\“] defconf_file1 defconf_file2“ version = “%prog 1.2“)
parse.add_option(“-d“ “--diff-type“ dest = “diff_type“ action = “store“ type = str default = “a-b“ help = “file compare type“)
parse.add_option(‘-v‘ “--ver“ dest = “get_version“ action = “store_true“ help=‘Show Version Info‘)
parse.add_option(‘-V‘ “--verbose“ dest = “in_detail“ action = “store_true“ help=‘Output information in detail‘)
options args = parse.parse_args()
diff_type = options.diff_type
in_detail = options.in_detail
if in_detail:
print “options: “ + str(options)
print “args: “ + str(args)
if diff_type == “a-b“:
fn_idx = 0
elif diff_type == “b-a“:
fn_idx = 1
elif diff_type == “a|b“:
fn_idx = 2
elif diff_type == “a&b“:
fn_idx = 3
else:
show_help(sys.argv[0])
os._exit(0)
args_num = len(args)
if args_num != 2:
show_help(sys.argv[0])
os._exit(-1)
for arg_idx in range(0 args_num):
file_name = args[arg_idx]
if os.access(file_name os.R_OK) != True:
print ““
print “file \“%s\“ could not read“ % file_name
show_help(sys.argv[0])
os._exit(-1)
config_a_set = set()
config_b_set = set()
def fill_set_by_config(a_set filename):
fd = open(filename)
line_idx = 0
if in_detail:
print “################################################“
print “#### deal with file \“%s\“ ####“ % filename
print “################################################“
for line in fd.readlines():
stripline = line.strip()
- 上一篇:人工神经网络
- 下一篇:python之最简单实现arp攻击
评论
共有 条评论