Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Commit

Permalink
Merge b884363 into fe6fbe2
Browse files Browse the repository at this point in the history
  • Loading branch information
goanpeca committed Sep 21, 2016
2 parents fe6fbe2 + b884363 commit a914e0e
Show file tree
Hide file tree
Showing 12 changed files with 113 additions and 101 deletions.
12 changes: 10 additions & 2 deletions bootstrap.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# -*- coding: utf-8 -*-
# -*- coding:utf-8 -*-
# -----------------------------------------------------------------------------
# Copyright © 2015 The Spyder Development Team
# Copyright © 2014 Gonzalo Peña-Castellanos (@goanpeca)
#
# Licensed under the terms of the MIT License
# -----------------------------------------------------------------------------
"""Bottstrap script."""

# Standard library imports
import os.path as osp
import sys

Expand All @@ -9,7 +17,7 @@

# Patch sys.path
sys.path.insert(0, DEVPATH)
print("01. Added %s to sys.path" % DEVPATH)
print("01. Added {0} to sys.path".format(DEVPATH))

# Run the app
from conda_manager.app import main
Expand Down
8 changes: 5 additions & 3 deletions conda_manager/models/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def __init__(self, parent, dic, packages_sizes=None):
self._timer_dots = ['. ', '.. ', '...', ' ']
self._timer_counter = 0

if len(dic) == 0:
if not dic:
self._timer.start(650)
self._rows = [[_(u'Resolving dependencies '), u'', u'', u'']]
self._bold_rows.append(0)
Expand Down Expand Up @@ -121,7 +121,8 @@ def _build_packages_table(self, dic):

return packages

def flags(self, index):
@staticmethod
def flags(index):
"""Override Qt method"""
if not index.isValid():
return Qt.ItemIsEnabled
Expand Down Expand Up @@ -174,7 +175,8 @@ def rowCount(self, index=QModelIndex()):
"""Override Qt method."""
return len(self._rows)

def columnCount(self, index=QModelIndex()):
@staticmethod
def columnCount(index=QModelIndex()):
"""Override Qt method."""
return 4

Expand Down
62 changes: 28 additions & 34 deletions conda_manager/models/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,21 @@ def _update_cell(self, row, column):
end = self.index(row, column)
self.dataChanged.emit(start, end)

def update_style_palette(self, palette={}):
def update_style_palette(self, palette=None):
"""Update style palette for conda-manager extension."""
if palette:
self._palette.update(palette)

def flags(self, index):
@staticmethod
def flags(index):
"""Override Qt method"""
column = index.column()

if index.isValid():
if column in [C.COL_START, C.COL_END]:
# return Qt.ItemFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)
return Qt.ItemFlags(Qt.ItemIsEnabled)
else:
return Qt.ItemFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)
# return Qt.ItemFlags(Qt.ItemIsEnabled)
else:
return Qt.ItemFlags(Qt.ItemIsEnabled)

Expand Down Expand Up @@ -196,39 +196,33 @@ def data(self, index, role=Qt.DisplayRole):
return to_qvariant(P['icon.add.pressed'])
else:
return to_qvariant(P['icon.add.active'])
elif (status == C.INSTALLED or
status == C.UPGRADABLE or
status == C.DOWNGRADABLE or
status == C.MIXGRADABLE):
elif status in [C.INSTALLED, C.UPGRADABLE, C.DOWNGRADABLE,
C.MIXGRADABLE]:
if r:
return to_qvariant(P['icon.remove.pressed'])
else:
return to_qvariant(P['icon.remove.active'])
else:
return to_qvariant(P['icon.add.inactive'])
elif column == C.COL_REMOVE:
if (status == C.INSTALLED or
status == C.UPGRADABLE or
status == C.DOWNGRADABLE or
status == C.MIXGRADABLE):
if status in [C.INSTALLED, C.UPGRADABLE, C.DOWNGRADABLE,
C.MIXGRADABLE]:
if r:
return to_qvariant(P['icon.remove.pressed'])
else:
return to_qvariant(P['icon.remove.active'])
else:
return to_qvariant(P['icon.remove.inactive'])
elif column == C.COL_UPGRADE:
if status == C.UPGRADABLE or \
status == C.MIXGRADABLE:
if status in [C.UPGRADABLE, C.MIXGRADABLE]:
if u:
return to_qvariant(P['icon.upgrade.pressed'])
else:
return to_qvariant(P['icon.upgrade.active'])
else:
return to_qvariant(P['icon.upgrade.inactive'])
elif column == C.COL_DOWNGRADE:
if status == C.DOWNGRADABLE or \
status == C.MIXGRADABLE:
if status in [C.DOWNGRADABLE, C.MIXGRADABLE]:
if d:
return to_qvariant(P['icon.downgrade.pressed'])
else:
Expand All @@ -243,26 +237,25 @@ def data(self, index, role=Qt.DisplayRole):
elif role == Qt.ToolTipRole:
if column == C.COL_INSTALL and status == C.NOT_INSTALLED:
return to_qvariant(_('Install package'))
elif column == C.COL_INSTALL and (status == C.INSTALLED or
status == C.UPGRADABLE or
status == C.DOWNGRADABLE or
status == C.MIXGRADABLE):
elif column == C.COL_INSTALL and (status in [C.INSTALLED,
C.UPGRADABLE,
C.DOWNGRADABLE,
C.MIXGRADABLE]):
return to_qvariant(_('Remove package'))
elif column == C.COL_UPGRADE and (status == C.INSTALLED or
status == C.UPGRADABLE or
status == C.MIXGRADABLE):
elif column == C.COL_UPGRADE and (status in [C.INSTALLED,
C.UPGRADABLE,
C.MIXGRADABLE]):
return to_qvariant(_('Upgrade package'))
elif column == C.COL_DOWNGRADE and (status == C.INSTALLED or
status == C.DOWNGRADABLE or
status == C.MIXGRADABLE):
elif column == C.COL_DOWNGRADE and (status in [C.INSTALLED,
C.DOWNGRADABLE,
C.MIXGRADABLE]):
return to_qvariant(_('Downgrade package'))
elif column == C.COL_PACKAGE_TYPE:
if type_ == C.CONDA_PACKAGE:
return to_qvariant(_('Conda package'))
elif type_ == C.PIP_PACKAGE:
return to_qvariant(_('Python package'))
elif column == C.COL_VERSION:
if is_upgradable:
elif column == C.COL_VERSION and is_upgradable:
return to_qvariant(_('Update available'))
elif role == Qt.ForegroundRole:
palette = QPalette()
Expand All @@ -275,17 +268,17 @@ def data(self, index, role=Qt.DisplayRole):
color = palette.color(QPalette.Mid)
color = P['foreground.not.installed']
return to_qvariant(color)
elif column in [C.COL_VERSION]:
if is_upgradable:
elif column in [C.COL_VERSION] and is_upgradable:
return to_qvariant(P['foreground.upgrade'])

elif role == Qt.SizeHintRole:
if column in [C.ACTION_COLUMNS] + [C.COL_PACKAGE_TYPE]:
elif (role == Qt.SizeHintRole and column in
C.ACTION_COLUMNS + [C.COL_PACKAGE_TYPE]):
return to_qvariant(QSize(24, 24))

return to_qvariant()

def headerData(self, section, orientation, role=Qt.DisplayRole):
@staticmethod
def headerData(section, orientation, role=Qt.DisplayRole):
"""Override Qt method"""
if role == Qt.TextAlignmentRole:
if orientation == Qt.Horizontal:
Expand All @@ -310,7 +303,8 @@ def rowCount(self, index=QModelIndex()):
"""Override Qt method"""
return len(self._rows)

def columnCount(self, index=QModelIndex()):
@staticmethod
def columnCount(index=QModelIndex()):
"""Override Qt method"""
return len(C.COLUMNS)

Expand Down
2 changes: 1 addition & 1 deletion conda_manager/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def toint(x):
# replace letters found by a negative number
replace_dic = {}
alpha = sorted(alpha, reverse=True)
if len(alpha):
if alpha:
replace_dic = dict(zip(alpha, list(range(-1, -(len(alpha)+1), -1))))

# Complete with zeros based on longest item and replace alphas with number
Expand Down
2 changes: 1 addition & 1 deletion conda_manager/utils/encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def encode(text, orig_coding):
try:
return text.encode(coding), coding
except (UnicodeError, LookupError):
raise RuntimeError("Incorrect encoding (%s)" % coding)
raise RuntimeError("Incorrect encoding ({0})".format(coding))
if (orig_coding and orig_coding.endswith('-default') or
orig_coding.endswith('-guessed')):
coding = orig_coding.replace("-default", "")
Expand Down
16 changes: 6 additions & 10 deletions conda_manager/utils/misc.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
# -*- coding: utf-8 -*-

def human_bytes(n):
"""
Return the number of bytes n in more human readable form.
"""
"""Return the number of bytes n in more human readable form."""
if n < 1024:
return '%d B' % n
return '{0} B'.format(n)
k = n/1024
if k < 1024:
return '%d KB' % round(k)
return '{0} KB'.format(round(k))
m = k/1024
if m < 1024:
return '%.1f MB' % m
return '{0:1f} MB'.format(m)
g = m/1024
return '%.2f GB' % g
return '{0:1f} GB'.format(g)


def split_canonical_name(cname):
"""
Split a canonical package name into (name, version, build) strings.
"""
"""Split a canonical package name into (name, version, build) strings."""
return tuple(cname.rsplit('-', 2))
2 changes: 1 addition & 1 deletion conda_manager/utils/qthelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def qapplication(translate=True, test_time=3):
if translate:
install_translator(app)

test_travis = os.environ.get('TEST_CI', None)
test_travis = os.environ.get('TEST_CI')
if test_travis is not None:
timer_shutdown = QTimer(app)
timer_shutdown.timeout.connect(app.quit)
Expand Down
15 changes: 10 additions & 5 deletions conda_manager/widgets/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,23 +116,28 @@ def set_environments(self, prefix):
""" """
self.packages.set_environment(prefix=prefix)

def add_env(self):
@staticmethod
def add_env():
""" """
# TODO:

def clone_env(self):
@staticmethod
def clone_env():
""" """
# TODO:

def remove_env(self):
@staticmethod
def remove_env():
""" """
# TODO:

def preferences(self):
@staticmethod
def preferences():
""" """
# TODO:

def report_issue(self):
@staticmethod
def report_issue():
if PY3:
from urllib.parse import quote
else:
Expand Down

0 comments on commit a914e0e

Please sign in to comment.