class AppsList():
    '''
        List of existing apps
        Goal : provide the links between python objects and network paths
        Singleton class (entirely static)
        App import is done only just before using an app
    '''

    def get_server_app_key(network_path):
        if network_path.startswith("/login/"):
            return "/login/"
        elif network_path.startswith("/chat/"):
            return network_path
        elif network_path.startswith("/wiki/"):
            return "/wiki/"
        elif network_path.startswith("/game/"):
            return network_path
        else:
            return None
    
    # return a server app object to handle the given network path
    def get_server_app(network_path):
        if network_path.startswith("/login/"):
            from apps.login_server import LoginServer
            return LoginServer(network_path)
        elif network_path.startswith("/chat/"):
            from apps.chat_server import ChatServer
            return ChatServer(network_path)
        elif network_path.startswith("/wiki/"):
            from apps.wiki_server import WikiServer
            return WikiServer(network_path)
        elif network_path.startswith("/game/"):
            from apps.turnbasedgame_server import TurnBasedGameServer
            return TurnBasedGameServer(network_path)
        else:
            return None

    def get_client_app(network_path):
        if network_path.startswith("/chat/"):
            from apps.chat_client import ChatClient
            chat_client =  ChatClient()
            chat_client.chat_address = network_path
            return chat_client
        elif network_path.startswith("/wiki/"):
            from apps.wiki_client import WikiClient
            wiki_client = WikiClient()
            wiki_client.target_address = network_path
            return wiki_client
        elif network_path.startswith("/game/"):
            from apps.turnbasedgame_client import TurnBasedGameClient
            game_client = TurnBasedGameClient()
            game_client.target_address = network_path
            return game_client
        else:
            return None