'Initialize a new ObjectId.
An ObjectId is a 12-byte unique identifier consisting of:
- a 4-byte value representing the seconds since the Unix epoch,
- a 3-byte machine identifier,
- a 2-byte process id, and
- a 3-byte counter, starting with a random value.
By default, ``ObjectId()`` creates a new unique identifier. The
optional parameter `oid` can be an :class:`ObjectId`, or any 12
:class:`bytes` or, in Python 2, any 12-character :class:`str`.
For example, the 12 bytes b\'foo-bar-quux\' do not follow the ObjectId
specification but they are acceptable input::
>>> ObjectId(b\'foo-bar-quux\')
ObjectId(\'666f6f2d6261722d71757578\')
`oid` can also be a :class:`unicode` or :class:`str` of 24 hex digits::
>>> ObjectId(\'0123456789ab0123456789ab\')
ObjectId(\'0123456789ab0123456789ab\')
>>> # A u-prefixed unicode literal:
>>> ObjectId(u\'0123456789ab0123456789ab\')
ObjectId(\'0123456789ab0123456789ab\')
Raises :class:`~bson.errors.InvalidId` if `oid` is not 12 bytes nor
24 hex digits, or :class:`TypeError` if `oid` is not an accepted type.
:Parameters:
- `oid` (optional): a valid ObjectId.
.. mongodoc:: objectids'

def __init__(self, oid=None):

    if (oid is None):
        self.__generate()
    elif (isinstance(oid, bytes) and (len(oid) == 12)):
        self.__id = oid
    else:
        self.__validate(oid)
