Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
eoyilmaz committed Jun 5, 2023
2 parents a498ab1 + 542cf52 commit b5d6c25
Show file tree
Hide file tree
Showing 15 changed files with 150 additions and 206 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,29 @@ jobs:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
wx-version:
- "4.1.1"
- "4.2.0"
exclude:
- python-version: "3.11"
wx-version: "4.1.1"

steps:

- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set Environment Variables
run: |
echo "py_version=$(echo ${{ matrix.python-version }} | tr -d .)" >> $GITHUB_ENV
if [[ ${{ matrix.wx-version }} == "4.1.1" ]]; then echo "wx_url=wxpython.p5k.org/wxPython-4.1.1"; fi >> $GITHUB_ENV
if [[ ${{ matrix.wx-version }} == "4.2.0" ]]; then echo "wx_url=extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-20.04/wxPython-4.2.0"; fi >> $GITHUB_ENV
if [ "${{ matrix.python-version }}" == "3.8" ]; then
echo "add_dir_str=${{ matrix.python-version }}" >> $GITHUB_ENV
elif [ "${{ matrix.python-version }}" == "3.9" ]; then
echo "add_dir_str=${{ matrix.python-version }}" >> $GITHUB_ENV
elif [ "${{ matrix.python-version }}" == "3.10" ]; then
echo "add_dir_str=cpython-310" >> $GITHUB_ENV
elif [ "${{ matrix.python-version }}" == "3.11" ]; then
echo "add_dir_str=cpython-311" >> $GITHUB_ENV
fi
- name: Setup timezone
Expand All @@ -58,7 +62,7 @@ jobs:
sudo /usr/bin/Xvfb $DISPLAY -screen 0 1280x1024x24 &
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -71,7 +75,7 @@ jobs:
- name: Install wxPython wheels ${{ matrix.wx-version }}
run: |
pip install https://${{ env.wx_url }}-cp${{ env.py_version }}-cp${{ env.py_version }}-linux_x86_64.whl
pip install https://wxpython.p5k.org/wxPython-${{ matrix.wx-version }}-cp${{ env.py_version }}-cp${{ env.py_version }}-linux_x86_64.whl
- name: Install Python dependencies
run: |
Expand Down
2 changes: 2 additions & 0 deletions DisplayCAL/RealDisplaySizeMM.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
from DisplayCAL.lib64.python39.RealDisplaySizeMM import *
elif sys.version_info[:2] == (3, 10):
from DisplayCAL.lib64.python310.RealDisplaySizeMM import *
elif sys.version_info[:2] == (3, 11):
from DisplayCAL.lib64.python311.RealDisplaySizeMM import *
# else:
# pass

Expand Down
175 changes: 9 additions & 166 deletions DisplayCAL/defaultpaths.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,57 +54,6 @@ def SHGetSpecialFolderPath(hwndOwner, nFolder, create=0):
from DisplayCAL.util_os import expanduseru, expandvarsu, getenvu, waccess


def get_known_folder_path(folderid, user=True):
"""Get known folder path.
Uses GetKnownFolderPath API on Windows Vista and later, and XDG user dirs
on Linux.
Falls back to ~/<folderid> in all other cases.
folderid can be "Desktop", "Downloads", "Documents", "Music", "Pictures",
"Public", "Templates", or "Videos".
user Return user folder instead of common (Windows) or default (Linux)
"""
folder_path = os.path.join(home, folderid)
if sys.platform == "win32" and sys.getwindowsversion() >= (6,):
# Windows Vista or newer
from DisplayCAL import win_knownpaths

try:
folder_path = win_knownpaths.get_path(
getattr(win_knownpaths.FOLDERID, folderid),
getattr(win_knownpaths.UserHandle, "current" if user else "common"),
)
except Exception:
print("Warning: Could not get known folder %r" % folderid)
elif sys.platform not in ("darwin", "win32"):
# Linux
user_dir = folderid
folderid = (
{"Downloads": folderid[:-1], "Public": folderid + "share"}
.get(folderid, folderid)
.upper()
)
if folderid != "DESKTOP" or XDG.UserDirs.enabled:
user_dir = XDG.UserDirs.default_dirs.get(folderid)
if user:
user_dir = XDG.UserDirs.user_dirs.get(folderid, user_dir)
if user_dir:
folder_path = os.path.join(home, user_dir)
if (
folderid != "DESKTOP"
and (
not user_dir
or (not os.path.isdir(folder_path) and not XDG.UserDirs.enabled)
)
) or not waccess(folder_path, os.W_OK):
folder_path = home
return folder_path


home = expanduseru("~")
if sys.platform == "win32":
# Always specify create=1 for SHGetSpecialFolderPath so we don't get an
Expand Down Expand Up @@ -235,9 +184,14 @@ def set_translation(obj):
obj.GETTEXT_PACKAGE, locale_dir, codeset="UTF-8"
)
except TypeError:
obj.translation = gettext.translation(
obj.GETTEXT_PACKAGE, locale_dir
)
try:
obj.translation = gettext.translation(
obj.GETTEXT_PACKAGE, locale_dir
)
except FileNotFoundError as exc:
print("XDG:", exc)
obj.translation = gettext.NullTranslations()
return False
except IOError as exception:
print("XDG:", exception)
obj.translation = gettext.NullTranslations()
Expand All @@ -261,11 +215,7 @@ def get_config_files(filename):

@staticmethod
def shell_unescape(s):
a = []
for i, c in enumerate(s):
if c == "\\" and len(s) > i + 1:
continue
a.append(c)
a = [c for i, c in enumerate(s) if c != "\\" or len(s) <= i + 1]
return "".join(a)

@staticmethod
Expand All @@ -287,113 +237,6 @@ def process_config_file(path, fn):
return False
return True

class _UserDirs(object):

GETTEXT_PACKAGE = "xdg-user-dirs"

enabled = True
filename_encoding = "UTF-8"
default_dirs = {}
user_dirs = {}

_initialized = False

def __getattribute__(self, name):
if name != "init" and not object.__getattribute__(self, "_initialized"):
object.__getattribute__(self, "init")()
return object.__getattribute__(self, name)

def load_config(self, path):
def fn(key, value):
if key == "enabled":
self.enabled = XDG.is_true(value)
elif key == "filename_encoding":
value = value.upper()
if value == "LOCALE":
current_locale = locale.getlocale()
locale.setlocale(locale.LC_ALL, "")
self.filename_encoding = locale.nl_langinfo(locale.CODESET)
locale.setlocale(locale.LC_ALL, current_locale)
else:
self.filename_encoding = value

return XDG.process_config_file(path, fn)

def load_all_configs(self):
for path in reversed(XDG.get_config_files("user-dirs.conf")):
self.load_config(path)

def load_default_dirs(self):
paths = XDG.get_config_files("user-dirs.defaults")
if not paths:
print("XDG.UserDirs: No default user directories")
return False

def fn(name, path):
self.default_dirs[name] = self.localize_path_name(path)

return XDG.process_config_file(paths[0], fn)

def load_user_dirs(self):
path = os.path.join(XDG.config_home, "user-dirs.dirs")
if not path or not os.path.isfile(path):
return False

def fn(key, value):
if (
key.startswith("XDG_")
and key.endswith("_DIR")
and value.startswith('"')
and value.endswith('"')
):
name = key[4:-4]
if not name:
return
value = value.strip('"')
if value.startswith("$HOME"):
value = value[5:]
if value.startswith("/"):
value = value[1:]
elif value:
# Not ending after $HOME, nor followed by slash.
# Ignore
return
elif not value.startswith("/"):
return
self.user_dirs[name] = XDG.shell_unescape(value).decode(
"UTF-8", "ignore"
)

return XDG.process_config_file(path, fn)

def localize_path_name(self, path):
elements = path.split(os.path.sep)

for i, element in enumerate(elements):
elements[i] = self.translation.ugettext(element)

return os.path.join(*elements)

def init(self):
self._initialized = True

XDG.set_translation(self)

self.load_all_configs()
try:
codecs.lookup(self.filename_encoding)
except LookupError:
print(
"XDG.UserDirs: Can't convert from UTF-8 to",
self.filename_encoding,
)
return False

self.load_default_dirs()
self.load_user_dirs()

UserDirs = _UserDirs()

for name in dir(XDG):
attr = getattr(XDG, name)
if isinstance(attr, (str, list)):
Expand Down
2 changes: 1 addition & 1 deletion DisplayCAL/display_cal.py
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ def show_ccxx_info(event):
lstr_en = lang.getstr("colorimeter_correction.web_check.info", lcode="en")
if lstr != lstr_en or lang.getcode() == "en":
info_txt = wx.StaticText(dlg, -1, lstr)
info_txt.Wrap(640 * scale)
info_txt.Wrap(int(640 * scale))
dlg.sizer3.Add(info_txt, 1, flag=wx.TOP | wx.ALIGN_LEFT, border=12)
if len(cgats) > 1:
# We got several matches
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion DisplayCAL/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
name_html = '<span class="appname">Display<span>CAL</span></span>'

py_minversion = (3, 8)
py_maxversion = (3, 10)
py_maxversion = (3, 11)

version = VERSION_STRING
version_lin = VERSION_STRING # Linux
Expand Down
7 changes: 3 additions & 4 deletions DisplayCAL/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@
)
from DisplayCAL.defaultpaths import (
cache,
get_known_folder_path,
iccprofiles_home,
iccprofiles_display_home,
appdata,
Expand Down Expand Up @@ -6584,7 +6583,7 @@ def exec_cmd(
if os.path.isfile(okfilename):
try:
os.remove(okfilename)
except OSError, e:
except OSError:
pass
else:
break
Expand Down Expand Up @@ -6625,7 +6624,7 @@ def exec_cmd(
waitfile.write("#!/usr/bin/env python3\n")
waitfile.write(pythonscript)
os.chmod(waitfilename, 0o755)
args[index] += '"%s" ./%s' % (
args[index] += '%s ./%s' % (
strtr(safe_str(python), {'"': r"\"", "$": r"\$"}),
os.path.basename(waitfilename),
)
Expand Down Expand Up @@ -13631,7 +13630,7 @@ def prepare_dispread(self, apply_calibration=True):
if ext.lower() != ".ti1":
ti3_lines = [line.strip() for line in ti3]
ti3.close()
if "CTI3" not in ti3_lines:
if b"CTI3" not in ti3_lines:
return (
Error(
lang.getstr(
Expand Down
6 changes: 6 additions & 0 deletions DisplayCAL/wxLUTViewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
BaseApp,
BaseFrame,
BitmapBackgroundPanelText,
BitmapBackgroundPanelTextGamut,
CustomCheckBox,
FileDrop,
InfoDialog,
Expand Down Expand Up @@ -828,6 +829,7 @@ def __init__(self, *args, **kwargs):
self.sizer.Add(self.box_panel, flag=wx.EXPAND)

self.status = BitmapBackgroundPanelText(self, name="statuspanel")
self.gamut_status = BitmapBackgroundPanelTextGamut(self, name="statuspanel")
self.status.SetMaxFontSize(11)
self.status.label_y = 8
self.status.textshadow = False
Expand Down Expand Up @@ -2318,6 +2320,10 @@ def SetStatusText(self, text):
self.status.Label = text
self.status.Refresh()

def SetGamutStatusText(self, text):
self.gamut_status.Label = text
self.status.Refresh()

def UpdatePointLabel(self, xy):
if self.client.GetEnablePointLabel():
# Show closest point (when enbled)
Expand Down
Loading

0 comments on commit b5d6c25

Please sign in to comment.