Skip to content

fix deprecation warning when test #170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/diffpy/pdfgui/control/pdfguicontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def run(self):

def startQueue(self):
"""start queue manager"""
self.queueManager.setDaemon(True)
self.queueManager.daemon = True
self.queueManager.start()

def checkQueue(self):
Expand Down
4 changes: 2 additions & 2 deletions src/diffpy/pdfgui/gui/extendedplotframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,9 @@ def legendBoxProperties():
return _lbp
# figure out matplotlib version and appropriate names
from matplotlib import __version__ as mplver
from pkg_resources import parse_version
from packaging.version import parse

if parse_version(mplver) >= parse_version("0.98.5"):
if parse(mplver) >= parse("0.98.5"):
_lbp = {
"loc": "upper right",
"numpoints": 3, # number of points in the legend line
Expand Down
13 changes: 6 additions & 7 deletions src/diffpy/pdfgui/gui/pdfguiglobals.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
"""This module contains global parameters needed by PDFgui."""

import os.path

from pkg_resources import Requirement, resource_filename
from importlib.resources import files

from diffpy.pdfgui.gui import debugoptions

Expand All @@ -31,23 +30,23 @@
isAltered = False

# Resolve APPDATADIR base path to application data files.
_mydir = os.path.abspath(resource_filename(__name__, ""))
_mydir = os.path.abspath(str(files(__name__)))
_upbasedir = os.path.normpath(_mydir + "/../../..")
_development_mode = os.path.basename(_upbasedir) == "src" and os.path.isfile(
os.path.join(_upbasedir, "../setup.py")
os.path.join(_upbasedir, "../pyproject.toml")
)

# Requirement must have egg-info. Do not use in _development_mode.
_req = Requirement.parse("diffpy.pdfgui")
_req = "diffpy.pdfgui"

# pavol
# APPDATADIR = (os.path.dirname(_upbasedir) if _development_mode
# else resource_filename(_req, ""))
# else str(files(_req)))
# long
if _development_mode:
APPDATADIR = os.path.dirname(_mydir)
else:
APPDATADIR = os.path.join(resource_filename(_req, ""), "diffpy/pdfgui")
APPDATADIR = str(files(_req))

APPDATADIR = os.path.abspath(APPDATADIR)

Expand Down
5 changes: 2 additions & 3 deletions src/diffpy/pdfgui/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,12 @@ def testsuite(pattern=""):
The TestSuite object containing the matching tests.
"""
import re
from importlib.resources import files
from itertools import chain
from os.path import dirname

from pkg_resources import resource_filename

loader = unittest.defaultTestLoader
thisdir = resource_filename(__name__, "")
thisdir = str(files(__name__))
depth = __name__.count(".") + 1
topdir = thisdir
for i in range(depth):
Expand Down
4 changes: 2 additions & 2 deletions src/diffpy/pdfgui/tests/testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@


def datafile(filename):
from pkg_resources import resource_filename
from importlib.resources import files

rv = resource_filename(__name__, "testdata/" + filename)
rv = str(files(__name__).joinpath("testdata", filename))
return rv


Expand Down
7 changes: 3 additions & 4 deletions src/diffpy/pdfgui/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,15 @@
__all__ = ["__date__", "__git_commit__", "__timestamp__", "__version__"]

import os.path

from pkg_resources import resource_filename
from importlib.resources import files

# obtain version information from the version.cfg file
cp = dict(version="", date="", commit="", timestamp="0")
fcfg = resource_filename(__name__, "version.cfg")
fcfg = str(files(__name__).joinpath("version.cfg"))
if not os.path.isfile(fcfg): # pragma: no cover
from warnings import warn

warn('Package metadata not found, execute "./setup.py egg_info".')
warn("Package metadata not found.")
fcfg = os.devnull
with open(fcfg) as fp:
kwords = [[w.strip() for w in line.split(" = ", 1)] for line in fp if line[:1].isalpha() and " = " in line]
Expand Down
Loading