Esempio n. 1
0
    def __init__(self,
                 host,
                 user=None,
                 password=None,
                 authenticator=None,
                 base="",
                 collapse_scope=True):
        """
        Constructor for the API-Singleton. Use it once with parameters, and then the
        subsequent calls internal to the API will work.

        @type host: str
        @param host: the host to connect to, e.g. "api.soundcloud.com". If a port is needed, use
                "api.soundcloud.com:1234"
        @type user: str
        @param user: if given, the username for basic HTTP authentication
        @type password: str
        @param password: if the user is given, you have to give a password as well
        @type authenticator: OAuthAuthenticator | BasicAuthenticator
        @param authenticator: the authenticator to use, see L{scapi.authentication}
        """
        self.host = host
        if authenticator is not None:
            self.authenticator = authenticator
        elif user is not None and password is not None:
            self.authenticator = BasicAuthenticator(user, password)
        self._base = base
        self.collapse_scope = collapse_scope