human
Complete the below
def ext_pillar(minion_id, pillar, collection='pillar', id_field='_id', re_pattern=None, re_replace='', fields=None):

    ''''Connect to a mongo database and read per-node pillar information.
    Parameters:
    * `collection`: The mongodb collection to read data from. Defaults to
    ``\'pillar\'``.
    * `id_field`: The field in the collection that represents an individual
    minion id. Defaults to ``\'_id\'``.
    * `re_pattern`: If your naming convention in the collection is shorter
    than the minion id, you can use this to trim the name.
    `re_pattern` will be used to match the name, and `re_replace` will
    be used to replace it. Backrefs are supported as they are in the
    Python standard library. If ``None``, no mangling of the name will
    be performed - the collection will be searched with the entire
    minion id. Defaults to ``None``.
    * `re_replace`: Use as the replacement value in node ids matched with
    `re_pattern`. Defaults to \'\'. Feel free to use backreferences here.
    * `fields`: The specific fields in the document to use for the pillar
    data. If ``None``, will use the entire document. If using the
    entire document, the ``_id`` field will be converted to string. Be
    careful with other fields in the document as they must be string
    serializable. Defaults to ``None``.'
    '''

Write me a the Python program you requested?
assistant
#Here is the Python program you requested.
    host = __opts__['mongo.host']
    port = __opts__['mongo.port']
    log.info('connecting    to    {0}:{1}    for    mongo    ext_pillar'.format(host, port))
    conn = pymongo.MongoClient(host, port)
    log.debug("using    database    '{0}'".format(__opts__['mongo.db']))
    mdb = conn[__opts__['mongo.db']]
    user = __opts__.get('mongo.user')
    password = __opts__.get('mongo.password')
    if (user and password):
        log.debug("authenticating    as    '{0}'".format(user))
        mdb.authenticate(user, password)
    if re_pattern:
        minion_id = re.sub(re_pattern, re_replace, minion_id)
    log.info("ext_pillar.mongo:    looking    up    pillar    def    for    {{'{0}':    '{1}'}}    in    mongo".format(id_field, minion_id))
    result = mdb[collection].find_one({id_field: minion_id}, projection=fields)
    if result:
        if fields:
            log.debug("ext_pillar.mongo:    found    document,    returning    fields    '{0}'".format(fields))
        else:
            log.debug('ext_pillar.mongo:    found    document,    returning    whole    doc')
        if ('_id' in result):
            result['_id'] = str(result['_id'])
        return result
    else:
        log.debug('ext_pillar.mongo:    no    document    found    in    collection    {0}'.format(collection))
        return {}