fixes to use the program with repr
This commit is contained in:
parent
c38274b58e
commit
221aa5d3aa
@ -1,20 +1,18 @@
|
|||||||
#!python
|
#!python
|
||||||
# pyright: basic
|
# pyright: basic
|
||||||
|
import sys
|
||||||
|
from os import makedirs, mkdir
|
||||||
|
from shutil import rmtree
|
||||||
|
|
||||||
from articles import Article, Articles
|
from articles import Article, Articles
|
||||||
from config import config
|
from config import config
|
||||||
from converter import highlight_unknown_chars
|
from converter import highlight_unknown_chars
|
||||||
from database import db
|
from database import db
|
||||||
|
|
||||||
if __name__ != "__main__":
|
if __name__ != "__main__":
|
||||||
exit()
|
# Clean the output dir & create a new
|
||||||
|
rmtree(config.output_dir, True)
|
||||||
import sys
|
mkdir(config.output_dir)
|
||||||
from os import makedirs, mkdir
|
|
||||||
from shutil import rmtree
|
|
||||||
|
|
||||||
# Clean the output dir & create a new
|
|
||||||
rmtree(config.output_dir, True)
|
|
||||||
mkdir(config.output_dir)
|
|
||||||
|
|
||||||
# Connect to the MySQL database with Peewee ORM
|
# Connect to the MySQL database with Peewee ORM
|
||||||
db.init(config.db, host=config.db_host, user=config.db_user, password=config.db_pass)
|
db.init(config.db, host=config.db_host, user=config.db_user, password=config.db_pass)
|
||||||
@ -36,8 +34,9 @@ RESET: str = "\033[0m"
|
|||||||
# Articles that contains unknown chars
|
# Articles that contains unknown chars
|
||||||
unknown_chars_articles: list[Article] = []
|
unknown_chars_articles: list[Article] = []
|
||||||
|
|
||||||
# Loop among first maxexport articles & export them
|
if __name__ != "__main__":
|
||||||
for counter, article in Articles(maxexport):
|
# Loop among first maxexport articles & export them
|
||||||
|
for counter, article in Articles(maxexport):
|
||||||
if (counter["exported"] - 1) % 100 == 0:
|
if (counter["exported"] - 1) % 100 == 0:
|
||||||
print(
|
print(
|
||||||
f"\n{BOLD}Exporting {R}{counter['remaining']+1}{RESET}"
|
f"\n{BOLD}Exporting {R}{counter['remaining']+1}{RESET}"
|
||||||
@ -57,7 +56,7 @@ for counter, article in Articles(maxexport):
|
|||||||
if len(article.get_unknown_chars()) > 0:
|
if len(article.get_unknown_chars()) > 0:
|
||||||
unknown_chars_articles.append(article)
|
unknown_chars_articles.append(article)
|
||||||
|
|
||||||
for article in unknown_chars_articles:
|
for article in unknown_chars_articles:
|
||||||
unknown_chars_apparitions: list = article.get_unknown_chars()
|
unknown_chars_apparitions: list = article.get_unknown_chars()
|
||||||
nb: int = len(unknown_chars_apparitions)
|
nb: int = len(unknown_chars_apparitions)
|
||||||
s: str = "s" if nb > 1 else ""
|
s: str = "s" if nb > 1 else ""
|
||||||
@ -68,4 +67,4 @@ for article in unknown_chars_articles:
|
|||||||
for text in unknown_chars_apparitions:
|
for text in unknown_chars_apparitions:
|
||||||
print(f" {BOLD}…{RESET} " + highlight_unknown_chars(text))
|
print(f" {BOLD}…{RESET} " + highlight_unknown_chars(text))
|
||||||
|
|
||||||
db.close() # Close the database connection
|
db.close() # Close the database connection
|
||||||
|
Loading…
Reference in New Issue
Block a user