@frappe.whitelist()
def get_permissions(doctype=None, role=None):
	frappe.only_for("System Manager")
	out = frappe.db.sql("""select * from tabDocPerm
		where %s%s order by parent, permlevel, role""" %
		(doctype and (" parent='%s'" % frappe.db.escape(doctype)) or "",
		role and ((doctype and " and " or "") + " role='%s'" % frappe.db.escape(role)) or ""),
		as_dict=True)

	linked_doctypes = {}
	for d in out:
		d.linked_doctypes = linked_doctypes.setdefault(d.parent, get_linked_doctypes(d.parent))

	return out
dataset/ETHPy150Open frappe/frappe/frappe/core/page/permission_manager/permission_manager.py/get_permissions/original