Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PEP8 fixes #919

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion extensions/cpsection/aboutcomputer/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ def get_secondary_licenses():
licenses_path = config.licenses_path
if os.path.isdir(licenses_path):
for file_name in os.listdir(licenses_path):
file_path = os.path.join(licenses_path, file_name)
try:
file_path = os.path.join(licenses_path, file_name)
with open(file_path) as f:
licenses.append(f.read())
except IOError:
Expand Down
4 changes: 2 additions & 2 deletions extensions/cpsection/webaccount/web_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

class WebService():
def get_icon_name(self):
raise "Not implemented"
raise NotImplementedError

def config_service_cb(self, widget, event, container):
raise "Not implemented"
raise NotImplementedError
4 changes: 2 additions & 2 deletions extensions/deviceicon/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,5 @@ def setup(tray):
# of the OSK has many unresolved corner cases, see
# http://dev.laptop.org/ticket/12281

if _HAS_MALIIT:
tray.add_device(DeviceView())
# if _HAS_MALIIT:
# tray.add_device(DeviceView())
2 changes: 1 addition & 1 deletion src/jarabe/desktop/favoritesview.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def __settings_changed_cb(self, **kwargs):

def _set_layout(self, layout):
if layout not in LAYOUT_MAP:
logging.warn('Unknown favorites layout: %r', layout)
logging.warning('Unknown favorites layout: %r', layout)
layout = favoriteslayout.RingLayout.key
assert layout in LAYOUT_MAP

Expand Down
2 changes: 1 addition & 1 deletion src/jarabe/frame/clipboardtray.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def drag_data_received_cb(self, widget, context, x, y, selection,
object_id = self._context_map.get_object_id(context)
try:
if selection is None:
logging.warn('ClipboardTray: empty selection for target %s',
logging.warning('ClipboardTray: empty selection for target %s',
selection.get_target())
else:
self._add_selection(object_id, selection)
Expand Down
4 changes: 4 additions & 0 deletions src/jarabe/journal/bundlelauncher.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ def get_bundle(bundle_id=None, object_id=None):

return activities[0]
else:
obj = datastore.get(object_id)
if obj.metadata['mime_type'] is None:
return None
mime_type = str(obj.metadata['mime_type'])
bundle = bundleregistry.get_registry().get_bundle(bundle_id)
if bundle is None:
logging.warning('Activity with the bundle_id %s was not found',
Expand Down
2 changes: 1 addition & 1 deletion src/jarabe/journal/listview.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def _get_width_for_string(self, text):

widget = Gtk.Label(label='')
context = widget.get_pango_context()
layout = Pango.Layout(context)
layout = Pango.Layout.new(context)
layout.set_text(text, len(text))
width, height_ = layout.get_pixel_size()
return width
Expand Down
8 changes: 4 additions & 4 deletions src/jarabe/journal/palettes.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def __friend_selected_cb(self, menu_item, buddy):
file_name = model.get_file(self._metadata['uid'])

if not file_name or not os.path.exists(file_name):
logging.warn('Entries without a file cannot be sent.')
logging.warning('Entries without a file cannot be sent.')
self.emit('volume-error',
_('Entries without a file cannot be sent.'),
_('Warning'))
Expand Down Expand Up @@ -387,7 +387,7 @@ def __copy_to_volume_cb(self, menu_item):
file_path = model.get_file(uid)

if not file_path or not os.path.exists(file_path):
logging.warn('Entries without a file cannot be copied.')
logging.warning('Entries without a file cannot be copied.')
self.emit('volume-error',
_('Entries without a file cannot be copied.'),
_('Warning'))
Expand Down Expand Up @@ -416,7 +416,7 @@ def _get_confirmation_alert_message(self, entries_len):
def _perform_copy(self, metadata):
file_path = model.get_file(metadata['uid'])
if not file_path or not os.path.exists(file_path):
logging.warn('Entries without a file cannot be copied.')
logging.warning('Entries without a file cannot be copied.')
return
try:
model.copy(metadata, self._mount_point)
Expand Down Expand Up @@ -447,7 +447,7 @@ def __copy_to_clipboard_cb(self, menu_item):
uid = uid_list[0]
file_path = model.get_file(uid)
if not file_path or not os.path.exists(file_path):
logging.warn('Entries without a file cannot be copied.')
logging.warning('Entries without a file cannot be copied.')
self.emit('volume-error',
_('Entries without a file cannot be copied.'),
_('Warning'))
Expand Down
2 changes: 1 addition & 1 deletion src/jarabe/journal/volumestoolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def _drag_data_received_cb(self, widget, drag_context, x, y,
metadata = model.get(object_id)
file_path = model.get_file(metadata['uid'])
if not file_path or not os.path.exists(file_path):
logging.warn('Entries without a file cannot be copied.')
logging.warning('Entries without a file cannot be copied.')
self.emit('volume-error',
_('Entries without a file cannot be copied.'),
_('Warning'))
Expand Down
2 changes: 1 addition & 1 deletion src/jarabe/model/bundleregistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ def _scan_directory(self, path):
# Sort by mtime to ensure a stable activity order
bundles = {}
for f in os.listdir(path):
bundle_dir = os.path.join(path, f)
try:
bundle_dir = os.path.join(path, f)
if os.path.isdir(bundle_dir):
bundles[bundle_dir] = os.stat(bundle_dir).st_mtime
except Exception:
Expand Down
33 changes: 19 additions & 14 deletions src/jarabe/model/filetransfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,25 @@
from jarabe.model import neighborhood


FT_STATE_NONE = 0
FT_STATE_PENDING = 1
FT_STATE_ACCEPTED = 2
FT_STATE_OPEN = 3
FT_STATE_COMPLETED = 4
FT_STATE_CANCELLED = 5

FT_REASON_NONE = 0
FT_REASON_REQUESTED = 1
FT_REASON_LOCAL_STOPPED = 2
FT_REASON_REMOTE_STOPPED = 3
FT_REASON_LOCAL_ERROR = 4
FT_REASON_LOCAL_ERROR = 5
Saumya-Mishra9129 marked this conversation as resolved.
Show resolved Hide resolved
FT_REASON_REMOTE_ERROR = 6
FT_STATE_NONE = TelepathyGLib.FileTransferState.NONE
FT_STATE_PENDING = TelepathyGLib.FileTransferState.PENDING
FT_STATE_ACCEPTED = TelepathyGLib.FileTransferState.ACCEPTED
FT_STATE_OPEN = TelepathyGLib.FileTransferState.OPEN
FT_STATE_COMPLETED = TelepathyGLib.FileTransferState.COMPLETED
FT_STATE_CANCELLED = TelepathyGLib.FileTransferState.CANCELLED

FT_REASON_NONE = \
TelepathyGLib.FileTransferStateChangeReason.NONE
FT_REASON_REQUESTED = \
TelepathyGLib.FileTransferStateChangeReason.REQUESTED
FT_REASON_LOCAL_STOPPED = \
TelepathyGLib.FileTransferStateChangeReason.LOCAL_STOPPED
FT_REASON_REMOTE_STOPPED = \
TelepathyGLib.FileTransferStateChangeReason.REMOTE_STOPPED
FT_REASON_LOCAL_ERROR = \
TelepathyGLib.FileTransferStateChangeReason.LOCAL_ERROR
FT_REASON_REMOTE_ERROR = \
TelepathyGLib.FileTransferStateChangeReason.REMOTE_ERROR


new_file_transfer = dispatch.Signal()
Expand Down
6 changes: 3 additions & 3 deletions src/jarabe/view/viewsource.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def __destroy_cb(self, window, document_path):
if document_path is not None and os.path.exists(document_path):
os.unlink(document_path)

self._gdk_window.set_cursor(Gdk.Cursor(Gdk.CursorType.LEFT_PTR))
self._gdk_window.set_cursor(Gdk.Cursor.new(Gdk.CursorType.LEFT_PTR))
Gdk.flush()

def __key_press_event_cb(self, window, event):
Expand Down Expand Up @@ -418,9 +418,9 @@ def __set_busy_cursor(self, busy):
cursor = None

if busy:
cursor = Gdk.Cursor(Gdk.CursorType.WATCH)
cursor = Gdk.Cursor.new(Gdk.CursorType.WATCH)
else:
cursor = Gdk.Cursor(Gdk.CursorType.LEFT_PTR)
cursor = Gdk.Cursor.new(Gdk.CursorType.LEFT_PTR)

gdk_window = self.get_root_window()
gdk_window.set_cursor(cursor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from jarabe.webservice import accountsmanager

from cpsection.webaccount.web_service import WebService
from extensions.cpsection.webaccount.web_service import WebService

_SERVICE_NAME = 'mock'

Expand Down
4 changes: 2 additions & 2 deletions tests/extensions/cpsection/webaccount/web_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

class WebService():
def get_icon_name(self):
raise "Not implemented"
raise NotImplementedError

def config_service_cb(self, widget, event, container):
raise "Not implemented"
raise NotImplementedError
4 changes: 2 additions & 2 deletions tests/test_backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
# we need import from the extensions path
sys.path.append(config.ext_path)

from cpsection.backup.backupmanager import BackupManager
from cpsection.backup.backends.backend_tools import Backend
from extensions.cpsection.backup.backupmanager import BackupManager
from extensions.cpsection.backup.backends.backend_tools import Backend


class TestBackup(unittest.TestCase):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_modemconfiguration.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

from mock import patch

from cpsection.modemconfiguration.model import CountryCodeParser, \
from extensions.cpsection.modemconfiguration.model import CountryCodeParser, \
ServiceProvidersParser, ServiceProviders, PROVIDERS_PATH
from cpsection.modemconfiguration.model import CONF_SP_COUNTRY, \
from extensions.cpsection.modemconfiguration.model import CONF_SP_COUNTRY, \
CONF_SP_PROVIDER, CONF_SP_PLAN


Expand Down
2 changes: 1 addition & 1 deletion tests/test_user_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import unittest

from cpsection.aboutme import model
from extensions.cpsection.aboutme import model
from jarabe.intro.agepicker import AGES
from jarabe.intro.genderpicker import GENDERS

Expand Down