7
7
import sunlight .service
8
8
import json
9
9
10
- service_url = "http://capitolwords.org/api"
10
+ service_url = "http://capitolwords.org/api/1 "
11
11
12
12
13
13
class CapitolWords (sunlight .service .Service ):
@@ -35,7 +35,7 @@ def dates(self, phrase, **kwargs):
35
35
endpoint <http://capitolwords.org/api/#dates.json>`_.
36
36
"""
37
37
kwargs ['phrase' ] = phrase
38
- return self .get ("dates" , ** kwargs )
38
+ return self .get ([ "dates" ] , ** kwargs )
39
39
40
40
def phrases (self , entity_type , entity_value , ** kwargs ):
41
41
"""
@@ -49,7 +49,7 @@ def phrases(self, entity_type, entity_value, **kwargs):
49
49
kwargs ['entity_type' ] = entity_type
50
50
kwargs ['entity_value' ] = entity_value
51
51
52
- return self .get ("phrases" , ** kwargs )
52
+ return self .get ([ "phrases" ] , ** kwargs )
53
53
54
54
def phrases_by_entity (self , entity_type , ** kwargs ):
55
55
"""
@@ -60,8 +60,7 @@ def phrases_by_entity(self, entity_type, **kwargs):
60
60
For a list of arguments see `Capitol Words' phrases/entity.json
61
61
endpoint <http://capitolwords.org/api/#phrases/entity.json>`_.
62
62
"""
63
- lss = "%s/%s" % ("phrases" , entity_type )
64
- return self .get (lss , ** kwargs )
63
+ return self .get (["phrases" , entity_type ], ** kwargs )
65
64
66
65
def text (self , phrase = None , title = None , ** kwargs ):
67
66
"""
@@ -88,14 +87,17 @@ def text(self, phrase=None, title=None, **kwargs):
88
87
if title :
89
88
kwargs ['title' ] = title
90
89
91
- return self .get ("text" , ** kwargs )
90
+ return self .get ([ "text" ] , ** kwargs )
92
91
93
92
# API impl methods below
94
93
95
- def _get_url (self , obj , apikey , ** kwargs ):
94
+ def _get_url (self , pathparts , apikey , ** kwargs ):
95
+ # join pieces by slashes and add a trailing slash
96
+ endpoint_path = "/" .join (pathparts )
97
+
96
98
ret = "%s/%s.json?apikey=%s&%s" % (
97
99
service_url ,
98
- obj ,
100
+ endpoint_path ,
99
101
apikey ,
100
102
sunlight .service .safe_encode (kwargs )
101
103
)
0 commit comments