def update_static_names(names_file, files):
 if os.path.exists(names_file):
  names = json.load(open(names_file))
 else:
  names = {}
 base = os.path.dirname(names_file)
 for path in files:
  name = os.path.relpath(path, base)
  mangled_name = generate_static_name(name, base)
  names[name] = mangled_name
  if (not os.path.islink(path)):
   mangled_path = os.path.join(base, mangled_name)
   shutil.move(path, mangled_path)
   if os.path.exists(path):
    os.unlink(path)
   os.symlink(mangled_name, path)
 json_enc = json.JSONEncoder(indent=2, sort_keys=True)
 open(names_file, 'w').write(json_enc.encode(names))
 return names

def update_static_names ( names_file , files ) : if os . path . exists ( names_file ) : names = json . load ( open ( names_file ) ) else : names = { } base = os . path . dirname ( names_file ) for path in files : name = os . path . relpath ( path , base ) mangled_name = generate_static_name ( name , base ) names [ name ] = mangled_name if ( not os . path . islink ( path ) ) : mangled_path = os . path . join ( base , mangled_name ) shutil . move ( path , mangled_path ) if os . path . exists ( path ) : os . unlink ( path ) os . symlink ( mangled_name , path ) json_enc = json . JSONEncoder ( indent = 2 , sort_keys = True ) open ( names_file , 'w' ) . write ( json_enc . encode ( names ) ) return names
generate a unique file name mapping for files and write it to a json file at names_file .