jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/511090 )
Change subject: [cleanup] Use defaultdict for date.formats['YearAD'] ......................................................................
[cleanup] Use defaultdict for date.formats['YearAD']
This improves test time by 25 %
Change-Id: Iedde700a3386476dc36a33cb466e9cd8049f8005 --- M pywikibot/date.py 1 file changed, 3 insertions(+), 97 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/date.py b/pywikibot/date.py index e684519..bf05fc8 100644 --- a/pywikibot/date.py +++ b/pywikibot/date.py @@ -14,6 +14,7 @@ from __future__ import absolute_import, division, unicode_literals
import calendar +from collections import defaultdict import datetime import re from string import digits as _decimalDigits # noqa: N812 @@ -878,121 +879,26 @@ 'zh': lambda v: dh_number(v, '%d'), },
- 'YearAD': { - 'af': dh_simpleYearAD, - 'an': dh_simpleYearAD, - 'ang': dh_simpleYearAD, - 'ar': dh_simpleYearAD, - 'ast': dh_simpleYearAD, - 'az': dh_simpleYearAD, - 'be': dh_simpleYearAD, - 'bg': dh_simpleYearAD, + 'YearAD': defaultdict(lambda: dh_simpleYearAD, **{ 'bn': lambda v: dh_yearAD(v, '%B'), - 'br': dh_simpleYearAD, - 'bs': dh_simpleYearAD, - 'ca': dh_simpleYearAD, - 'ceb': dh_simpleYearAD, - 'cs': dh_simpleYearAD, - 'csb': dh_simpleYearAD, - 'cv': dh_simpleYearAD, - 'cy': dh_simpleYearAD, - 'da': dh_simpleYearAD, - 'de': dh_simpleYearAD, - 'el': dh_simpleYearAD, - 'en': dh_simpleYearAD, - 'eo': dh_simpleYearAD, - 'es': dh_simpleYearAD, - 'et': dh_simpleYearAD, - 'eu': dh_simpleYearAD, 'fa': lambda v: dh_yearAD(v, '%F (میلادی)'), - 'fi': dh_simpleYearAD, - 'fo': dh_simpleYearAD, - 'fr': dh_simpleYearAD, - 'fur': dh_simpleYearAD, - 'fy': dh_simpleYearAD, - 'ga': dh_simpleYearAD, 'gan': lambda v: dh_yearAD(v, '%d年'), - 'gd': dh_simpleYearAD, - 'gl': dh_simpleYearAD, - 'gsw': dh_simpleYearAD, 'gu': lambda v: dh_yearAD(v, '%G'), - 'he': dh_simpleYearAD, 'hi': lambda v: dh_yearAD(v, '%H'), 'hr': lambda v: dh_yearAD(v, '%d.'), - 'hu': dh_simpleYearAD, - 'hy': dh_simpleYearAD, - 'ia': dh_simpleYearAD, - 'id': dh_simpleYearAD, - 'ie': dh_simpleYearAD, - 'ilo': dh_simpleYearAD, - 'io': dh_simpleYearAD, - 'is': dh_simpleYearAD, - 'it': dh_simpleYearAD, 'ja': lambda v: dh_yearAD(v, '%d年'), 'jbo': lambda v: dh_yearAD(v, '%dmoi nanca'), - 'ka': dh_simpleYearAD, 'kn': lambda v: dh_yearAD(v, '%K'), 'ko': lambda v: dh_yearAD(v, '%d년'), 'ksh': lambda v: dh_yearAD(v, 'Joohr %d'), - 'ku': dh_simpleYearAD, - 'kw': dh_simpleYearAD, - 'la': dh_simpleYearAD, - 'lb': dh_simpleYearAD, - 'li': dh_simpleYearAD, - 'lt': dh_simpleYearAD, - 'lv': dh_simpleYearAD, - 'mi': dh_simpleYearAD, - 'mhr': dh_simpleYearAD, - 'mk': dh_simpleYearAD, - 'ml': dh_simpleYearAD, - 'mo': dh_simpleYearAD, 'mr': lambda v: dh_yearAD(v, 'ई.स. %H'), - 'ms': dh_simpleYearAD, - 'na': dh_simpleYearAD, 'nan': lambda v: dh_yearAD(v, '%d nî'), - 'nap': dh_simpleYearAD, - 'nds': dh_simpleYearAD, - 'nl': dh_simpleYearAD, - 'nn': dh_simpleYearAD, - 'nb': dh_simpleYearAD, - 'nso': dh_simpleYearAD, - 'oc': dh_simpleYearAD, - 'os': dh_simpleYearAD, - 'pdc': dh_simpleYearAD, - 'pl': dh_simpleYearAD, - 'pt': dh_simpleYearAD, - 'rm': dh_simpleYearAD, - 'ro': dh_simpleYearAD, - 'rup': dh_simpleYearAD, 'ru': lambda v: dh_yearAD(v, '%d год'), - 'sco': dh_simpleYearAD, - 'scn': dh_simpleYearAD, - 'se': dh_simpleYearAD, - 'sh': dh_simpleYearAD, - 'sk': dh_simpleYearAD, - 'sl': dh_simpleYearAD, - 'sm': dh_simpleYearAD, - 'sq': dh_simpleYearAD, - 'sr': dh_simpleYearAD, - 'sv': dh_simpleYearAD, - 'su': dh_simpleYearAD, - 'ta': dh_simpleYearAD, - 'te': dh_simpleYearAD, # 2005 => 'พ.ศ. 2548' 'th': lambda v: dh_yearAD(v, 'พ.ศ. %T'), - 'tl': dh_simpleYearAD, - 'tpi': dh_simpleYearAD, - 'tr': dh_simpleYearAD, - 'tt': dh_simpleYearAD, - 'uk': dh_simpleYearAD, 'ur': lambda v: dh_yearAD(v, '%dء'), - 'uz': dh_simpleYearAD, - 'vec': dh_simpleYearAD, - 'vi': dh_simpleYearAD, - 'vo': dh_simpleYearAD, - 'wa': dh_simpleYearAD, 'zh': lambda v: dh_yearAD(v, '%d年'), - }, + }),
'YearBC': { 'af': lambda v: dh_yearBC(v, '%d v.C.'),
pywikibot-commits@lists.wikimedia.org