diff options
author | Mykyta Holubakha <hilobakho@gmail.com> | 2017-07-26 05:09:14 +0300 |
---|---|---|
committer | Mykyta Holubakha <hilobakho@gmail.com> | 2017-07-26 05:09:14 +0300 |
commit | 8e9b7e59696a2facf7fb625bf0b8fc5c577929f1 (patch) | |
tree | 897e00b1adf8c140dce69de1afb0028079d2b368 /pomu/util | |
parent | Unsealed url and bugz package source modules (diff) | |
download | pomu-8e9b7e59696a2facf7fb625bf0b8fc5c577929f1.tar.gz pomu-8e9b7e59696a2facf7fb625bf0b8fc5c577929f1.tar.bz2 pomu-8e9b7e59696a2facf7fb625bf0b8fc5c577929f1.zip |
Paid off some technical debt
error fixes, syntax, logic
finally converted bugz to iquery
fixed extra imports in iquery
totally disabled writing in temp files in the url backend, fixed full
Diffstat (limited to 'pomu/util')
-rw-r--r-- | pomu/util/iquery.py | 16 | ||||
-rw-r--r-- | pomu/util/misc.py | 2 |
2 files changed, 9 insertions, 9 deletions
diff --git a/pomu/util/iquery.py b/pomu/util/iquery.py index 032838d..df76251 100644 --- a/pomu/util/iquery.py +++ b/pomu/util/iquery.py @@ -1,14 +1,12 @@ """A module to interactively query""" from pydoc import pager -from curtsies import CursorAwareWindow, Input, FSArray, fsarray, fmtstr +from curtsies import CursorAwareWindow, Input, fsarray, fmtstr from curtsies.fmtfuncs import underline from pbraw import grab class Position: - row = attr.ib() - column = attr.ib() def __init__(self, row=0, column=0): self.row = row self.column = column @@ -21,7 +19,7 @@ def render_entry(entry, width, active=False): char = '*' if entry[2] else ' ' w = 3 + fmtstr(entry[0]).width + 2 text = fmtstr(entry[3]) - return fsmtstr( + return fmtstr( '[' + underline(char) if active else char + '] ' + entry[0] + ' ' + entry[3][:width - w - 2] + '..' if text.width < width - w else entry[3]) @@ -46,7 +44,7 @@ class Prompt: CursorAwareWindow(in_stream=tty_in, out_stream=tty_out, hide_cursor=False, - extra_bytes_callback=input_generator.unget_bytes) as window: + extra_bytes_callback=input_.unget_bytes) as window: self.window = window self.render() for event in input_: @@ -61,22 +59,22 @@ class Prompt: def preview(self): entry = self.entries[self.idx] if entry[0] is not None: - pydoc.pager(entry[1]) + pager(entry[1]) else: gr = grab(entry) if not gr: del self.entries[self.idx] self.idx = clamp(self.idx - 1) - pydoc.pager('Error: could not fetch '.format(entry)) + pager('Error: could not fetch '.format(entry)) self.entries[self.idx:self.idx+1] = [process_entry((x[0], x[1].encode('utf-8'))) for x in gr] - pydoc.pager(self.entries[self.idx][1]) + pager(self.entries[self.idx][1]) def toggle(self): if self.idx == len(self.entries): return self.entries[self.idx][3] = not self.entries[self.idx][3] - def process_event(self): + def process_event(self, event): if self.list: if event == '<UP>': self.idx = clamp(self.idx - 1) diff --git a/pomu/util/misc.py b/pomu/util/misc.py index 09d4232..de297af 100644 --- a/pomu/util/misc.py +++ b/pomu/util/misc.py @@ -1,6 +1,8 @@ """Miscellaneous utility functions""" import re +from pomu.util.result import Result + def list_add(dst, src): """ Extends the target list with a scalar, or contents of the given list |