diff --git a/docs/usage.rst b/docs/usage.rst index 835615c..fc73cf9 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -62,7 +62,7 @@ Create new job job = dq.submit_job(job_config, input_data=input_data) # with data in a variable - job = dq.submit_job(job_config, input_file='my_file.csv', input_file_encoding='windows-1250') # with data inside file + job = dq.submit_job(job_config, input_file='my_file.csv') # with data inside file print(job.id) print(job.name) @@ -97,7 +97,7 @@ Create new deduplication job job_config.module_std(address=True, names=True, contact=True) job_config.extend(gus=True, geocode=True, diagnostic=True) - job = dq.submit_job(job_config, input_data=input_data) + job = dq.submit_job(job_config, input_data=input_data) print(job) ... @@ -176,7 +176,7 @@ Analogously for other modules: * NIP * REGON - + Check job state --------------- :: diff --git a/dq/__init__.py b/dq/__init__.py index e518a35..dbebc52 100644 --- a/dq/__init__.py +++ b/dq/__init__.py @@ -5,6 +5,6 @@ __author__ = """Mikołaj Olszewski""" __email__ = 'mikolaj.olszewski@algolytics.pl' -__version__ = '0.4.0' +__version__ = '0.5.0' __all__ = ['DQClient', 'JobConfig'] diff --git a/dq/client.py b/dq/client.py index 5bfb45b..db4d14e 100644 --- a/dq/client.py +++ b/dq/client.py @@ -24,8 +24,7 @@ def list_jobs(self): return self.request_client.get('/jobs') @from_response(Job) - def submit_job(self, config, input_data=None, input_file=None, - input_file_encoding='utf-8'): + def submit_job(self, config, input_data=None, input_file=None): """ POST 'https://app.dataquality.pl/api/v1/jobs' """ parts = { 'config': { @@ -41,9 +40,7 @@ def submit_job(self, config, input_data=None, input_file=None, if input_data: parts['file']['content'] = str(input_data) else: - parts['file']['content'] = open(input_file, 'r', - encoding=input_file_encoding) - + parts['file']['content'] = open(input_file, 'rb') return self.request_client.post_multipart('/jobs', parts=parts) def job_state(self, job_id): @@ -61,13 +58,13 @@ 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, code_page = 'utf-8'): + def job_results(self, job_id, out_file=None, encoding='utf-8'): """ GET 'https://app.dataquality.pl/api/v1/jobs/{{job_id}}/result' """ - response = self.request_client.get('/jobs/{}/result'.format(job_id)) + response = self.request_client.get('/jobs/{}/result'.format(job_id), encoding=encoding) if not response.is_ok(): raise DQError(status=response.status, message=response.content) if out_file: - with open(out_file, 'w', encoding=code_page) as file: + with open(out_file, 'w', encoding=encoding) as file: file.write(response.content) def delete_job(self, job_id): diff --git a/dq/request_client.py b/dq/request_client.py index 0d6687e..1fc3d66 100644 --- a/dq/request_client.py +++ b/dq/request_client.py @@ -18,8 +18,9 @@ def __init__(self, base_url, token): def __make_url(self, path): return '{}/{}'.format(self.base_url, path) - def get(self, path, headers={}): + def get(self, path, headers={}, encoding=None): response = self.session.get(self.__make_url(path), headers=headers) + response.encoding = encoding return Response('GET', response.status_code, response.text) def post(self, path, headers={}): diff --git a/setup.cfg b/setup.cfg index fd99a65..416bdd2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.4.0 +current_version = 0.5.0 commit = True tag = True diff --git a/setup.py b/setup.py index 27f172e..6855a24 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ setup( name='dq-client', - version='0.4.0', + version='0.5.0', description="Python library which allows to use http://dataquality.pl in easy way.", long_description=readme + '\n\n' + history, author="Mikołaj Olszewski",