1
0
mirror of https://github.com/gryf/wicd.git synced 2025-12-19 20:38:00 +01:00

Remove uses of ternary operator from wicd-curses, restoring support for python 2.4.

This commit is contained in:
Andrew Psaltis
2009-09-29 12:38:11 -04:00
parent 27c7c786ca
commit 740204ee50
2 changed files with 26 additions and 10 deletions

View File

@@ -65,8 +65,11 @@ class DynWrap(urwid.AttrWrap):
def __init__(self,w,sensitive=True,attrs=('editbx','editnfc'),focus_attr='editfc'): def __init__(self,w,sensitive=True,attrs=('editbx','editnfc'),focus_attr='editfc'):
self._attrs=attrs self._attrs=attrs
self._sensitive = sensitive self._sensitive = sensitive
cur_attr = attrs[0] if sensitive else attrs[1] if sensitive:
cur_attr = attrs[0]
else:
cur_attr = attrs[1]
self.__super.__init__(w,cur_attr,focus_attr) self.__super.__init__(w,cur_attr,focus_attr)
@@ -211,24 +214,27 @@ class TabColumns(urwid.WidgetWrap):
return True return True
def keypress(self,size,key): def keypress(self,size,key):
# If the key is page up or page down, move focus to the tabs and call
# left or right on the tabs.
if key == "page up" or key == "page down": if key == "page up" or key == "page down":
self._w.get_body().set_focus(0) self._w.get_body().set_focus(0)
newK = 'left' if key == "page up" else 'right' if key == "page up":
newK = 'left'
else:
newK = 'right'
self.keypress(size,newK) self.keypress(size,newK)
self._w.get_body().set_focus(1) self._w.get_body().set_focus(1)
else: else:
key = self._w.keypress(size,key) key = self._w.keypress(size,key)
wid = self.pile.get_focus().get_body() wid = self.pile.get_focus().get_body()
if wid == self.columns: if wid == self.columns:
# lw = self.listbox.body
# lw.pop(1)
self.active_tab.set_attr('body') self.active_tab.set_attr('body')
self.columns.get_focus().set_attr('tab active') self.columns.get_focus().set_attr('tab active')
self.active_tab = self.columns.get_focus() self.active_tab = self.columns.get_focus()
self.gen_pile(self.tab_map[self.active_tab]) self.gen_pile(self.tab_map[self.active_tab])
return key return key
# self.listbox.body = lw
def mouse_event(self,size,event,button,x,y,focus): def mouse_event(self,size,event,button,x,y,focus):
wid = self.pile.get_focus().get_body() wid = self.pile.get_focus().get_body()
if wid == self.columns: if wid == self.columns:

View File

@@ -254,9 +254,14 @@ def help_dialog(body):
def run_configscript(parent,netname,nettype): def run_configscript(parent,netname,nettype):
configfile = wpath.etc+netname+'-settings.conf' configfile = wpath.etc+netname+'-settings.conf'
header = 'profile' if nettype == 'wired' else 'BSSID' if nettype != 'wired':
profname = netname if nettype == 'wired' else wireless.GetWirelessProperty( header = 'profile'
int(netname),'bssid') else:
header ='BSSID'
if nettype == 'wired':
profname = nettype
else:
profname = wireless.GetWirelessProperty( int(netname),'bssid')
theText = [ theText = [
language['cannot_edit_scripts_1'].replace('$A',configfile).replace('$B',header), language['cannot_edit_scripts_1'].replace('$A',configfile).replace('$B',header),
"\n\n["+profname+"]\n\n", "\n\n["+profname+"]\n\n",
@@ -329,7 +334,12 @@ class NetLabel(urwid.WidgetWrap):
str(wireless.GetWirelessProperty(id, strenstr))) str(wireless.GetWirelessProperty(id, strenstr)))
self.essid = wireless.GetWirelessProperty(id, 'essid') self.essid = wireless.GetWirelessProperty(id, 'essid')
self.bssid = wireless.GetWirelessProperty(id, 'bssid') self.bssid = wireless.GetWirelessProperty(id, 'bssid')
self.encrypt = wireless.GetWirelessProperty(id,'encryption_method') if wireless.GetWirelessProperty(id, 'encryption') else language['unsecured']
if wireless.GetWirelessProperty(id, 'encryption'):
self.encrypt = wireless.GetWirelessProperty(id,'encryption_method')
else:
self.encrypt = language['unsecured']
self.mode = wireless.GetWirelessProperty(id, 'mode') # Master, Ad-Hoc self.mode = wireless.GetWirelessProperty(id, 'mode') # Master, Ad-Hoc
self.channel = wireless.GetWirelessProperty(id, 'channel') self.channel = wireless.GetWirelessProperty(id, 'channel')
theString = ' %-*s %25s %9s %17s %6s %4s' % (gap, theString = ' %-*s %25s %9s %17s %6s %4s' % (gap,