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:
- '*.py'
- 'requirements.txt'
- 'app/**'
- 'tests/**'
- 'libretranslate/**'
- '.github/workflows/run-tests.yml'
jobs:

View file

@ -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()

View file

@ -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']

View file

@ -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__)

View file

@ -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):

View file

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

View file

@ -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():

View file

@ -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():

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 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()

View file

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

View file

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

View file

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

View file

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

View file

@ -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'
],
},

View file

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