replace underscores with spaces in BaseSite._username

Following bug 61832 comment 3 suggestion a)

Change-Id: Ibaa00e00bc61c734955e1377604241541eab336b
core specific code improvements

- use site code instead of site.lang
- replace page.get() with page.text
- replace page.put() with page.save
- remove old setAction method

Change-Id: Ife82ea3dd66e8e0393ea03741dbd869d852289f9
use site method apipath() instead of Family.apipath()

this ensures the site code is used instead of site.lang

Change-Id: Ic6b314c56923a3aba2d6e6be35940b3931f707e9
(bug 66403) enable redirect.py follows section links

site.getredirtarget() didn't take into account sections and also
page.getRedirectTarget() didn't find the section. This is a
breaking change againts compat behaviour and causes redirect.py
to fail. This patch looks for the section in the redirect target.

Additional improvements:
- normalize title by api result
- title encoding for Exception messages

Change-Id: I4b6d7f32fc1ec79eb962fa8d21d283b4fe783fbf
Add whitespaces per PEP 8

Change-Id: Ia1a80643cbb83827f9587dc4bdac4ddc34dbc35d
Code improvements, split code into parts

- findTranslated() becomes a generator
- Split featuredWithInterwiki() into main loop and
- add_template() to place/change the template

Change-Id: I40693c603423ee7aabba53a4226df20c1e81b88b
Log package versions

The version of major dependencies 'httplib2' and 'mwparserfromhell'
shoud be written to the log, and included in the script version.py.

In verbose mode it is helpful to see what other major packages are
being automatically loaded into the python environment, and their
versions.

Move the online startup checks after the local checks.

Change-Id: Iae9f73b23ab1eb1a4acce46a690c0b4f9f9396a8
textlib InterwikiFormat() depends on config

InterwikiFormat implicitly uses Page.title() which by default uses
config settings to dynamically determine whether to include a family and/or
lang prefix to the title.  InterwikiFormat is supposed to format
interwikis relative to 'insite', not config variables such as family.

Explicitly invoke Page.title() with appropriate parameters to override
config settings.

The relevant test failed when config.family was not wikipedia.
In addition to the bug in textlib, the test also depended on config
settings.  Link()'s should be instantiated with a source in these tests.

Change-Id: I9ab8780e659517db7068d4af3164a2f54ce85461
Update of Vikidia and Wikia MediaWiki version

Change-Id: I0e3f635c9a00612a838d5002d279dbafcb407e79
Do not print thread info under unittests

On Python 2.6, this causes errors.  Everywhere else it is
confusing to have differences between running tests individually
vs as a batch via setup.py

Change-Id: I7ea207f1f9e994e7542ac93eb4130ea60ad646a0
Merge "Update of Vikidia and Wikia MediaWiki version"
Fix py2.6 unicode output test cases

The behavior of streams with an '.encoding' parameter changed
from 2.6 to 2.7: writing unicode is not allowed in 2.6, but
is in 2.7. In 3.x, the latter is the standard behavior.

At least, for stdin/stdout. We can also have a binary file
stream, in which case we have to decide the encoding ourselves.

Change-Id: I29118b548ef95544d0f6a148d76bae109e9cfbe5
Merge "Fix py2.6 unicode output test cases"
Fix wikibase 2.6 tests

Use %s and %r to format numbers in a format that corresponds
to the format actually used while formatting (i.e. str() and
repr())

Change-Id: I50d0632606f413c9b5e32341dece2cf9d3eb2a21
upload.py: pyflakes fixes

- undefined name 'rlen'
- undefined name '_contents'
- local variable 'e' is assigned to but never used

Change-Id: I3a8f069d32c9d9a209536adf081cf11420908414
Merge "Fix wikibase 2.6 tests"
Merge "upload.py: pyflakes fixes"
Site: add canonical namespaces to site._namespaces

Needed to identify which namespaces can be accessed by an Extension.
E.g. Proofread Page works on Page and Index namespaces, which keep the
same name as 'canonical' namespaces but not as 'actual' namespaces.

Code improvements as well

Preparation for ProofreadPage class.

Change-Id: I58d67501e00ff9f1afdbdde97ac43bd7aeb40963
reflinks.py : fix use of NoReferencesBot

Adapt this script after Change-Id I089625044be4a1866aeb6d42027b661ab316de1d

Change-Id: I782a0e73d6144da99edc8305aa1167031e3ddb89
(bug 66345) solve unicode error in html2unicode

unichr() isn't defined for values >= 0x10000 in python 2
(I guess in py3 it is, but there are remaining problems on Windows
for py < 3.4)
and raises a ValueError with that remark "(narrow Python build)".

Now unicode char is created as '\Uxxxxxxxx' literal.

Change-Id: I7a38aae7a19079e7cdf93d6cc6922b2214558973