Skip to content

Commit 67764ed

Browse files
Compatibilize slicindice-python client with python 3
1 parent 48ca40b commit 67764ed

File tree

9 files changed

+60
-63
lines changed

9 files changed

+60
-63
lines changed

README.md

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ Whether you want to test the client installation or simply check more examples o
1919

2020
In order to install the Python client, you only need to use [`pip`](https://packaging.python.org/installing/).
2121

22-
**IMPORTANT:** Currently we only support Python 2.7
23-
2422
```bash
2523
pip install pyslicer --extra-index-url=https://packagecloud.io/slicingdice/clients/pypi/simple
2624
```
@@ -63,7 +61,7 @@ query_data = {
6361
}
6462
]
6563
}
66-
print client.count_entity(query_data)
64+
print(client.count_entity(query_data))
6765
```
6866

6967
## Reference
@@ -93,7 +91,7 @@ Get information about current database(related to api keys informed on construct
9391
```python
9492
from pyslicer import SlicingDice
9593
client = SlicingDice('MASTER_API_KEY', uses_test_endpoint=False)
96-
print client.get_database()
94+
print(client.get_database())
9795
```
9896

9997
#### Output example
@@ -115,7 +113,7 @@ Get all created columns, both active and inactive ones. This method corresponds
115113
```python
116114
from pyslicer import SlicingDice
117115
client = SlicingDice('MASTER_API_KEY', uses_test_endpoint=False)
118-
print client.get_columns()
116+
print(client.get_columns())
119117
```
120118

121119
#### Output example
@@ -161,7 +159,7 @@ column = {
161159
"description": "Year of manufacturing",
162160
"storage": "latest-value"
163161
}
164-
print client.create_column(column)
162+
print(client.create_column(column))
165163
```
166164

167165
#### Output example
@@ -216,7 +214,7 @@ insert_data = {
216214
},
217215
"auto-create": ["table", "column"]
218216
}
219-
print client.insert(insert_data)
217+
print(client.insert(insert_data))
220218
```
221219

222220
#### Output example
@@ -243,7 +241,7 @@ ids = [
243241
"user2@slicingdice.com",
244242
"user3@slicingdice.com"
245243
]
246-
print client.exists_entity(ids)
244+
print(client.exists_entity(ids))
247245
```
248246

249247
#### Output example
@@ -271,7 +269,7 @@ Count the number of inserted entities in the whole database. This method corresp
271269
from pyslicer import SlicingDice
272270
client = SlicingDice('MASTER_OR_READ_API_KEY', uses_test_endpoint=False)
273271

274-
print client.count_entity_total()
272+
print(client.count_entity_total())
275273
```
276274

277275
#### Output example
@@ -297,7 +295,7 @@ client = SlicingDice('MASTER_OR_READ_API_KEY', uses_test_endpoint=False)
297295

298296
tables = ['default']
299297

300-
print client.count_entity_total(tables)
298+
print(client.count_entity_total(tables))
301299
```
302300

303301
#### Output example
@@ -350,7 +348,7 @@ query = [
350348
"bypass-cache": False
351349
}
352350
]
353-
print client.count_entity(query)
351+
print(client.count_entity(query))
354352
```
355353

356354
#### Output example
@@ -406,7 +404,7 @@ query = [
406404
"bypass-cache": True
407405
}
408406
]
409-
print client.count_event(query)
407+
print(client.count_event(query))
410408
```
411409

412410
#### Output example
@@ -438,7 +436,7 @@ query = {
438436
"car-model": 3
439437
}
440438
}
441-
print client.top_values(query)
439+
print(client.top_values(query))
442440
```
443441

444442
#### Output example
@@ -499,7 +497,7 @@ query = {
499497
}
500498
]
501499
}
502-
print client.aggregation(query)
500+
print(client.aggregation(query))
503501
```
504502

505503
#### Output example
@@ -537,7 +535,7 @@ Get all saved queries. This method corresponds to a [GET request at /query/saved
537535
```python
538536
from pyslicer import SlicingDice
539537
client = SlicingDice('MASTER_API_KEY', uses_test_endpoint=False)
540-
print client.get_saved_queries()
538+
print(client.get_saved_queries())
541539
```
542540

543541
#### Output example
@@ -606,7 +604,7 @@ query = {
606604
],
607605
"cache-period": 100
608606
}
609-
print client.create_saved_query(query)
607+
print(client.create_saved_query(query))
610608
```
611609

612610
#### Output example
@@ -659,7 +657,7 @@ new_query = {
659657
],
660658
"cache-period": 100
661659
}
662-
print client.update_saved_query('my-saved-query', new_query)
660+
print(client.update_saved_query('my-saved-query', new_query))
663661
```
664662

665663
#### Output example
@@ -695,7 +693,7 @@ Executed a saved query at SlicingDice. This method corresponds to a [GET request
695693
```python
696694
from pyslicer import SlicingDice
697695
client = SlicingDice('MASTER_OR_READ_API_KEY', uses_test_endpoint=False)
698-
print client.get_saved_query('my-saved-query')
696+
print(client.get_saved_query('my-saved-query'))
699697
```
700698

701699
#### Output example
@@ -732,7 +730,7 @@ Delete a saved query at SlicingDice. This method corresponds to a [DELETE reques
732730
```python
733731
from pyslicer import SlicingDice
734732
client = SlicingDice('MASTER_API_KEY', uses_test_endpoint=False)
735-
print client.delete_saved_query('my-saved-query')
733+
print(client.delete_saved_query('my-saved-query'))
736734
```
737735

738736
#### Output example
@@ -784,7 +782,7 @@ query = {
784782
"columns": ["car-model", "year"],
785783
"limit": 2
786784
}
787-
print client.result(query)
785+
print(client.result(query))
788786
```
789787

790788
#### Output example
@@ -832,7 +830,7 @@ query = {
832830
"columns": ["car-model", "year"],
833831
"limit": 2
834832
}
835-
print client.score(query)
833+
print(client.score(query))
836834
```
837835

838836
#### Output example

pyslicer/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33

4-
from client import SlicingDice
4+
from .client import SlicingDice

pyslicer/api.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
import ujson
66
import requests
77

8-
import pyslicer.exceptions as exceptions
9-
10-
from pyslicer.core.handler_response import SDHandlerResponse
11-
from pyslicer.core.requester import Requester
8+
from . import exceptions
9+
from .core.handler_response import SDHandlerResponse
10+
from .core.requester import Requester
1211

1312

1413
class SlicingDiceAPI(object):

pyslicer/client.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,18 @@
1818
"""A library that provides a Python client to Slicing Dice API"""
1919
import ujson
2020

21-
import pyslicer.utils.validators as validators
22-
import pyslicer.exceptions as exceptions
23-
24-
from pyslicer.api import SlicingDiceAPI
25-
from pyslicer.url_resources import URLResources
21+
from . import exceptions
22+
from .api import SlicingDiceAPI
23+
from .url_resources import URLResources
24+
from .utils import validators
2625

2726

2827
class SlicingDice(SlicingDiceAPI):
2928
"""A python interface to Slicing Dice API
3029
3130
Example usage:
3231
33-
To create an object of the SliceDicer:
32+
To create an object of the SlicingDice:
3433
3534
from pyslicer.api import SlicingDice
3635
sd = SlicingDice('my-token')

pyslicer/core/helper_handler_exceptions.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33

4-
import pyslicer.exceptions as exceptions
5-
4+
from .. import exceptions
65
from collections import defaultdict
76

87

pyslicer/core/requester.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import requests
55

6-
import pyslicer.exceptions as exceptions
6+
from .. import exceptions
77

88

99
class Requester(object):

pyslicer/utils/validators.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
# -*- coding: utf-8 -*-
33

44
import abc
5+
import six
56

6-
import pyslicer.exceptions as exceptions
7-
7+
from .. import exceptions
88
from pyslicer.utils.data_utils import is_str_empty
99

1010
MAX_QUERY_SIZE = 10
@@ -142,7 +142,7 @@ def exceeds_columns_limit(self):
142142
Returns:
143143
false if don't exceeds the limit
144144
"""
145-
for key, value in self.data.iteritems():
145+
for key, value in six.iteritems(self.data):
146146
if len(value) > 6:
147147
raise exceptions.MaxLimitException(
148148
"The query '{0}' exceeds the limit of columns "
@@ -159,7 +159,7 @@ def exceeds_values_contains_limit(self):
159159
Returns:
160160
false if don't exceeds the limit
161161
"""
162-
for key, value in self.data.iteritems():
162+
for key, value in six.iteritems(self.data):
163163
if "contains" in value and len(value['contains']) > 5:
164164
raise exceptions.MaxLimitException(
165165
"The query '{0}' exceeds the limit of contains "

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def read(fname):
1111
author="SlicingDice LLC",
1212
author_email="help@slicingdice.com",
1313
description="Official Python client for SlicingDice, Data Warehouse and Analytics Database as a Service.",
14-
install_requires=["requests", "ujson"],
14+
install_requires=["requests", "six", "ujson"],
1515
license="BSD",
1616
keywords="slicingdice slicing dice data analysis analytics database",
1717
packages=[

0 commit comments

Comments
 (0)