diff options
author | Gary E. Miller <gem@rellim.com> | 2017-07-01 18:02:44 -0700 |
---|---|---|
committer | Gary E. Miller <gem@rellim.com> | 2017-07-01 18:02:44 -0700 |
commit | 77e48bb6d86e46b49e3eb4e374c23ab251b0bcce (patch) | |
tree | fb1a5922463ebabc240e745ccd49a819476f4bba /xgpsspeed | |
parent | 613132ca575cbdf08ae2217d00280e0dd4c3ccd3 (diff) | |
download | gpsd-77e48bb6d86e46b49e3eb4e374c23ab251b0bcce.tar.gz |
xgpsspeed: pep8 fixes
Diffstat (limited to 'xgpsspeed')
-rwxr-xr-x | xgpsspeed | 55 |
1 files changed, 36 insertions, 19 deletions
@@ -109,8 +109,10 @@ class LandSpeedometer(Speedometer): y + (radius - long_inset) * sin(i * pi / 6.0) ) self.cr.line_to( - x + (radius + (self.cr.get_line_width() / 2)) * cos(i * pi / 6.0), - y + (radius + (self.cr.get_line_width() / 2)) * sin(i * pi / 6.0) + (x + (radius + (self.cr.get_line_width() / 2)) + * cos(i * pi / 6.0)), + (y + (radius + (self.cr.get_line_width() / 2)) + * sin(i * pi / 6.0)) ) self.cr.select_font_face( 'Georgia', @@ -130,13 +132,17 @@ class LandSpeedometer(Speedometer): if i in (-8, -7, -6, -5, -4): self.cr.move_to( - (x + (radius - long_inset - (t_width / 2)) * cos(i * pi / 6.0)), - (y + (radius - long_inset - (t_height * 2)) * sin(i * pi / 6.0)) + (x + (radius - long_inset - (t_width / 2)) + * cos(i * pi / 6.0)), + (y + (radius - long_inset - (t_height * 2)) + * sin(i * pi / 6.0)) ) elif i in (-2, -1, 0, 2, 1): self.cr.move_to( - (x + (radius - long_inset - (t_width * 1.5)) * cos(i * pi / 6.0)), - (y + (radius - long_inset - (t_height * 2)) * sin(i * pi / 6.0)) + (x + (radius - long_inset - (t_width * 1.5)) + * cos(i * pi / 6.0)), + (y + (radius - long_inset - (t_height * 2)) + * sin(i * pi / 6.0)) ) elif i in (-3,): self.cr.move_to( @@ -159,14 +165,15 @@ class LandSpeedometer(Speedometer): ) for z in self.short_ticks: + w_half = self.cr.get_line_width() / 2 if i < 0: self.cr.move_to( x + (radius - short_inset) * cos((i + z) * pi / 6.0), y + (radius - short_inset) * sin((i + z) * pi / 6.0) ) self.cr.line_to( - x + (radius + (self.cr.get_line_width() / 2)) * cos((i + z) * pi / 6.0), - y + (radius + (self.cr.get_line_width() / 2)) * sin((i + z) * pi / 6.0) + x + (radius + w_half) * cos((i + z) * pi / 6.0), + y + (radius + w_half) * sin((i + z) * pi / 6.0) ) else: self.cr.move_to( @@ -174,8 +181,8 @@ class LandSpeedometer(Speedometer): y + (radius - short_inset) * sin((i - z) * pi / 6.0) ) self.cr.line_to( - x + (radius + (self.cr.get_line_width() / 2)) * cos((i - z) * pi / 6.0), - y + (radius + (self.cr.get_line_width() / 2)) * sin((i - z) * pi / 6.0) + x + (radius + w_half) * cos((i - z) * pi / 6.0), + y + (radius + w_half) * sin((i - z) * pi / 6.0) ) self.cr.stroke() @@ -209,8 +216,10 @@ class LandSpeedometer(Speedometer): # cairo.FONT_WEIGHT_BOLD ) self.cr.set_font_size(radius / 10) - _x_bearing, _y_bearing, t_width, _t_height = self.cr.text_extents(speed)[:4] - self.cr.move_to((x - t_width / 2), (y + radius) - self.long_inset(radius)) + _x_bearing, _y_bearing, t_width, _t_height = \ + self.cr.text_extents(speed)[:4] + self.cr.move_to((x - t_width / 2), + (y + radius) - self.long_inset(radius)) self.cr.show_text(speed) self.cr.restore() @@ -268,7 +277,8 @@ class NauticalSpeedometer(Speedometer): self.draw_arc_and_ticks(width, height, radius, x, y) self.draw_heading(20, self.last_heading, radius, x, y) for sat in self.satellites: - self.draw_sat(sat, radius * NauticalSpeedometer.HEADING_SAT_GAP, x, y) + self.draw_sat(sat, radius * NauticalSpeedometer.HEADING_SAT_GAP, + x, y) self.draw_speed(radius, x, y) def draw_text(self, x, y, text, fontsize=10): @@ -392,7 +402,8 @@ class NauticalSpeedometer(Speedometer): # short tick for n in range(1, 10): aglshrt = agllong + n * pi / 60 - self.cr.move_to(*self.polar2xy(radius - short_inset, aglshrt, x, y)) + self.cr.move_to(*self.polar2xy(radius - short_inset, + aglshrt, x, y)) self.cr.line_to(*self.polar2xy(radius, aglshrt, x, y)) self.cr.stroke() @@ -466,8 +477,10 @@ class NauticalSpeedometer(Speedometer): self.cr.new_sub_path() if gps.is_sbas(satsoup['PRN']): - self.cr.rectangle(x0 - NauticalSpeedometer.SAT_SIZE, y0 - NauticalSpeedometer.SAT_SIZE, - NauticalSpeedometer.SAT_SIZE * 2, NauticalSpeedometer.SAT_SIZE * 2) + self.cr.rectangle(x0 - NauticalSpeedometer.SAT_SIZE, + y0 - NauticalSpeedometer.SAT_SIZE, + NauticalSpeedometer.SAT_SIZE * 2, + NauticalSpeedometer.SAT_SIZE * 2) else: self.cr.arc(x0, y0, NauticalSpeedometer.SAT_SIZE, 0, pi * 2.0) @@ -566,7 +579,9 @@ class Main(object): ('Nautical', None, '_Nautical', '<Control>n', 'Nautical Units', 2) ], - 0, lambda a, unused: setattr(self.widget, 'speed_unit', ['mph', 'kmh', 'knots'][a.get_current_value()]) + 0, lambda a, unused: setattr( + self.widget, 'speed_unit', + ['mph', 'kmh', 'knots'][a.get_current_value()]) ) self.uimanager.insert_action_group(self.actiongroup, 0) @@ -685,7 +700,8 @@ if __name__ == '__main__': usage = ('%s [-V|--version] [-h|--help] [--debug] [--host] ' + '[--port] [--device] [--speedunits {[mph] [kmh] [knots]}] ' + '[host [:port [:device]]]') % (prog) - epilog = 'BSD terms apply: see the file COPYING in the distribution root for details.' + epilog = 'BSD terms apply: see the file COPYING in the distribution root' \ + ' for details.' parser = OptionParser(usage=usage, epilog=epilog) parser.add_option( @@ -710,7 +726,8 @@ if __name__ == '__main__': '--speedunits', dest='speedunits', default='mph', - help='The unit of speed. Possible units are: mph, kmh, knots. [Default mph]' + help='The unit of speed. Possible units are: mph, kmh, knots. ' + '[Default mph]' ) parser.add_option( '--maxspeed', |