Page MenuHomePhabricator

prefer userscripts over scripts
Closed, ResolvedPublic

Description

currently pwb.py wrapper script searches for scripts in several folders. The order is given in find_filename function:

script_paths = ['scripts',
                'scripts.maintenance',
                'scripts.userscripts']

If a user_script_path is given in user-config.py that path is priorized. But we have a default empty userscript path. But currently that path is the last to be searched for scripts. I propose to priorizes userscripts over scripts. This gives the ability to run a customized script with the same filename found in framework script folder.

Event Timeline

Xqt created this task.Mar 24 2020, 7:56 AM
Restricted Application added subscribers: pywikibot-bugs-list, Aklapper. · View Herald TranscriptMar 24 2020, 7:56 AM
Xqt triaged this task as Low priority.Mar 24 2020, 7:56 AM
Huji awarded a token.Mar 24 2020, 11:41 AM

Hi @Xqt ,
In user-config.py it is mentioned that user_script_path is search in this given order:

  1. scripts
  2. scripts/maintenance
  3. scripts/archive

But in the find_filename function, there is no search in archives. Do we need to add this too in script_paths?

Hi @Mh-3110 ,
no, the other way around :) We need to remove scripts/archive from user-config.py

Ok @Dvorapa ,
I will work on this ticket.
Thanks

Mh-3110 claimed this task.Mar 25 2020, 9:06 AM

@Dvorapa ,

currently user-config.py is ignored as listed in .gitignore .
can I exclude it from the .gitignore file to update it?

Thanks

Xqt added a comment.Mar 25 2020, 2:48 PM

@Dvorapa ,

currently user-config.py is ignored as listed in .gitignore .
can I exclude it from the .gitignore file to update it?

Thanks

No because user-config.py is a private settings file which may override settings done by config2.py. Therefore you should change the doc in config2.py only. The new order should be:

  1. user_script_paths in the given order
  2. scripts/userscripts
  3. scripts
  4. scripts/maintenance

And script_path in find_filename must be updated accordingly.

Change 583362 had a related patch set uploaded (by Mh-3110; owner: Mahuton):
[pywikibot/core@master] [IMPR]-Prefer userscripts over scripts

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

Thanks @Xqt
Patch submitted

Mh-3110 moved this task from Backlog to Needs Review on the Pywikibot board.Mar 25 2020, 3:32 PM

Change 583362 merged by jenkins-bot:
[pywikibot/core@master] [IMPR] Prefer userscripts over scripts

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

Xqt closed this task as Resolved.Mar 25 2020, 7:11 PM

Thanks