https://bugzilla.wikimedia.org/show_bug.cgi?id=72503
Bug ID: 72503 Summary: generate_family_file.py fails Product: Pywikibot Version: core (2.0) Hardware: All OS: All Status: NEW Severity: normal Priority: Unprioritized Component: General Assignee: Pywikipedia-bugs@lists.wikimedia.org Reporter: Phoenixoverride@gmail.com Web browser: --- Mobile Platform: ---
if generate_family_file.py is invoked via pwb.py generate_family_file.py the framework doesnt generate a family file
https://bugzilla.wikimedia.org/show_bug.cgi?id=72503
John Mark Vandenberg jayvdb@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |UNCONFIRMED CC| |jayvdb@gmail.com Ever confirmed|1 |0
--- Comment #1 from John Mark Vandenberg jayvdb@gmail.com --- $ python pwb.py generate_family_file.py Usage: generate_family_file.py <url> <short name> Example: generate_family_file.py https://www.mywiki.bogus/wiki/Main_Page mywiki This will create the file families/mywiki_family.py Please insert URL to wiki: http://glossary.reuters.com Please insert a short name (eg: freeciv): reuters Generating family file from http://glossary.reuters.com *** WARNING: Api does not seem to be enabled on http://glossary.reuters.com
================================== api url: http://glossary.reuters.com/api.php MediaWiki version: 1.11.1 ==================================
Determining other languages... Loading wikis... * en... in cache Writing pywikibot/families/reuters_family.py... $ cat pywikibot/families/reuters_family.py # -*- coding: utf-8 -*- """ This family file was auto-generated by $Id: 78e663f86b4d504a28387ecbf0c2e0e8e549cf4e $ Configuration parameters: url = http://glossary.reuters.com name = reuters
Please do not commit this to the Git repository! """
from pywikibot import family
class Family(family.Family): def __init__(self): family.Family.__init__(self) self.name = 'reuters' self.langs = { 'en': 'glossary.reuters.com', }
def scriptpath(self, code): return { 'en': '', }[code]
def version(self, code): return { 'en': u'1.11.1', }[code]
Please add more detailed steps to reproduce
https://bugzilla.wikimedia.org/show_bug.cgi?id=72503
--- Comment #2 from Betacommand Phoenixoverride@gmail.com --- C:\rewrite>pwb.py generate_family_file.py http://mysite.org/wiki/Main_Page mysit e NOTE: 'user-config.py' was not found! Please follow the prompts to create it: No user-config.py found in directory 'C:\rewrite'.
WARNING: Skipping loading of user-config.py. WARNING: Running on Windows and transliteration_target is not set. Please see https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Pywikibot/Wi ndows WARNING: family and mylang are not set. Defaulting to family='test' and mylang='test'.
Your default user directory is "C:\rewrite" WARNING: pywikibot.bot.inputChoice is deprecated, use input_choice instead. How to proceed? ([K]eep, [c]hange) k WARNING: pywikibot.bot.inputChoice is deprecated, use input_choice instead. Do you want to copy user files from an existing Pywikibot installation? ([y]es, [n]o) n WARNING: pywikibot.bot.inputChoice is deprecated, use input_choice instead. Create user-config.py file? Required for running bots. ([y]es, [N]o) n user-fixes.py already exists in the directory
https://bugzilla.wikimedia.org/show_bug.cgi?id=72503
Merlijn van Deen valhallasw@arctus.nl changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW CC| |valhallasw@arctus.nl Summary|generate_family_file.py |pwb.py does not run scripts |fails |if user-config.py does not | |exist Ever confirmed|0 |1
--- Comment #3 from Merlijn van Deen valhallasw@arctus.nl --- Ah, so rather the issue is generate_family_file is not run when no user-config.py exists. What happens is the following:
- pwb.py sees no user-config and thus invokes create_user_files.py - you don't want to create a user-config file yet, because you need the to-be-created family for that
The simplest way to fix this is to add a special case for generate_family_file.py in pwb.py, as it really *is* a special case. Allowing other scripts to continue would mean using test:test as site, for instance. Essentially it's our config singleton biting us again...
https://bugzilla.wikimedia.org/show_bug.cgi?id=72503
Fabian CommodoreFabianus@gmx.de changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |CommodoreFabianus@gmx.de
--- Comment #4 from Fabian CommodoreFabianus@gmx.de --- (In reply to Merlijn van Deen from comment #3)
Essentially it's our config singleton biting us again...
The current version of 'generate_family_file' could be run without a user config (like generate_user_files). The problem is just that pwb.py doesn't know that. Although the question is how can we pwb.py let it know? We could have just a list of files which don't require a user config, but then we need to make sure it's kept in sync with the file name(s).
Or only load the (user) config as soon as the script requires it which would be the default. So in generate_family_file it's setting a environment variable to say "user config is optional" and only then it queries the code to load the config. The problem here is when a file doesn't need it but depends on a file which does. If the default (when nothing is done about it) is to require the user config (so we only need to change generate_family_file) and a file does request that it doesn't need a user config it sets that variable. Later it depends then on something which does require the user config but doesn't set the variable because by default it doesn't need to.
Both scenarios sound like I'm overthinking it so maybe someone has a better and easier idea.
But thinking about it, it'd be nice if generate_family_file knows which family file directories are configured to give the user the configured directories to choose from. But that would require an “load user-config.py if possible but ignore otherwise” option.
https://bugzilla.wikimedia.org/show_bug.cgi?id=72503
--- Comment #5 from John Mark Vandenberg jayvdb@gmail.com --- Or generate_user_files could ask the user if they want to add a family , and invoke generate_family_file
https://bugzilla.wikimedia.org/show_bug.cgi?id=72503
John Mark Vandenberg jayvdb@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Priority|Unprioritized |Normal Blocks| |70936
pywikipedia-bugs@lists.wikimedia.org