Page MenuHomePhabricator

Rewrite scripts using new option handler
Closed, ResolvedPublic

Description

With rPWBCc2a4f9e the bot option handler was improved.

old behaviour

each bot option must be accessed by self.getOption() method e.g. self.getOption('always')

new behaviour

Option can be accessed as attibute or via keyword, for example:

  • self.opt.always
  • self.opt['always']

By the way self.opt gives a dict of all valid Options. This can be easily used for format string for example:
'Always option is {always}'.format_map(self.opt) or 'Always option is {always}'.format(**self.opt)

scripts should be rewritten by using the new option handler to get the full advantage of

  • shorter and intuitive access to bot options
  • bot option as attribute
  • bot option as keyword item
  • bot options Access as dict

What to do?

  • replace getOption() method by that way described above
  • replace availableOptions by available_options
  • replace setOptions by set_options

Event Timeline

Sure. Just use the action Assign/claim.

Hi @Xqt the first change, replace getOption() method by that way described above, I need some clarifications, is this to be replace with this
self.opt.always or
self.opt['always']

Hi @Xqt the first change, replace getOption() method by that way described above, I need some clarifications, is this to be replace with this
self.opt.always or
self.opt['always']

Both works but I prefer the first one.

Alright I'd use the first one then

Change 636022 had a related patch set uploaded (by Udoka; owner: Udoka):
[pywikibot/core@master] [IMPR] Rewrite scripts using new option handler

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

Change 636025 had a related patch set uploaded (by Udoka; owner: Udoka):
[pywikibot/core@master] [IMPR] Rewrite scripts using new option handler

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

Change 636028 had a related patch set uploaded (by Udoka; owner: Udoka):
[pywikibot/core@master] [IMPR] Rewrite scripts using new option handler

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

Hi @Xqt apologies for the delay in sending patches for this task, I am in the process of concluding my outreachy application and should be able to send in patches by Saturday. Thanks for your understanding.

Hi @Xqt apologies for the delay in sending patches for this task, I am in the process of concluding my outreachy application and should be able to send in patches by Saturday. Thanks for your understanding.

Do not rush; take the time you need. Don't change more than 5 files in a single patch; that is easier to review then.

Change 637741 had a related patch set uploaded (by Udoka; owner: Udoka):
[pywikibot/core@master] [IMPR] Rewrite scripts using new option handler

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

Change 637837 had a related patch set uploaded (by Udoka; owner: Udoka):
[pywikibot/core@master] [IMPR] Rewrite scripts using new option handler

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

Change 637837 merged by jenkins-bot:
[pywikibot/core@master] [IMPR] Rewrite scripts using new option handler

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

Change 636025 abandoned by Xqt:
[pywikibot/core@master] [IMPR] Rewrite scripts using new option handler

Reason:
See review comment

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

Change 636028 abandoned by Udoka:
[pywikibot/core@master] [IMPR] Rewrite scripts using new option handler

Reason:
issue fixed on another patch

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

Change 636022 abandoned by Udoka:
[pywikibot/core@master] [IMPR] Rewrite scripts using new option handler

Reason:
issue fixed on another patch

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

Change 637741 merged by jenkins-bot:
[pywikibot/core@master] [IMPR] Rewrite scripts using new option handler

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

Hi @Xqt I think I am done with this.

@Udoka_Ugo: thanks a lot for your help. There was one issue to be fixed which I have overseen previously; I've done it with https://gerrit.wikimedia.org/r/c/pywikibot/core/+/637863. More to come ;)