From: philipp Date: Sun, 29 Jan 2017 22:19:13 +0000 (+0000) Subject: Moved dbkey_to_title from mwapi to mwmarkup. X-Git-Url: https://git.toastfreeware.priv.at/philipp/winterrodeln/wrpylib.git/commitdiff_plain/f79845eb370b636288c83b9c59d3518264dd847f?hp=dc88d2d476403b7e8a1e7d48514cda13f1abcd32 Moved dbkey_to_title from mwapi to mwmarkup. git-svn-id: http://www.winterrodeln.org/svn/wrpylib/trunk@2636 7aebc617-e5e2-0310-91dc-80fb5f6d2477 --- diff --git a/tests/test_mwapi.py b/tests/test_mwapi.py deleted file mode 100644 index a3ed4bc..0000000 --- a/tests/test_mwapi.py +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/python3.4 -# $Id$ -# $HeadURL$ -import unittest -from wrpylib.mwapi import dbkey_to_title - - -class TestMwApi(unittest.TestCase): - def test_dbkey_to_title(self): - self.assertEqual(dbkey_to_title('My_Title'), 'My Title') - self.assertEqual(dbkey_to_title('My Title'), 'My Title') # should not happen - self.assertEqual(dbkey_to_title('My_nice_Title'), 'My nice Title') diff --git a/tests/test_mwmarkup.py b/tests/test_mwmarkup.py index 9955656..41225f1 100644 --- a/tests/test_mwmarkup.py +++ b/tests/test_mwmarkup.py @@ -147,3 +147,10 @@ class TestFormatTemplate(unittest.TestCase): value = mwparserfromhell.parse('{{ my_template || | var = 7 }}').filter_templates()[0] wrpylib.mwmarkup.format_template_oneline(value) self.assertEqual('{{my_template| | |var=7}}', value) + + +class TestMwApi(unittest.TestCase): + def test_dbkey_to_title(self): + self.assertEqual(wrpylib.mwmarkup.dbkey_to_title('My_Title'), 'My Title') + self.assertEqual(wrpylib.mwmarkup.dbkey_to_title('My Title'), 'My Title') # should not happen + self.assertEqual(wrpylib.mwmarkup.dbkey_to_title('My_nice_Title'), 'My nice Title') diff --git a/wrpylib/mwapi.py b/wrpylib/mwapi.py deleted file mode 100644 index 5686c47..0000000 --- a/wrpylib/mwapi.py +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/python3.4 -# $Id$ -# $HeadURL$ -"""This module contains general functions for using the MediaWiki API. There is one very -good Python wrapper implementation of the MediaWiki API: -* wikitools http://code.google.com/p/python-wikitools/ - -Therefore this module doesn't need to have much content. -""" - - -def dbkey_to_title(value): - """Converts a article database key to a article title. Private function secureAndSplit() of the Title class - on line 3316 of includes/Title.php says: - $this->mTextform = str_replace( '_', ' ', $this->mDbkeyform ); - No check for None because a missing title is an error.""" - return value.replace('_', ' ') diff --git a/wrpylib/mwmarkup.py b/wrpylib/mwmarkup.py index 04c2ffa..221f1cb 100644 --- a/wrpylib/mwmarkup.py +++ b/wrpylib/mwmarkup.py @@ -53,3 +53,11 @@ def format_template_oneline(template): if value == '': value = ' ' param.value = value + + +def dbkey_to_title(value): + """Converts a article database key to a article title. Private function secureAndSplit() of the Title class + on line 3316 of includes/Title.php says: + $this->mTextform = str_replace( '_', ' ', $this->mDbkeyform ); + No check for None because a missing title is an error.""" + return value.replace('_', ' ')