<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def read_kwfile(fname):
 """Syntax used as of r452 in commissioning tests"""

    d={}
    f=open(fname)
    for line in f:
        try:
            kvpair=re.findall("(.*):: (.*)=(.*)$",line)[0]
            d['name']=os.path.basename(kvpair[0])
            key,val=kvpair[1:]
            d[key.lower()]=val
        except (ValueError,IndexError):
            break
        
    f.close()
    return d