jayvdb added a comment.

In https://phabricator.wikimedia.org/T90156#1307131, @XZise wrote:

> So is this bug report actually about the fact that you need the `future` 
> package in Python 2.6 (or that pywikibot needs `OrderedDict`)? Or did I 
> misunderstand that update?


Yes.  On that box, @multichill can't install python packages into the global 
system, and it doesnt have virtualenv installed.  So reducing the code paths 
that utilise OrderedDict helps keep that box running.

In this case the workaround is to set config.ignore_bot_templates to True.
A simple way to bed that workaround into the system is by adding post config 
logic to config that 'if a ordereddict isnt available, turn on 
ignore_bot_templates with a user warning'.  We could take that further and add 
'if a ordereddict or counter isnt available, make DataSite and the new Page 
methods depending on OrderedDict/Counter return NotImplementedError'.

To reduce how much needs to be disabled, my initial attempt at adding an 
OrderedDict dependency could also be used, as it falls back to using a 
(unordered) dict, which is perfectly acceptable for most uses. 
https://gerrit.wikimedia.org/r/#/c/147665/1/pywikibot/__init__.py,cm .  Counter 
is very easy to reimplemented, esp. if some of its methods raise 
NotImplementedError.

In https://phabricator.wikimedia.org/T90156#1306982, @Multichill wrote:

> Nice solution would be to check if the template actually exists before trying 
> to parse a page with textlib


This approach would work for @multichill and some others, as he is using py2.6 
on a private wiki which doesnt have this template.  The current code is very 
Wikimedia-centric.
A patch to reduce the problem is https://gerrit.wikimedia.org/r/#/c/179177/ .  
That is -1'd because 
https://phabricator.wikimedia.org/rPWBC7e3772cae04f95cb55b223a198fb6350f73b0639 
added a warning that some templates may not appear in 
https://www.mediawiki.org/wiki/API:Templates , so falling back to text parsing 
is 'mandatory'.  I cant see any mention of this problem in any relevant 
documentation.

This approach could be achieved by botMayEdit asking for a specific template 
list very early, such as:

  self.templatesWithParams(only_template_names=['bots', 'nobots']) , 

Then templatesWithParams could pass the list to extract_templates_and_params , 
and the regex and mwpfh implementations could optimise their algorithm 
accordingly, and return less data, and often no data at all.


TASK DETAIL
  https://phabricator.wikimedia.org/T90156

EMAIL PREFERENCES
  https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: jayvdb
Cc: Ricordisamoa, jayvdb, XZise, Aklapper, Multichill, pywikipedia-bugs



_______________________________________________
pywikibot-bugs mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs

Reply via email to