Added precommit hook

This commit is contained in:
Dmitriy Shishkov 2021-07-02 04:52:26 +05:00
parent f8a6271f9a
commit ea89cf6dde
No known key found for this signature in database
GPG Key ID: 14358F96FCDD8060
4 changed files with 15 additions and 7 deletions

View File

@ -1,4 +1,4 @@
name: Prettier name: Lint and format
on: push on: push
@ -27,7 +27,7 @@ jobs:
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Format with black - name: Format with black
run: black --check . run: black .
- name: Commit changes - name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4.1.2 uses: stefanzweifel/git-auto-commit-action@v4.1.2

View File

@ -1,7 +1,7 @@
from tempfile import SpooledTemporaryFile from tempfile import SpooledTemporaryFile
import xml.etree.ElementTree as ET import xml.etree.ElementTree as ET
from xml.etree.ElementTree import Element from xml.etree.ElementTree import Element
from typing import Optional, Union from typing import Optional
from fastapi import HTTPException from fastapi import HTTPException
from .utils import Document_Tokens, strip_whitespace from .utils import Document_Tokens, strip_whitespace
@ -71,7 +71,7 @@ def fb22tokens(file: SpooledTemporaryFile) -> Document_Tokens:
metadata["title"] = book_info.find("./book-title", namespaces).text metadata["title"] = book_info.find("./book-title", namespaces).text
metadata["author"] = get_author(book_info.find("./author", namespaces)) metadata["author"] = get_author(book_info.find("./author", namespaces))
metadata["cover"] = get_cover(book_info.find("./coverpage", namespaces)) metadata["cover"] = get_cover(book_info.find("./coverpage", namespaces))
if not "cover" in metadata.keys(): if "cover" not in metadata.keys():
metadata.pop("cover") metadata.pop("cover")
if len(metadata.keys()): if len(metadata.keys()):
@ -108,7 +108,7 @@ def get_author(author: Element) -> str:
"last-name", "last-name",
): ):
el = author.find("./" + tag_name, namespaces) el = author.find("./" + tag_name, namespaces)
if not el is None: if el is not None:
res.append(el.text) res.append(el.text)
if len(res) == 0: if len(res) == 0:
res = author.find("./nickname", namespaces).text res = author.find("./nickname", namespaces).text

View File

@ -1,6 +1,4 @@
from fastapi import FastAPI, File, UploadFile, HTTPException from fastapi import FastAPI, File, UploadFile, HTTPException
from fastapi.responses import HTMLResponse
from typing import Union
from .epub import epub2html from .epub import epub2html
from .fb2 import fb22html from .fb2 import fb22html

View File

@ -1,13 +1,23 @@
aiofiles==0.7.0 aiofiles==0.7.0
appdirs==1.4.4
asgiref==3.4.0 asgiref==3.4.0
black==21.6b0
click==8.0.1 click==8.0.1
EbookLib==0.17.1 EbookLib==0.17.1
fastapi==0.65.2 fastapi==0.65.2
flake8==3.9.2
h11==0.12.0 h11==0.12.0
lxml==4.6.3 lxml==4.6.3
mccabe==0.6.1
mypy-extensions==0.4.3
pathspec==0.8.1
pycodestyle==2.7.0
pydantic==1.8.2 pydantic==1.8.2
pyflakes==2.3.1
python-multipart==0.0.5 python-multipart==0.0.5
regex==2021.7.1
six==1.16.0 six==1.16.0
starlette==0.14.2 starlette==0.14.2
toml==0.10.2
typing-extensions==3.10.0.0 typing-extensions==3.10.0.0
uvicorn==0.14.0 uvicorn==0.14.0