def commit_cache(cache_name):
	_path = os.path.join(profiles.get_world_directory(WORLD_INFO['id']), '%s_history.dat' % cache_name)
	_write_cache = []

	if not os.path.exists(_path):
		return False

	with open(_path, 'r') as f:
		_cache = f.readlines()

		for _line in _cache:
			line = _line.rstrip()
			
			if line == '\n' or not line:
				continue
			
			print repr(line)
			_historic_item = json.loads(line)
			_historic_item['_allow_dump'] = True
			_write_cache.append(json.dumps(_historic_item))

	if cache_name == 'items':
		for item_uid in ITEMS_HISTORY:
			_historic_item = ITEMS_HISTORY[item_uid]
			if not _historic_item['_on_disk']:
				continue
			
			_historic_item['_allow_dump'] = True

	with open(_path, 'w') as f:
		f.write('\n'.join(_write_cache))

	logging.debug('Cache: Committed.')
dataset/ETHPy150Open flags/Reactor-3/cache.py/commit_cache/original