flake8 fixes

This commit is contained in:
Aniket21mathur 2019-07-06 12:29:22 +05:30 committed by James Cameron
parent f5c86da271
commit 3b28597486
17 changed files with 87 additions and 52 deletions

View File

@ -135,7 +135,8 @@ def main():
command = bundle.get_command()
if command.startswith('sugar-activity'):
if not command.startswith('sugar-activity3'):
logging.warning("Activity written for Python 2, consider porting to Python 3.")
logging.warning("Activity written for Python 2,\
consider porting to Python 3.")
activity_class = command.split(" ")[1]
# when an activity is started outside sugar,

View File

@ -34,7 +34,8 @@ from sugar3.graphics.palettemenu import PaletteMenuBox
from sugar3 import profile
def _(msg): return gettext.dgettext('sugar-toolkit-gtk3', msg)
def _(msg):
return gettext.dgettext('sugar-toolkit-gtk3', msg)
def _create_activity_icon(metadata):
@ -337,7 +338,8 @@ class ActivityToolbar(Gtk.Toolbar):
if activity.metadata:
title_button = TitleEntry(activity)
title_button.connect('enter-key-press', lambda widget: self.emit('enter-key-press'))
title_button.connect('enter-key-press',
lambda widget: self.emit('enter-key-press'))
title_button.show()
self.insert(title_button, -1)
self.title = title_button.entry

View File

@ -29,10 +29,12 @@ an `[Activity]` header on the first line:
1.2.3, 1.2.3-country, or 1.2.3~developer,
* `bundle_id` - the activity bundle identifier, using [Java package
naming conventions](http://en.wikipedia.org/wiki/Java_package#Package_naming_conventions),
naming conventions]
(http://en.wikipedia.org/wiki/Java_package#Package_naming_conventions),
should conform to the [D-Bus specification for message protocol
names](http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names)(hyphens
are not allowed), usually an organisation or individual domain name
names]
(http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names)
(hyphens are not allowed), usually an organisation or individual domain name
in reverse order, e.g. `org.sugarlabs.Name`,
* `license` - an identifier for the software license of the bundle,
@ -58,7 +60,8 @@ Optional metadata keys are;
files of these MIME types. Used to offer your activity when opening a
downloaded file or a journal object.
* `url` - link to a home page or user documentation on https://help.sugarlabs.org/,
* `url` - link to a home page or user documentation on
https://help.sugarlabs.org/,
* `repository` - link to repository for activity code, for use by git clone,
@ -84,7 +87,8 @@ Deprecated metadata keys are;
* `update_url` - the updater no longer uses this.
.. _SPDX License Identifier: http://spdx.org/licenses/
.. _Fedora License Short Name: https://fedoraproject.org/wiki/Licensing:Main?rd=Licensing#Good_Licenses
.. _Fedora License Short Name:
https://fedoraproject.org/wiki/Licensing:Main?rd=Licensing#Good_Licenses
AppStream Metadata
==================
@ -132,12 +136,27 @@ Example `activity.info`
metadata_license = CC0-1.0
description:
<p>Surf the world! Here you can do research, watch educational videos, take online courses, find books, connect with friends and more. Browse is powered by the WebKit2 rendering engine with the Faster Than Light javascript interpreter - allowing you to view the full beauty of the web.</p>
<p>
Surf the world! Here you can do research, watch educational videos,
take online courses, find books, connect with friends and more.
Browse is powered by the WebKit2 rendering engine with the Faster
Than Light javascript interpreter - allowing you to view the
full beauty of the web.
</p>
<p>To help in researching, Browse offers many features:</p>
<ul>
<li>Bookmark (save) good pages you find - never loose good resources or forget to add them to your bibliography</li>
<li>Bookmark pages with collaborators in real time - great for researching as a group or teachers showing pages to their class</li>
<li>Comment on your bookmarked pages - a great tool for making curated collections</li>
<li>
Bookmark (save) good pages you find - never loose good resources
or forget to add them to your bibliography
</li>
<li>
Bookmark pages with collaborators in real time - great for
researching as a group or teachers showing pages to their class
</li>
<li>
Comment on your bookmarked pages - a great tool for making curated
collections
</li>
</ul>
screenshots = https://people.sugarlabs.org/sam/activity-ss/browse-1-1.png https://people.sugarlabs.org/sam/activity-ss/browse-1-2.png
'''

View File

@ -43,7 +43,8 @@ Based on the implementation of :pep:`386`, but adapted to our
numeration schema.
Attributes:
VERSION_RE (RegexObject): regular expression for versions, deprecated, as it is insufficient by itself.
VERSION_RE (RegexObject): regular expression for versions,\
deprecated, as it is insufficient by itself.
"""
import re

View File

@ -167,7 +167,8 @@ class BoundMethodWeakref(object):
def __cmp__(self, other):
"""Compare with another reference"""
if not isinstance(other, self.__class__):
return ((self.__class__ > type(other)) - (self.__class__ < type(other)))
return ((self.__class__ > type(other)) -
(self.__class__ < type(other)))
return ((self.key > other.key) - (self.key < other.key))
def __call__(self):

View File

@ -61,7 +61,8 @@ from sugar3.graphics import style
from sugar3.graphics.icon import Icon
def _(msg): return gettext.dgettext('sugar-toolkit-gtk3', msg)
def _(msg):
return gettext.dgettext('sugar-toolkit-gtk3', msg)
if not hasattr(GObject.ParamFlags, 'READWRITE'):

View File

@ -29,7 +29,8 @@ from sugar3.graphics.icon import Icon
from sugar3.graphics.palette import Palette, ToolInvoker, WidgetInvoker
def _(msg): return gettext.dgettext('sugar-toolkit-gtk3', msg)
def _(msg):
return gettext.dgettext('sugar-toolkit-gtk3', msg)
if not hasattr(GObject.ParamFlags, 'READWRITE'):
@ -123,7 +124,8 @@ class _ColorButton(Gtk.Button):
context = self.get_style_context()
fg_color = context.get_color(Gtk.StateType.NORMAL)
# the color components are stored as float values between 0.0 and 1.0
return '#%.2X%.2X%.2X' % (int(fg_color.red * 255), int(fg_color.green * 255),
return '#%.2X%.2X%.2X' % (int(fg_color.red * 255),
int(fg_color.green * 255),
int(fg_color.blue * 255))
def set_color(self, color):

View File

@ -209,7 +209,7 @@ class _IconBuffer(object):
# try read from the .icon file
icon_filename = info.get_filename().replace('.svg', '.icon')
if icon_filename != info.get_filename() and \
os.path.exists(icon_filename):
os.path.exists(icon_filename):
try:
with open(icon_filename) as config_file:
@ -1309,8 +1309,7 @@ class CellRendererIcon(Gtk.CellRenderer):
# widget is the treeview
x, y = widget.get_pointer()
x, y = widget.convert_widget_to_bin_window_coords(x, y)
return ((cell_area.x <= x <= cell_area.x + cell_area.width)
and
return ((cell_area.x <= x <= cell_area.x + cell_area.width) and
(cell_area.y <= y <= cell_area.y + cell_area.height))
pointer_inside = is_pointer_inside()
@ -1379,10 +1378,10 @@ def get_icon_state(base_name, perc, step=5):
'''
Get the closest icon name for a given state in percent.
First, you need a set of icons. They must be prefixed with `base_name`, for
example "network-wireless". They must be suffixed with 3 digit percentage
numbers, for example "-000", "-200", etc. Eventually, you get a collection
of icon names like:
First, you need a set of icons. They must be prefixed with `base_name`,
for example "network-wireless". They must be suffixed with 3 digit
percentage numbers, for example "-000", "-200", etc. Eventually, you get
a collection of icon names like:
* network-wireless-000
* network-wireless-020

View File

@ -37,7 +37,8 @@ if not hasattr(GObject.ParamFlags, 'READWRITE'):
class Notebook(Gtk.Notebook):
'''
Notebook class that creates a :class:`Gtk.Notebook`. It is possible to set
the `can-close-tabs` property from the constructor through Notebook(can_close_tabs=True)
the `can-close-tabs` property from the constructor
through Notebook(can_close_tabs=True)
'''
__gtype_name__ = 'SugarNotebook'
@ -112,7 +113,8 @@ class Notebook(Gtk.Notebook):
'''
Adds a page to the notebook and sets the newly added page as current.
Returns True if the page is successfully added to the notebook.
If `can-close-tabs` is true, then a GtkEventBox is also created to close the tab.
If `can-close-tabs` is true, then a GtkEventBox is also created
to close the tab.
Args:
text_label (string): label of page to be added

View File

@ -51,8 +51,10 @@ def get_preview_pixbuf(preview_data, width=-1, height=-1):
sugar3.datastore.datastore.DSObject.get_metadata() method.
Keyword Args:
width (int): the pixbuf width, if is not set, the default width will be used
height (int): the pixbuf width, if is not set, the default height will be used
width (int): the pixbuf width, if is not set,
the default width will be used
height (int): the pixbuf width, if is not set,
the default height will be used
Returns:
Pixbuf, the generated Pixbuf
@ -117,8 +119,9 @@ class ObjectChooser(object):
"""
UI interface for object choosers.
Object choosers can be used by acivities to allow the user to select objects
from the file system or from some other similar source.
Object choosers can be used by acivities to allow the
user to select objects from the file system or from
some other similar source.
Keyword Args:
parent (:class:`Gtk.Widget`): the widget calling ObjectChooser
@ -194,8 +197,8 @@ class ObjectChooser(object):
Runs the object chooser and displays it.
Returns:
Gtk.ResponseType constant, the response received from displaying the
object chooser.
Gtk.ResponseType constant, the response received
from displaying the object chooser.
"""
self._object_id = None

View File

@ -1319,7 +1319,7 @@ class CursorInvoker(Invoker):
self._leave_hid = self._item.connect('leave-notify-event',
self.__leave_notify_event_cb)
self._release_hid = self._item.connect('button-release-event',
self.__button_release_event_cb)
self.__button_release_event_cb)
self._long_pressed_hid = self._long_pressed_controller.connect(
'pressed',
self.__long_pressed_event_cb, self._item)

View File

@ -33,16 +33,16 @@ from gi.repository import GLib
class ScrollingDetector(GObject.GObject):
'''
The scrolling detector sends signals when a scrolled window is scrolled and
when a scrolled window stops scrolling. Only one `scroll-start` signal will be
emitted until scrolling stops.
when a scrolled window stops scrolling. Only one `scroll-start`
signal will be emitted until scrolling stops.
The `scroll-start` signal is emitted when scrolling begins and
The `scroll-end` signal is emitted when scrolling ends
Neither of these two signals have any arguments
Args:
scrolled_window (Gtk.ScrolledWindow): A GTK scrolled window object for which
scrolling is to be detected
scrolled_window (Gtk.ScrolledWindow): A GTK scrolled window
object for which scrolling is to be detected
timeout (int): time in milliseconds to establish the interval for which
scrolling is detected

View File

@ -78,7 +78,8 @@ class Toolbox(Gtk.VBox):
Args:
name (string): name of toolbar to be added
toolbar (.. :class:`Gtk.Toolbar`): Gtk.Toolbar to be appended to this toolbox
toolbar (.. :class:`Gtk.Toolbar`):
Gtk.Toolbar to be appended to this toolbox
'''
label = Gtk.Label(label=name)
req = label.size_request()

View File

@ -210,7 +210,8 @@ colors = [['#B20008', '#FF2B34'],
def _parse_string(color_string):
'''
Returns array of length 2 of two colors in standard html form of [stroke color, fill color]
Returns array of length 2 of two colors in standard html
form of [stroke color, fill color]
Args:
color_string (string): two html format strings separated by a comma

View File

@ -33,7 +33,8 @@ from gi.repository import GdkPixbuf
from gi.repository import Gio
def _(msg): return gettext.dgettext('sugar-toolkit-gtk3', msg)
def _(msg):
return gettext.dgettext('sugar-toolkit-gtk3', msg)
GENERIC_TYPE_TEXT = 'Text'

View File

@ -88,11 +88,11 @@ class Profile(object):
return None
magic = 'ssh-dss '
for l in lines:
l = l.strip()
if not l.startswith(magic):
for line in lines:
line = line.strip()
if not line.startswith(magic):
continue
return l[len(magic):]
return line[len(magic):]
else:
logging.error('Error parsing public key.')
return None
@ -114,17 +114,17 @@ class Profile(object):
key = ""
begin_found = False
end_found = False
for l in lines:
l = l.strip()
if l.startswith(('-----BEGIN DSA PRIVATE KEY-----',
'-----BEGIN OPENSSH PRIVATE KEY-----')):
for line in lines:
line = line.strip()
if line.startswith(('-----BEGIN DSA PRIVATE KEY-----',
'-----BEGIN OPENSSH PRIVATE KEY-----')):
begin_found = True
continue
if l.startswith(('-----END DSA PRIVATE KEY-----',
'-----END OPENSSH PRIVATE KEY-----')):
if line.startswith(('-----END DSA PRIVATE KEY-----',
'-----END OPENSSH PRIVATE KEY-----')):
end_found = True
continue
key += l
key += line
if not (len(key) and begin_found and end_found):
logging.error('Error parsing public key.')
return None

View File

@ -32,7 +32,8 @@ import logging
import atexit
def _(msg): return gettext.dgettext('sugar-toolkit-gtk3', msg)
def _(msg):
return gettext.dgettext('sugar-toolkit-gtk3', msg)
def printable_hash(in_hash):