Permalink
Browse files

Placate flake8

  • Loading branch information...
inducer committed May 24, 2018
1 parent f774eb2 commit 1dd021152ace2b093de2bc2658fcbdfa7b5da427
Showing with 11 additions and 5 deletions.
  1. +1 −0 pudb/ui_tools.py
  2. +10 −5 pudb/var_view.py
View
@@ -15,6 +15,7 @@ def text_width(txt):
"""
return calc_width(txt, 0, len(txt))
+
def make_canvas(txt, attr, maxcol, fill_attr=None):
processed_txt = []
processed_attr = []
View
@@ -167,7 +167,8 @@ def render(self, size, focus=False):
if self.wrap:
text = self._get_text(size)
- extralabel_full, extralabel_rem = divmod(text_width(var_label[maxcol:]), maxcol)
+ extralabel_full, extralabel_rem = divmod(
+ text_width(var_label[maxcol:]), maxcol)
totallen = sum([text_width(i) for i in text])
labellen = (
len(self.prefix) # Padding of first line
@@ -190,20 +191,24 @@ def render(self, size, focus=False):
return make_canvas(text, attr, maxcol, apfx+"value")
+ lprefix = len(self.prefix)
+
if self.value_str is not None:
if self.var_label is not None:
if len(self.prefix) + text_width(self.var_label) > self.SIZE_LIMIT:
# label too long? generate separate value line
text = [self.prefix + self.var_label,
self.prefix+" " + self.value_str]
- attr = [[(apfx+"label", len(self.prefix)+text_width(self.var_label))],
- [(apfx+"value", len(self.prefix)+2+text_width(self.value_str))]]
+ attr = [
+ [(apfx+"label", lprefix+text_width(self.var_label))],
+ [(apfx+"value", lprefix+2+text_width(self.value_str))]
+ ]
else:
text = [self.prefix + self.var_label + ": " + self.value_str]
attr = [[
- (apfx+"label", len(self.prefix)+text_width(self.var_label)+2),
+ (apfx+"label", lprefix+text_width(self.var_label)+2),
(apfx+"value", text_width(self.value_str)),
]]
else:
@@ -216,7 +221,7 @@ def render(self, size, focus=False):
else:
text = [self.prefix + self.var_label]
- attr = [[(apfx+"label", len(self.prefix) + text_width(self.var_label)), ]]
+ attr = [[(apfx+"label", lprefix + text_width(self.var_label)), ]]
# Ellipses to show text was cut off
#encoding = urwid.util.detected_encoding

0 comments on commit 1dd0211

Please sign in to comment.