Skip to content

Commit e0f1f66

Browse files
committed
ImageIOHandler: removed add_change_path and adapt_path methods
1 parent 5fa36b2 commit e0f1f66

File tree

4 files changed

+34
-44
lines changed

4 files changed

+34
-44
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# Changelog #
22

3+
## Version 2.2.1 ##
4+
5+
Changes:
6+
7+
* Image plot items deserialization:
8+
* When an image plot item is deserialized, and needs to be reloaded from a file,
9+
the file path is adapted to the current working directory if file is not found
10+
(this is the legacy behavior).
11+
* An unnecessary call to `ImageIOHandler.adapt_path` method was removed from the
12+
`RawImageItem.deserialize` method: this issue has to be handled by the host
13+
application, not by the PlotPy library.
14+
* `ImageIOHandler`: removed `add_change_path` and `adapt_path` methods
15+
316
## Version 2.2.0 ##
417

518
In this release, test coverage is 75%.

plotpy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
.. _GitHub: https://github.com/PierreRaybaut/plotpy
2121
"""
2222

23-
__version__ = "2.2.0"
23+
__version__ = "2.2.1"
2424
__VERSION__ = tuple([int(number) for number in __version__.split(".")])
2525

2626
# --- Important note: DATAPATH and LOCALEPATH are used by guidata.configtools

plotpy/io.py

Lines changed: 20 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,6 @@ class ImageIOHandler:
136136

137137
def __init__(self):
138138
self.filetypes = []
139-
self.select_func = None
140-
self.prec_path = None # le précédent path proposé pour actualisation
141139

142140
def allfilters(self, action, dtype, template):
143141
"""
@@ -226,34 +224,6 @@ def get_writefunc(self, ext):
226224
else:
227225
return ftype.write_func
228226

229-
def add_change_path(self, select_func):
230-
self.select_func = select_func
231-
232-
def adapt_path(self, filename):
233-
"""Change le path du fichier si nécessaire avec l'aide de l'utilisateur"""
234-
if not osp.exists(filename):
235-
old_path = osp.dirname(filename)
236-
basename = osp.basename(filename)
237-
if self.prec_path is None:
238-
# on demande à l'utilisateur
239-
self.prec_path = self.select_func(old_path, basename)
240-
241-
# on essait avec le path proposé
242-
filename = osp.join(self.prec_path, basename)
243-
if not osp.exists(filename):
244-
# on essait avec le path proposé et la fin du path précédent
245-
# (cas de la double numérisation)
246-
head, tail = osp.split(old_path)
247-
filename = osp.join(self.prec_path, tail, basename)
248-
if not osp.exists(filename):
249-
raise ImportError(
250-
"le fichier "
251-
+ basename
252-
+ " n'a pas été trouvé dans le répertoire"
253-
+ self.prec_path
254-
)
255-
return filename
256-
257227

258228
iohandler = ImageIOHandler()
259229

@@ -689,9 +659,11 @@ def item_name_from_object(obj: Any) -> str | None:
689659

690660

691661
def save_item(
692-
writer: guidata.dataset.io.HDF5Writer
693-
| guidata.dataset.io.INIWriter
694-
| guidata.dataset.io.JSONWriter,
662+
writer: (
663+
guidata.dataset.io.HDF5Writer
664+
| guidata.dataset.io.INIWriter
665+
| guidata.dataset.io.JSONWriter
666+
),
695667
group_name,
696668
item: Any,
697669
) -> None:
@@ -712,9 +684,11 @@ def save_item(
712684

713685

714686
def load_item(
715-
reader: guidata.dataset.io.HDF5Reader
716-
| guidata.dataset.io.INIReader
717-
| guidata.dataset.io.JSONReader,
687+
reader: (
688+
guidata.dataset.io.HDF5Reader
689+
| guidata.dataset.io.INIReader
690+
| guidata.dataset.io.JSONReader
691+
),
718692
group_name,
719693
) -> Any | None:
720694
"""Load plot item from HDF5, INI or JSON file
@@ -740,9 +714,11 @@ def load_item(
740714

741715

742716
def save_items(
743-
writer: guidata.dataset.io.HDF5Writer
744-
| guidata.dataset.io.INIWriter
745-
| guidata.dataset.io.JSONWriter,
717+
writer: (
718+
guidata.dataset.io.HDF5Writer
719+
| guidata.dataset.io.INIWriter
720+
| guidata.dataset.io.JSONWriter
721+
),
746722
items: list[Any],
747723
) -> None:
748724
"""Save items to HDF5, INI or JSON file
@@ -769,9 +745,11 @@ def _get_name(item):
769745

770746

771747
def load_items(
772-
reader: guidata.dataset.io.HDF5Reader
773-
| guidata.dataset.io.INIReader
774-
| guidata.dataset.io.JSONReader,
748+
reader: (
749+
guidata.dataset.io.HDF5Reader
750+
| guidata.dataset.io.INIReader
751+
| guidata.dataset.io.JSONReader
752+
),
775753
) -> list[Any]:
776754
"""Load items from HDF5, INI or JSON file
777755

plotpy/items/image/base.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1264,7 +1264,6 @@ def deserialize(
12641264
lut_range = reader.read(group_name="lut_range")
12651265
if reader.read(group_name="load_from_fname"):
12661266
name = reader.read(group_name="fname", func=reader.read_unicode)
1267-
name = io.iohandler.adapt_path(name)
12681267
self.set_filename(name)
12691268
self.load_data()
12701269
else:

0 commit comments

Comments
 (0)