Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_format_json():
text = '[,,"en",,,,0.96954316,,[["en"],,[0.96954316]]]'
result = utils.legacy_format_json(text)
assert result == [None, None, 'en', None, None, None, 0.96954316, None,
[['en'], None, [0.96954316]]]
def test_format_malformed_json():
text = '[,,"en",,,,0.96954316,,[["en"],,0.96954316]]]'
with raises(ValueError):
utils.legacy_format_json(text)
def _translate(self, text, dest, src):
if not PY3 and isinstance(text, str): # pragma: nocover
text = text.decode('utf-8')
token = self.token_acquirer.do(text)
params = utils.build_params(query=text, src=src, dest=dest,
token=token)
url = urls.TRANSLATE.format(host=self._pick_service_url())
r = self.session.get(url, params=params)
data = utils.format_json(r.text)
return data
def _translate(self, text, dest, src):
if not PY3 and isinstance(text, str): # pragma: nocover
text = text.decode('utf-8')
token = self.token_acquirer.do(text)
params = utils.build_params(query=text, src=src, dest=dest,
token=token)
url = urls.TRANSLATE.format(host=self._pick_service_url())
r = self.session.get(url, params=params)
data = utils.format_json(r.text)
return data
def _translate(self, text, dest, src):
if not PY3 and isinstance(text, str): # pragma: nocover
text = text.decode('utf-8')
token = self.token_acquirer.do(text)
params = utils.build_params(query=text, src=src, dest=dest,
token=token)
url = urls.TRANSLATE.format(host=self._pick_service_url())
r = self.session.get(url, params=params)
data = utils.format_json(r.text)
return data
def _translate(self, text, dest, src):
if not PY3 and isinstance(text, str): # pragma: nocover
text = text.decode('utf-8')
token = self.token_acquirer.do(text)
params = utils.build_params(query=text, src=src, dest=dest,
token=token)
url = urls.TRANSLATE.format(host=self._pick_service_url())
r = self.session.get(url, params=params)
data = utils.format_json(r.text)
return data
def _translate(self, text, dest, src):
if not PY3 and isinstance(text, str): # pragma: nocover
text = text.decode('utf-8')
token = self.token_acquirer.do(text)
params = utils.build_params(query=text, src=src, dest=dest,
token=token)
params['client'] = 'webapp'
url = urls.TRANSLATE.format(host=self._pick_service_url())
r = self.session.get(url, params=params)
data = utils.format_json(r.text)
return data
def _translate(self, text, dest, src):
if not PY3 and isinstance(text, str): # pragma: nocover
text = text.decode('utf-8')
token = self.token_acquirer.do(text)
params = utils.build_params(query=text, src=src, dest=dest,
token=token)
url = urls.TRANSLATE.format(host=self._pick_service_url())
r = self.session.get(url, params=params)
data = utils.format_json(r.text)
return data
def _translate(self, text, dest, src):
if not PY3 and isinstance(text, str): # pragma: nocover
text = text.decode('utf-8')
token = self.token_acquirer.do(text)
params = utils.build_params(query=text, src=src, dest=dest,
token=token)
url = urls.TRANSLATE.format(host=self._pick_service_url())
r = self.session.get(url, params=params)
data = utils.format_json(r.text)
return data
def _translate(self, text, dest, src):
if not PY3 and isinstance(text, str): # pragma: nocover
text = text.decode('utf-8')
token = self.token_acquirer.do(text)
params = utils.build_params(query=text, src=src, dest=dest,
token=token)
params['client'] = 'webapp'
url = urls.TRANSLATE.format(host=self._pick_service_url())
r = self.session.get(url, params=params)
data = utils.format_json(r.text)
return data