jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/697994 )
Change subject: [IMPR] Rename compat2core.py to update_script.py ......................................................................
[IMPR] Rename compat2core.py to update_script.py
Change-Id: I86de7fdef40bb0daab45f566779f6823f698f72c --- M HISTORY.rst M README-conversion.rst M scripts/README.rst R scripts/maintenance/update_script.py R tests/update_script_tests.py 5 files changed, 26 insertions(+), 19 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/HISTORY.rst b/HISTORY.rst index 031c036..2973a39 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -95,7 +95,6 @@ * getSite() function was removed in favour of Site() constructor * Page.fileUrl() was removed in favour of Page.get_file_url() * Deprecated getuserinfo and getglobaluserinfo Site methods were removed -* compat2core.py script was archived
6.0.1 diff --git a/README-conversion.rst b/README-conversion.rst index 726686e..c3e081a 100644 --- a/README-conversion.rst +++ b/README-conversion.rst @@ -10,7 +10,7 @@ There is also a helper script which does a lot of changes automatically. Just call it::
- pwb.py compat2core [<script to convert>] + pwb.py update_script [<script to convert>]
and follow the instructions and hints.
diff --git a/scripts/README.rst b/scripts/README.rst index 801fedd..34b3173 100644 --- a/scripts/README.rst +++ b/scripts/README.rst @@ -246,8 +246,8 @@ +------------------------+---------------------------------------------------------+ | colors.py | Utility to show pywikibot colors. | +------------------------+---------------------------------------------------------+ - | compat2core.py | Helper script to convert compat 1.0 scripts to the core | - | | 3.0 framework. Also works for newer Pywikibot releases. | + | update_script.py | Helper script to update scripts and replace deprecated | + | | code parts. | +------------------------+---------------------------------------------------------+ | make_i18n_dict.py | Generate an i18n file from a given script. | +------------------------+---------------------------------------------------------+ diff --git a/scripts/maintenance/compat2core.py b/scripts/maintenance/update_script.py similarity index 91% rename from scripts/maintenance/compat2core.py rename to scripts/maintenance/update_script.py index 347e913..cc245e5 100755 --- a/scripts/maintenance/compat2core.py +++ b/scripts/maintenance/update_script.py @@ -1,6 +1,8 @@ #!/usr/bin/python """ -A helper script to convert compat 1.0 scripts to the new core 3.0 framework. +A helper script to update scripts and replace deprecated parts. + +This also convert compat 1.0 scripts to the new core framework.
NOTE: Please be aware that this script is not able to convert your codes completely. It may support you with some automatic replacements and it gives @@ -9,7 +11,7 @@ finally.
The scripts asks for the .py file and converts it to -<scriptname>-core.py in the same directory. The following option is supported: +<scriptname>-new.py in the same directory. The following option is supported:
-warnonly Do not convert the source but show warning messages. This is good to check already merged scripts. @@ -18,11 +20,11 @@
to convert a script and show warnings about deprecated methods:
- python pwb.py compat2core <scriptname> + python pwb.py update_script <scriptname>
to show warnings about deprecated methods:
- python pwb.py compat2core <scriptname> -warnonly + python pwb.py update_script <scriptname> -warnonly """ # # (C) Pywikibot team, 2014-2021 @@ -39,10 +41,13 @@
# be careful with replacement order! replacements = ( + ############################# + # compat 2 core replacements + ############################# # doc strings ('#\r?\n__version__.*\r?\n', '#\n' - '# Automatically ported from compat branch by compat2core.py script\n'), + '# Automatically ported from compat branch by update_script.py script\n'), ('Pywikipedia bot team', 'Pywikibot team'), # importing changes ('import wikipedia(?: as pywikibot)?', 'import pywikibot'), @@ -88,6 +93,9 @@
# some warnings which must be changed manually warnings = ( + ############################# + # compat 2 core warnings + ############################# ('pywikibot.setAction(', 'setAction() no longer works; you must pass an explicit edit summary\n' 'message to save() or put()'), @@ -171,7 +179,7 @@
def get_dest(self): """Ask for destination script name.""" - self.dest = '{}-core.{}'.format(*self.source.rsplit('.', 1)) + self.dest = '{}-new.{}'.format(*self.source.rsplit('.', 1)) if not self.warnonly and not pywikibot.input_yn( 'Destination file is {}.'.format(self.dest), default=True, automatic_quit=False): diff --git a/tests/compat2core_tests.py b/tests/update_script_tests.py similarity index 66% rename from tests/compat2core_tests.py rename to tests/update_script_tests.py index bed2e9a..9047031 100644 --- a/tests/compat2core_tests.py +++ b/tests/update_script_tests.py @@ -1,4 +1,4 @@ -"""compat2core.py tests.""" +"""update_script.py tests.""" # # (C) Pywikibot team, 2019-2021 # @@ -6,33 +6,33 @@ # import unittest
-import scripts.maintenance.compat2core as c2c +import scripts.maintenance.update_script as us from tests.aspects import TestCase
class Compat2CoreTests(TestCase):
- """Validate compat2core script.""" + """Validate update_script script."""
net = False
def test_replacements(self): - """Test compat2core replacements.""" - for item in c2c.replacements: + """Test update_script replacements.""" + for item in us.replacements: self.assertLength(item, 2) self.assertIsInstance(item[0], str) self.assertIsInstance(item[1], str)
def test_warnings(self): - """Test compat2core warnings.""" - for item in c2c.warnings: + """Test update_script warnings.""" + for item in us.warnings: self.assertLength(item, 2) self.assertIsInstance(item[0], str) self.assertIsInstance(item[1], str)
def test_bot(self): - """Test compat2core bot.""" - bot = c2c.ConvertBot(warnonly=True) + """Test update_script bot.""" + bot = us.ConvertBot(warnonly=True) self.assertIsNone(bot.source) self.assertTrue(bot.warnonly)