bintree.py: fix str() calls for Python 2 (532784)

Avoid a UnicodeDecodeError raised when str(e) converts an exception
to bytes with Python 2. Since this file has unicode_literals enabled,
use literal unicode format strings to format messages for unicode
exceptions. However, with Python 2, an EnvironmentError exception
may contain either bytes or unicode, so use _unicode(errors="replace")
to ensure safety for EnvironmentError with all locales.

Also, convert remaining str() calls to use _unicode() for uniform
behavior regardless of python version.

X-Gentoo-Bug: 532784
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=532784
Acked-by: Brian Dolbec <dolsen@gentoo.org>
Update links to Handbooks
Fix "TabError: inconsistent use of tabs and spaces in indentation" with Python 3.

Regression was introduced in commit 17bc89c5db424c3f04af28a1da5bf90a943ac368.
Support override of default profile EAPI (532670)

Add support for a profile-default-eapi flag in the metadata/layout.conf
profile-formats field. When this flag is enabled, it enables support for
a profile_eapi_when_unspecified attribute which can be used to specify
the default EAPI to use for profile directories that do not contain an
eapi file. For example, the following settings will cause all profiles
that do not contain an eapi file to default to EAPI 5 instead of EAPI 0:

	profile-formats = profile-default-eapi
	profile_eapi_when_unspecified = 5

This is convenient for organizations that maintain their own profiles
in separate repositories from Gentoo, since they typically want to use
EAPI 5 for all of their profiles, and this allows them to avoid having
separate eapi files in each directory of their profiles. The name of
the profile_eapi_when_unspecified attribute is inherited from Paludis,
which has supported this attribute in exheres repositories for many
years.

The implementation may seem a bit messy because it needs to account for
3 different types of profile nodes:

 * Regular profile nodes

 * User profile override directory in /etc/portage/profile

 * The root "profiles" directory, which is not really a profile
   node, but is used for repository-level configurations (package.mask
   being the most common example used by Gentoo)

The default EAPI setting is stored in the RepoConfig.eapi attribute,
which is used as the "default" parameter for all
read_corresponding_eapi_file calls. Each profile node in
LocationsManager.profiles_complex now has an eapi attribute which
serves to cache the computed EAPI for that node, allowing redundant
read_corresponding_eapi_file calls to be eliminated. As a result,
functions such as grabfile_package now have eapi and eapi_default
parameters, where eapi is used to pass in a cached EAPI, and
eapi_default is used to pass in a default for
read_corresponding_eapi_file to use when a cached EAPI is not
available. For /etc/portage/profile, the EAPI is considered to have a
default value of None, which means that atoms from any supported EAPI
are allowed.

X-Gentoo-Bug: 532670
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=532670