Use b"", not u"", for _EMPTY_PREFIX.

Signed-off-by: mulhern <amulhern@redhat.com>
Make _lowerASCII() python 3 compatible and add a method header.

Signed-off-by: mulhern <amulhern@redhat.com>
Rewrite _parseSpec() and convertTo()

This fixes a bug where most English specifiers would not be parsed
unless the locale was a lot like English; after failing to be parsed
in the English section, they still got their chance to be parsed in
the locale-specific section, and if it was close enough, as it usually
is for me, it would be parsed there.

Add a method, _parseUnits(), which handles the parsing of the units
part of the spec. Abstract this for both translated and non-translated.
If there is no exact match for the units, see if the units are a prefix
of a binary abbreviation.

Remove _makeSpecs() entirely, and redistribute its functionality between
new methods _parseUnits() and _makeSpec().

Rewrite convertTo() so that it uses newly introduced _parseUnits() not
newly removed _makeSpecs() and make it work with translated specs as well
as untranslated.
Thereby fix a small bug where the spec was lower-cased as if it were locale
specific, but the prefixes to match against were untranslated.
Change default to "", which means bytes, just like "b".
These changes emphasises that _parseSpec() and convertTo() should agree on
what a spec means.
Also, just accept the default for calls to convertTo() in size.

Remove now useless imports, constants, functions.

Update tests appropriately.

Signed-off-by: mulhern <amulhern@redhat.com>
Add xlate parameter to humanReadable().

Make default True, so no visible change.
We don't often look at logs generated in a foreign locale, but if we
did, and the locale were different enough from English, I would have
a bit of trouble interpreting the Size values since Size.__str__()
just turns around and invokes humanReadable(). We should probably,
for purposes of logs, explicitly invoke humanReadable(xlate=False).
This just sets up humanReadable() so that is possible.

Also, translate less eagerly.

The only prefix or abbreviation that needs to be translated is the
one that is displayed, so wait until display time to translate, if required.

Signed-off-by: mulhern <amulhern@redhat.com>
Add a number of new tests.

Factor locale related tests into a separate class so that current locale
can be saved and restored more consistently.

Signed-off-by: mulhern <amulhern@redhat.com>