def flagsmaildir2imap(maildirflaglist):
 retval = []
 for (imapflag, maildirflag) in flagmap:
  if (maildirflag in maildirflaglist):
   retval.append(imapflag)
 return (('(' + ' '.join(sorted(retval))) + ')')

def flagsmaildir2imap ( maildirflaglist ) : retval = [ ] for ( imapflag , maildirflag ) in flagmap : if ( maildirflag in maildirflaglist ) : retval . append ( imapflag ) return ( ( '(' + ' ' . join ( sorted ( retval ) ) ) + ')' )
convert set of flags into a string .