Skip to content

Commit e1f5222

Browse files
authored
Merge pull request #3 from SpanishST/clean_statement
Bump version to 0.2.1 and update license to GPL-3.0-or-later; enhance…
2 parents d864968 + 886b54c commit e1f5222

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

pyproject.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,17 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "hueclientrest"
7-
version = "0.2.0"
7+
version = "0.2.1"
88
authors = [
99
{name = "Ramon LOPEZ", email = "ramon.lopez@outlook.fr"},
1010
]
1111
description = "A Python REST client for interacting with Hadoop Hue's REST API"
1212
readme = "README.md"
13-
license = {text = "GPL-3.0"}
13+
license = "GPL-3.0-or-later"
1414
requires-python = ">=3.9"
1515
classifiers = [
1616
"Development Status :: 3 - Alpha",
1717
"Intended Audience :: Developers",
18-
"License :: OSI Approved :: MIT License",
1918
"Operating System :: OS Independent",
2019
"Programming Language :: Python :: 3",
2120
"Programming Language :: Python :: 3.9",

src/hueclientrest/core.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import re
23
import time
34
import csv
45
import json
@@ -47,7 +48,7 @@ def login(self):
4748

4849
self.session.headers.update({"Authorization": f"Bearer {self.token}"})
4950

50-
def execute(self, statement: str, dialect: str = "hive") -> str:
51+
def execute(self, statement: str, dialect: str = "hive", clean_statement: bool = True) -> str:
5152
"""
5253
Execute query and get operation ID (history_uuid)
5354
Raises:
@@ -60,7 +61,14 @@ def execute(self, statement: str, dialect: str = "hive") -> str:
6061
"""
6162

6263
url = f"{self.host}/api/v1/editor/execute/{dialect}"
63-
resp = self.session.post(url, data={"statement": statement})
64+
65+
clean_statement = statement.strip()
66+
67+
if clean_statement:
68+
clean_statement = re.sub(r'[\x00-\x1F]+', ' ', clean_statement)
69+
clean_statement = re.sub(r'\s+', ' ', clean_statement)
70+
71+
resp = self.session.post(url, data={"statement": clean_statement})
6472
resp.raise_for_status()
6573
js = resp.json()
6674

0 commit comments

Comments
 (0)