fix E226 missing whitespace around arithmetic operator

src/gpodder/gtkui/desktopfile.py
src/gpodder/gtkui/download.py
src/gpodder/gtkui/draw.py
This commit is contained in:
MarkusHackspacher 2018-03-23 22:13:10 +01:00
parent 41f893806a
commit 9a63417591
3 changed files with 64 additions and 53 deletions

View file

@ -75,7 +75,7 @@ class PlayerListModel(Gtk.ListStore):
else:
self.append((None, name, value, True))
return len(self)-1
return len(self) - 1
@classmethod
def is_separator(cls, model, iter):
@ -105,7 +105,7 @@ class UserApplication(object):
return theme.load_icon(icon_name, 24, 0)
def is_mime(self, mimetype):
return self.mime.find(mimetype+'/') != -1
return self.mime.find(mimetype + '/') != -1
WIN32_APP_REG_KEYS = [
@ -153,10 +153,10 @@ class UserAppsReader(object):
self.__has_read = False
self.__finished = threading.Event()
self.__has_sep = False
self.apps.append(UserApplication(_('Default application'), 'default', ';'.join((mime+'/*' for mime in self.mimetypes)), Gtk.STOCK_OPEN))
self.apps.append(UserApplication(_('Default application'), 'default', ';'.join((mime + '/*' for mime in self.mimetypes)), Gtk.STOCK_OPEN))
def add_separator(self):
self.apps.append(UserApplication('', '', ';'.join((mime+'/*' for mime in self.mimetypes)), ''))
self.apps.append(UserApplication('', '', ';'.join((mime + '/*' for mime in self.mimetypes)), ''))
self.__has_sep = True
def read( self):
@ -197,7 +197,7 @@ class UserAppsReader(object):
# Find out if we need it by comparing mime types
app_mime = parser.get(sect, 'MimeType')
for needed_type in self.mimetypes:
if app_mime.find(needed_type+'/') != -1:
if app_mime.find(needed_type + '/') != -1:
app_name = parser.get(sect, 'Name')
app_cmd = parser.get(sect, 'Exec')
app_icon = parser.get(sect, 'Icon')

View file

@ -78,13 +78,13 @@ class DownloadStatusModel(Gtk.ListStore):
elif task.status == task.DOWNLOADING:
status_message = '%s (%.0f%%, %s/s)' % (\
task.STATUS_MESSAGE[task.status], \
task.progress*100, \
task.progress * 100, \
util.format_filesize(task.speed))
else:
status_message = task.STATUS_MESSAGE[task.status]
if task.progress > 0 and task.progress < 1:
current = util.format_filesize(task.progress*task.total_size, digits=1)
current = util.format_filesize(task.progress * task.total_size, digits=1)
total = util.format_filesize(task.total_size, digits=1)
# Remove unit from current if same as in total
@ -104,7 +104,7 @@ class DownloadStatusModel(Gtk.ListStore):
self.set(iter,
self.C_NAME, self._format_message(task.episode.title,
status_message, task.episode.channel.title),
self.C_PROGRESS, 100.*task.progress, \
self.C_PROGRESS, 100. * task.progress, \
self.C_PROGRESS_TEXT, progress_message, \
self.C_ICON_NAME, self._status_ids[task.status])

View file

@ -60,24 +60,24 @@ def draw_rounded_rectangle(ctx, x, y, w, h, r=10, left_side_width = None, sides_
if close: offset = 0.5
if sides_to_draw & RRECT_LEFT_SIDE:
ctx.move_to(x+int(left_side_width)-offset, y+h)
ctx.line_to(x+r, y+h)
ctx.curve_to(x, y+h, x, y+h, x, y+h-r)
ctx.line_to(x, y+r)
ctx.curve_to(x, y, x, y, x+r, y)
ctx.line_to(x+int(left_side_width)-offset, y)
ctx.move_to(x + int(left_side_width) - offset, y + h)
ctx.line_to(x + r, y + h)
ctx.curve_to(x, y + h, x, y + h, x, y + h - r)
ctx.line_to(x, y + r)
ctx.curve_to(x, y, x, y, x + r, y)
ctx.line_to(x + int(left_side_width) - offset, y)
if close:
ctx.line_to(x+int(left_side_width)-offset, y+h)
ctx.line_to(x + int(left_side_width) - offset, y + h)
if sides_to_draw & RRECT_RIGHT_SIDE:
ctx.move_to(x+int(left_side_width)+offset, y)
ctx.line_to(x+w-r, y)
ctx.curve_to(x+w, y, x+w, y, x+w, y+r)
ctx.line_to(x+w, y+h-r)
ctx.curve_to(x+w, y+h, x+w, y+h, x+w-r, y+h)
ctx.line_to(x+int(left_side_width)+offset, y+h)
ctx.move_to(x + int(left_side_width) + offset, y)
ctx.line_to(x + w - r, y)
ctx.curve_to(x + w, y, x + w, y, x + w, y + r)
ctx.line_to(x + w, y + h - r)
ctx.curve_to(x + w, y + h, x + w, y + h, x + w - r, y + h)
ctx.line_to(x + int(left_side_width) + offset, y + h)
if close:
ctx.line_to(x+int(left_side_width)+offset, y)
ctx.line_to(x + int(left_side_width) + offset, y)
def rounded_rectangle(ctx, x, y, width, height, radius=4.):
@ -101,7 +101,7 @@ def draw_text_box_centered(ctx, widget, w_width, w_height, text, font_desc=None,
if font_desc is None:
font_desc = style_context.get_font(Gtk.StateFlags.NORMAL)
font_desc.set_size(14*Pango.SCALE)
font_desc.set_size(14 * Pango.SCALE)
pango_context = widget.create_pango_context()
layout = Pango.Layout(pango_context)
@ -109,7 +109,7 @@ def draw_text_box_centered(ctx, widget, w_width, w_height, text, font_desc=None,
layout.set_text(text, -1)
width, height = layout.get_pixel_size()
ctx.move_to(w_width/2-width/2, w_height/2-height/2)
ctx.move_to(w_width / 2 - width / 2, w_height / 2 - height / 2)
ctx.set_source_rgba(text_color.red, text_color.green, text_color.blue, 0.5)
PangoCairo.show_layout(ctx, layout)
@ -118,9 +118,13 @@ def draw_text_box_centered(ctx, widget, w_width, w_height, text, font_desc=None,
bar_height = 10
ctx.set_source_rgba(*text_color)
ctx.set_line_width(1.)
rounded_rectangle(ctx, w_width/2-width/2-.5, w_height/2+height-.5, width+1, bar_height+1)
rounded_rectangle(ctx,
w_width / 2 - width / 2 - .5,
w_height / 2 + height - .5, width + 1, bar_height + 1)
ctx.stroke()
rounded_rectangle(ctx, w_width/2-width/2, w_height/2+height, int(width*add_progress)+.5, bar_height)
rounded_rectangle(ctx,
w_width / 2 - width / 2,
w_height / 2 + height, int(width * add_progress) + .5, bar_height)
ctx.fill()
@ -140,8 +144,8 @@ def draw_cake(percentage, text=None, emblem=None, size=None):
txc = get_foreground_color(Gtk.StateFlags.NORMAL)
border = 1.5
height = int(size*.4)
width = size - 2*border
height = int(size * .4)
width = size - 2 * border
y = (size - height) / 2 + .5
x = border
@ -152,8 +156,8 @@ def draw_cake(percentage, text=None, emblem=None, size=None):
# Filling
if percentage > 0:
fill_width = max(1, min(width-2, (width-2)*percentage+.5))
ctx.rectangle(x+1, y+1, fill_width, height-2)
fill_width = max(1, min(width - 2, (width - 2) * percentage + .5))
ctx.rectangle(x + 1, y + 1, fill_width, height - 2)
ctx.set_source_rgb(0.289, 0.5625, 0.84765625)
ctx.fill()
@ -176,7 +180,7 @@ def draw_text_pill(left_text, right_text, x=0, y=0, border=2, radius=14, font_de
# Padding (in px) at the right edge of the image (for Ubuntu; bug 1533)
padding_right = 7
x_border = border*2
x_border = border * 2
if font_desc is None:
font_desc = style_context.get_font(Gtk.StateFlags.NORMAL)
@ -195,8 +199,8 @@ def draw_text_pill(left_text, right_text, x=0, y=0, border=2, radius=14, font_de
text_height = max(height_left, height_right)
image_height = int(y+text_height+border*2)
image_width = int(x+width_left+width_right+x_border*4+padding_right)
image_height = int(y + text_height + border * 2)
image_width = int(x + width_left + width_right + x_border * 4 + padding_right)
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, image_width, image_height)
ctx = cairo.Context(surface)
@ -210,14 +214,14 @@ def draw_text_pill(left_text, right_text, x=0, y=0, border=2, radius=14, font_de
if right_text == '0':
right_text = None
left_side_width = width_left + x_border*2
right_side_width = width_right + x_border*2
left_side_width = width_left + x_border * 2
right_side_width = width_right + x_border * 2
rect_width = left_side_width + right_side_width
rect_height = text_height + border*2
rect_height = text_height + border * 2
if left_text is not None:
draw_rounded_rectangle(ctx,x,y,rect_width,rect_height,radius, left_side_width, RRECT_LEFT_SIDE, right_text is None)
linear = cairo.LinearGradient(x, y, x+left_side_width/2, y+rect_height/2)
linear = cairo.LinearGradient(x, y, x + left_side_width / 2, y + rect_height / 2)
linear.add_color_stop_rgba(0, .8, .8, .8, .5)
linear.add_color_stop_rgba(.4, .8, .8, .8, .7)
linear.add_color_stop_rgba(.6, .8, .8, .8, .6)
@ -225,7 +229,7 @@ def draw_text_pill(left_text, right_text, x=0, y=0, border=2, radius=14, font_de
linear.add_color_stop_rgba(1, .8, .8, .8, .9)
ctx.set_source(linear)
ctx.fill()
xpos, ypos, width_left, height = x+1, y+1, left_side_width, rect_height-2
xpos, ypos, width_left, height = x + 1, y + 1, left_side_width, rect_height - 2
if right_text is None:
width_left -= 2
draw_rounded_rectangle(ctx, xpos, ypos, rect_width, height, radius, width_left, RRECT_LEFT_SIDE, right_text is None)
@ -237,16 +241,20 @@ def draw_text_pill(left_text, right_text, x=0, y=0, border=2, radius=14, font_de
ctx.set_line_width(1)
ctx.stroke()
ctx.move_to(x+x_border, y+1+border)
ctx.move_to(x + x_border, y + 1 + border)
ctx.set_source_rgba( 0, 0, 0, 1)
PangoCairo.show_layout(ctx, layout_left)
ctx.move_to(x-1+x_border, y+border)
ctx.move_to(x - 1 + x_border, y + border)
ctx.set_source_rgba( 1, 1, 1, 1)
PangoCairo.show_layout(ctx, layout_left)
if right_text is not None:
draw_rounded_rectangle(ctx, x, y, rect_width, rect_height, radius, left_side_width, RRECT_RIGHT_SIDE, left_text is None)
linear = cairo.LinearGradient(x+left_side_width, y, x+left_side_width+right_side_width/2, y+rect_height)
linear = cairo.LinearGradient(
x + left_side_width,
y,
x + left_side_width + right_side_width / 2,
y + rect_height)
linear.add_color_stop_rgba(0, .2, .2, .2, .9)
linear.add_color_stop_rgba(.4, .2, .2, .2, .8)
linear.add_color_stop_rgba(.6, .2, .2, .2, .6)
@ -254,9 +262,9 @@ def draw_text_pill(left_text, right_text, x=0, y=0, border=2, radius=14, font_de
linear.add_color_stop_rgba(1, .2, .2, .2, .5)
ctx.set_source(linear)
ctx.fill()
xpos, ypos, width, height = x, y+1, rect_width-1, rect_height-2
xpos, ypos, width, height = x, y + 1, rect_width - 1, rect_height - 2
if left_text is None:
xpos, width = x+1, rect_width-2
xpos, width = x + 1, rect_width - 2
draw_rounded_rectangle(ctx, xpos, ypos, width, height, radius, left_side_width, RRECT_RIGHT_SIDE, left_text is None)
ctx.set_source_rgba(1., 1., 1., .3)
ctx.set_line_width(1)
@ -266,10 +274,10 @@ def draw_text_pill(left_text, right_text, x=0, y=0, border=2, radius=14, font_de
ctx.set_line_width(1)
ctx.stroke()
ctx.move_to(x+left_side_width+x_border, y+1+border)
ctx.move_to(x + left_side_width + x_border, y + 1 + border)
ctx.set_source_rgba( 0, 0, 0, 1)
PangoCairo.show_layout(ctx, layout_right)
ctx.move_to(x-1+left_side_width+x_border, y+border)
ctx.move_to(x - 1 + left_side_width + x_border, y + border)
ctx.set_source_rgba( 1, 1, 1, 1)
PangoCairo.show_layout(ctx, layout_right)
@ -317,10 +325,10 @@ def progressbar_pixbuf(width, height, percentage):
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
ctx = cairo.Context(surface)
padding = int(width/8.0)
bar_width = 2*padding
bar_height = height - 2*padding
bar_height_fill = bar_height*percentage
padding = int(width / 8.0)
bar_width = 2 * padding
bar_height = height - 2 * padding
bar_height_fill = bar_height * percentage
# Background
ctx.rectangle(padding, padding, bar_width, bar_height)
@ -328,16 +336,19 @@ def progressbar_pixbuf(width, height, percentage):
ctx.fill()
# Foreground
ctx.rectangle(padding, padding+bar_height-bar_height_fill, bar_width, bar_height_fill)
ctx.rectangle(padding, padding + bar_height - bar_height_fill, bar_width, bar_height_fill)
ctx.set_source_rgba(*COLOR_FG)
ctx.fill()
ctx.rectangle(padding+bar_width/3, padding+bar_height-bar_height_fill, bar_width/4, bar_height_fill)
ctx.rectangle(padding + bar_width / 3,
padding + bar_height - bar_height_fill,
bar_width / 4,
bar_height_fill)
ctx.set_source_rgba(*COLOR_FG_HIGH)
ctx.fill()
# Border
ctx.rectangle(padding-.5, padding-.5, bar_width+1, bar_height+1)
ctx.set_source_rgba(*COLOR_BORDER)
ctx.rectangle(padding- .5, padding - .5, bar_width + 1, bar_height + 1)
ctx.set_source_rgba(* COLOR_BORDER)
ctx.set_line_width(1.)
ctx.stroke()