1
0
mirror of https://github.com/LibreTranslate/LibreTranslate.git synced 2024-12-24 10:06:43 +02:00

Fixed all pep8 errors

Removed unused imports, variables
This commit is contained in:
YOGESHWARAN R 2021-05-18 09:21:33 +05:30
parent 202db95f52
commit 32061eed7b
No known key found for this signature in database
GPG Key ID: A43D3BDEF049D20D
11 changed files with 32 additions and 20 deletions

View File

@ -1,8 +1,8 @@
import os import os
from appdirs import user_data_dir
# override polyglot path # override polyglot path
import polyglot import polyglot
from appdirs import user_data_dir
polyglot.polyglot_path = os.path.join( polyglot.polyglot_path = os.path.join(
user_data_dir(appname="LibreTranslate", appauthor="uav4geo"), "polyglot_data" user_data_dir(appname="LibreTranslate", appauthor="uav4geo"), "polyglot_data"

View File

@ -1,5 +1,6 @@
import sqlite3 import sqlite3
import uuid import uuid
from expiringdict import ExpiringDict from expiringdict import ExpiringDict
DEFAULT_DB_PATH = "api_keys.db" DEFAULT_DB_PATH = "api_keys.db"

View File

@ -1,12 +1,14 @@
import os import os
from flask import Flask, render_template, jsonify, request, abort, send_from_directory from functools import wraps
from flask import Flask, abort, jsonify, render_template, request
from flask_swagger import swagger from flask_swagger import swagger
from flask_swagger_ui import get_swaggerui_blueprint from flask_swagger_ui import get_swaggerui_blueprint
from pkg_resources import resource_filename
from .api_keys import Database
from app.language import detect_languages, transliterate
from app import flood from app import flood
from functools import wraps from app.language import detect_languages, transliterate
from .api_keys import Database
def get_json_dict(request): def get_json_dict(request):
@ -128,8 +130,7 @@ def create_app(args):
ak = request.values.get("api_key") ak = request.values.get("api_key")
if ( if (
api_keys_db.lookup(ak) is None api_keys_db.lookup(ak) is None and request.headers.get("Origin") != args.require_api_key_origin
and request.headers.get("Origin") != args.require_api_key_origin
): ):
abort( abort(
403, 403,

View File

@ -1,4 +1,3 @@
import time
import atexit import atexit
from apscheduler.schedulers.background import BackgroundScheduler from apscheduler.schedulers.background import BackgroundScheduler

View File

@ -1,9 +1,9 @@
import os
from pathlib import Path from pathlib import Path
from argostranslate import settings, package, translate
import os, glob, shutil, zipfile
import app.language
import polyglot import polyglot
from argostranslate import package, translate
import app.language
def boot(load_only=None): def boot(load_only=None):
@ -39,8 +39,7 @@ def check_and_install_models(force=False, load_only_lang_codes=None):
available_packages = [ available_packages = [
pack pack
for pack in available_packages for pack in available_packages
if pack.from_code in load_only_lang_codes if pack.from_code in load_only_lang_codes and pack.to_code in load_only_lang_codes
and pack.to_code in load_only_lang_codes
] ]
if not available_packages: if not available_packages:
raise ValueError("no available package") raise ValueError("no available package")

View File

@ -4,7 +4,6 @@ from argostranslate import translate
from polyglot.detect.base import Detector, UnknownLanguage from polyglot.detect.base import Detector, UnknownLanguage
from polyglot.transliteration.base import Transliterator from polyglot.transliteration.base import Transliterator
languages = translate.load_installed_languages() languages = translate.load_installed_languages()
@ -24,7 +23,7 @@ def detect_languages(text):
for t in text: for t in text:
try: try:
candidates.extend(Detector(t).languages) candidates.extend(Detector(t).languages)
except UnknownLanguage as e: except UnknownLanguage:
pass pass
# total read bytes of the provided text # total read bytes of the provided text

View File

@ -1,5 +1,6 @@
import argparse import argparse
import operator import operator
from app.app import create_app from app.app import create_app

View File

@ -1,4 +1,5 @@
import argparse import argparse
from app.api_keys import Database from app.api_keys import Database

View File

@ -3,5 +3,5 @@
from app.init import check_and_install_models, check_and_install_transliteration from app.init import check_and_install_models, check_and_install_transliteration
if __name__ == "__main__": if __name__ == "__main__":
check_and_install_models(force=True) check_and_install_models(force=True)
check_and_install_transliteration(force=True) check_and_install_transliteration(force=True)

12
setup.cfg Normal file
View File

@ -0,0 +1,12 @@
[flake8]
exclude = .git,
.vscode,
.gitignore,
README.md,
venv,
test,
setup.py,
app/__init__.py
max-line-length = 136
ignore = E741

View File

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