import os,sys,os.path,subprocess

g_dbg = '-dbg' in sys.argv or False
g_verbose = '-verbose' in sys.argv or False

k_vt_col_map = { '':'\x1b[0m', 'default':'\x1b[0m', 'black':'\x1b[30m', 'red':'\x1b[31m', 'green':'\x1b[32m', 'yellow':'\x1b[33m',
	'blue':'\x1b[34m', 'magenta':'\x1b[35m', 'cyan':'\x1b[36m', 'white':'\x1b[37m',
	'bdefault':'\x1b[49m', 'bblack':'\x1b[40m', 'bred':'\x1b[41m', 'bgreen':'\x1b[42m', 'byellow':'\x1b[43m',
	'bblue':'\x1b[44m', 'bmagenta':'\x1b[45m', 'bcyan':'\x1b[46m', 'bwhite':'\x1b[47m' }
vt_cm = k_vt_col_map
def set_vt_col(col):
	sys.stdout.write(k_vt_col_map[col])
def unistr(str):
	if not isinstance(str, unicode):
		return unicode(str, "utf-8")
	return str
largv = []
def largv_has(keys):
	for i in range(len(keys)):
		 if (keys[i] in largv):
			return True
	return False
def largv_has_key(keys):
	for key in keys:
		ki = largv.index(key) if key in largv else -1
		if (ki >= 0 and ki+1 < len(largv)):
			return True
	return False
def largv_get(keys, dflt):
	if ( hasattr(sys, 'argv')):
		for key in keys:
			ki = largv.index(key) if key in largv else -1
			if (ki >= 0 and ki+1 < len(largv)):
				return largv[ki+1]
	return dflt
def largv_geti(i, dflt):
	if (i >= len(largv)):
		return dflt
	return largv[i]
def fphere():
	return os.path.dirname(os.path.realpath(__file__))
def main():
	ifp = largv[1]
	ofd = os.path.dirname(os.path.realpath(ifp))
	ofp = ''; ofile = None; do_handle = False;
	handletool = os.path.join(fphere(), 'handle_file.sh')
	with open(ifp, "r") as ifile:
		for line in ifile.readlines():
			if (line.startswith('--[') or line.startswith('-=['))  and line.rstrip().endswith(']'):
				if ofile:
					ofile.close()
					if (do_handle):
						pop_in = [handletool, ofp]
						#print ''; sys.stdout.flush();
						pop = subprocess.Popen(pop_in)
						pop.wait()
						#print ''
				do_handle = line.startswith('-=[')
				ofn = line[len('--['):-2]; ofp = os.path.join(ofd, ofn);
				ofile = open(ofp, "w")
				if g_dbg or g_verbose:
					set_vt_col('yellow'); print ' {}'.format(ofn); set_vt_col('default'); sys.stdout.flush();
			else:
				if line.startswith('--#') == False:
					ofile.write(line)
	if ofile:
		ofile.close()
largv = sys.argv
main()

@@ -25,16 +25,24 @@
 bprocess
+,hashlib
 %0A%0Ag_dbg 
@@ -114,16 +114,56 @@
 or False
+%0Ag_force = '-force' in sys.argv or False
 %0A%0Ak_vt_c
@@ -1363,16 +1363,360 @@
 main():%0A
+%09def handle_file(fp, old_md5):%0A%09%09new_md5 = hashlib.md5(open(fp, 'r').read()).hexdigest()%0A%09%09if new_md5 != old_md5:%0A%09%09%09handletool = os.path.join(fphere(), 'handle_file.sh')%0A%09%09%09pop_in = %5Bhandletool, ofp%5D%0A%09%09%09#print ''; sys.stdout.flush();%0A%09%09%09pop = subprocess.Popen(pop_in)%0A%09%09%09pop.wait()%0A%09%09%09#print ''%0A%09%09else:%0A%09%09%09if g_verbose:%0A%09%09%09%09print '  (cached)'%0A
 %09ifp = l
@@ -1816,63 +1816,34 @@
 lse;
-%0A%09handletool = os.path.join(fphere(), 'handle_file.sh')
+ old_md5 = None;%0A%09find = 0
 %0A%09wi
@@ -2058,141 +2058,33 @@
 %09%09%09%09
-pop_in = %5Bhandletool, ofp%5D%0A%09%09%09%09%09%09#print ''; sys.stdout.flush();%0A%09%09%09%09%09%09pop = subprocess.Popen(pop_in)%0A%09%09%09%09%09%09pop.wait()%0A%09%09%09%09%09%09#print ''
+handle_file(ofp, old_md5)
 %0A%09%09%09
@@ -2180,16 +2180,112 @@
 , ofn);%0A
+%09%09%09%09if do_handle and not g_force:%0A%09%09%09%09%09old_md5 = hashlib.md5(open(ofp, 'r').read()).hexdigest()%0A
 %09%09%09%09ofil
@@ -2303,16 +2303,34 @@
 p, %22w%22)%0A
+%09%09%09%09find = find+1%0A
 %09%09%09%09if g
@@ -2542,16 +2542,63 @@
 close()%0A
+%09%09if (do_handle):%0A%09%09%09handle_file(ofp, old_md5)%0A
 largv = 

Update multifile.py