Example #1
0
def gather_configs():
	if len(sys.argv) >= 2:
		fnames = sys.argv[1:]
	else:
		fnames = []
		for dirpath, dnames, nfnames in os.walk("./"):
			fnames.extend([os.path.join(dirpath, f) for f in nfnames if f.endswith(".ccf")])

	words = set(neon.strings)
	smap = {}
	for fname in fnames:
		print(fname)
		with open(fname, "rb") as ccf:
			data = ccf.read()

		smap[fname] = sections = neon.parse_ccf(data)
		collect_strings(sections, words)

	unhash = {neon.eld_hash(word): word for word in words}

	data = {}
	for sections in smap.values():
		for section_hash, section in sections.items():
			if section_hash in unhash:
				for key_hash, value in section:
					if key_hash in unhash:
						data.setdefault(unhash[section_hash], {})[unhash[key_hash]] = value
	return data
Example #2
0
File: cfg.py Project: dkreuter/ce
if __name__ == '__main__':
	import sys

	if len(sys.argv) >= 2:
		fnames = sys.argv[1:]
	else:
		fnames = []
		for dirpath, dnames, nfnames in os.walk("./"):
			fnames.extend([os.path.join(dirpath, f) for f in nfnames if f.endswith(".ccf")])

	words = set(neon.strings)
	smap = {}
	for fname in fnames:
		print(fname)
		with open(fname, "rb") as ccf:
			data = ccf.read()

		smap[fname] = sections = neon.parse_ccf(data)
		collect_strings(sections, words)

	print()

	unhash = {neon.eld_hash(word): word for word in words}
	for fname in fnames:
		#print(fname)
		sections = smap[fname]
		with open(fname+".txt", "wb") as out:
			totext(sections, unhash, out)
			#toconsole(sections, unhash, sys.stdout)