def build_user_permissions(user):
	out = frappe.cache().hget("user_permissions", user)
	if out==None:
		out = {}
		for key, value in frappe.db.sql("""select defkey, ifnull(defvalue, '') as defvalue
			from tabDefaultValue where parent=%s and parenttype='User Permission'""", (user,)):
			out.setdefault(key, []).append(value)

		# add profile match
		if user not in out.get("User", []):
			out.setdefault("User", []).append(user)

		frappe.cache().hset("user_permissions", user, out)
	return out
dataset/ETHPy150Open frappe/frappe/frappe/defaults.py/build_user_permissions/original