def _legalize_stage(path, replacements, length, extension, fragment):
 path = sanitize_path(path, replacements)
 if (not fragment):
  path = bytestring_path(path)
 path += extension.lower()
 pre_truncate_path = path
 path = truncate_path(path, length)
 return (path, (path != pre_truncate_path))

def _legalize_stage ( path , replacements , length , extension , fragment ) : path = sanitize_path ( path , replacements ) if ( not fragment ) : path = bytestring_path ( path ) path += extension . lower ( ) pre_truncate_path = path path = truncate_path ( path , length ) return ( path , ( path != pre_truncate_path ) )
perform a single round of path legalization steps .