Rename variables named 'type'

This commit is contained in:
David Bartley 2007-12-12 01:15:12 -05:00
parent cc33ace5ea
commit 7254b4c880
4 changed files with 19 additions and 19 deletions

View File

@ -270,15 +270,15 @@ def set_position(position, members):
if len(mods['del']) == 0 and len(mods['add']) == 0:
return
for type in ['del', 'add']:
for userid in mods[type]:
for action in ['del', 'add']:
for userid in mods[action]:
dn = 'uid=%s,%s' % (escape(userid), user_base)
entry1 = {'position' : [position]}
entry2 = {} #{'position' : []}
entry = ()
if type == 'del':
if action == 'del':
entry = (entry1, entry2)
elif type == 'add':
elif action == 'add':
entry = (entry2, entry1)
mlist = ldap_connection.make_modlist(entry[0], entry[1])
ceo_ldap.modify_s(dn, mlist)

View File

@ -10,7 +10,7 @@ def menu_items(items):
return [ urwid.AttrWrap( ButtonText( cb, data, txt ), 'menu', 'selected') for (txt, cb, data) in items ]
def change_group_member(data):
push_wizard("%s %s Member" % (data["type"], data["name"]), [
push_wizard("%s %s Member" % (data["action"], data["name"]), [
(ChangeMember, data),
EndPage,
])
@ -33,9 +33,9 @@ def group_members(data):
return
add_data = data.copy()
add_data['type'] = 'Add'
add_data['action'] = 'Add'
remove_data = data.copy()
remove_data['type'] = 'Remove'
remove_data['action'] = 'Remove'
menu = [
("Add %s member" % data["name"].lower(),
change_group_member, add_data),
@ -96,7 +96,7 @@ class ChangeMember(WizardPanel):
data = self.state['data']
self.widgets = [
urwid.Text( "%s %s Member" % (data['type'], data['name']) ),
urwid.Text( "%s %s Member" % (data['action'], data['name']) ),
urwid.Divider(),
self.userid,
]
@ -125,21 +125,21 @@ class EndPage(WizardPanel):
pop_window()
def activate(self):
data = self.state['data']
type = data['type'].lower()
action = data['action'].lower()
failed = []
for group in data['groups']:
try:
members.change_group_member(type, group, self.state['userid'])
members.change_group_member(action, group, self.state['userid'])
except:
failed.append(group)
if len(failed) == 0:
self.headtext.set_text("%s succeeded" % data['type'])
self.headtext.set_text("%s succeeded" % data['action'])
self.midtext.set_text("Congratulations, the group modification "
"has succeeded.")
else:
self.headtext.set_text("%s partially succeeded" % data['type'])
self.headtext.set_text("%s partially succeeded" % data['action'])
self.midtext.set_text("Failed to %s member to %s for the "
"following groups: %s. This may indicate an attempt to add a "
"duplicate group member or to delete a non-present group "
"member." % (data['type'].lower(), data['name'],
"member." % (data['action'].lower(), data['name'],
', '.join(failed)))

View File

@ -135,7 +135,7 @@ class PassPage(WizardPanel):
class EndPage(WizardPanel):
def __init__(self, state, utype='member'):
self.type = utype
self.utype = utype
WizardPanel.__init__(self, state)
def init_widgets(self):
self.headtext = urwid.Text("")
@ -152,10 +152,10 @@ class EndPage(WizardPanel):
def activate(self):
problem = None
try:
if self.type == 'member':
if self.utype == 'member':
accounts.create_member( self.state['userid'], self.state['password'], self.state['name'], self.state['program'] )
members.register( self.state['userid'], terms.current() )
elif self.type == 'club':
elif self.utype == 'club':
accounts.create_club( self.state['userid'], self.state['name'] )
else:
raise Exception("Internal Error")

View File

@ -666,10 +666,10 @@ class Sasl:
def __init__(self, mech, realm, userid, password):
self.mech = mech
if mech == 'GSSAPI':
type, arg = password
credtype, cred = password
kinit_args = [ '/usr/bin/kinit', '%s@%s' % (userid, realm) ]
if type == 'keytab':
kinit_args += [ '-kt', arg ]
if credtype == 'keytab':
kinit_args += [ '-kt', cred ]
kinit = Popen(kinit_args, stdin=PIPE, stdout=PIPE, stderr=PIPE)
kinit.wait()