From a23a9fbd7528d7f37dc2b88114f119e339cadc4d Mon Sep 17 00:00:00 2001 From: reynoldsnlp Date: Thu, 29 Dec 2022 16:44:53 -0700 Subject: [PATCH] app->libretranslate; mv tests/ inside libretranslate/ --- .github/workflows/run-tests.yml | 3 +-- install_models.py | 2 +- {app => libretranslate}/__init__.py | 0 {app => libretranslate}/api_keys.py | 2 +- {app => libretranslate}/app.py | 8 ++++---- {app => libretranslate}/default_values.py | 0 {app => libretranslate}/detect.py | 0 {app => libretranslate}/flood.py | 0 {app => libretranslate}/init.py | 4 ++-- {app => libretranslate}/language.py | 2 +- {app => libretranslate}/main.py | 4 ++-- {app => libretranslate}/manage.py | 4 ++-- {app => libretranslate}/no_limiter.py | 0 {app => libretranslate}/remove_translated_files.py | 0 {app => libretranslate}/security.py | 0 {app => libretranslate}/static/css/dark-theme.css | 0 {app => libretranslate}/static/css/main.css | 0 .../static/css/material-icons.css | 0 .../static/css/materialize.min.css | 0 {app => libretranslate}/static/css/prism.min.css | 0 {app => libretranslate}/static/favicon.ico | Bin .../static/fonts/MaterialIcons-Regular.eot | Bin .../static/fonts/MaterialIcons-Regular.ttf | Bin .../static/fonts/MaterialIcons-Regular.woff | Bin .../static/fonts/MaterialIcons-Regular.woff2 | Bin {app => libretranslate}/static/icon.svg | 0 {app => libretranslate}/static/js/app.js | 0 .../static/js/materialize.min.js | 0 {app => libretranslate}/static/js/prism.min.js | 0 {app => libretranslate}/static/js/vue@2.js | 0 {app => libretranslate}/suggestions.py | 0 {app => libretranslate}/templates/index.html | 0 .../templates/javascript-licenses.html | 0 {tests => libretranslate/tests}/__init__.py | 0 .../tests}/test_api/__init__.py | 0 .../tests}/test_api/conftest.py | 6 +++--- .../tests}/test_api/test_api_detect_language.py | 0 .../tests}/test_api/test_api_frontend_settings.py | 0 .../tests}/test_api/test_api_get_languages.py | 0 .../tests}/test_api/test_api_spec.py | 0 .../tests}/test_api/test_api_translate.py | 0 {tests => libretranslate/tests}/test_init.py | 2 +- main.py | 2 +- manage.py | 2 +- setup.cfg | 2 +- setup.py | 4 ++-- wsgi.py | 2 +- 47 files changed, 24 insertions(+), 25 deletions(-) rename {app => libretranslate}/__init__.py (100%) rename {app => libretranslate}/api_keys.py (97%) rename {app => libretranslate}/app.py (99%) rename {app => libretranslate}/default_values.py (100%) rename {app => libretranslate}/detect.py (100%) rename {app => libretranslate}/flood.py (100%) rename {app => libretranslate}/init.py (98%) rename {app => libretranslate}/language.py (98%) rename {app => libretranslate}/main.py (98%) rename {app => libretranslate}/manage.py (94%) rename {app => libretranslate}/no_limiter.py (100%) rename {app => libretranslate}/remove_translated_files.py (100%) rename {app => libretranslate}/security.py (100%) rename {app => libretranslate}/static/css/dark-theme.css (100%) rename {app => libretranslate}/static/css/main.css (100%) rename {app => libretranslate}/static/css/material-icons.css (100%) rename {app => libretranslate}/static/css/materialize.min.css (100%) rename {app => libretranslate}/static/css/prism.min.css (100%) rename {app => libretranslate}/static/favicon.ico (100%) rename {app => libretranslate}/static/fonts/MaterialIcons-Regular.eot (100%) rename {app => libretranslate}/static/fonts/MaterialIcons-Regular.ttf (100%) rename {app => libretranslate}/static/fonts/MaterialIcons-Regular.woff (100%) rename {app => libretranslate}/static/fonts/MaterialIcons-Regular.woff2 (100%) rename {app => libretranslate}/static/icon.svg (100%) rename {app => libretranslate}/static/js/app.js (100%) rename {app => libretranslate}/static/js/materialize.min.js (100%) rename {app => libretranslate}/static/js/prism.min.js (100%) rename {app => libretranslate}/static/js/vue@2.js (100%) rename {app => libretranslate}/suggestions.py (100%) rename {app => libretranslate}/templates/index.html (100%) rename {app => libretranslate}/templates/javascript-licenses.html (100%) rename {tests => libretranslate/tests}/__init__.py (100%) rename {tests => libretranslate/tests}/test_api/__init__.py (100%) rename {tests => libretranslate/tests}/test_api/conftest.py (62%) rename {tests => libretranslate/tests}/test_api/test_api_detect_language.py (100%) rename {tests => libretranslate/tests}/test_api/test_api_frontend_settings.py (100%) rename {tests => libretranslate/tests}/test_api/test_api_get_languages.py (100%) rename {tests => libretranslate/tests}/test_api/test_api_spec.py (100%) rename {tests => libretranslate/tests}/test_api/test_api_translate.py (100%) rename {tests => libretranslate/tests}/test_init.py (83%) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 82fd4ee..eba163c 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -9,8 +9,7 @@ on: paths: - '*.py' - 'requirements.txt' - - 'app/**' - - 'tests/**' + - 'libretranslate/**' - '.github/workflows/run-tests.yml' jobs: diff --git a/install_models.py b/install_models.py index 7aa3c68..8fbae93 100755 --- a/install_models.py +++ b/install_models.py @@ -1,6 +1,6 @@ #!/usr/bin/env python import argparse -from app.init import check_and_install_models +from libretranslate.init import check_and_install_models if __name__ == "__main__": parser = argparse.ArgumentParser() diff --git a/app/__init__.py b/libretranslate/__init__.py similarity index 100% rename from app/__init__.py rename to libretranslate/__init__.py diff --git a/app/api_keys.py b/libretranslate/api_keys.py similarity index 97% rename from app/api_keys.py rename to libretranslate/api_keys.py index d314cb0..dc1da3e 100644 --- a/app/api_keys.py +++ b/libretranslate/api_keys.py @@ -3,7 +3,7 @@ import sqlite3 import uuid import requests from expiringdict import ExpiringDict -from app.default_values import DEFAULT_ARGUMENTS as DEFARGS +from libretranslate.default_values import DEFAULT_ARGUMENTS as DEFARGS DEFAULT_DB_PATH = DEFARGS['API_KEYS_DB_PATH'] diff --git a/app/app.py b/libretranslate/app.py similarity index 99% rename from app/app.py rename to libretranslate/app.py index 2022915..af78b88 100644 --- a/app/app.py +++ b/libretranslate/app.py @@ -16,8 +16,8 @@ from translatehtml import translate_html from werkzeug.utils import secure_filename from werkzeug.exceptions import HTTPException -from app import flood, remove_translated_files, security -from app.language import detect_languages, improve_translation_formatting +from libretranslate import flood, remove_translated_files, security +from libretranslate.language import detect_languages, improve_translation_formatting from .api_keys import Database, RemoteDatabase from .suggestions import Database as SuggestionsDatabase @@ -100,11 +100,11 @@ def get_routes_limits(default_req_limit, daily_req_limit, api_keys_db): def create_app(args): - from app.init import boot + from libretranslate.init import boot boot(args.load_only, args.update_models) - from app.language import load_languages + from libretranslate.language import load_languages app = Flask(__name__) diff --git a/app/default_values.py b/libretranslate/default_values.py similarity index 100% rename from app/default_values.py rename to libretranslate/default_values.py diff --git a/app/detect.py b/libretranslate/detect.py similarity index 100% rename from app/detect.py rename to libretranslate/detect.py diff --git a/app/flood.py b/libretranslate/flood.py similarity index 100% rename from app/flood.py rename to libretranslate/flood.py diff --git a/app/init.py b/libretranslate/init.py similarity index 98% rename from app/init.py rename to libretranslate/init.py index d0c4de4..d0cb23e 100644 --- a/app/init.py +++ b/libretranslate/init.py @@ -2,7 +2,7 @@ from pathlib import Path from argostranslate import package, translate -import app.language +import libretranslate.language def boot(load_only=None, update_models=False): @@ -57,4 +57,4 @@ def check_and_install_models(force=False, load_only_lang_codes=None): print( "Loaded support for %s languages (%s models total)!" % (len(translate.get_installed_languages()), len(available_packages)) - ) \ No newline at end of file + ) diff --git a/app/language.py b/libretranslate/language.py similarity index 98% rename from app/language.py rename to libretranslate/language.py index 05696b6..1386bad 100644 --- a/app/language.py +++ b/libretranslate/language.py @@ -1,7 +1,7 @@ import string from argostranslate import translate -from app.detect import Detector, UnknownLanguage +from libretranslate.detect import Detector, UnknownLanguage __languages = None diff --git a/app/main.py b/libretranslate/main.py similarity index 98% rename from app/main.py rename to libretranslate/main.py index b4e1748..27827ae 100644 --- a/app/main.py +++ b/libretranslate/main.py @@ -2,8 +2,8 @@ import argparse import operator import sys -from app.app import create_app -from app.default_values import DEFAULT_ARGUMENTS as DEFARGS +from libretranslate.app import create_app +from libretranslate.default_values import DEFAULT_ARGUMENTS as DEFARGS def get_args(): diff --git a/app/manage.py b/libretranslate/manage.py similarity index 94% rename from app/manage.py rename to libretranslate/manage.py index 2385e46..40ac514 100644 --- a/app/manage.py +++ b/libretranslate/manage.py @@ -1,8 +1,8 @@ import argparse import os -from app.api_keys import Database -from app.default_values import DEFAULT_ARGUMENTS as DEFARGS +from libretranslate.api_keys import Database +from libretranslate.default_values import DEFAULT_ARGUMENTS as DEFARGS def manage(): diff --git a/app/no_limiter.py b/libretranslate/no_limiter.py similarity index 100% rename from app/no_limiter.py rename to libretranslate/no_limiter.py diff --git a/app/remove_translated_files.py b/libretranslate/remove_translated_files.py similarity index 100% rename from app/remove_translated_files.py rename to libretranslate/remove_translated_files.py diff --git a/app/security.py b/libretranslate/security.py similarity index 100% rename from app/security.py rename to libretranslate/security.py diff --git a/app/static/css/dark-theme.css b/libretranslate/static/css/dark-theme.css similarity index 100% rename from app/static/css/dark-theme.css rename to libretranslate/static/css/dark-theme.css diff --git a/app/static/css/main.css b/libretranslate/static/css/main.css similarity index 100% rename from app/static/css/main.css rename to libretranslate/static/css/main.css diff --git a/app/static/css/material-icons.css b/libretranslate/static/css/material-icons.css similarity index 100% rename from app/static/css/material-icons.css rename to libretranslate/static/css/material-icons.css diff --git a/app/static/css/materialize.min.css b/libretranslate/static/css/materialize.min.css similarity index 100% rename from app/static/css/materialize.min.css rename to libretranslate/static/css/materialize.min.css diff --git a/app/static/css/prism.min.css b/libretranslate/static/css/prism.min.css similarity index 100% rename from app/static/css/prism.min.css rename to libretranslate/static/css/prism.min.css diff --git a/app/static/favicon.ico b/libretranslate/static/favicon.ico similarity index 100% rename from app/static/favicon.ico rename to libretranslate/static/favicon.ico diff --git a/app/static/fonts/MaterialIcons-Regular.eot b/libretranslate/static/fonts/MaterialIcons-Regular.eot similarity index 100% rename from app/static/fonts/MaterialIcons-Regular.eot rename to libretranslate/static/fonts/MaterialIcons-Regular.eot diff --git a/app/static/fonts/MaterialIcons-Regular.ttf b/libretranslate/static/fonts/MaterialIcons-Regular.ttf similarity index 100% rename from app/static/fonts/MaterialIcons-Regular.ttf rename to libretranslate/static/fonts/MaterialIcons-Regular.ttf diff --git a/app/static/fonts/MaterialIcons-Regular.woff b/libretranslate/static/fonts/MaterialIcons-Regular.woff similarity index 100% rename from app/static/fonts/MaterialIcons-Regular.woff rename to libretranslate/static/fonts/MaterialIcons-Regular.woff diff --git a/app/static/fonts/MaterialIcons-Regular.woff2 b/libretranslate/static/fonts/MaterialIcons-Regular.woff2 similarity index 100% rename from app/static/fonts/MaterialIcons-Regular.woff2 rename to libretranslate/static/fonts/MaterialIcons-Regular.woff2 diff --git a/app/static/icon.svg b/libretranslate/static/icon.svg similarity index 100% rename from app/static/icon.svg rename to libretranslate/static/icon.svg diff --git a/app/static/js/app.js b/libretranslate/static/js/app.js similarity index 100% rename from app/static/js/app.js rename to libretranslate/static/js/app.js diff --git a/app/static/js/materialize.min.js b/libretranslate/static/js/materialize.min.js similarity index 100% rename from app/static/js/materialize.min.js rename to libretranslate/static/js/materialize.min.js diff --git a/app/static/js/prism.min.js b/libretranslate/static/js/prism.min.js similarity index 100% rename from app/static/js/prism.min.js rename to libretranslate/static/js/prism.min.js diff --git a/app/static/js/vue@2.js b/libretranslate/static/js/vue@2.js similarity index 100% rename from app/static/js/vue@2.js rename to libretranslate/static/js/vue@2.js diff --git a/app/suggestions.py b/libretranslate/suggestions.py similarity index 100% rename from app/suggestions.py rename to libretranslate/suggestions.py diff --git a/app/templates/index.html b/libretranslate/templates/index.html similarity index 100% rename from app/templates/index.html rename to libretranslate/templates/index.html diff --git a/app/templates/javascript-licenses.html b/libretranslate/templates/javascript-licenses.html similarity index 100% rename from app/templates/javascript-licenses.html rename to libretranslate/templates/javascript-licenses.html diff --git a/tests/__init__.py b/libretranslate/tests/__init__.py similarity index 100% rename from tests/__init__.py rename to libretranslate/tests/__init__.py diff --git a/tests/test_api/__init__.py b/libretranslate/tests/test_api/__init__.py similarity index 100% rename from tests/test_api/__init__.py rename to libretranslate/tests/test_api/__init__.py diff --git a/tests/test_api/conftest.py b/libretranslate/tests/test_api/conftest.py similarity index 62% rename from tests/test_api/conftest.py rename to libretranslate/tests/test_api/conftest.py index 8ce03d1..3eb4f79 100644 --- a/tests/test_api/conftest.py +++ b/libretranslate/tests/test_api/conftest.py @@ -1,9 +1,9 @@ import sys import pytest -from app.app import create_app -from app.default_values import DEFAULT_ARGUMENTS -from app.main import get_args +from libretranslate.app import create_app +from libretranslate.default_values import DEFAULT_ARGUMENTS +from libretranslate.main import get_args @pytest.fixture() diff --git a/tests/test_api/test_api_detect_language.py b/libretranslate/tests/test_api/test_api_detect_language.py similarity index 100% rename from tests/test_api/test_api_detect_language.py rename to libretranslate/tests/test_api/test_api_detect_language.py diff --git a/tests/test_api/test_api_frontend_settings.py b/libretranslate/tests/test_api/test_api_frontend_settings.py similarity index 100% rename from tests/test_api/test_api_frontend_settings.py rename to libretranslate/tests/test_api/test_api_frontend_settings.py diff --git a/tests/test_api/test_api_get_languages.py b/libretranslate/tests/test_api/test_api_get_languages.py similarity index 100% rename from tests/test_api/test_api_get_languages.py rename to libretranslate/tests/test_api/test_api_get_languages.py diff --git a/tests/test_api/test_api_spec.py b/libretranslate/tests/test_api/test_api_spec.py similarity index 100% rename from tests/test_api/test_api_spec.py rename to libretranslate/tests/test_api/test_api_spec.py diff --git a/tests/test_api/test_api_translate.py b/libretranslate/tests/test_api/test_api_translate.py similarity index 100% rename from tests/test_api/test_api_translate.py rename to libretranslate/tests/test_api/test_api_translate.py diff --git a/tests/test_init.py b/libretranslate/tests/test_init.py similarity index 83% rename from tests/test_init.py rename to libretranslate/tests/test_init.py index dacffef..198f223 100644 --- a/tests/test_init.py +++ b/libretranslate/tests/test_init.py @@ -1,4 +1,4 @@ -from app.init import boot +from libretranslate.init import boot from argostranslate import package diff --git a/main.py b/main.py index bf80680..5053db2 100644 --- a/main.py +++ b/main.py @@ -1,4 +1,4 @@ -from app import main +from libretranslate import main if __name__ == "__main__": main() diff --git a/manage.py b/manage.py index 3a80139..66bda9b 100644 --- a/manage.py +++ b/manage.py @@ -1,4 +1,4 @@ -from app import manage +from libretranslate import manage if __name__ == "__main__": manage() diff --git a/setup.cfg b/setup.cfg index 5c96027..e7ca7e4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -6,7 +6,7 @@ exclude = .git, venv, test, setup.py, - app/__init__.py + libretranslate/__init__.py max-line-length = 136 ignore = E741 diff --git a/setup.py b/setup.py index d1a5066..94527ca 100644 --- a/setup.py +++ b/setup.py @@ -17,8 +17,8 @@ setup( include_package_data=True, entry_points={ 'console_scripts': [ - 'libretranslate=app.main:main', - 'ltmanage=app.manage:manage' + 'libretranslate=libretranslate.main:main', + 'ltmanage=libretranslate.manage:manage' ], }, diff --git a/wsgi.py b/wsgi.py index aaf531e..35d9fa8 100644 --- a/wsgi.py +++ b/wsgi.py @@ -1,4 +1,4 @@ -from app import main +from libretranslate import main def app(*args, **kwargs): import sys