Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
giumas committed May 16, 2024
1 parent 264126e commit c66d565
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 129 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/kng_on_linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Kng on Linux

on: [push]

jobs:
build:
runs-on: ubuntu-latest
strategy:
max-parallel: 5

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: setup-conda
uses: s-weigand/setup-conda@v1.2.1
with:
update-conda: true
python-version: 3.11
- name: Install dependencies
run: |
conda config --add channels conda-forge
conda install appdirs cartopy gdal matplotlib-base numpy psutil pyproj qt-material
pip install PySide6
pip install hyo2.abc2
sudo apt-get install -y libegl1
pip install --no-deps .
- name: Lint with flake8
run: |
conda install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 ./hyo2/kng --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 ./hyo2/kng --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
continue-on-error: true
- name: Test with pytest
run: |
pip install coveralls PyYAML pytest pytest-cov
py.test --cov
coverage report -m
coveralls
continue-on-error: false
43 changes: 43 additions & 0 deletions .github/workflows/kng_on_windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Kng on Windows

on: [push]

jobs:
build:
runs-on: windows-latest
strategy:
max-parallel: 5

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: setup-conda
uses: s-weigand/setup-conda@v1.2.1
with:
update-conda: true
python-version: 3.11
- name: Install dependencies
run: |
conda config --add channels conda-forge
conda install appdirs cartopy gdal matplotlib-base numpy psutil pyproj qt-material
pip install PySide6
pip install hyo2.abc2
pip install --no-deps .
- name: Lint with flake8
run: |
conda install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 .\hyo2\kng --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 .\hyo2\kng --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
continue-on-error: true
- name: Test with pytest
run: |
pip install coveralls PyYAML pytest pytest-cov
py.test --cov
coverage report -m
coveralls
continue-on-error: false
54 changes: 0 additions & 54 deletions .travis.yml

This file was deleted.

59 changes: 0 additions & 59 deletions appveyor.yml

This file was deleted.

5 changes: 3 additions & 2 deletions hyo2/kng/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
logger.addHandler(logging.NullHandler())

name = "Kng"
__version__ = "1.3.0"
__version__ = "1.3.1"
__author__ = "gmasetti@ccom.unh.edu"

pkg_info = PkgInfo(
Expand All @@ -24,6 +24,7 @@
latest_url="https://www.hydroffice.org/latest/sis_emu.txt",
deps_dict={
"hyo2.abc2": "hyo2.abc2",
"PySide6": "PySide6"
"PySide6": "PySide6",
"numpy": "numpy"
}
)
9 changes: 4 additions & 5 deletions hyo2/kng/app/sis_emu/controlpanel.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import logging
import os
from typing import Union

from PySide6 import QtCore, QtGui, QtWidgets

Expand Down Expand Up @@ -57,7 +56,7 @@ def __init__(self):
self.viewer.ensureCursorVisible()
# create a monospace font
font = QtGui.QFont("Courier New")
font.setStyleHint(QtGui.QFont.TypeWriter)
font.setStyleHint(QtGui.QFont.StyleHint.TypeWriter)
font.setFixedPitch(True)
font.setPointSize(9)
self.viewer.document().setDefaultFont(font)
Expand Down Expand Up @@ -166,7 +165,7 @@ def _make_sis_settings(self):
self.set_timing.setMaximum(5)
self.set_timing.setTickInterval(1)
self.set_timing.setValue(1)
self.set_timing.setTickPosition(QtWidgets.QSlider.TicksBelow)
self.set_timing.setTickPosition(QtWidgets.QSlider.TickPosition.TicksBelow)
# noinspection PyUnresolvedReferences
self.set_timing.valueChanged.connect(self.on_replay_timing)
hbox.addWidget(self.set_timing)
Expand Down Expand Up @@ -304,7 +303,7 @@ def _add_source_files(self):
logger.debug('adding files')

settings = QtCore.QSettings()
source_folder = settings.value("source_folder", self.here) # type: Union[object,str]
source_folder = settings.value("source_folder", self.here) # type: object | str

# ask the file path to the user
if self.sis_4.isChecked():
Expand Down Expand Up @@ -338,7 +337,7 @@ def _add_source_files(self):
# noinspection PyCallByClass,PyArgumentList,PyTypeChecker
QtWidgets.QMessageBox.warning(self, "File Duplication",
"Attempt to add a listed file:\n%s" % os.path.basename(f),
QtWidgets.QMessageBox.Ok)
QtWidgets.QMessageBox.StandardButton.Ok)
continue
item = QtWidgets.QListWidgetItem(f)
self.list_files.addItem(item)
Expand Down
10 changes: 5 additions & 5 deletions hyo2/kng/app/sis_emu/mainwin.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,22 @@ def _check_latest_release(cls):
except Exception as e:
logger.warning(e)

def _do_you_really_want(self, title="Quit", text="quit"):
def _do_you_really_want(self, title="Quit", text="quit") -> int:
"""helper function that show to the user a message windows asking to confirm an action"""
msg_box = QtWidgets.QMessageBox(self)
msg_box.setWindowTitle(title)
msg_box.setIconPixmap(QtGui.QPixmap(app_info.app_icon_path).scaled(QtCore.QSize(36, 36)))
msg_box.setText('Do you really want to %s?' % text)
# noinspection PyUnresolvedReferences
msg_box.setStandardButtons(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
msg_box.setDefaultButton(QtWidgets.QMessageBox.No)
msg_box.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.No)
msg_box.setDefaultButton(QtWidgets.QMessageBox.StandardButton.No)
return msg_box.exec()

def closeEvent(self, event):
def closeEvent(self, event: QtGui.QCloseEvent) -> None:
""" actions to be done before close the app """
reply = self._do_you_really_want("Quit", "quit %s" % self.name)

if reply == QtWidgets.QMessageBox.Yes:
if reply == QtWidgets.QMessageBox.StandardButton.Yes:

event.accept()
self.panel.stop_emulation()
Expand Down
2 changes: 1 addition & 1 deletion hyo2/kng/lib/kng_all.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import enum
import logging
import struct
from typing.io import BinaryIO
from typing import BinaryIO

logger = logging.getLogger(__name__)

Expand Down
4 changes: 2 additions & 2 deletions hyo2/kng/lib/kng_kmall.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
import struct
from datetime import datetime, timedelta
from typing.io import BinaryIO
from typing import BinaryIO

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -72,4 +72,4 @@ def read(self, file_input: BinaryIO, file_size: int) -> Flags:
@classmethod
def kmall_datetime(cls, dgm_time_sec: int, dgm_time_nanosec: int = 0):
return datetime.utcfromtimestamp(dgm_time_sec) + \
timedelta(microseconds=(dgm_time_nanosec / 1000.0))
timedelta(microseconds=(dgm_time_nanosec / 1000.0))
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def find_version(*file_paths):
install_requires=[
"hyo2.abc2",
"numpy",
# "PySide6"
"PySide6"
],
python_requires='>=3.8',
entry_points={
Expand All @@ -77,6 +77,7 @@ def find_version(*file_paths):
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
'Topic :: Scientific/Engineering :: GIS',
'Topic :: Office/Business :: Office Suites',
],
Expand Down

0 comments on commit c66d565

Please sign in to comment.