<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def path_from_uri(self, uri):
 """Make a safe path name from uri. In the case that uri is already a local path then the same path is returned. """

        (scheme, netloc, path, params, query, frag) = urlparse(uri)
        if (netloc == ''):
            return(uri)
        path = '/'.join([netloc, path])
        path = re.sub('[^\w\-\.]', '_', path)
        path = re.sub('__+', '_', path)
        path = re.sub('[_\.]+$', '', path)
        path = re.sub('^[_\.]+', '', path)
        return(path)