From cca05ceb7941ba5d3b98fbfbe2c5995b9ff830fa Mon Sep 17 00:00:00 2001 From: NovemLinguae <79697282+NovemLinguae@users.noreply.github.com> Date: Mon, 4 Dec 2023 08:40:17 -0800 Subject: [PATCH] fix #302 deploy script adding strange unicode character (#306) This patch brought to you by StackOverflow: https://stackoverflow.com/a/844443/3480193 Tested, works. https://test.wikipedia.org/w/index.php?title=MediaWiki:Gadget-afchelper.js/tpl-submissions.js&diff=prev&oldid=584115 --- scripts/upload.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/upload.py b/scripts/upload.py index 88bc4779..b4fdc5ca 100644 --- a/scripts/upload.py +++ b/scripts/upload.py @@ -92,6 +92,7 @@ def stripFirstLine(text): return '\n'.join(text.splitlines()[1:]) +# Which of the two bot libraries are we using to write our edits? if using_mwclient: if wiki == 'en': server_name = 'en.wikipedia.org' @@ -109,7 +110,7 @@ def setPageText(title, text, summary): page.save(text, summary=summary) else: print('Skipping {}, no changes made'.format(title)) -else: +else: #pywikibot site = pywikibot.Site(wiki, "wikipedia") site.login() print('Logged in as {}.'.format(site.user())) @@ -156,16 +157,16 @@ def uploadDirectory(directory): for script in files: # Skip hidden files and Emacs spam if not script.startswith('.') and not script.endswith('~'): - with open(directory + '/' + script, 'r') as f: + with open(directory + '/' + script, mode="r", encoding="utf-8") as f: content = f.read() uploadSubscript(os.path.splitext(script)[0], content) # Upload afch.js -with open('build/afch.js', 'r') as f: +with open('build/afch.js', mode="r", encoding="utf-8") as f: uploadFile(root + '.js', f.read()) # Upload afch.css -with open('build/afch.css', 'r') as f: +with open('build/afch.css', mode="r", encoding="utf-8") as f: uploadFile(root + '.css', f.read()) # Now upload everything else: modules, templates