jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/862267 )

Change subject: [IMPR] use pathlib instead of codecs for sorting_order.py
......................................................................

[IMPR] use pathlib instead of codecs for sorting_order.py

Change-Id: I3616d0719ca32f620c51d198e9ae7c6d7b252f46
---
M scripts/maintenance/sorting_order.py
1 file changed, 15 insertions(+), 8 deletions(-)

Approvals:
  D3r1ck01: Looks good to me, approved
  Xqt: Looks good to me, approved
  jenkins-bot: Verified




diff --git a/scripts/maintenance/sorting_order.py 
b/scripts/maintenance/sorting_order.py
index 5e64e88..5bfad98 100755
--- a/scripts/maintenance/sorting_order.py
+++ b/scripts/maintenance/sorting_order.py
@@ -5,8 +5,8 @@
 #
 # Distributed under the terms of the MIT license.
 #
-import codecs
 import re
+from pathlib import Path

 import pywikibot
 from pywikibot.family import Family
@@ -23,8 +23,8 @@

 def update_family(list_name, page):
     """Update family.py file."""
-    pywikibot.info('\nReading {} sorting order from\nfrom {}...'
-                   .format(list_name, page.title(with_ns=False)))
+    pywikibot.info(f'\nReading {list_name} sorting order from\n'
+                   f'{page.title(with_ns=False)!r}...')
 
     original = getattr(Family, list_name)
     new = page.text.split()
@@ -57,13 +57,11 @@
     text += line + '\n'
     text += '    ]'
     pywikibot.info(text)
-    family_file_name = 'pywikibot/family.py'
-    with codecs.open(family_file_name, 'r', 'utf8') as family_file:
-        family_text = family_file.read()
+    filepath = Path('pywikibot/family.py')
+    family_text = filepath.read_text(encoding='utf8')
     family_text = re.sub(r'(?ms)^ {4}%s.+?\]' % list_name,
                          text, family_text, 1)
-    with codecs.open(family_file_name, 'w', 'utf8') as family_file:
-        family_file.write(family_text)
+    filepath.write_text(family_text, encoding='utf8')


 def main():

--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/862267
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I3616d0719ca32f620c51d198e9ae7c6d7b252f46
Gerrit-Change-Number: 862267
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: D3r1ck01 <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to