diff --git a/Fix-compatibility-with-python-3.8.4.patch b/Fix-compatibility-with-python-3.8.4.patch deleted file mode 100644 index 3ce6f63..0000000 --- a/Fix-compatibility-with-python-3.8.4.patch +++ /dev/null @@ -1,61 +0,0 @@ -From 9b913229ace838958e51a16cabc41905a2460f7b Mon Sep 17 00:00:00 2001 -From: Conrad Kostecki -Date: Tue, 25 Aug 2020 00:24:53 +0200 -Subject: [PATCH] Fix compatibility with >=python-3.8.4 - -Signed-off-by: Conrad Kostecki ---- - xdg/Menu.py | 16 ++++++++++++++-- - 1 file changed, 14 insertions(+), 2 deletions(-) - -diff --git a/xdg/Menu.py b/xdg/Menu.py -index 1d03cad..ee406bd 100644 ---- a/xdg/Menu.py -+++ b/xdg/Menu.py -@@ -21,6 +21,7 @@ import os - import locale - import subprocess - import ast -+import sys - try: - import xml.etree.cElementTree as etree - except ImportError: -@@ -35,6 +36,17 @@ import xdg.Locale - import xdg.Config - - -+def _ast_const(name): -+ if sys.version_info >= (3, 4): -+ name = ast.literal_eval(name) -+ if sys.version_info >= (3, 8): -+ return ast.Constant(name) -+ else: -+ return ast.NameConstant(name) -+ else: -+ return ast.Name(id=name, ctx=ast.Load()) -+ -+ - def _strxfrm(s): - """Wrapper around locale.strxfrm that accepts unicode strings on Python 2. - -@@ -754,7 +766,7 @@ class XMLMenuBuilder(object): - if expr: - tree.body = expr - else: -- tree.body = ast.Name('False', ast.Load()) -+ tree.body = _ast_const('False') - ast.fix_missing_locations(tree) - return Rule(type, tree) - -@@ -781,7 +793,7 @@ class XMLMenuBuilder(object): - expr = self.parse_bool_op(node, ast.Or()) - return ast.UnaryOp(ast.Not(), expr) if expr else None - elif tag == 'All': -- return ast.Name('True', ast.Load()) -+ return _ast_const('True') - elif tag == 'Category': - category = node.text - return ast.Compare( --- -2.39.0.windows.2 - diff --git a/Fix-several-ResourceWarnings-unclosed-file.patch b/Fix-several-ResourceWarnings-unclosed-file.patch deleted file mode 100644 index f8d574e..0000000 --- a/Fix-several-ResourceWarnings-unclosed-file.patch +++ /dev/null @@ -1,174 +0,0 @@ -From 73476af1eecb8e29f2a461e003a2d8a735d22306 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Micka=C3=ABl=20Schoentgen?= -Date: Sun, 9 Dec 2018 17:31:24 +0100 -Subject: [PATCH] Fix several ResourceWarnings: unclosed file - ---- - xdg/IniFile.py | 61 +++++++++++++++++++++++----------------------- - xdg/Mime.py | 9 ++++--- - xdg/RecentFiles.py | 43 ++++++++++++++++---------------- - 3 files changed, 57 insertions(+), 56 deletions(-) - -diff --git a/xdg/IniFile.py b/xdg/IniFile.py -index 718589f..84be614 100644 ---- a/xdg/IniFile.py -+++ b/xdg/IniFile.py -@@ -56,38 +56,37 @@ class IniFile: - return - - # parse file -- for line in fd: -- line = line.strip() -- # empty line -- if not line: -- continue -- # comment -- elif line[0] == '#': -- continue -- # new group -- elif line[0] == '[': -- currentGroup = line.lstrip("[").rstrip("]") -- if debug and self.hasGroup(currentGroup): -- raise DuplicateGroupError(currentGroup, filename) -- else: -- content[currentGroup] = {} -- # key -- else: -- try: -- key, value = line.split("=", 1) -- except ValueError: -- raise ParsingError("Invalid line: " + line, filename) -- -- key = key.strip() # Spaces before/after '=' should be ignored -- try: -- if debug and self.hasKey(key, currentGroup): -- raise DuplicateKeyError(key, currentGroup, filename) -+ with fd: -+ for line in fd: -+ line = line.strip() -+ # empty line -+ if not line: -+ continue -+ # comment -+ elif line[0] == '#': -+ continue -+ # new group -+ elif line[0] == '[': -+ currentGroup = line.lstrip("[").rstrip("]") -+ if debug and self.hasGroup(currentGroup): -+ raise DuplicateGroupError(currentGroup, filename) - else: -- content[currentGroup][key] = value.strip() -- except (IndexError, UnboundLocalError): -- raise ParsingError("Parsing error on key, group missing", filename) -- -- fd.close() -+ content[currentGroup] = {} -+ # key -+ else: -+ try: -+ key, value = line.split("=", 1) -+ except ValueError: -+ raise ParsingError("Invalid line: " + line, filename) -+ -+ key = key.strip() # Spaces before/after '=' should be ignored -+ try: -+ if debug and self.hasKey(key, currentGroup): -+ raise DuplicateKeyError(key, currentGroup, filename) -+ else: -+ content[currentGroup][key] = value.strip() -+ except (IndexError, UnboundLocalError): -+ raise ParsingError("Parsing error on key, group missing", filename) - - self.filename = filename - self.tainted = False -diff --git a/xdg/Mime.py b/xdg/Mime.py -index 3bff8b2..886cb42 100644 ---- a/xdg/Mime.py -+++ b/xdg/Mime.py -@@ -749,14 +749,16 @@ def install_mime_info(application, package_file): - file with the same name (if the contents are different)""" - application += '.xml' - -- new_data = open(package_file).read() -+ with open(package_file) as f: -+ new_data = f.read() - - # See if the file is already installed - package_dir = os.path.join('mime', 'packages') - resource = os.path.join(package_dir, application) - for x in BaseDirectory.load_data_paths(resource): - try: -- old_data = open(x).read() -+ with open(x) as f: -+ old_data = f.read() - except: - continue - if old_data == new_data: -@@ -770,7 +772,8 @@ def install_mime_info(application, package_file): - new_file = os.path.join(BaseDirectory.save_data_path(package_dir), application) - - # Write the file... -- open(new_file, 'w').write(new_data) -+ with open(new_file, 'w') as f: -+ f.write(new_data) - - # Update the database... - command = 'update-mime-database' -diff --git a/xdg/RecentFiles.py b/xdg/RecentFiles.py -index 3038b57..7ee7ee5 100644 ---- a/xdg/RecentFiles.py -+++ b/xdg/RecentFiles.py -@@ -71,28 +71,27 @@ class RecentFiles: - elif not filename: - filename = self.filename - -- f = open(filename, "w") -- fcntl.lockf(f, fcntl.LOCK_EX) -- f.write('\n') -- f.write("\n") -- -- for r in self.RecentFiles: -- f.write(" \n") -- f.write(" %s\n" % xml.sax.saxutils.escape(r.URI)) -- f.write(" %s\n" % r.MimeType) -- f.write(" %s\n" % r.Timestamp) -- if r.Private == True: -- f.write(" \n") -- if len(r.Groups) > 0: -- f.write(" \n") -- for group in r.Groups: -- f.write(" %s\n" % group) -- f.write(" \n") -- f.write(" \n") -- -- f.write("\n") -- fcntl.lockf(f, fcntl.LOCK_UN) -- f.close() -+ with open(filename, "w") as f: -+ fcntl.lockf(f, fcntl.LOCK_EX) -+ f.write('\n') -+ f.write("\n") -+ -+ for r in self.RecentFiles: -+ f.write(" \n") -+ f.write(" %s\n" % xml.sax.saxutils.escape(r.URI)) -+ f.write(" %s\n" % r.MimeType) -+ f.write(" %s\n" % r.Timestamp) -+ if r.Private == True: -+ f.write(" \n") -+ if len(r.Groups) > 0: -+ f.write(" \n") -+ for group in r.Groups: -+ f.write(" %s\n" % group) -+ f.write(" \n") -+ f.write(" \n") -+ -+ f.write("\n") -+ fcntl.lockf(f, fcntl.LOCK_UN) - - def getFiles(self, mimetypes=None, groups=None, limit=0): - """Get a list of recently used files. --- -2.39.0.windows.2 - diff --git a/pyxdg-0.26.tar.gz b/pyxdg-0.26.tar.gz deleted file mode 100644 index 296dac9..0000000 Binary files a/pyxdg-0.26.tar.gz and /dev/null differ diff --git a/pyxdg-0.28-test-example.tar.gz b/pyxdg-0.28-test-example.tar.gz new file mode 100644 index 0000000..3cb519a Binary files /dev/null and b/pyxdg-0.28-test-example.tar.gz differ diff --git a/pyxdg-0.28.tar.gz b/pyxdg-0.28.tar.gz new file mode 100644 index 0000000..893e100 Binary files /dev/null and b/pyxdg-0.28.tar.gz differ diff --git a/pyxdg.spec b/pyxdg.spec index 36a21bc..73058cd 100644 --- a/pyxdg.spec +++ b/pyxdg.spec @@ -1,12 +1,12 @@ Name: pyxdg -Version: 0.26 -Release: 5 +Version: 0.28 +Release: 1 Summary: Python library to access freedesktop APIs License: LGPLv2 URL: http://freedesktop.org/Software/pyxdg Source0: https://pypi.io/packages/source/P/PyXDG/pyxdg-%{version}.tar.gz -Patch0: Fix-several-ResourceWarnings-unclosed-file.patch -Patch1: Fix-compatibility-with-python-3.8.4.patch +# https://gitlab.freedesktop.org/xdg/pyxdg/-/archive/rel-%{version}/pyxdg-rel-%{version}.tar.gz?path=test/example +Source1: pyxdg-0.28-test-example.tar.gz BuildArch: noarch @@ -18,17 +18,17 @@ PyXDG package provides a library to invoke APIs that conform to freedesktop.org %package -n python3-pyxdg Summary: Python3 library to access freedesktop APIs BuildRequires: python%{python3_pkgversion}-devel -%if %{with check} +BuildRequires: python%{python3_pkgversion}-setuptools +BuildRequires: python%{python3_pkgversion}-pytest -BuildRequires: python%{python3_pkgversion}-nose -%endif %{?python_provide:%python_provide python%{python3_pkgversion}-pyxdg} %description -n python%{python3_pkgversion}-pyxdg This package contains a Python 3 version of PyXDG. %prep -%autosetup -p1 +%setup -q -b 1 +cp -r ../pyxdg-rel-%{version}-test-example/test/example test/ %build %py3_build @@ -36,10 +36,9 @@ This package contains a Python 3 version of PyXDG. %install %py3_install -%if %{with check} %check -nosetests-%{python3_version} || : -%endif +export PYTHONPATH=%{buildroot}%{python3_sitelib} +pytest test/test*.py -v %files -n python%{python3_pkgversion}-pyxdg %license COPYING @@ -48,6 +47,9 @@ nosetests-%{python3_version} || : %{python3_sitelib}/pyxdg-*.egg-info %changelog +* Thu Jun 08 2023 yaoxin - 0.28-1 +- Update to 0.28 + * Tue Jan 17 2023 zhangliangpengkun - 0.26-5 - Fix-compatibility-with-python-3.8.4.patch