def get_user_permission_doctypes(user_permission_doctypes, user_permissions):
 if cint(frappe.db.get_single_value(u'System Settings', u'ignore_user_permissions_if_missing')):
  user_permission_doctypes = [list(set(doctypes).intersection(set(user_permissions.keys()))) for doctypes in user_permission_doctypes]
 if (len(user_permission_doctypes) > 1):
  common = user_permission_doctypes[0]
  for i in xrange(1, len(user_permission_doctypes), 1):
   common = list(set(common).intersection(set(user_permission_doctypes[i])))
   if (not common):
    break
  if common:
   for doctypes in user_permission_doctypes:
    if (set(common) == set(doctypes)):
     user_permission_doctypes = [common]
     break
 return user_permission_doctypes

def get_user_permission_doctypes ( user_permission_doctypes , user_permissions ) : if cint ( frappe . db . get_single_value ( u'System Settings' , u'ignore_user_permissions_if_missing' ) ) : user_permission_doctypes = [ list ( set ( doctypes ) . intersection ( set ( user_permissions . keys ( ) ) ) ) for doctypes in user_permission_doctypes ] if ( len ( user_permission_doctypes ) > 1 ) : common = user_permission_doctypes [ 0 ] for i in xrange ( 1 , len ( user_permission_doctypes ) , 1 ) : common = list ( set ( common ) . intersection ( set ( user_permission_doctypes [ i ] ) ) ) if ( not common ) : break if common : for doctypes in user_permission_doctypes : if ( set ( common ) == set ( doctypes ) ) : user_permission_doctypes = [ common ] break return user_permission_doctypes
returns a list of list like [["user" .