<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def fileinfo(path):
    '''
    Return information on a file located on the Moose

    CLI Example:

    .. code-block:: bash

        salt '*' moosefs.fileinfo /path/to/dir/
    '''
    cmd = 'mfsfileinfo ' + path
    ret = {}
    chunknum = ''
    out = __salt__['cmd.run_all'](cmd, python_shell=False)

    output = out['stdout'].splitlines()
    for line in output:
        if not line:
            continue
        if '/' in line:
            comps = line.split('/')

            chunknum = comps[0].strip().split(':')
            meta = comps[1].strip().split(' ')

            chunk = chunknum[0].replace('chunk ', '')
            loc = chunknum[1].strip()
            id_ = meta[0].replace('(id:', '')
            ver = meta[1].replace(')', '').replace('ver:', '')

            ret[chunknum[0]] = {
                'chunk': chunk,
                'loc': loc,
                'id': id_,
                'ver': ver,
            }
        if 'copy' in line:
            copyinfo = line.strip().split(':')
            ret[chunknum[0]][copyinfo[0]] = {
                'copy': copyinfo[0].replace('copy ', ''),
                'ip': copyinfo[1].strip(),
                'port': copyinfo[2],
            }
    return ret