'Convert uri to absolute filepath
Parameters
uri : string
URI of python module to return path for
Returns
path : None or string
Returns None if there is no valid path for this URI
Otherwise returns absolute file system path for URI
Examples
>>> docwriter = ApiDocWriter(\'sphinx\')
>>> import sphinx
>>> modpath = sphinx.__path__[0]
>>> res = docwriter._uri2path(\'sphinx.builder\')
>>> res == os.path.join(modpath, \'builder.py\')
True
>>> res = docwriter._uri2path(\'sphinx\')
>>> res == os.path.join(modpath, \'__init__.py\')
True
>>> docwriter._uri2path(\'sphinx.does_not_exist\')'

def _uri2path(self, uri):

    if (uri == self.package_name):
        return os.path.join(self.root_path, '__init__.py')
    path = uri.replace('.', os.path.sep)
    path = path.replace((self.package_name + os.path.sep), '')
    path = os.path.join(self.root_path, path)
    if os.path.exists((path + '.py')):
        path += '.py'
    elif os.path.exists((path + '.pyx')):
        path += '.pyx'
    elif os.path.exists(os.path.join(path, '__init__.py')):
        path = os.path.join(path, '__init__.py')
    else:
        return None
    return path
