'Creates a single entry using a filepath and a type (file/dir)'

def create_entry(self, filepath, test_mode):

    filepath = filepath.abspath()
    entry = Entry()
    entry[u'location'] = filepath
    if PY2:
        import urllib
        import urlparse
        entry[u'url'] = urlparse.urljoin(u'file:', urllib.pathname2url(filepath.encode(u'utf8')))
    else:
        import pathlib
        entry[u'url'] = pathlib.Path(filepath).absolute().as_uri()
    entry[u'filename'] = filepath.name
    if filepath.isfile():
        entry[u'title'] = filepath.namebase
    else:
        entry[u'title'] = filepath.name
    try:
        entry[u'timestamp'] = datetime.fromtimestamp(filepath.getmtime())
    except Exception as e:
        log.warning((u'Error    setting    timestamp    for    %s:    %s' % (filepath, e)))
        entry[u'timestamp'] = None
    entry[u'accessed'] = datetime.fromtimestamp(filepath.getatime())
    entry[u'modified'] = datetime.fromtimestamp(filepath.getmtime())
    entry[u'created'] = datetime.fromtimestamp(filepath.getctime())
    if entry.isvalid():
        if test_mode:
            log.info(u'Test    mode.    Entry    includes:')
            log.info((u'                Title:    %s' % entry[u'title']))
            log.info((u'                URL:    %s' % entry[u'url']))
            log.info((u'                Filename:    %s' % entry[u'filename']))
            log.info((u'                Location:    %s' % entry[u'location']))
            log.info((u'                Timestamp:    %s' % entry[u'timestamp']))
        return entry
    else:
        log.error((u'Non    valid    entry    created:    %s    ' % entry))
        return
