XZise has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/245610

Change subject: [IMPROV] i18n: Deprecate list as code in twtranslate
......................................................................

[IMPROV] i18n: Deprecate list as code in twtranslate

`twtranslate` supports a list as code in order to change it and return the
actually used code. This was only used for `twntranslate` and shouldn't be used
anymore.

Change-Id: I13d45e39ea52d77983fb4e654f8c0772f0263306
---
M pywikibot/i18n.py
1 file changed, 8 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/10/245610/1

diff --git a/pywikibot/i18n.py b/pywikibot/i18n.py
index 58e23fd..3bd9e9e 100644
--- a/pywikibot/i18n.py
+++ b/pywikibot/i18n.py
@@ -33,6 +33,7 @@
 import pkgutil
 
 from collections import defaultdict, Mapping
+from warnings import warn
 
 import pywikibot
 
@@ -554,7 +555,9 @@
     ...     % {'descr': 'seulement'})
     'Robot: Changer seulement quelques pages.'
 
-    @param code: The language code
+    @param code: When it's a site it's using the code attribute and otherwise 
it
+        is using the value directly.
+    @type code: BaseSite or str
     @param twtitle: The TranslateWiki string title, in <package>-<key> format
     @param parameters: For passing parameters. It should be a mapping but for
         backwards compatibility can also be a list, tuple or a single value.
@@ -583,6 +586,10 @@
         lang = code.code
     # check whether we need the language code back
     elif isinstance(code, list):
+        # For backwards compatibility still support lists, when twntranslate
+        # was not deprecated and needed a way to get the used language code 
back
+        warn('The code argument should not be a list but either a BaseSite or '
+             'a str/unicode.', DeprecationWarning, 2)
         lang = code.pop()
         code_needed = True
     else:

-- 
To view, visit https://gerrit.wikimedia.org/r/245610
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I13d45e39ea52d77983fb4e654f8c0772f0263306
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <commodorefabia...@gmx.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to