tertran 1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of tertran might be problematic. Click here for more details.

@@ -0,0 +1,17 @@
1
+ MIT License
2
+ Copyright (c) 2018 YOUR NAME
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+ The above copyright notice and this permission notice shall be included in all
10
+ copies or substantial portions of the Software.
11
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17
+ SOFTWARE.
tertran-1.0/PKG-INFO ADDED
@@ -0,0 +1,12 @@
1
+ Metadata-Version: 2.1
2
+ Name: tertran
3
+ Version: 1.0
4
+ License-File: LICENSE.txt
5
+ Requires-Dist: certifi
6
+ Requires-Dist: charset-normalizer
7
+ Requires-Dist: click
8
+ Requires-Dist: requests
9
+ Requires-Dist: tabulate
10
+ Requires-Dist: urllib3
11
+ Requires-Dist: idna
12
+ Requires-Dist: requests-cache
tertran-1.0/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # Tertran (Terminal translator)
2
+
3
+ Tertran is a very bad name to my CLI built in python made to work in the terminal without the need for any browser.
4
+
5
+ ## Requeriments
6
+
7
+ It needs python and pip to work. It will also require external packages which can be installed with pip.
8
+
9
+ ## Install
10
+
11
+ Download or use Git to clone this repository, once the directory is selected, use pip to install it on your machine
12
+
13
+ ```cmd
14
+ pip install .
15
+ ```
16
+
17
+ or:
18
+
19
+ ```cmd
20
+ pip install tertran
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ Write tertran to use the translation function
26
+
27
+ ```cmd
28
+ tertran <source lang> <target lang> <input>
29
+ ```
30
+
31
+ Example:
32
+ ![Using terminal translator](image/../images/tertran_basic_usage.png "Tertram terminal translator")
33
+
34
+ Use tertram-langs to get a table with all language codes :D
35
+
36
+ ![Display of table with language codes](image/../images/tertran_basic_langs.png "Display of table with language codes")
37
+
38
+ ## How it works?
39
+
40
+ It's simple, works by requesting a translation from the google translate API.
41
+
42
+ _Example:_
43
+
44
+ ```py
45
+ api_url = "https://translate.googleapis.com/translate_a/single?client=gtx&sl={}&tl={}&dt=t&q={}"
46
+
47
+ r = requests.get(api_url.format(source_lang, target_lang, input_text))
48
+
49
+ ```
50
+
51
+ Feel free to add new features if you want, but maybe my code is a bad base to work on, I'm inexperienced in this
tertran-1.0/setup.cfg ADDED
@@ -0,0 +1,7 @@
1
+ [metadata]
2
+ description-file = README.md
3
+
4
+ [egg_info]
5
+ tag_build =
6
+ tag_date = 0
7
+
tertran-1.0/setup.py ADDED
@@ -0,0 +1,25 @@
1
+
2
+ from setuptools import setup, find_packages
3
+
4
+ setup(
5
+ name="tertran",
6
+ version="1.0",
7
+ packages=find_packages(),
8
+ include_package_data=True,
9
+ pt_modules=["tertran.py"],
10
+ install_requires=[
11
+ "certifi",
12
+ "charset-normalizer",
13
+ "click",
14
+ "requests",
15
+ "tabulate",
16
+ "urllib3",
17
+ "idna",
18
+ "requests-cache",
19
+ ],
20
+ entry_points="""
21
+ [console_scripts]
22
+ tertran=src.scripts.translate:translate
23
+ tertran-langs=src.scripts.get_langs:get_langs
24
+ """,
25
+ )
File without changes
File without changes
@@ -0,0 +1,61 @@
1
+
2
+ langs = {
3
+ "af": "Afrikaans Afrikaans",
4
+ "sq": "Albanian Shqip",
5
+ "ar": "Arabic عربي",
6
+ "hy": "Armenian Հայերէն",
7
+ "az": "Azerbaijani آذربایجان دیلی",
8
+ "eu": "Basque Euskara",
9
+ "be": "Belarusian Беларуская",
10
+ "bg": "Bulgarian Български",
11
+ "ca": "Catalan Català",
12
+ "zh-CN": "Chinese (Simplified) 中文简体",
13
+ "zh-TW": "Chinese (Traditional) 中文繁體",
14
+ "hr": "Croatian Hrvatski",
15
+ "cs": "Czech Čeština",
16
+ "da": "Danish Dansk",
17
+ "nl": "Dutch Nederlands",
18
+ "en": "English English",
19
+ "et": "Estonian Eesti keel",
20
+ "tl": "Filipino Filipino",
21
+ "fi": "Finnish Suomi",
22
+ "fr": "French Français",
23
+ "gl": "Galician Galego",
24
+ "ka": "Georgian ქართული",
25
+ "de": "German Deutsch",
26
+ "el": "Greek Ελληνικά",
27
+ "ht": "Haitian Creole Kreyòl ayisyen",
28
+ "iw": "Hebrew עברית ",
29
+ "hi": "Hindi हिन्दी",
30
+ "hu": "Hungarian Magyar",
31
+ "is": "Icelandic Íslenska",
32
+ "id": "Indonesian Bahasa Indonesia",
33
+ "ga": "Irish Gaeilge",
34
+ "it": "Italian Italiano",
35
+ "ja": "Japanese 日本語",
36
+ "ko": "Korean 한국어",
37
+ "lv": "Latvian Latviešu",
38
+ "lt": "Lithuanian Lietuvių kalba",
39
+ "mk": "Macedonian Македонски",
40
+ "ms": "Malay Malay",
41
+ "mt": "Maltese Malti",
42
+ "no": "Norwegian Norsk",
43
+ "fa": "Persian فارسی ",
44
+ "pl": "Polish Polski",
45
+ "pt": "Portuguese Português",
46
+ "ro": "Romanian Română",
47
+ "ru": "Russian Русский",
48
+ "sr": "Serbian Српски",
49
+ "sk": "Slovak Slovenčina",
50
+ "sl": "Slovenian Slovensko",
51
+ "es": "Spanish Español",
52
+ "sw": "Swahili Kiswahili",
53
+ "sv": "Swedish Svenska",
54
+ "th": "Thai ไทย",
55
+ "tr": "Turkish Türkçe",
56
+ "uk": "Ukrainian Українська",
57
+ "ur": "Urdu اردو ",
58
+ "vi": "Vietnamese Tiếng Việt",
59
+ "cy": "Welsh Cymraeg",
60
+ "yi": "Yiddish ייִדיש ",
61
+ }
@@ -0,0 +1,4 @@
1
+ import colorama
2
+
3
+ goodArrow = f"{colorama.Fore.MAGENTA}-->{colorama.Fore.RESET}"
4
+ badArrow = f"{colorama.Fore.RED}-->{colorama.Fore.RESET}"
File without changes
@@ -0,0 +1,17 @@
1
+ import click
2
+ import src.data.langs as lg
3
+ import colorama
4
+ from tabulate import tabulate
5
+ colorama.init(autoreset=True)
6
+
7
+ @click.command()
8
+ def get_langs():
9
+ '''
10
+ Command line to get a table with avaiable langs
11
+ '''
12
+ allLangs = [ [
13
+ colorama.Fore.GREEN + key ,
14
+ colorama.Fore.RESET + lg.langs[key]
15
+ ] for key in lg.langs.keys()]
16
+
17
+ click.echo(tabulate(allLangs))
@@ -0,0 +1,30 @@
1
+ import click
2
+ import src.data.langs as lg
3
+ import requests_cache
4
+ import urllib.parse
5
+ from src.data.symbols import goodArrow, badArrow
6
+
7
+
8
+ @click.command()
9
+ @click.argument("source_lang", type=click.Choice(lg.langs.keys()))
10
+ @click.argument("target_lang", type=click.Choice(lg.langs.keys()))
11
+ @click.argument("input_text")
12
+ def translate(source_lang, target_lang, input_text):
13
+ '''
14
+ Command line to translate any text
15
+ '''
16
+ api_url = "https://translate.googleapis.com/translate_a/single?client=gtx&sl={}&tl={}&dt=t&q={}"
17
+
18
+ input_text = input_text.replace("\n", " ")
19
+ input_text = urllib.parse.quote(input_text)
20
+ try:
21
+ session = requests_cache.CachedSession(
22
+ cache_name="cache", expire_after=604800)
23
+ r = session.get(api_url.format(source_lang, target_lang, input_text))
24
+
25
+ if r.status_code == 200:
26
+ click.echo(f"\n{goodArrow} {r.json()[0][0][0]}\n")
27
+ else:
28
+ click.echo(f"{badArrow} Error ... status code {r.status_code}")
29
+ except Exception as e:
30
+ click.echo(f"{badArrow} Connection error")
@@ -0,0 +1,12 @@
1
+ Metadata-Version: 2.1
2
+ Name: tertran
3
+ Version: 1.0
4
+ License-File: LICENSE.txt
5
+ Requires-Dist: certifi
6
+ Requires-Dist: charset-normalizer
7
+ Requires-Dist: click
8
+ Requires-Dist: requests
9
+ Requires-Dist: tabulate
10
+ Requires-Dist: urllib3
11
+ Requires-Dist: idna
12
+ Requires-Dist: requests-cache
@@ -0,0 +1,17 @@
1
+ LICENSE.txt
2
+ README.md
3
+ setup.cfg
4
+ setup.py
5
+ src/__init__.py
6
+ src/data/__init__.py
7
+ src/data/langs.py
8
+ src/data/symbols.py
9
+ src/scripts/__init__.py
10
+ src/scripts/get_langs.py
11
+ src/scripts/translate.py
12
+ tertran.egg-info/PKG-INFO
13
+ tertran.egg-info/SOURCES.txt
14
+ tertran.egg-info/dependency_links.txt
15
+ tertran.egg-info/entry_points.txt
16
+ tertran.egg-info/requires.txt
17
+ tertran.egg-info/top_level.txt
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ tertran = src.scripts.translate:translate
3
+ tertran-langs = src.scripts.get_langs:get_langs
@@ -0,0 +1,8 @@
1
+ certifi
2
+ charset-normalizer
3
+ click
4
+ requests
5
+ tabulate
6
+ urllib3
7
+ idna
8
+ requests-cache
@@ -0,0 +1 @@
1
+ src