Exemplo n.º 1
0
def sort_subscriptions(username, password):
    l = locator.Locator(username)
    url = l.subscriptions_uri(format='json')
    r = requests.get(url, auth=(username, password))
    page = r.content
    jsn = json.loads(page)
    return sorted(jsn, key=sort_by_subscribers)
Exemplo n.º 2
0
def subscription(username, password):
    l = locator.Locator(username)
    url = l.subscriptions_uri(format='json')
    r = requests.get(url, auth=(username, password))
    page = r.content
    jsn = json.loads(page)
    return jsn
Exemplo n.º 3
0
    def __init__(self, host=mygpoclient.HOST, client_class=json.JsonClient):
        """Creates a new Public API client

        The parameter host is optional and defaults to
        the main webservice.

        The parameter client_class is optional and should
        not need to be changed in normal use cases. If it
        is changed, it should provide the same interface
        as the json.JsonClient class in mygpoclient.
        """
        self._locator = locator.Locator(None, host)
        self._client = client_class(None, None)
Exemplo n.º 4
0
    def __init__(self, root_url=mygpoclient.ROOT_URL, client_class=json.JsonClient):
        """Creates a new Public API client

        The parameter root_url is optional and defaults to
        the main webservice. It can be either a hostname or
        a full URL (to force https, for instance).

        The parameter client_class is optional and should
        not need to be changed in normal use cases. If it
        is changed, it should provide the same interface
        as the json.JsonClient class in mygpoclient.
        """
        self._locator = locator.Locator(None, root_url)
        self._client = client_class(None, None)
Exemplo n.º 5
0
    def __init__(self, username, password, root_url=mygpoclient.ROOT_URL,
                 client_class=json.JsonClient):
        """Creates a new Simple API client

        Username and password must be specified and are
        the user's login data for the webservice.

        The parameter root_url is optional and defaults to
        the main webservice. It can be either a hostname or
        a full URL (to force https, for instance).

        The parameter client_class is optional and should
        not need to be changed in normal use cases. If it
        is changed, it should provide the same interface
        as the json.JsonClient class in mygpoclient.
        """
        self.username = username
        self.password = password
        self._locator = locator.Locator(username, root_url)
        self._client = client_class(username, password)
Exemplo n.º 6
0
    def __init__(self,
                 username,
                 password,
                 host=mygpoclient.HOST,
                 client_class=json.JsonClient):
        """Creates a new Simple API client

        Username and password must be specified and are
        the user's login data for the webservice.

        The parameter host is optional and defaults to
        the main webservice.

        The parameter client_class is optional and should
        not need to be changed in normal use cases. If it
        is changed, it should provide the same interface
        as the json.JsonClient class in mygpoclient.
        """
        self.username = username
        self.password = password
        self._locator = locator.Locator(username, host)
        self._client = client_class(username, password)
Exemplo n.º 7
0
 def test_create_with_url(self):
     """Test locator creation with a root URL instead of host"""
     loc = locator.Locator('hello', 'https://gpo.self.hosted/my')
     self.assertEquals(loc.toplist_uri(),
                       'https://gpo.self.hosted/my/toplist/50.opml')
Exemplo n.º 8
0
 def setUp(self):
     self.locator = locator.Locator('jane')
Exemplo n.º 9
0
 def test_create_with_host(self):
     """Test locator creation with a host"""
     loc = locator.Locator('hello', 'gpo.self.hosted')
     self.assertEquals(loc.toplist_uri(),
                       'http://gpo.self.hosted/toplist/50.opml')
Exemplo n.º 10
0
 def test_create_with_url_slash(self):
     """Test locator creation with a root URL ending with a slash"""
     loc = locator.Locator('hello', 'https://gpo.self.hosted/my/')
     self.assertEquals(loc.toplist_uri(),
                       'https://gpo.self.hosted/my/toplist/50.opml')