jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/583062 )
Change subject: [cleanup] Remove functions dealing with stars list ......................................................................
[cleanup] Remove functions dealing with stars list
stars lists functionality was replaced by wikidata and related templates where deleted around 2015
Change-Id: I7aad4b282c30356402eed611b6481bbb9a822516 --- M pywikibot/textlib.py M tests/textlib_tests.py 2 files changed, 0 insertions(+), 159 deletions(-)
Approvals: Zhuyifei1999: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py index 5339249..58a26a6 100644 --- a/pywikibot/textlib.py +++ b/pywikibot/textlib.py @@ -1906,111 +1906,6 @@ return '{{%s\n%s}}' % (template, text)
-# ---------------------------------------------- -# functions dealing with stars list (deprecated) -# ---------------------------------------------- - -starsList = [ - 'bueno', - 'bom interwiki', - 'cyswllt[ _]erthygl[ _]ddethol', 'dolen[ _]ed', - 'destacado', 'destaca[tu]', - 'enllaç[ _]ad', - 'enllaz[ _]ad', - 'leam[ _]vdc', - 'legătură[ _]a[bcf]', - 'liamm[ _]pub', - 'lien[ _]adq', - 'lien[ _]ba', - 'liên[ _]kết[ _]bài[ _]chất[ _]lượng[ _]tốt', - 'liên[ _]kết[ _]chọn[ _]lọc', - 'ligam[ _]adq', - 'ligazón[ _]a[bd]', - 'ligoelstara', - 'ligoleginda', - 'link[ _][afgu]a', 'link[ _]adq', 'link[ _]f[lm]', 'link[ _]km', - 'link[ _]sm', 'linkfa', - 'na[ _]lotura', - 'nasc[ _]ar', - 'tengill[ _][úg]g', - 'ua', - 'yüm yg', - 'רא', - 'وصلة مقالة جيدة', - 'وصلة مقالة مختارة', -] - - -@deprecated(future_warning=True, since='20200324') -def get_stars(text): - """ - Extract stars templates from wikitext. - - @param text: a wiki text - @type text: str - @return: list of stars templates - @rtype: list - """ - allstars = [] - starstext = removeDisabledParts(text) - for star in starsList: - regex = re.compile(r'({{(?:template:|)%s|.*?}}[\s]*)' - % star, re.I) - found = regex.findall(starstext) - if found: - allstars += found - return allstars - - -@deprecated(future_warning=True, since='20200324') -def remove_stars(text, stars_list): - """ - Remove stars templates from text. - - @param text: a wiki text - @type text: str - @param start_list: list of stars templates previously found in text - @return: modified text - @rtype: str - """ - for star in stars_list: - text = text.replace(star, '') - return text - - -@deprecated(future_warning=True, since='20200324') -def append_stars(text, stars_list, site=None): - """ - Remove stars templates from text. - - @param text: a wiki text - @type text: str - @param stars_list: list of stars templates previously found in text - @type stars_list: list - @param site: a site where the given text is used. - interwiki_text_separator is used when a site object is given. - Otherwise two line separators are used to separate stars list. - @type site: BaseSite - @return: modified text - @rtype: str - """ - LS = '\n\n' if not site else site.family.interwiki_text_separator - text = text.strip() + LS - stars = stars_list[:] - stars.sort() - for element in stars: - text += element.strip() + '\n' - return text - - -@deprecated(future_warning=True, since='20200324') -def standardize_stars(text): - """Make sure that star templates are in the right order.""" - allstars = get_stars(text) - text = remove_stars(text, allstars) - return append_stars(text, allstars) - - # -------------------------- # Page parsing functionality # -------------------------- diff --git a/tests/textlib_tests.py b/tests/textlib_tests.py index 9fb9461..b647ab6 100644 --- a/tests/textlib_tests.py +++ b/tests/textlib_tests.py @@ -1624,60 +1624,6 @@ '!23<>'"&&')
-class TestStarList(TestCase): - - """Test starlist.""" - - net = False - - def test_basic(self): - """Test standardizing {{linkfa}} without parameters.""" - self.assertEqual( - 'foo\n{{linkfa}}\nbar\n\n', - textlib.standardize_stars('foo\n{{linkfa}}\nbar')) - - def test_with_params(self): - """Test standardizing text with {{linkfa|...}}.""" - self.assertEqual( - 'foo\nbar\n\n{{linkfa|...}}\n', - textlib.standardize_stars('foo\n{{linkfa|...}}\nbar')) - - def test_with_sorting_params(self): - """Test standardizing text with sorting parameters.""" - self.assertEqual( - 'foo\n\n{{linkfa|bar}}\n{{linkfa|de}}\n' - '{{linkfa|en}}\n{{linkfa|fr}}\n', - textlib.standardize_stars( - 'foo\n{{linkfa|en}}\n{{linkfa|de}}\n' - '{{linkfa|fr}}\n{{linkfa|bar}}')) - - def test_get_stars(self): - """Test get_starts method.""" - self.assertEqual( - ['{{linkfa|en}}\n', '{{linkfa|de}}\n', - '{{linkfa|fr}}\n', '{{linkfa|bar}}'], - textlib.get_stars( - 'foo\n{{linkfa|en}}\n{{linkfa|de}}\n' - '{{linkfa|fr}}\n{{linkfa|bar}}')) - - def test_remove_stars(self): - """Test remove_stars method.""" - self.assertEqual( - 'foo\n{{linkfa|en}}\n{{linkfa|fr}}\n{{linkfa|bar}}', - textlib.remove_stars( - 'foo\n{{linkfa|en}}\n{{linkfa|de}}\n' - '{{linkfa|fr}}\n{{linkfa|bar}}', ['{{linkfa|de}}\n'])) - - def test_append_stars(self): - """Test append_stars method.""" - self.assertEqual( - 'foo\n\n{{linkfa|bar}}\n{{linkfa|de}}\n' - '{{linkfa|en}}\n{{linkfa|fr}}\n', - textlib.append_stars( - 'foo', ['{{linkfa|en}}\n', '{{linkfa|de}}\n', - '{{linkfa|fr}}\n', '{{linkfa|bar}}'])) - - class TestExtractSections(DefaultDrySiteTestCase):
"""Test the extract_sections function."""
pywikibot-commits@lists.wikimedia.org