def parse_auth(rule):
 parser = argparse.ArgumentParser()
 rules = shlex.split(rule)
 rules.pop(0)
 noargs = ('back', 'test', 'nostart', 'kickstart', 'probe', 'enablecache', 'disablecache', 'disablenis', 'enableshadow', 'disableshadow', 'enablemd5', 'disablemd5', 'enableldap', 'enableldapauth', 'enableldaptls', 'disableldap', 'disableldapauth', 'enablekrb5kdcdns', 'disablekrb5kdcdns', 'enablekrb5realmdns', 'disablekrb5realmdns', 'disablekrb5', 'disablehe-siod', 'enablesmbauth', 'disablesmbauth', 'enablewinbind', 'enablewinbindauth', 'disablewinbind', 'disablewinbindauth', 'enablewinbindusedefaultdomain', 'disablewinbindusedefaultdomain', 'enablewins', 'disablewins')
 for arg in noargs:
  parser.add_argument('--{0}'.format(arg), dest=arg, action='store_true')
 parser.add_argument('--enablenis', dest='enablenis', action='store')
 parser.add_argument('--hesiodrhs', dest='hesiodrhs', action='store')
 parser.add_argument('--krb5adminserver', dest='krb5adminserver', action='append')
 parser.add_argument('--krb5kdc', dest='krb5kdc', action='append')
 parser.add_argument('--ldapbasedn', dest='ldapbasedn', action='store')
 parser.add_argument('--ldapserver', dest='ldapserver', action='append')
 parser.add_argument('--nisserver', dest='nisserver', action='append')
 parser.add_argument('--passalgo', dest='passalgo', action='store')
 parser.add_argument('--smbidmapgid', dest='smbidmapgid', action='store')
 parser.add_argument('--smbidmapuid', dest='smbidmapuid', action='store')
 parser.add_argument('--smbrealm', dest='smbrealm', action='store')
 parser.add_argument('--smbsecurity', dest='smbsecurity', action='store', choices=['user', 'server', 'domain', 'dns'])
 parser.add_argument('--smbservers', dest='smbservers', action='store')
 parser.add_argument('--smbworkgroup', dest='smbworkgroup', action='store')
 parser.add_argument('--winbindjoin', dest='winbindjoin', action='store')
 parser.add_argument('--winbindseparator', dest='winbindseparator', action='store')
 parser.add_argument('--winbindtemplatehomedir', dest='winbindtemplatehomedir', action='store')
 parser.add_argument('--winbindtemplateprimarygroup', dest='winbindtemplateprimarygroup', action='store')
 parser.add_argument('--winbindtemplateshell', dest='winbindtemplateshell', action='store')
 parser.add_argument('--enablekrb5', dest='enablekrb5', action='store_true')
 if ('--enablekrb5' in rules):
  parser.add_argument('--krb5realm', dest='krb5realm', action='store', required=True)
 parser.add_argument('--enablehesiod', dest='enablehesiod', action='store_true')
 if ('--enablehesiod' in rules):
  parser.add_argument('--hesiodlhs', dest='hesiodlhs', action='store', required=True)
 args = clean_args(vars(parser.parse_args(rules)))
 parser = None
 return args

def parse_auth ( rule ) : parser = argparse . ArgumentParser ( ) rules = shlex . split ( rule ) rules . pop ( 0 ) noargs = ( 'back' , 'test' , 'nostart' , 'kickstart' , 'probe' , 'enablecache' , 'disablecache' , 'disablenis' , 'enableshadow' , 'disableshadow' , 'enablemd5' , 'disablemd5' , 'enableldap' , 'enableldapauth' , 'enableldaptls' , 'disableldap' , 'disableldapauth' , 'enablekrb5kdcdns' , 'disablekrb5kdcdns' , 'enablekrb5realmdns' , 'disablekrb5realmdns' , 'disablekrb5' , 'disablehe-siod' , 'enablesmbauth' , 'disablesmbauth' , 'enablewinbind' , 'enablewinbindauth' , 'disablewinbind' , 'disablewinbindauth' , 'enablewinbindusedefaultdomain' , 'disablewinbindusedefaultdomain' , 'enablewins' , 'disablewins' ) for arg in noargs : parser . add_argument ( '--{0}' . format ( arg ) , dest = arg , action = 'store_true' ) parser . add_argument ( '--enablenis' , dest = 'enablenis' , action = 'store' ) parser . add_argument ( '--hesiodrhs' , dest = 'hesiodrhs' , action = 'store' ) parser . add_argument ( '--krb5adminserver' , dest = 'krb5adminserver' , action = 'append' ) parser . add_argument ( '--krb5kdc' , dest = 'krb5kdc' , action = 'append' ) parser . add_argument ( '--ldapbasedn' , dest = 'ldapbasedn' , action = 'store' ) parser . add_argument ( '--ldapserver' , dest = 'ldapserver' , action = 'append' ) parser . add_argument ( '--nisserver' , dest = 'nisserver' , action = 'append' ) parser . add_argument ( '--passalgo' , dest = 'passalgo' , action = 'store' ) parser . add_argument ( '--smbidmapgid' , dest = 'smbidmapgid' , action = 'store' ) parser . add_argument ( '--smbidmapuid' , dest = 'smbidmapuid' , action = 'store' ) parser . add_argument ( '--smbrealm' , dest = 'smbrealm' , action = 'store' ) parser . add_argument ( '--smbsecurity' , dest = 'smbsecurity' , action = 'store' , choices = [ 'user' , 'server' , 'domain' , 'dns' ] ) parser . add_argument ( '--smbservers' , dest = 'smbservers' , action = 'store' ) parser . add_argument ( '--smbworkgroup' , dest = 'smbworkgroup' , action = 'store' ) parser . add_argument ( '--winbindjoin' , dest = 'winbindjoin' , action = 'store' ) parser . add_argument ( '--winbindseparator' , dest = 'winbindseparator' , action = 'store' ) parser . add_argument ( '--winbindtemplatehomedir' , dest = 'winbindtemplatehomedir' , action = 'store' ) parser . add_argument ( '--winbindtemplateprimarygroup' , dest = 'winbindtemplateprimarygroup' , action = 'store' ) parser . add_argument ( '--winbindtemplateshell' , dest = 'winbindtemplateshell' , action = 'store' ) parser . add_argument ( '--enablekrb5' , dest = 'enablekrb5' , action = 'store_true' ) if ( '--enablekrb5' in rules ) : parser . add_argument ( '--krb5realm' , dest = 'krb5realm' , action = 'store' , required = True ) parser . add_argument ( '--enablehesiod' , dest = 'enablehesiod' , action = 'store_true' ) if ( '--enablehesiod' in rules ) : parser . add_argument ( '--hesiodlhs' , dest = 'hesiodlhs' , action = 'store' , required = True ) args = clean_args ( vars ( parser . parse_args ( rules ) ) ) parser = None return args
parse rfc2617 http authentication header string and return tuple or none .