Skip to content

Commit c6ea686

Browse files
authored
Merge pull request #12 from NickGeek/XP-11
Move to Qt6 to support Python 3.9 to 3.12
2 parents 2e87583 + 45cd270 commit c6ea686

24 files changed

+130
-45
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
.idea
33

44
**/.cache
5+
**/__pycache__
56
build/**
67
dist/**
78
XDG_Prefs.egg-info/**

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
SRC = xdgprefs requirements.txt setup.py
2+
3+
build-wheel: $(SRC)
4+
python setup.py bdist_wheel
5+
6+
install: $(SRC)
7+
python setup.py install
8+
9+
clean:
10+
rm -rf build dist XDG_Prefs.egg-info

README.md

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,15 @@ tool to manage these preferences ; this software works on every Window Manager
2424

2525
## Getting started
2626

27-
Download the Wheel (.whl) file in the [releases] section and install it using
28-
`pip install XDG_Prefs-<version>-py3-none-any.whl` (replace `<version>` with
29-
the number of the version you downloaded, such as `0.1`:
30-
`XDG_Prefs-0.1-py3-none-any.whl`).
31-
Please note that you must use Python3.5 or later (you might need to replace
27+
You may install *XDG-Prefs* by using `pip install git+https://github.com/rchaput/xdg-prefs`
28+
(or `pip install --user git+https://github.com/rchaput/xdg-prefs` if you prefer
29+
installing for the current user only).
30+
Please note that you must use Python3.6 or later (you might need to replace
3231
`pip` with `pip3` on some distributions, such as Debian).
3332

3433
Alternatively, you can clone this project on your computer and run
3534
`python setup.py install`. This is recommended if you want to contribute.
36-
Again, you will need to use Python3.5 or later (you might need to replace
35+
Again, you will need to use Python3.6 or later (you might need to replace
3736
`python` with `python3` on some distributions, such as Debian).
3837

3938
This will install the required files and create a `xdg-prefs` executable.
@@ -75,11 +74,9 @@ Directly reads the files that compose each of the following databases:
7574
## Dependencies
7675

7776
This project only depends on
78-
* Python3.5 (should work with later versions)
79-
* PySide2 (Qt5 for Python ; tested with version 5.9.0a1)
77+
* Python3.6 (should work with later versions)
78+
* PySide6 (Qt6 for Python)
8079
* configparser (Python standard library to read config files)
81-
* [future_fstrings](https://pypi.org/project/future-fstrings/)
82-
(in order to use PEP498's F-strings in Python3.5)
8380
* Uses code from https://github.com/wor/desktop_file_parser
8481
(in order to parse [Desktop files][apps-spec])
8582

poetry.lock

Lines changed: 70 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[tool.poetry]
2+
name = "XDG-Prefs"
3+
version = "0.3.0"
4+
description = "A GUI program to view and change your default programs preferences (which program should open which type of file), using the XDG Specifications"
5+
authors = ["Remy Chaput <rchaput.pro@gmail.com>"]
6+
license = "Apache"
7+
readme = "README.md"
8+
packages = [{include = "xdgprefs"}]
9+
10+
[tool.poetry.dependencies]
11+
python = "^3.9, <3.13"
12+
PySide6 = "^6.7"
13+
14+
15+
[build-system]
16+
requires = [
17+
"setuptools >= 40.9.0",
18+
]
19+
build-backend = "setuptools.build_meta"

requirements.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
pyside2
2-
future_fstrings
1+
pyside6

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ def read(fname):
88

99
setup(
1010
name='XDG-Prefs',
11-
version='0.1',
11+
version='0.3',
1212

1313
packages=['xdgprefs', 'xdgprefs.core', 'xdgprefs.gui'],
14-
install_requires=['PySide2', 'future-fstrings'],
14+
install_requires=['PySide6'],
1515

1616
entry_points={
1717
'gui_scripts': [
@@ -38,7 +38,7 @@ def read(fname):
3838
'License :: OSI Approved :: Apache Software License',
3939
'Natural Language :: English',
4040
'Operating System :: Unix',
41-
'Programming Language :: Python :: 3.5',
41+
'Programming Language :: Python :: 3.9',
4242
'Topic :: Utilities'
4343
]
4444
)

xdgprefs/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
import sys
7-
from PySide2.QtWidgets import QApplication
7+
from PySide6.QtWidgets import QApplication
88

99
from xdgprefs.gui.main_window import MainWindow
1010

xdgprefs/core/app_database.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: future_fstrings -*-
21
"""
32
This module defines functions and class to handle the Application Database
43
(i.e. the list of Desktop Entries that represent applications).

xdgprefs/core/associations_database.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: future_fstrings -*-
21
"""
32
This module defines the database that lists associations between
43
MIME Types and Applications (represented by Desktop Entries).
@@ -21,6 +20,7 @@
2120
ADDED = 'Added Applications'
2221
REMOVED = 'Removed Applications'
2322
DEFAULT = 'Default Applications'
23+
CACHE = 'MIME Cache'
2424

2525

2626
class Associations(object):
@@ -118,7 +118,8 @@ def before_write(self, parser, section, option, value):
118118

119119
def parse_mimeapps(file_path):
120120
config = configparser.ConfigParser(delimiters='=',
121-
interpolation=ArrayInterpolation())
121+
interpolation=ArrayInterpolation(),
122+
strict=False)
122123
try:
123124
config.read(file_path)
124125
for section in [ADDED, REMOVED, DEFAULT]:
@@ -154,19 +155,22 @@ def _parse_mimeapps_file(self, path):
154155
if config is None:
155156
self.logger.warning(f'Badly formatted file: {path}')
156157
return
157-
section = config['Added Applications']
158+
section = config[ADDED]
158159
for mimetype, apps in section.items():
159160
self.associations[mimetype].extend_added(apps)
160-
section = config['Removed Applications']
161+
section = config[REMOVED]
161162
for mimetype, apps in section.items():
162163
self.associations[mimetype].extend_removed(apps)
163-
section = config['Default Applications']
164+
section = config[DEFAULT]
164165
for mimetype, apps in section.items():
165166
self.associations[mimetype].extend_default(apps)
166167

167168
def _parse_cache_file(self, path):
168169
config = parse_mimeapps(path)
169-
for mimetype, apps in config['MIME Cache'].items():
170+
if config is None:
171+
self.logger.warning(f'Badly formatted file: {path}')
172+
return
173+
for mimetype, apps in config[CACHE].items():
170174
assoc = self.associations[mimetype]
171175
assoc.extend_default(apps)
172176

xdgprefs/core/desktop_entry.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: future_fstrings -*-
21
"""
32
This module defines code relative to Desktop Entries, i.e. applications
43
which are compliant with the XDG specifications.

xdgprefs/core/desktop_entry_parser.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: future_fstrings -*-
21
"""
32
Desktop file tokenizer and parser.
43
Source: https://github.com/wor/desktop_file_parser

xdgprefs/core/mime_database.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: future_fstrings -*-
21
"""
32
This module provides functions and classes used to handle the Mime Database
43
(i.e. the set of known MIME Types, with associated meta information).

xdgprefs/core/mime_type.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: future_fstrings -*-
21
"""
32
This module defines the MimeType class as well as a MimeTypeParser (used
43
to parse media types from their XML files).

xdgprefs/core/os_env.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: future_fstrings -*-
21
"""
32
This module allows access to various environment variables of the Operating
43
System, such as XDG configuration values, the current Desktop Environment,

xdgprefs/core/xdg_mime_wrapper.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: future_fstrings -*-
21
"""
32
This module defines wrapper functions for the `xdg-mime` software.
43

xdgprefs/gui/app_item.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: future_fstrings -*-
21
"""
32
This module defines a single Application Item in the AppsPanel.
43
"""

xdgprefs/gui/apps_panel.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
# -*- coding: future_fstrings -*-
21
"""
32
This module defines Qt Widgets that allow to view the list of applications
43
as a Qt List (using a custom widget for the layout).
54
"""
65

76

8-
from PySide2.QtWidgets import QListWidget, QWidget, \
7+
from PySide6.QtWidgets import QListWidget, QWidget, \
98
QLabel, QGridLayout, QLineEdit, QCheckBox
109

1110
from xdgprefs.core import DesktopEntry

xdgprefs/gui/association_item.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
# -*- coding: future_fstrings -*-
21
"""
32
This module defines a single AssociationItem in the AssociationsPanel.
43
"""
54

65

76
from threading import Thread
87

9-
from PySide2.QtWidgets import QComboBox
8+
from PySide6.QtWidgets import QComboBox
109

1110
from xdgprefs.gui.mime_item import MimeTypeItem
1211

xdgprefs/gui/associations_panel.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
# -*- coding: future_fstrings -*-
21
"""
32
This modules defines widgets that allow to view the associations between
43
MIME Types and Applications as a Qt List, and to modify the associated
54
application for each MIME Type.
65
"""
76

87

9-
from PySide2.QtWidgets import QListWidget, QWidget, \
8+
from PySide6.QtWidgets import QListWidget, QWidget, \
109
QLabel, QCheckBox, QLineEdit, QGridLayout
1110

1211
from xdgprefs.core import MimeType

xdgprefs/gui/custom_item.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: future_fstrings -*-
21
"""
32
This module defines a custom QListWidgetItem that uses the following layout:
43
- icon on the left
@@ -9,10 +8,10 @@
98
"""
109

1110

12-
from PySide2.QtWidgets import QListWidgetItem, QWidget, \
11+
from PySide6.QtWidgets import QListWidgetItem, QWidget, \
1312
QVBoxLayout, QHBoxLayout, QLabel
14-
from PySide2.QtGui import QPixmap
15-
from PySide2.QtCore import QSize
13+
from PySide6.QtGui import QPixmap
14+
from PySide6.QtCore import QSize
1615

1716

1817
class CustomItem(QListWidgetItem):

xdgprefs/gui/main_window.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
# -*- coding: future_fstrings -*-
21
"""
32
This module defines the main window, allowing the user to effectively
43
use the application.
54
"""
65

76

8-
from PySide2.QtWidgets import QMainWindow, QTabWidget
7+
from PySide6.QtWidgets import QMainWindow, QTabWidget
98

109
from xdgprefs.gui import MimeTypePanel, AppsPanel, AssociationsPanel
1110
from xdgprefs.core import MimeDatabase, AppDatabase, AssociationsDatabase

xdgprefs/gui/mime_item.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: future_fstrings -*-
21
"""
32
This module defines a single MimeTypeItem in the MimeTypePanel.
43
"""

xdgprefs/gui/mime_type_panel.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
# -*- coding: future_fstrings -*-
21
"""
32
This module defines Qt Widgets that allow to view the list of MIME Types
43
as a Qt List (using a custom widget for the layout).
54
"""
65

76

8-
from PySide2.QtWidgets import QListWidget, QWidget, QLabel, QGridLayout, \
7+
from PySide6.QtWidgets import QListWidget, QWidget, QLabel, QGridLayout, \
98
QLineEdit, QCheckBox
109

1110
from xdgprefs.core import MimeType

0 commit comments

Comments
 (0)