def redate_file(fn):
	"""redates file if file modification datetime differs from svn info"""
	global ALL_CNT, CHANGED_CNT
	ALL_CNT += 1
	svn_dt = None
	s = os.stat(fn)
	file_time = s[8]
	if DEBUG:
		print(fn)
	f = open(fn, 'rb')
	try:
		for line in f.readlines():
			if '$Id:' in line:
				svn_dt = extract_svn_dt(line)
				break
	finally:
		f.close()
	if svn_dt:
		svn_time = svndtinfo2time(svn_dt)
		secs_diff = file_time - svn_time
		MAX_DIFF = 130.0
		if secs_diff > MAX_DIFF or secs_diff < -MAX_DIFF:
			print "%s    %s -> %s" % (fn, show_fdt(file_time), show_fdt(svn_time))
			os.utime(fn, (svn_time, svn_time))
			CHANGED_CNT += 1
redates file if file modification datetime differs from svn info
recipes/Python/577341_Redate_source_files_using_SVN_info/recipe-577341.py