Important advices.

Here, I have described a sum up of the different suggestions and guidelines I had been directed for porting..

Basic in general guidelines:

  • This is the ultimate guide to start working.
  • Besides, for an overall study on all aspects of Pywikibot on may refer to the compilation mediawiki and at wikibooks.
  • Do the scripting according to pep8 , pep257 , flake8 and pyflakes guidelines..
  • Make minute changes based on the present version, date, author etc.. details.
  • Retain the functionality of the script based on the pywikibot module.
  • Don’t forget to test the script, in different environments (python version, OS version, etc.), before submitting it.
  • Make sure that before calling super __init__, you update self.availableOptions. For Bot implementation it’s advisable to use self.availableOptions.update({}) in __init__ where the defined parameters’s value may be obtained by using self.getOption(‘<parameter name’>). This may be facilated in two ways as depicted in script parser_function_count.py and scripts/commons_link.py.
  • Make necessary changes in user-config.py to get logging in from commandline/terminal for testing scripts.
  • Using userPut() in place of put() is widely done. For reference see scripts/pagefromfile.py and pywikibot/bot.py.
  • Expected format to write docstrings : See the top of other scripts, e.g. solve_disambiguation.
  • @deprecated(“fileIsShared”)
    def fileIsOnCommons(self): –>  this means to use fileIsShared()
  • @param and @type are only used for functions and methods
  • Don’t use print.
  • It is more compelling to use unicode_literals when back-porting new or existing Python 3 code to Python 2/3 than when porting existing Python 2 code to 2/3. In the latter case, explicitly marking up all unicode string literals with u'' prefixes would help to avoid unintentionally changing the existing Python 2 API.
  • Don’t remove u’…’ just for fun but only if git blame was broken anyway.
  • If a bot uses GeneratorFactory, the module should include the line
    docuReplacements = {‘&params;’: pywikibot.pagegenerators.parameterHelp}
    and include the marker &params; in the module’s docstring
    We manually include it so the parameters show up in the auto-generated module documentation:
  • # creating & retrieving urls – help
  • using __future__ as
    from __future__ import (absolute_import, division, print_function, unicode_literals)
  • Unicode doesn’t exist in Python 3, but this here is easy: str.decode generates a unicode object.
    eg. : unicode_text = unicode(mungedText, ‘utf-8’) rewritten as : mungedText.decode(encoding=‘utf-8’)
  • Using input_yn instead of inputChoice:
    answer = pywikibot.input_yn(u’Do you want to import %s?’, default=False, automatic_quit=False)
  • When issue like Jenkins actually saying to rebase the latest patch been submitted it refers to rebase on the master. It may be done directly by stashing unstaged changes first and then using ‘git rebase master’
    Usually it works always unless you depend on other patches which aren’t merged (this means the PS is not merged) (So if the patch is merged but you depend on not the latest PS (so not on the PS which got merged) then you need to rebase it differently)
  • MORE to COME
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s