<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def list_profiles():
 """ Lists all of the database profiles available Examples -------- No doctest, covered by unittest list_profiles() {'demo': {u'dbname': None, u'dbtype': u'sqlite', u'filename': u'/Users/glamp/repos/yhat/opensource/db.py/db/data/chinook.sqlite', u'hostname': u'localhost', u'password': None, u'port': 5432, u'username': None}, 'muppets': {u'dbname': u'muppetdb', u'dbtype': u'postgres', u'filename': None, u'hostname': u'muppets.yhathq.com', u'password': None, u'port': 5432, u'username': u'kermit'}} """

    profiles = {}
    user = os.path.expanduser("~")
    for f in os.listdir(user):
        if f.startswith(".db.py_"):
            profile = load_from_json(os.path.join(user, f))
            tables = profile.pop('tables', None)
            if tables:
                profile['metadata'] = True
            else:
                profile['metadata'] = False
            profiles[f[7:]] = profile
    return profiles