Browse Source

Fix some trailing whitespace.

suites/jessie-proposed-backports
Ben Finney 14 years ago
parent
commit
adb3bae4f9
  1. 8
      reportbug_ui_newt.py
  2. 44
      reportbug_ui_text.py
  3. 42
      reportbug_ui_urwid.py

8
reportbug_ui_newt.py

@ -56,7 +56,7 @@ def newt_infobox(text, height=6, width=50, title="", screen=None):
s = snack.SnackScreen()
else:
s = screen
t = snack.TextboxReflowed(width, text, maxHeight = s.height - 12)
g = snack.GridForm(s, title[:width], 1, 2)
g.add(t, 0, 0, padding = (0, 0, 0, 1))
@ -165,7 +165,7 @@ def show_report(number, system, mirrors, http_proxy, screen=None, queryonly=0,
buttons = ['Ok', 'More details (launch browser)', 'Quit']
if not queryonly:
buttons.append('Submit more information')
s.popWindow()
while 1:
(bugtitle, bodies) = info
@ -193,7 +193,7 @@ def show_report(number, system, mirrors, http_proxy, screen=None, queryonly=0,
# os.system('stty sane; clear')
launch_browser(debianbts.get_report_url(system, number, archived))
s.resume()
if not screen:
s.finish()
return
@ -213,7 +213,7 @@ def handle_bts_query(package, bts, mirrors=None, http_proxy="",
scr = screen
if not scr:
scr = newt_screen()
if isinstance(package, basestring):
if source:
newt_infobox('Querying %s bug tracking system for reports on'

44
reportbug_ui_text.py

@ -70,7 +70,7 @@ def indent_wrap_text(text, starttext='', indent=0, linelen=None):
text = ' '.join(text.split())
if not text:
return starttext+'\n'
output = textwrap.fill(text, width=linelen, initial_indent=starttext,
subsequent_indent=si)
if output.endswith('\n'):
@ -97,7 +97,7 @@ class our_completer(object):
def complete(self, text, i):
if not self.completions: return None
matching = [x for x in self.completions if x.startswith(text)]
if i < len(matching):
return matching[i]
@ -134,7 +134,7 @@ def select_options(msg, ok, help, allow_numbers=None, nowrap=False):
if option in string.ascii_uppercase:
default=option
break
if not help: help = {}
if '?' not in ok: ok = ok+'?'
@ -164,7 +164,7 @@ def select_options(msg, ok, help, allow_numbers=None, nowrap=False):
', '.join(map(str, nums))
except (ValueError, TypeError):
pass
if not ch: ch = default
ch = ch[0]
if ch=='?':
@ -184,7 +184,7 @@ def select_options(msg, ok, help, allow_numbers=None, nowrap=False):
ewrite(indent_wrap_text(err_message))
else:
ewrite('Invalid selection.\n')
return select_options(msg, ok, help, allow_numbers, nowrap)
def yes_no(msg, yeshelp, nohelp, default=True, nowrap=False):
@ -193,7 +193,7 @@ def yes_no(msg, yeshelp, nohelp, default=True, nowrap=False):
ok = 'Ynq'
else:
ok = 'yNq'
res = select_options(msg, ok, {'y': yeshelp, 'n': nohelp, 'q' : 'Quit.'},
nowrap=nowrap)
if res == 'q':
@ -248,7 +248,7 @@ def get_password(prompt=None):
def FilenameCompleter(text, i):
paths = glob.glob(text+'*')
if not paths: return None
if i < len(paths):
entry = paths[i]
if os.path.isdir(entry):
@ -306,7 +306,7 @@ def menu(par, options, prompt, default=None, title=None, any_ok=False,
allowed = map(lambda x: x[0], options)
allowed = allowed + extras
maxlen_name = min(max(map(len, allowed)), columns/3)
digits = int(math.ceil(math.log10(len(options)+1)))
@ -324,7 +324,7 @@ def menu(par, options, prompt, default=None, title=None, any_ok=False,
if multiple:
prompt += '(one at a time) '
while 1:
if default:
aprompt = prompt + '[%s] ' % default
@ -333,7 +333,7 @@ def menu(par, options, prompt, default=None, title=None, any_ok=False,
response = our_raw_input(aprompt, allowed)
if not response: response = default
try:
num = int(response)
if 1 <= num <= len(options):
@ -384,11 +384,11 @@ def show_report(number, system, mirrors,
http_proxy=http_proxy, archived=archived)
except:
info = None
if not info:
ewrite('No report available: #%s\n', number)
return
(title, messages) = info
current_message = 0
skip_pager = False
@ -399,7 +399,7 @@ def show_report(number, system, mirrors,
messages[current_message])
else:
text = 'Original report - %s\n\n%s' % (title, messages[0])
if not skip_pager:
fd = os.popen('sensible-pager', 'w')
try:
@ -413,7 +413,7 @@ def show_report(number, system, mirrors,
skip_pager = False
options = 'xOrbq'
if (current_message+1) < len(messages):
options = 'N'+options.lower()
if (current_message):
@ -450,7 +450,7 @@ def handle_bts_query(package, bts, mirrors=None, http_proxy="",
queryonly=False, title="", screen=None, archived='no',
source=False, version=None):
import debianbts
root = debianbts.SYSTEMS[bts].get('btsroot')
if not root:
ewrite('%s bug tracking system has no web URL; bypassing query\n',
@ -460,7 +460,7 @@ def handle_bts_query(package, bts, mirrors=None, http_proxy="",
srcstr = ""
if source:
srcstr = " (source)"
if isinstance(package, basestring):
long_message('Querying %s BTS for reports on %s%s...\n',
debianbts.SYSTEMS[bts]['name'], package, srcstr)
@ -577,7 +577,7 @@ def browse_bugs(hierarchy, count, bugs, bts, queryonly, mirrors,
'f' : 'Filter bug list using a pattern.'}
if skipmsg:
helptext['n'] = helptext['n'][:-1]+' (skip to Next page).'
while 1:
sys.stderr.writelines(lastpage)
x = select_options(pstr, options, helptext,
@ -685,7 +685,7 @@ def proc_hierarchy(hierarchy):
if match:
bugs.append(int(match.group(1)))
return count, bugs
def search_bugs(hierarchyfull, bts, queryonly, mirrors,
http_proxy, screen, title):
"""Search for the bug list using a pattern."""
@ -704,10 +704,10 @@ def search_bugs(hierarchyfull, bts, queryonly, mirrors,
except InvalidRegex:
our_raw_input('Invalid regular expression, press ENTER to continue.')
return "FilterEnd"
count, bugs = proc_hierarchy(hierarchy)
exp = re.compile(r'\#(\d+):')
if not count:
our_raw_input('No match found, press ENTER to continue.')
return "FilterEnd"
@ -777,7 +777,7 @@ def search_bugs(hierarchyfull, bts, queryonly, mirrors,
't' : 'Top of the bug list (remove all filters).'}
if skipmsg:
helptext['n'] = helptext['n'][:-1]+' (skip to Next page).'
while 1:
sys.stderr.writelines(lastpage)
x = select_options(pstr, options, helptext,
@ -790,7 +790,7 @@ def search_bugs(hierarchyfull, bts, queryonly, mirrors,
elif x == 'q':
raise NoReport
elif x == 's':
return
return
elif x == 'y':
if queryonly:
return

42
reportbug_ui_urwid.py

@ -71,7 +71,7 @@ class dialog(object):
def __init__(self, message, body=None, width=None, height=None,
title='', long_message=''):
self.body = body
self.scrollmode=False
if not body:
if long_message:
@ -92,7 +92,7 @@ class dialog(object):
if message:
self.frame.header = urwid.Pile([urwid.Text(message),
urwid.Divider()])
w = self.frame
# pad area around listbox
w = urwid.Padding(w, ('fixed left',2), ('fixed right',2))
@ -102,7 +102,7 @@ class dialog(object):
if title:
w = urwid.Frame(w)
w.header = urwid.Text( ('title', title) )
# "shadow" effect
w = urwid.Columns( [w, ('fixed', 1, urwid.AttrWrap( urwid.Filler(urwid.Text(('border',' ')), "top") ,'shadow'))])
w = urwid.Frame( w, footer = urwid.AttrWrap(urwid.Text(('border',' ')),'shadow'))
@ -152,7 +152,7 @@ class dialog(object):
for k in keys:
if urwid.is_mouse_event(k):
event, button, col, row = k
self.view.mouse_event( size,
self.view.mouse_event( size,
event, button, col, row,
focus=True)
if k == 'window resize':
@ -165,7 +165,7 @@ class dialog(object):
def on_exit(self, exitcode):
return exitcode
def unhandled_key(self, size, k):
if k in ('tab', 'shift tab'):
focus = self.frame.focus_part
@ -173,7 +173,7 @@ class dialog(object):
self.frame.set_focus('body')
else:
self.frame.set_focus('footer')
if k in ('up','page up', 'down', 'page down'):
if self.scrollmode:
self.frame.set_focus('body')
@ -182,7 +182,7 @@ class dialog(object):
self.frame.set_focus('body')
else:
self.frame.set_focus('footer')
if k == 'enter':
# pass enter to the "ok" button
self.frame.set_focus('footer')
@ -232,7 +232,7 @@ class listdialog(dialog):
for (w, label) in widgets:
self.items.append(w)
if label:
w = urwid.Columns( [('fixed', buttonwidth, w),
w = urwid.Columns( [('fixed', buttonwidth, w),
urwid.Text(label)], 2 )
w = urwid.AttrWrap(w, 'selectable','focus')
l.append(w)
@ -257,12 +257,12 @@ class listdialog(dialog):
class checklistdialog(listdialog):
def on_exit(self, exitcode):
"""
Mimick dialog(1)'s --checklist exit.
Mimick dialog(1)'s --checklist exit.
Put each checked item in double quotes with a trailing space.
"""
if exitcode:
return exitcode, []
l = []
for i in self.items:
if i.get_state():
@ -277,7 +277,7 @@ def display_message(message, *args, **kwargs):
title = kwargs['title']
else:
title = ''
if 'ui' in kwargs:
ui = kwargs['ui']
else:
@ -299,12 +299,12 @@ def long_message(message, *args, **kwargs):
title = kwargs['title']
else:
title = ''
if 'ui' in kwargs:
ui = kwargs['ui']
else:
ui = None
# Rewrap the message
chunks = re.split('\n\n+', message)
chunks = [re.sub(r'\s+', ' ', x).strip() for x in chunks]
@ -348,7 +348,7 @@ def get_string(prompt, options=None, title=None, force_prompt=False,
title = '%s: %s' % (reportbug.VERSION, title)
else:
title = reportbug.VERSION
box = textentry(prompt, title=title)
box.add_buttons([ ("OK", 0) ])
code, text = box.main(ui)
@ -443,7 +443,7 @@ def menu(par, options, prompt, default=None, title=None, any_ok=False,
b.exitcode = option
b = urwid.AttrWrap( b, 'selectable','focus' )
widgets.append((b, desc))
## if any_ok:
## editbox = urwid.Edit(multiline=False)
## e = urwid.ListBox([editbox])
@ -464,7 +464,7 @@ def menu(par, options, prompt, default=None, title=None, any_ok=False,
if opt[0] == default:
focus = i
break
result, chosen = box.main(ui)
if result < 0:
return result
@ -491,7 +491,7 @@ def show_report(number, system, mirrors,
ui = initialize_urwid_ui()
sysinfo = debianbts.SYSTEMS[system]
display_message('Retrieving report #%d from %s bug tracking system...',
display_message('Retrieving report #%d from %s bug tracking system...',
number, sysinfo['name'], title=title, ui=ui)
info = debianbts.get_report(number, system, mirrors=mirrors,
@ -503,7 +503,7 @@ def show_report(number, system, mirrors,
options = dict(o='Ok', d='More details (launch browser)',
m='Submit more information', q='Quit')
valid = 'Odmq'
while 1:
(bugtitle, bodies) = info
body = bodies[0]
@ -535,12 +535,12 @@ def handle_bts_query(package, bts, mirrors=None, http_proxy="",
ui = screen
if not ui:
ui = initialize_urwid_ui()
if isinstance(package, basestring):
pkgname = package
if source:
pkgname += ' (source)'
display_message('Querying %s bug tracking system for reports on %s',
debianbts.SYSTEMS[bts]['name'], pkgname,
ui=ui, title=title)
@ -591,7 +591,7 @@ def handle_bts_query(package, bts, mirrors=None, http_proxy="",
else:
cancellabel = 'Continue'
quitlabel='Quit'
while True:
info = menu('Select a bug to read the report:', buglist,
'', ui=ui, title=sectitle, default=p,

Loading…
Cancel
Save