def path_status(path, filename='', status=None, verbosity=0):
    """ Retrieve the access, modify, and create timetags for a path along with its size

    Arguments:
        path (str): full path to the file or directory to be statused
        status (dict): optional existing status to be updated/overwritten with new status values

    Returns:
        dict: {'size': bytes (int), 'accessed': (datetime), 'modified': (datetime), 'created': (datetime)}
    """
    status = status or {}
    if not filename:
        dir_path, filename = os.path.split()  # this will split off a dir and as `filename` if path doesn't end in a /
    else:
        dir_path = path
    full_path = os.path.join(dir_path, filename)
    if verbosity > 1:
        print(full_path)
    status['name'] = filename
    status['path'] = full_path
    status['dir'] = dir_path
    status['type'] = []
    try:
        status['size'] = os.path.getsize(full_path)
        status['accessed'] = datetime.datetime.fromtimestamp(os.path.getatime(full_path))
        status['modified'] = datetime.datetime.fromtimestamp(os.path.getmtime(full_path))
        status['created'] = datetime.datetime.fromtimestamp(os.path.getctime(full_path))
        status['mode'] = os.stat(full_path).st_mode   # first 3 digits are User, Group, Other permissions: 1=execute,2=write,4=read
        if os.path.ismount(full_path):
            status['type'] += ['mount-point']
        elif os.path.islink(full_path):
            status['type'] += ['symlink']
        if os.path.isfile(full_path):
            status['type'] += ['file']
        elif os.path.isdir(full_path):
            status['type'] += ['dir']
        if not status['type']:
            if os.stat.S_ISSOCK(status['mode']):
                status['type'] += ['socket']
            elif os.stat.S_ISCHR(status['mode']):
                status['type'] += ['special']
            elif os.stat.S_ISBLK(status['mode']):
                status['type'] += ['block-device']
            elif os.stat.S_ISFIFO(status['mode']):
                status['type'] += ['pipe']
        if not status['type']:
            status['type'] += ['unknown']
        elif status['type'] and status['type'][-1] == 'symlink':
            status['type'] += ['broken']
    except OSError:
        status['type'] = ['nonexistent'] + status['type']
        if verbosity > -1:
            warnings.warn("Unable to stat path '{}'".format(full_path))
    status['type'] = '->'.join(status['type'])

    return status
def path_status ( path , filename = '' , status = None , verbosity = 0 ) : status = status or { } if not filename : dir_path , filename = os . path . split ( ) else : dir_path = path full_path = os . path . join ( dir_path , filename ) if verbosity > 1 : print ( full_path ) status [ 'name' ] = filename status [ 'path' ] = full_path status [ 'dir' ] = dir_path status [ 'type' ] = [ ] try : status [ 'size' ] = os . path . getsize ( full_path ) status [ 'accessed' ] = datetime . datetime . fromtimestamp ( os . path . getatime ( full_path ) ) status [ 'modified' ] = datetime . datetime . fromtimestamp ( os . path . getmtime ( full_path ) ) status [ 'created' ] = datetime . datetime . fromtimestamp ( os . path . getctime ( full_path ) ) status [ 'mode' ] = os . stat ( full_path ) . st_mode if os . path . ismount ( full_path ) : status [ 'type' ] += [ 'mount-point' ] elif os . path . islink ( full_path ) : status [ 'type' ] += [ 'symlink' ] if os . path . isfile ( full_path ) : status [ 'type' ] += [ 'file' ] elif os . path . isdir ( full_path ) : status [ 'type' ] += [ 'dir' ] if not status [ 'type' ] : if os . stat . S_ISSOCK ( status [ 'mode' ] ) : status [ 'type' ] += [ 'socket' ] elif os . stat . S_ISCHR ( status [ 'mode' ] ) : status [ 'type' ] += [ 'special' ] elif os . stat . S_ISBLK ( status [ 'mode' ] ) : status [ 'type' ] += [ 'block-device' ] elif os . stat . S_ISFIFO ( status [ 'mode' ] ) : status [ 'type' ] += [ 'pipe' ] if not status [ 'type' ] : status [ 'type' ] += [ 'unknown' ] elif status [ 'type' ] and status [ 'type' ] [ - 1 ] == 'symlink' : status [ 'type' ] += [ 'broken' ] except OSError : status [ 'type' ] = [ 'nonexistent' ] + status [ 'type' ] if verbosity > - 1 : warnings . warn ( "Unable to stat path '{}'" . format ( full_path ) ) status [ 'type' ] = '->' . join ( status [ 'type' ] ) return status
Retrieve the access, modify, and create timetags for a path along with its size

    Arguments:
        path (str): full path to the file or directory to be statused
        status (dict): optional existing status to be updated/overwritten with new status values

    Returns:
        dict: {'size': bytes (int), 'accessed': (datetime), 'modified': (datetime), 'created': (datetime)}