🎨 reformat using black
This commit is contained in:
parent
a1ab4c0b5a
commit
1994109507
5 changed files with 70 additions and 53 deletions
|
@ -6,8 +6,10 @@ from tqdm import tqdm
|
|||
from config import *
|
||||
|
||||
# Template strings
|
||||
HIDDEN_COMMENT = '<!-- This page is auto-generated. Do not edit manually. -->'
|
||||
CATEGORY_TEMPLATE = '\n'.join('[[Category:{0}]]'.format(cat) for cat in WIKI_CATEGORY_LIST)
|
||||
HIDDEN_COMMENT = "<!-- This page is auto-generated. Do not edit manually. -->"
|
||||
CATEGORY_TEMPLATE = "\n".join(
|
||||
"[[Category:{0}]]".format(cat) for cat in WIKI_CATEGORY_LIST
|
||||
)
|
||||
|
||||
# Connect to MediaWiki
|
||||
site = mwclient.Site(WIKI_HOST, path=WIKI_PATH)
|
||||
|
@ -15,11 +17,11 @@ site.login(WIKI_USERNAME, WIKI_PASSWORD)
|
|||
|
||||
# Process and upload each .mediawiki file
|
||||
for filename in tqdm(os.listdir(OUTDIR_MEDIAWIKI)):
|
||||
if filename.endswith('.mediawiki'):
|
||||
if filename.endswith(".mediawiki"):
|
||||
filepath = os.path.join(OUTDIR_MEDIAWIKI, filename)
|
||||
article_name = WIKI_ARTICLE_PREFIX + filename.replace('.mediawiki', '')
|
||||
article_name = WIKI_ARTICLE_PREFIX + filename.replace(".mediawiki", "")
|
||||
|
||||
with open(filepath, 'r', encoding='utf-8') as f:
|
||||
with open(filepath, "r", encoding="utf-8") as f:
|
||||
content = f.read()
|
||||
|
||||
# Compose final content
|
||||
|
@ -27,4 +29,4 @@ for filename in tqdm(os.listdir(OUTDIR_MEDIAWIKI)):
|
|||
|
||||
# Post to MediaWiki
|
||||
page = site.pages[article_name]
|
||||
page.save(final_content, summary='Automated upload of recipe page')
|
||||
page.save(final_content, summary="Automated upload of recipe page")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue