Skip to content

Commit

Permalink
Merge pull request #12 from NickGeek/XP-11
Browse files Browse the repository at this point in the history
Move to Qt6 to support Python 3.9 to 3.12
  • Loading branch information
rchaput authored Aug 1, 2024
2 parents 2e87583 + 45cd270 commit c6ea686
Show file tree
Hide file tree
Showing 24 changed files with 130 additions and 45 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.idea

**/.cache
**/__pycache__
build/**
dist/**
XDG_Prefs.egg-info/**
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
SRC = xdgprefs requirements.txt setup.py

build-wheel: $(SRC)
python setup.py bdist_wheel

install: $(SRC)
python setup.py install

clean:
rm -rf build dist XDG_Prefs.egg-info
17 changes: 7 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,15 @@ tool to manage these preferences ; this software works on every Window Manager

## Getting started

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

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

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

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

Expand Down
70 changes: 70 additions & 0 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[tool.poetry]
name = "XDG-Prefs"
version = "0.3.0"
description = "A GUI program to view and change your default programs preferences (which program should open which type of file), using the XDG Specifications"
authors = ["Remy Chaput <[email protected]>"]
license = "Apache"
readme = "README.md"
packages = [{include = "xdgprefs"}]

[tool.poetry.dependencies]
python = "^3.9, <3.13"
PySide6 = "^6.7"


[build-system]
requires = [
"setuptools >= 40.9.0",
]
build-backend = "setuptools.build_meta"
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
pyside2
future_fstrings
pyside6
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ def read(fname):

setup(
name='XDG-Prefs',
version='0.1',
version='0.3',

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

entry_points={
'gui_scripts': [
Expand All @@ -38,7 +38,7 @@ def read(fname):
'License :: OSI Approved :: Apache Software License',
'Natural Language :: English',
'Operating System :: Unix',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.9',
'Topic :: Utilities'
]
)
2 changes: 1 addition & 1 deletion xdgprefs/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


import sys
from PySide2.QtWidgets import QApplication
from PySide6.QtWidgets import QApplication

from xdgprefs.gui.main_window import MainWindow

Expand Down
1 change: 0 additions & 1 deletion xdgprefs/core/app_database.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: future_fstrings -*-
"""
This module defines functions and class to handle the Application Database
(i.e. the list of Desktop Entries that represent applications).
Expand Down
16 changes: 10 additions & 6 deletions xdgprefs/core/associations_database.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: future_fstrings -*-
"""
This module defines the database that lists associations between
MIME Types and Applications (represented by Desktop Entries).
Expand All @@ -21,6 +20,7 @@
ADDED = 'Added Applications'
REMOVED = 'Removed Applications'
DEFAULT = 'Default Applications'
CACHE = 'MIME Cache'


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

def parse_mimeapps(file_path):
config = configparser.ConfigParser(delimiters='=',
interpolation=ArrayInterpolation())
interpolation=ArrayInterpolation(),
strict=False)
try:
config.read(file_path)
for section in [ADDED, REMOVED, DEFAULT]:
Expand Down Expand Up @@ -154,19 +155,22 @@ def _parse_mimeapps_file(self, path):
if config is None:
self.logger.warning(f'Badly formatted file: {path}')
return
section = config['Added Applications']
section = config[ADDED]
for mimetype, apps in section.items():
self.associations[mimetype].extend_added(apps)
section = config['Removed Applications']
section = config[REMOVED]
for mimetype, apps in section.items():
self.associations[mimetype].extend_removed(apps)
section = config['Default Applications']
section = config[DEFAULT]
for mimetype, apps in section.items():
self.associations[mimetype].extend_default(apps)

def _parse_cache_file(self, path):
config = parse_mimeapps(path)
for mimetype, apps in config['MIME Cache'].items():
if config is None:
self.logger.warning(f'Badly formatted file: {path}')
return
for mimetype, apps in config[CACHE].items():
assoc = self.associations[mimetype]
assoc.extend_default(apps)

Expand Down
1 change: 0 additions & 1 deletion xdgprefs/core/desktop_entry.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: future_fstrings -*-
"""
This module defines code relative to Desktop Entries, i.e. applications
which are compliant with the XDG specifications.
Expand Down
1 change: 0 additions & 1 deletion xdgprefs/core/desktop_entry_parser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: future_fstrings -*-
"""
Desktop file tokenizer and parser.
Source: https://github.com/wor/desktop_file_parser
Expand Down
1 change: 0 additions & 1 deletion xdgprefs/core/mime_database.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: future_fstrings -*-
"""
This module provides functions and classes used to handle the Mime Database
(i.e. the set of known MIME Types, with associated meta information).
Expand Down
1 change: 0 additions & 1 deletion xdgprefs/core/mime_type.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: future_fstrings -*-
"""
This module defines the MimeType class as well as a MimeTypeParser (used
to parse media types from their XML files).
Expand Down
1 change: 0 additions & 1 deletion xdgprefs/core/os_env.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: future_fstrings -*-
"""
This module allows access to various environment variables of the Operating
System, such as XDG configuration values, the current Desktop Environment,
Expand Down
1 change: 0 additions & 1 deletion xdgprefs/core/xdg_mime_wrapper.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: future_fstrings -*-
"""
This module defines wrapper functions for the `xdg-mime` software.
Expand Down
1 change: 0 additions & 1 deletion xdgprefs/gui/app_item.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: future_fstrings -*-
"""
This module defines a single Application Item in the AppsPanel.
"""
Expand Down
3 changes: 1 addition & 2 deletions xdgprefs/gui/apps_panel.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# -*- coding: future_fstrings -*-
"""
This module defines Qt Widgets that allow to view the list of applications
as a Qt List (using a custom widget for the layout).
"""


from PySide2.QtWidgets import QListWidget, QWidget, \
from PySide6.QtWidgets import QListWidget, QWidget, \
QLabel, QGridLayout, QLineEdit, QCheckBox

from xdgprefs.core import DesktopEntry
Expand Down
3 changes: 1 addition & 2 deletions xdgprefs/gui/association_item.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# -*- coding: future_fstrings -*-
"""
This module defines a single AssociationItem in the AssociationsPanel.
"""


from threading import Thread

from PySide2.QtWidgets import QComboBox
from PySide6.QtWidgets import QComboBox

from xdgprefs.gui.mime_item import MimeTypeItem

Expand Down
3 changes: 1 addition & 2 deletions xdgprefs/gui/associations_panel.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# -*- coding: future_fstrings -*-
"""
This modules defines widgets that allow to view the associations between
MIME Types and Applications as a Qt List, and to modify the associated
application for each MIME Type.
"""


from PySide2.QtWidgets import QListWidget, QWidget, \
from PySide6.QtWidgets import QListWidget, QWidget, \
QLabel, QCheckBox, QLineEdit, QGridLayout

from xdgprefs.core import MimeType
Expand Down
7 changes: 3 additions & 4 deletions xdgprefs/gui/custom_item.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: future_fstrings -*-
"""
This module defines a custom QListWidgetItem that uses the following layout:
- icon on the left
Expand All @@ -9,10 +8,10 @@
"""


from PySide2.QtWidgets import QListWidgetItem, QWidget, \
from PySide6.QtWidgets import QListWidgetItem, QWidget, \
QVBoxLayout, QHBoxLayout, QLabel
from PySide2.QtGui import QPixmap
from PySide2.QtCore import QSize
from PySide6.QtGui import QPixmap
from PySide6.QtCore import QSize


class CustomItem(QListWidgetItem):
Expand Down
3 changes: 1 addition & 2 deletions xdgprefs/gui/main_window.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# -*- coding: future_fstrings -*-
"""
This module defines the main window, allowing the user to effectively
use the application.
"""


from PySide2.QtWidgets import QMainWindow, QTabWidget
from PySide6.QtWidgets import QMainWindow, QTabWidget

from xdgprefs.gui import MimeTypePanel, AppsPanel, AssociationsPanel
from xdgprefs.core import MimeDatabase, AppDatabase, AssociationsDatabase
Expand Down
1 change: 0 additions & 1 deletion xdgprefs/gui/mime_item.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: future_fstrings -*-
"""
This module defines a single MimeTypeItem in the MimeTypePanel.
"""
Expand Down
3 changes: 1 addition & 2 deletions xdgprefs/gui/mime_type_panel.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# -*- coding: future_fstrings -*-
"""
This module defines Qt Widgets that allow to view the list of MIME Types
as a Qt List (using a custom widget for the layout).
"""


from PySide2.QtWidgets import QListWidget, QWidget, QLabel, QGridLayout, \
from PySide6.QtWidgets import QListWidget, QWidget, QLabel, QGridLayout, \
QLineEdit, QCheckBox

from xdgprefs.core import MimeType
Expand Down

0 comments on commit c6ea686

Please sign in to comment.