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

Change subject: [IMPR] use pywikibot.info instead of pywikibot.output
......................................................................

[IMPR] use pywikibot.info instead of pywikibot.output

also use f-strings

Change-Id: I12c372c44d571378b3db855f2ddc70d658c28dce
---
M pywikibot/config.py
M pywikibot/tools/formatter.py
M scripts/interwikidata.py
3 files changed, 52 insertions(+), 34 deletions(-)

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




diff --git a/pywikibot/config.py b/pywikibot/config.py
index e26387d..58db8c9 100644
--- a/pywikibot/config.py
+++ b/pywikibot/config.py
@@ -65,7 +65,7 @@
     removeprefix,
     removesuffix,
 )
-from pywikibot.logging import error, output, warning
+from pywikibot.logging import error, info, warning
 from pywikibot.tools import deprecated


@@ -406,7 +406,7 @@
             raise RuntimeError(exc_text)

         if __no_user_config != '2':
-            output(exc_text)
+            info(exc_text)

     return base_dir

@@ -418,8 +418,8 @@

 for arg in sys.argv[1:]:
     if arg.startswith('-verbose') or arg == '-v':
-        output('The base directory is ' + base_dir)
-        output('The user config file is ' + user_config_file)
+        info('The base directory is ' + base_dir)
+        info('The user config file is ' + user_config_file)
         break
 family_files = {}

@@ -1139,7 +1139,7 @@
                           + '( ...xxxxxxxx... )')
             else:
                 _value = repr('xxxxxxxx')
-            output(f'{_name}={_value}')
+            info(f'{_name}={_value}')

 # cleanup all locally-defined variables
 for __var in list(globals()):
diff --git a/pywikibot/tools/formatter.py b/pywikibot/tools/formatter.py
index 337bfbe..ad38a9d 100644
--- a/pywikibot/tools/formatter.py
+++ b/pywikibot/tools/formatter.py
@@ -1,13 +1,13 @@
 """Module containing various formatting related utilities."""
 #
-# (C) Pywikibot team, 2015-2022
+# (C) Pywikibot team, 2015-2023
 #
 # Distributed under the terms of the MIT license.
 #
 import math
 import re

-from pywikibot.logging import output
+from pywikibot.logging import info
 from pywikibot.tools import deprecated
 from pywikibot.userinterfaces import terminal_interface_base

@@ -60,7 +60,7 @@

     def output(self) -> None:
         """Output the text of the current sequence."""
-        output(self.out)
+        info(self.out)


 @deprecated('New color format pattern like <<color>>colored text<<default>>',
diff --git a/scripts/interwikidata.py b/scripts/interwikidata.py
index b2bba9d..65c6280 100755
--- a/scripts/interwikidata.py
+++ b/scripts/interwikidata.py
@@ -38,7 +38,7 @@
 import pywikibot
 import pywikibot.i18n
 import pywikibot.textlib
-from pywikibot import output, pagegenerators, warning
+from pywikibot import info, pagegenerators, warning
 from pywikibot.backports import Set
 from pywikibot.bot import (
     ConfigParserBot,
@@ -82,6 +82,7 @@
         if not self.site.has_data_repository:
             raise ValueError('{site} does not have a data repository, use '
                              'interwiki.py instead.'.format(site=self.site))
+
         self.repo = self.site.data_repository()
         if not self.opt.summary:
             self.opt.summary = pywikibot.i18n.twtranslate(
@@ -89,19 +90,19 @@

     def treat_page(self) -> None:
         """Check page."""
-        if (self.current_page.namespace() not in NAMESPACES
-                and not self.opt.ignore_ns):
-            output('{page} is not in allowed namespaces, skipping'
-                   .format(page=self.current_page.title(
-                       as_link=True)))
+        page = self.current_page
+        if (page.namespace() not in NAMESPACES and not self.opt.ignore_ns):
+            info(f'{page} is not in allowed namespaces, skipping')
             return
+
         self.iwlangs = pywikibot.textlib.getLanguageLinks(
-            self.current_page.text, insite=self.current_page.site)
+            page.text, insite=page.site)
         if not self.iwlangs:
-            output(f'No interlanguagelinks on {self.current_page}')
+            info(f'No interlanguagelinks on {page}')
             return
+
         try:
-            item = pywikibot.ItemPage.fromPage(self.current_page)
+            item = pywikibot.ItemPage.fromPage(page)
         except NoPageError:
             item = None

@@ -119,17 +120,20 @@

     def create_item(self) -> pywikibot.ItemPage:
         """Create item in repo for current_page."""
-        data = {'sitelinks':
-                {self.site.dbName():
-                 {'site': self.site.dbName(),
-                  'title': self.current_page.title()}
-                 },
-                'labels':
-                {self.site.lang:
-                 {'language': self.site.lang,
-                  'value': self.current_page.title()}
-                 }
+        data = {
+            'sitelinks': {
+                self.site.dbName(): {
+                    'site': self.site.dbName(),
+                    'title': self.current_page.title()
                 }
+            },
+            'labels': {
+                self.site.lang: {
+                    'language': self.site.lang,
+                    'value': self.current_page.title()
+                }
+            }
+        }
         for site, page in self.iwlangs.items():
             if not page.exists():
                 continue
@@ -142,7 +146,7 @@

         item = pywikibot.ItemPage(self.repo)
         item.editEntity(data, new='item', summary=summary)
-        output(f'Created item {item.getID()}')
+        info(f'Created item {item.getID()}')
         return item

     def handle_complicated(self) -> bool:
@@ -168,7 +172,7 @@
                     .format(self.current_page.title(as_link=True)))
             return

-        output('Cleaning up the page')
+        info('Cleaning up the page')
         new_text = pywikibot.textlib.removeLanguageLinks(
             self.current_page.text, site=self.current_page.site)
         self.put_current(new_text, summary=self.opt.summary)
@@ -184,8 +188,7 @@
             try:
                 wd_data.add(pywikibot.ItemPage.fromPage(iw_page))
             except NoPageError:
-                output('Interwiki {} does not have an item'
-                       .format(iw_page.title(as_link=True)))
+                info(f'Interwiki {iw_page} does not have an item')
         return wd_data

     def try_to_add(self) -> Union[pywikibot.ItemPage, bool, None]:
@@ -194,15 +197,18 @@
         if not wd_data:
             # will create a new item with interwiki
             return None
+
         if len(wd_data) > 1:
             warning('Interwiki conflict in {}, skipping...'
                     .format(self.current_page.title(as_link=True)))
             return False
+
         item = list(wd_data).pop()
         if self.current_page.site.dbName() in item.sitelinks:
             warning(f'Interwiki conflict in {item}, skipping...')
             return False
-        output('Adding link to ' + item.title())
+
+        info('Adding link to ' + item.title())
         item.setSitelink(self.current_page, summary='Added ' + (
             self.current_page.title(as_link=True, insite=item.site)))
         return item
@@ -213,10 +219,11 @@
         if not wd_data:
             # todo: add links to item
             return None
+
         if len(wd_data) > 1:
-            warning('Interwiki conflict in {}, skipping...'
-                    .format(self.current_page.title(as_link=True)))
+            warning(f'Interwiki conflict in {self.current_page}, skipping...')
             return False
+
         target_item = list(wd_data).pop()
         try:
             item.mergeInto(target_item)

--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/947351
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: I12c372c44d571378b3db855f2ddc70d658c28dce
Gerrit-Change-Number: 947351
Gerrit-PatchSet: 2
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