import posixpath


def find_remote_project_info( client,
                              url ):
    """Find a project_info.cmake or the info.py file
        in subdirectories of the specified url.
        Files are searched using the patterns :
        1) <url>/project_info.cmake
        2) <url>/python/*/info.py
        3) <url>/*/info.py
        4) <url>/info.py
    
    @type client: Client
    @param client: The Client instance to get access to files.
    
    @type url: string
    @param url: The url to search project_info.cmake or info.py
    
    @rtype: string
    @return: The url of the found file containing project information
    """
    
    project_info_patterns = ( posixpath.join( url,
                                              'project_info.cmake' ),
                              posixpath.join( url,
                                              'python',
                                              '*',
                                              'info.py' ),
                              posixpath.join( url,
                                              '*',
                                              'info.py' ),
                              posixpath.join( url,
                                              'info.py' ))
    # Searches for project_info.cmake and info.py file
    for pattern in project_info_patterns:
            project_info_url = client.vcs_glob( pattern )
            
            if project_info_url:
                return project_info_url[0]
  
    return None