def get_perms_for(roles, perm_doctype=u'DocPerm'):
 return frappe.db.sql(u'select * from `tab{doctype}` where docstatus=0\n DCTB  DCTB and ifnull(permlevel,0)=0\n DCTB  DCTB and role in ({roles})'.format(doctype=perm_doctype, roles=u', '.join(([u'%s'] * len(roles)))), tuple(roles), as_dict=1)

def get_perms_for ( roles , perm_doctype = u'DocPerm' ) : return frappe . db . sql ( u'select * from `tab{doctype}` where docstatus=0\n DCTB  DCTB and ifnull(permlevel,0)=0\n DCTB  DCTB and role in ({roles})' . format ( doctype = perm_doctype , roles = u', ' . join ( ( [ u'%s' ] * len ( roles ) ) ) ) , tuple ( roles ) , as_dict = 1 )
get perms for given roles .