diff --git a/CherryTomato/__init__.py b/CherryTomato/__init__.py index d1cb619..a70234f 100644 --- a/CherryTomato/__init__.py +++ b/CherryTomato/__init__.py @@ -4,6 +4,6 @@ MEDIA_DIR = os.path.join(BASE_DIR, 'media') APP_ICON = os.path.join(MEDIA_DIR, 'icon.png') -VERSION = '0.4.0' +VERSION = '0.4.1' ORGANIZATION_NAME = 'yakimka' APPLICATION_NAME = 'CherryTomato' diff --git a/CherryTomato/__main__.py b/CherryTomato/__main__.py deleted file mode 100644 index 12a7e52..0000000 --- a/CherryTomato/__main__.py +++ /dev/null @@ -1 +0,0 @@ -from . import main diff --git a/CherryTomato/about_window.py b/CherryTomato/about_window.py index 2b16915..0946ca5 100644 --- a/CherryTomato/about_window.py +++ b/CherryTomato/about_window.py @@ -3,7 +3,7 @@ from PyQt5.QtGui import QIcon from CherryTomato import APP_ICON, VERSION -from .about_ui import Ui_About +from CherryTomato.about_ui import Ui_About class About(QtWidgets.QWidget, Ui_About): diff --git a/CherryTomato/main.py b/CherryTomato/main.py index 5755c38..6ee5a2c 100755 --- a/CherryTomato/main.py +++ b/CherryTomato/main.py @@ -8,12 +8,18 @@ from CherryTomato import ORGANIZATION_NAME, APPLICATION_NAME from CherryTomato.main_window import CherryTomatoMainWindow -QCoreApplication.setOrganizationName(ORGANIZATION_NAME) -QCoreApplication.setApplicationName(APPLICATION_NAME) -app = Qt.QApplication(sys.argv) +def main(): + QCoreApplication.setOrganizationName(ORGANIZATION_NAME) + QCoreApplication.setApplicationName(APPLICATION_NAME) -watch = CherryTomatoMainWindow() -watch.show() + app = Qt.QApplication(sys.argv) -app.exec_() + watch = CherryTomatoMainWindow() + watch.show() + + app.exec_() + + +if __name__ == '__main__': + main() diff --git a/CherryTomato/settings.py b/CherryTomato/settings.py index d05ea44..623e2f7 100644 --- a/CherryTomato/settings.py +++ b/CherryTomato/settings.py @@ -105,7 +105,9 @@ def autoStopBreak(self, val): @property def switchToTomatoOnAbort(self): - return self.settings.value(self.SWITCH_TO_TOMATO_ON_ABORT, self.SWITCH_TO_TOMATO_ON_ABORT_DEFAULT, type=bool) + return self.settings.value( + self.SWITCH_TO_TOMATO_ON_ABORT, self.SWITCH_TO_TOMATO_ON_ABORT_DEFAULT, type=bool + ) @switchToTomatoOnAbort.setter def switchToTomatoOnAbort(self, val): @@ -133,7 +135,9 @@ def stateBreak(self, min): @property def stateLongBreak(self): - return self.settings.value(self.STATE_LONG_BREAK, State('long_break', self.LONG_BREAK_DEFAULT)) + return self.settings.value( + self.STATE_LONG_BREAK, State('long_break', self.LONG_BREAK_DEFAULT) + ) @stateLongBreak.setter def stateLongBreak(self, min): diff --git a/CherryTomato/tomato_timer.py b/CherryTomato/tomato_timer.py index 69dca4d..58dd7c1 100644 --- a/CherryTomato/tomato_timer.py +++ b/CherryTomato/tomato_timer.py @@ -89,7 +89,9 @@ def changeState(self): def _statesGen(self): while True: yield self.settings.stateTomato - yield self.settings.stateLongBreak if self._isTimeForLongBreak() else self.settings.stateBreak + longBreak = self.settings.stateLongBreak + break_ = self.settings.stateBreak + yield longBreak if self._isTimeForLongBreak() else break_ def _isTimeForLongBreak(self): if self.tomatoes == 0: diff --git a/CherryTomato/widget.py b/CherryTomato/widget.py index 814a480..60801ca 100644 --- a/CherryTomato/widget.py +++ b/CherryTomato/widget.py @@ -90,12 +90,9 @@ def calculateInnerRect(self, outerRadius: float): secondInnerRect = QRectF(left, top + firstHeight, width, height - firstHeight) return firstInnerRect, secondInnerRect, innerRadius - def drawTwoTexts(self, - p: QPainter, - firstRect: QRectF, - secondRect: QRectF, - innerRadius: float, - value: float): + def drawTwoTexts( + self, p: QPainter, firstRect: QRectF, secondRect: QRectF, innerRadius: float, value: float + ): if not self.m_format: return f = QFont(self.font()) diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f313b71 --- /dev/null +++ b/Makefile @@ -0,0 +1,30 @@ +all: init clean lint test + +clean: clean-build clean-pyc ## Clean build files and pyc files + rm -fr htmlcov/ + +clean-build: ## Clean build files + rm -fr build/ + rm -fr dist/ + rm -fr *.egg-info + +clean-pyc: ## Clean pyc files + find . -name '*.pyc' -exec rm -f {} + + find . -name '*.pyo' -exec rm -f {} + + find . -name '*~' -exec rm -f {} + + +init: ## Install test packages + pip install pytest pytest-qt pytest-mock flake8 + +test: ## Run tests + pytest + +flake: ## Run flake8 + flake8 --statistics --count + +lint: flake ## Run all linters + +.PHONY: help + +help: + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 876effd..0000000 --- a/requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -PyQt5 -qroundprogressbar -pytest -pytest-qt -pytest-mock diff --git a/setup.py b/setup.py index f6b6c38..4599fd1 100644 --- a/setup.py +++ b/setup.py @@ -1,14 +1,16 @@ from setuptools import setup -setup(name='CherryTomato', - author='yakimka', - version='0.4.0', - packages=['CherryTomato'], - python_requires='>=3.6', - install_requires=['PyQt5', 'qroundprogressbar'], - url='https://github.com/yakimka/CherryTomato', - license='GPL', - entry_points={'gui_scripts': ['cherry_tomato = CherryTomato.main']}, - package_data={ - '': ['media/*.*'], - }) +from CherryTomato import VERSION + +setup( + name='CherryTomato', + author='yakimka', + version=VERSION, + packages=['CherryTomato'], + python_requires='>=3.6', + install_requires=['PyQt5', 'qroundprogressbar'], + url='https://github.com/yakimka/CherryTomato', + license='GPL', + entry_points={'gui_scripts': ['cherry_tomato = CherryTomato.main:main']}, + package_data={'': ['media/*.*'], }, +) diff --git a/tests/conftest.py b/tests/conftest.py index 0fd40c0..83dc0a3 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -16,8 +16,6 @@ def value(self, key, default, type=None): @pytest.fixture def mock_qsettings(monkeypatch, mocker): - qsettings = mocker.patch('CherryTomato.settings.QSettings', MockQSettings) - monkeypatch.setattr(CherryTomatoSettings, 'TOMATO_DEFAULT', 100) monkeypatch.setattr(CherryTomatoSettings, 'BREAK_DEFAULT', 25) monkeypatch.setattr(CherryTomatoSettings, 'LONG_BREAK_DEFAULT', 50) @@ -26,13 +24,12 @@ def mock_qsettings(monkeypatch, mocker): monkeypatch.setattr(CherryTomatoSettings, 'AUTO_STOP_BREAK_DEFAULT', False) monkeypatch.setattr(CherryTomatoSettings, 'SWITCH_TO_TOMATO_ON_ABORT_DEFAULT', True) - return qsettings + return mocker.patch('CherryTomato.settings.QSettings', MockQSettings) + @pytest.fixture def settings(mock_qsettings): - settings = CherryTomatoSettings() - - return settings + return CherryTomatoSettings() @pytest.fixture diff --git a/tests/ui/test_main_window.py b/tests/ui/test_main_window.py index f9c7a69..7b15344 100644 --- a/tests/ui/test_main_window.py +++ b/tests/ui/test_main_window.py @@ -27,4 +27,3 @@ def test_stop_button_with_tomato(mock_main_window, qtbot): qtbot.mouseClick(mock_main_window.button, QtCore.Qt.LeftButton) assert mock_main_window.tomatoTimer.running is False - diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..feb881c --- /dev/null +++ b/tox.ini @@ -0,0 +1,4 @@ +[flake8] +max-complexity = 10 +max-line-length = 100 +exclude = *_ui.py,