-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
👀 Merge dev -> master | Major Update 1.0.2 (#4)
* Updated examples * Added tests * Reformatting * Added proxy support, improved type hinting * Ignore some files * Major Update: 1.0.1 * Fixed setup.py * Added CI * Improved examples * [ci] Bump python version to 3.9 * Fixed a RuntimeError bug maybe * Added __version__ attribute to Translator Co-authored-by: alsoGAMER <35269770+alsoGAMER@users.noreply.github.com>
- Loading branch information
1 parent
49e4e19
commit 90af4d8
Showing
11 changed files
with
249 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Gpytranslate CI | ||
|
||
on: | ||
push: | ||
branches: [ dev ] | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Set up Python 3.9 | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: 3.9 | ||
|
||
- name: Install Gpytranslate | ||
run: | | ||
python setup.py install | ||
- name: Run tests | ||
run: | | ||
cd tests | ||
python -m unittest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/venv/ | ||
/.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import asyncio | ||
|
||
from gpytranslate import Translator | ||
|
||
|
||
async def main(): | ||
t = Translator(proxies={"https://": "https://{proxy_ip_here}"}) | ||
# Check out https://www.python-httpx.org/compatibility/#proxy-keys | ||
translation = await t.translate("Ciao Mondo!", targetlang="en") | ||
# Hello World! | ||
print(f"Translation: {translation.text}") | ||
|
||
|
||
if __name__ == "__main__": | ||
asyncio.run(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import asyncio | ||
|
||
from httpx_socks import AsyncProxyTransport | ||
|
||
from gpytranslate import Translator | ||
|
||
|
||
async def main(): | ||
t = Translator( | ||
transport=AsyncProxyTransport.from_url("socks5://user:password@127.0.0.1:1080") | ||
) | ||
# Check out https://pypi.org/project/httpx-socks/ | ||
translation = await t.translate("Ciao Mondo!", targetlang="en") | ||
# Hello World! | ||
print(f"Translation: {translation.text}") | ||
|
||
|
||
if __name__ == "__main__": | ||
asyncio.run(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import unittest | ||
|
||
from gpytranslate import Translator | ||
|
||
|
||
class Test(unittest.IsolatedAsyncioTestCase): | ||
async def test_detect(self): | ||
translator = Translator() | ||
language: str = await translator.detect( | ||
text="Ciao Mondo." | ||
) | ||
|
||
self.assertEqual( | ||
language, | ||
"it", | ||
"Translations are not equal.", | ||
) |
Oops, something went wrong.