Skip to content

Commit

Permalink
Merge pull request #92 from Algolytics/encoding_support
Browse files Browse the repository at this point in the history
encoding support and config extension
  • Loading branch information
lszpak authored Jul 10, 2018
2 parents 3637c13 + 42c4ce8 commit c081249
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion dq/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@

__author__ = """Mikołaj Olszewski"""
__email__ = 'mikolaj.olszewski@algolytics.pl'
__version__ = '0.1.0'
__version__ = '0.4.0'

__all__ = ['DQClient', 'JobConfig']
8 changes: 2 additions & 6 deletions dq/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,14 @@ def job_report(self, job_id):
""" GET 'https://app.dataquality.pl/api/v1/jobs/{{job_id}}' """
return self.request_client.get('/jobs/{}'.format(job_id))

def job_results(self, job_id, out_file=None):
def job_results(self, job_id, out_file=None, code_page = 'utf-8'):
""" GET 'https://app.dataquality.pl/api/v1/jobs/{{job_id}}/result' """
response = self.request_client.get('/jobs/{}/result'.format(job_id))
if not response.is_ok():
raise DQError(status=response.status, message=response.content)
if out_file:
try:
file = open(out_file, 'w')
with open(out_file, 'w', encoding=code_page) as file:
file.write(response.content)
file.close()
except OSError:
print("No such file or directory.")

def delete_job(self, job_id):
""" DELETE 'https://app.dataquality.pl/api/v1/jobs/{{job_id}}' """
Expand Down
18 changes: 14 additions & 4 deletions dq/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(self, name):
self._input_format = {
"field_separator": ",",
"text_delimiter": "\"",
"header": 1
"code_page": "utf-8"
}
self._input_columns = {}
self._extend = {
Expand All @@ -58,16 +58,21 @@ def __init__(self, name):
"contact": 0,
"id_numbers": 0
}
self._client = {
"name": "",
"mode": ""
}

self._deduplication = {
"on": 0,
"incremental": 0
}

def input_format(self, field_separator=",", text_delimiter="\"",
has_header=True):
code_page="utf-8"):
self._input_format["field_separator"] = field_separator
self._input_format["text_delimiter"] = text_delimiter
self._input_format["header"] = self.__boolean_to_num(has_header)
self._input_format["code_page"] = code_page

def input_column(self, idx, name, function):
self._input_columns[idx] = {"no": idx, "name": name,
Expand All @@ -93,6 +98,10 @@ def module_std(self, address = False, names = False, contact = False, id_numbers
def deduplication(self, on = False, incremental = False):
self._deduplication["on"] = self.__boolean_to_num(on)
self._deduplication["incremental"] = self.__boolean_to_num(incremental)

def client(self, name, mode):
self._client["name"] = name
self._client["mode"] = mode

@staticmethod
def __boolean_to_num(value):
Expand All @@ -105,5 +114,6 @@ def data(self):
"input_columns": list(self._input_columns.values()),
"extend": self._extend,
"module_std": self._module_std,
"deduplication": self._deduplication
"deduplication": self._deduplication,
"client": self._client
}
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.3.0
current_version = 0.4.0
commit = True
tag = True

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

setup(
name='dq-client',
version='0.3.0',
version='0.4.0',
description="Python library which allows to use http://dataquality.pl in easy way.",
long_description=readme + '\n\n' + history,
author="Mikołaj Olszewski",
Expand Down

0 comments on commit c081249

Please sign in to comment.