1
0
mirror of https://github.com/LibreTranslate/LibreTranslate.git synced 2024-12-18 08:27:03 +02:00

Merge pull request #372 from reynoldsnlp/main

app->libretranslate; mv tests/ inside libretranslate/
This commit is contained in:
Piero Toffanin 2022-12-30 08:16:37 -05:00 committed by GitHub
commit 033554a121
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
47 changed files with 24 additions and 25 deletions

View File

@ -9,8 +9,7 @@ on:
paths: paths:
- '*.py' - '*.py'
- 'requirements.txt' - 'requirements.txt'
- 'app/**' - 'libretranslate/**'
- 'tests/**'
- '.github/workflows/run-tests.yml' - '.github/workflows/run-tests.yml'
jobs: jobs:

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
import argparse import argparse
from app.init import check_and_install_models from libretranslate.init import check_and_install_models
if __name__ == "__main__": if __name__ == "__main__":
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()

View File

@ -3,7 +3,7 @@ import sqlite3
import uuid import uuid
import requests import requests
from expiringdict import ExpiringDict 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'] DEFAULT_DB_PATH = DEFARGS['API_KEYS_DB_PATH']

View File

@ -16,8 +16,8 @@ from translatehtml import translate_html
from werkzeug.utils import secure_filename from werkzeug.utils import secure_filename
from werkzeug.exceptions import HTTPException from werkzeug.exceptions import HTTPException
from app import flood, remove_translated_files, security from libretranslate import flood, remove_translated_files, security
from app.language import detect_languages, improve_translation_formatting from libretranslate.language import detect_languages, improve_translation_formatting
from .api_keys import Database, RemoteDatabase from .api_keys import Database, RemoteDatabase
from .suggestions import Database as SuggestionsDatabase 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): def create_app(args):
from app.init import boot from libretranslate.init import boot
boot(args.load_only, args.update_models) boot(args.load_only, args.update_models)
from app.language import load_languages from libretranslate.language import load_languages
app = Flask(__name__) app = Flask(__name__)

View File

@ -2,7 +2,7 @@ from pathlib import Path
from argostranslate import package, translate from argostranslate import package, translate
import app.language import libretranslate.language
def boot(load_only=None, update_models=False): 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( print(
"Loaded support for %s languages (%s models total)!" "Loaded support for %s languages (%s models total)!"
% (len(translate.get_installed_languages()), len(available_packages)) % (len(translate.get_installed_languages()), len(available_packages))
) )

View File

@ -1,7 +1,7 @@
import string import string
from argostranslate import translate from argostranslate import translate
from app.detect import Detector, UnknownLanguage from libretranslate.detect import Detector, UnknownLanguage
__languages = None __languages = None

View File

@ -2,8 +2,8 @@ import argparse
import operator import operator
import sys import sys
from app.app import create_app from libretranslate.app import create_app
from app.default_values import DEFAULT_ARGUMENTS as DEFARGS from libretranslate.default_values import DEFAULT_ARGUMENTS as DEFARGS
def get_args(): def get_args():

View File

@ -1,8 +1,8 @@
import argparse import argparse
import os import os
from app.api_keys import Database from libretranslate.api_keys import Database
from app.default_values import DEFAULT_ARGUMENTS as DEFARGS from libretranslate.default_values import DEFAULT_ARGUMENTS as DEFARGS
def manage(): def manage():

View File

Before

Width:  |  Height:  |  Size: 262 KiB

After

Width:  |  Height:  |  Size: 262 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

@ -1,9 +1,9 @@
import sys import sys
import pytest import pytest
from app.app import create_app from libretranslate.app import create_app
from app.default_values import DEFAULT_ARGUMENTS from libretranslate.default_values import DEFAULT_ARGUMENTS
from app.main import get_args from libretranslate.main import get_args
@pytest.fixture() @pytest.fixture()

View File

@ -1,4 +1,4 @@
from app.init import boot from libretranslate.init import boot
from argostranslate import package from argostranslate import package

View File

@ -1,4 +1,4 @@
from app import main from libretranslate import main
if __name__ == "__main__": if __name__ == "__main__":
main() main()

View File

@ -1,4 +1,4 @@
from app import manage from libretranslate import manage
if __name__ == "__main__": if __name__ == "__main__":
manage() manage()

View File

@ -6,7 +6,7 @@ exclude = .git,
venv, venv,
test, test,
setup.py, setup.py,
app/__init__.py libretranslate/__init__.py
max-line-length = 136 max-line-length = 136
ignore = E741 ignore = E741

View File

@ -17,8 +17,8 @@ setup(
include_package_data=True, include_package_data=True,
entry_points={ entry_points={
'console_scripts': [ 'console_scripts': [
'libretranslate=app.main:main', 'libretranslate=libretranslate.main:main',
'ltmanage=app.manage:manage' 'ltmanage=libretranslate.manage:manage'
], ],
}, },

View File

@ -1,4 +1,4 @@
from app import main from libretranslate import main
def app(*args, **kwargs): def app(*args, **kwargs):
import sys import sys