Add various backports of Python 2.6 builtins: next(), any(), all(), bin()

This module contains four backports of Python 2.6 methods:
next() from Ross Brattain
any() from http://stackoverflow.com/questions/3785433/python-backports-for-some-methods
all() from http://stackoverflow.com/questions/3785433/python-backports-for-some-methods
bin() from http://code.activestate.com/recipes/576847/

These backports should be conditionally imported upon exception so they
do not shadow the builtin function on newer Pythons.

Example:

try:
    any([True])
except NameError:
    from autotest.client.shared.backports import any

Justification:

Using backports for builtin functions allows for forward-compatibility and
better performance on newer python versions.

bin() is used heavily when decoding hardware register bits.
any() and all() are useful for generators and list comprehensions
next() is useful because of the default argument, and it is consistent with
Python 3 usage.

v2: strip leading left zeros to match builtin bin()

Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
backports_unittest: unit tests for backported any(), all(), bin(), next()

v2: test backports.bin against builtin bin for a larger range of numbers

Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
backports: import OrderedDict backport by Raymond Hettinger

http://code.activestate.com/recipes/576693-ordered-dictionary-for-py24/

Documentation:
http://docs.python.org/2/library/collections.html#collections.OrderedDict

Changes from v1:
 * follow some pylint suggestions, disable other checks

Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
Signed-off-by: Cleber Rosa <crosa@redhat.com>
backports: import namedtuple backport by Raymond Hettinger

http://code.activestate.com/recipes/500261-named-tuples/

Documentation:
http://docs.python.org/2/library/collections.html#collections.namedtuple

Changes from v1:
 * follow some pylint suggestions, disabled some checks

Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
Signed-off-by: Cleber Rosa <crosa@redhat.com>
backports: import defaultdict backport by Jason Kirtland

http://code.activestate.com/recipes/523034-emulate-collectionsdefaultdict/

Documentation:
http://docs.python.org/2/library/collections.html#collections.defaultdict

Changes from v1:
 * follow some pylint suggestions, disabled other checks

Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
Signed-off-by: Cleber Rosa <crosa@redhat.com>
backports/collections: adjust namespace

So that names appear as autotest.client.shared.backports.collection.namedtuple

Changes from v1:
 * fixed whitespace

Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
backports: follow pylint suggestions

Signed-off-by: Cleber Rosa <crosa@redhat.com>
backports: fix file modes

That is, unset executable bits for files that should not be executable.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
backports_unittest.py: multiple improvements

 * Import the backport module from the autotest namespace.

 * Protect bin unittest when running on older Python by
catching the the NameError exception.

 * Move tests on namedtuple to unittest file.

 * make unittests use standard methods for assertion. Instead of
using builtin 'assert', use the more standard assertion methods
provided by the unittest.TestCase class.

Signed-off-by: Cleber Rosa <crosa@redhat.com>