diff --git a/ari/__init__.py b/ari/__init__.py index caafe24..cf2b6e1 100644 --- a/ari/__init__.py +++ b/ari/__init__.py @@ -7,9 +7,9 @@ import ari.client import swaggerpy.http_client -import urlparse +import urllib.parse -Client = client.Client +Client = ari.client.Client def connect(base_url, username, password): @@ -18,9 +18,10 @@ def connect(base_url, username, password): :param base_url: Base URL for Asterisk HTTP server (http://localhost:8088/) :param username: ARI username :param password: ARI password. - :return: + :return: ARI Client instance + :rtype: ari.client.Client """ - split = urlparse.urlsplit(base_url) + split = urllib.parse.urlsplit(base_url) http_client = swaggerpy.http_client.SynchronousHttpClient() http_client.set_basic_auth(split.hostname, username, password) - return Client(base_url, http_client) + return Client(base_url, http_client) \ No newline at end of file diff --git a/ari/client.py b/ari/client.py index c1ce6e7..6261cbd 100644 --- a/ari/client.py +++ b/ari/client.py @@ -7,7 +7,7 @@ import json import logging -import urlparse +import urllib.parse import swaggerpy.client from ari.model import * @@ -23,7 +23,7 @@ class Client(object): """ def __init__(self, base_url, http_client): - url = urlparse.urljoin(base_url, "ari/api-docs/resources.json") + url = urllib.parse.urljoin(base_url, "ari/api-docs/resources.json") self.swagger = swaggerpy.client.SwaggerClient( url, http_client=http_client) @@ -192,7 +192,7 @@ def extract_objects(event, *args, **kwargs): # If there's only one field in the schema, just pass that along if len(obj_fields) == 1: if obj: - obj = obj.values()[0] + obj = list(obj.values())[0] else: obj = None event_cb(obj, event, *args, **kwargs) @@ -295,5 +295,4 @@ def on_sound_event(self, event_type, fn, *args, **kwargs): :param kwargs: Keyword arguments to pass to fn """ return self.on_object_event(event_type, fn, Sound, 'Sound', - *args, **kwargs) - + *args, **kwargs) \ No newline at end of file diff --git a/ari/model.py b/ari/model.py index f18ccdc..2344eaf 100644 --- a/ari/model.py +++ b/ari/model.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """Model for mapping ARI Swagger resources and operations into objects. @@ -355,7 +355,7 @@ def promote(client, resp, operation_json): response_class = operation_json['responseClass'] is_list = False - m = re.match('''List\[(.*)\]''', response_class) + m = re.match(r'''List\[(.*)\]''', response_class) if m: response_class = m.group(1) is_list = True @@ -380,4 +380,4 @@ def promote(client, resp, operation_json): 'StoredRecording': StoredRecording, 'Mailbox': Mailbox, 'DeviceState': DeviceState, -} +} \ No newline at end of file