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
from appdirs import user_data_dir
# override polyglot path
import polyglot
from appdirs import user_data_dir
polyglot.polyglot_path = os.path.join(
user_data_dir(appname="LibreTranslate", appauthor="uav4geo"), "polyglot_data"

View File

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

View File

@ -1,12 +1,14 @@
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_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 functools import wraps
from app.language import detect_languages, transliterate
from .api_keys import Database
def get_json_dict(request):
@ -128,8 +130,7 @@ def create_app(args):
ak = request.values.get("api_key")
if (
api_keys_db.lookup(ak) is None
and request.headers.get("Origin") != args.require_api_key_origin
api_keys_db.lookup(ak) is None and request.headers.get("Origin") != args.require_api_key_origin
):
abort(
403,

View File

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

View File

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

View File

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

View File

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

View File

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

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 argostranslate import package