lvpyioTools 2.6.2__tar.gz → 2.7.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. {lvpyiotools-2.6.2/src/lvpyioTools.egg-info → lvpyiotools-2.7.0}/PKG-INFO +10 -1
  2. {lvpyiotools-2.6.2 → lvpyiotools-2.7.0}/README.md +1 -0
  3. {lvpyiotools-2.6.2 → lvpyiotools-2.7.0}/pyproject.toml +13 -3
  4. {lvpyiotools-2.6.2 → lvpyiotools-2.7.0}/src/lvpyioTools/scripts/viewer.py +4 -1
  5. {lvpyiotools-2.6.2 → lvpyiotools-2.7.0}/src/lvpyioTools/set.py +64 -28
  6. {lvpyiotools-2.6.2 → lvpyiotools-2.7.0/src/lvpyioTools.egg-info}/PKG-INFO +10 -1
  7. {lvpyiotools-2.6.2 → lvpyiotools-2.7.0}/LICENSE +0 -0
  8. {lvpyiotools-2.6.2 → lvpyiotools-2.7.0}/setup.cfg +0 -0
  9. {lvpyiotools-2.6.2 → lvpyiotools-2.7.0}/src/lvpyioTools/__init__.py +0 -0
  10. {lvpyiotools-2.6.2 → lvpyiotools-2.7.0}/src/lvpyioTools/attribute.py +0 -0
  11. {lvpyiotools-2.6.2 → lvpyiotools-2.7.0}/src/lvpyioTools/calibration.py +0 -0
  12. {lvpyiotools-2.6.2 → lvpyiotools-2.7.0}/src/lvpyioTools/frame.py +0 -0
  13. {lvpyiotools-2.6.2 → lvpyiotools-2.7.0}/src/lvpyioTools/mask.py +0 -0
  14. {lvpyiotools-2.6.2 → lvpyiotools-2.7.0}/src/lvpyioTools/setParser.py +0 -0
  15. {lvpyiotools-2.6.2 → lvpyiotools-2.7.0}/src/lvpyioTools/setProperties.py +0 -0
  16. {lvpyiotools-2.6.2 → lvpyiotools-2.7.0}/src/lvpyioTools/stubs/set.py +0 -0
  17. {lvpyiotools-2.6.2 → lvpyiotools-2.7.0}/src/lvpyioTools/stubs/set.pyi +0 -0
  18. {lvpyiotools-2.6.2 → lvpyiotools-2.7.0}/src/lvpyioTools.egg-info/SOURCES.txt +0 -0
  19. {lvpyiotools-2.6.2 → lvpyiotools-2.7.0}/src/lvpyioTools.egg-info/dependency_links.txt +0 -0
  20. {lvpyiotools-2.6.2 → lvpyiotools-2.7.0}/src/lvpyioTools.egg-info/entry_points.txt +0 -0
  21. {lvpyiotools-2.6.2 → lvpyiotools-2.7.0}/src/lvpyioTools.egg-info/requires.txt +0 -0
  22. {lvpyiotools-2.6.2 → lvpyiotools-2.7.0}/src/lvpyioTools.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lvpyioTools
3
- Version: 2.6.2
3
+ Version: 2.7.0
4
4
  Summary: A set of tools to handle LabView files and data via the lvpyio library.
5
5
  Author-email: SimKDT <simon.cadet79+github@proton.me>
6
6
  License-Expression: MIT
@@ -8,6 +8,14 @@ Project-URL: Homepage, https://github.com/SimKDT/lvpyio-tools
8
8
  Project-URL: Issues, https://github.com/SimKDT/lvpyio-tools/issues
9
9
  Project-URL: Documentation, https://simkdt.github.io/lvpyio-tools
10
10
  Classifier: Programming Language :: Python :: 3.12
11
+ Classifier: Topic :: Scientific/Engineering
12
+ Classifier: Topic :: Scientific/Engineering :: Image Processing
13
+ Classifier: Topic :: Scientific/Engineering :: Visualization
14
+ Classifier: Topic :: Multimedia
15
+ Classifier: Topic :: Multimedia :: Graphics :: Presentation
16
+ Classifier: Topic :: Multimedia :: Graphics :: Viewers
17
+ Classifier: Topic :: Multimedia :: Video
18
+ Classifier: Topic :: Multimedia :: Video :: Display
11
19
  Requires-Python: >=3.12.3
12
20
  Description-Content-Type: text/markdown
13
21
  License-File: LICENSE
@@ -26,6 +34,7 @@ Dynamic: license-file
26
34
  [![License](https://img.shields.io/github/license/SimKDT/lvpyio-tools?label=License)](LICENSE)
27
35
  ![Code Size](https://img.shields.io/github/languages/code-size/SimKDT/lvpyio-tools?label=Code%20Size)
28
36
  [![PyPi Version](https://img.shields.io/pypi/v/lvpyioTools)](https://pypi.org/project/lvpyioTools/)
37
+ [![PyPi Downloads](https://img.shields.io/pypi/dm/lvpyioTools)](https://pypi.org/project/lvpyioTools/)
29
38
  [![Documentation](https://img.shields.io/badge/docs-blue?label=sphinx&logo=sphinx&logoColor=white)](https://simkdt.github.io/lvpyio-tools/)
30
39
 
31
40
  A collection of helper tools to manipulate lvpyio objects such as Sets by using the [lvpyio](https://pypi.org/project/lvpyio/) library.
@@ -3,6 +3,7 @@
3
3
  [![License](https://img.shields.io/github/license/SimKDT/lvpyio-tools?label=License)](LICENSE)
4
4
  ![Code Size](https://img.shields.io/github/languages/code-size/SimKDT/lvpyio-tools?label=Code%20Size)
5
5
  [![PyPi Version](https://img.shields.io/pypi/v/lvpyioTools)](https://pypi.org/project/lvpyioTools/)
6
+ [![PyPi Downloads](https://img.shields.io/pypi/dm/lvpyioTools)](https://pypi.org/project/lvpyioTools/)
6
7
  [![Documentation](https://img.shields.io/badge/docs-blue?label=sphinx&logo=sphinx&logoColor=white)](https://simkdt.github.io/lvpyio-tools/)
7
8
 
8
9
  A collection of helper tools to manipulate lvpyio objects such as Sets by using the [lvpyio](https://pypi.org/project/lvpyio/) library.
@@ -3,11 +3,11 @@ name = "lvpyioTools"
3
3
  description = "A set of tools to handle LabView files and data via the lvpyio library."
4
4
  readme = { file = "README.md", content-type = "text/markdown" }
5
5
  requires-python = ">=3.12.3"
6
- version = "2.6.2"
6
+ version = "2.7.0"
7
7
  license = "MIT"
8
8
  license-files = ["LICENSE"]
9
9
  authors = [
10
- { name = "SimKDT", email = "simon.cadet79+github@proton.me" },
10
+ { name = "SimKDT", email = "simon.cadet79+github@proton.me" },
11
11
  ]
12
12
  dependencies = [
13
13
  "numpy",
@@ -16,7 +16,17 @@ dependencies = [
16
16
  "lvpyio>=1.4.0",
17
17
  ]
18
18
  classifiers = [
19
- "Programming Language :: Python :: 3.12",
19
+ "Programming Language :: Python :: 3.12",
20
+
21
+ "Topic :: Scientific/Engineering",
22
+ "Topic :: Scientific/Engineering :: Image Processing",
23
+ "Topic :: Scientific/Engineering :: Visualization",
24
+
25
+ "Topic :: Multimedia",
26
+ "Topic :: Multimedia :: Graphics :: Presentation",
27
+ "Topic :: Multimedia :: Graphics :: Viewers",
28
+ "Topic :: Multimedia :: Video",
29
+ "Topic :: Multimedia :: Video :: Display",
20
30
  ]
21
31
 
22
32
  [project.urls]
@@ -16,7 +16,10 @@ def main():
16
16
  import argparse
17
17
 
18
18
  doc = __doc__.strip() if __doc__ is not None else "LVPyIO Tools Viewer"
19
- parser = argparse.ArgumentParser(description=doc)
19
+ parser = argparse.ArgumentParser(
20
+ description=doc,
21
+ formatter_class=argparse.RawDescriptionHelpFormatter
22
+ )
20
23
  parser.add_argument("set", type=str, help="Path to the DaVis set file")
21
24
  parser.add_argument("--buffer", type=int, default=0, help="Buffer frame number to display (default: 0)")
22
25
  parser.add_argument("--frame", type=int, default=0, help="Frame number to display (default: 0)")
@@ -32,6 +32,45 @@ else:
32
32
  from .mask import create_mask
33
33
 
34
34
 
35
+ def sanitize_set_path(path: Path | str) -> Path:
36
+ """
37
+ Sanitize the provided set path.
38
+
39
+ This function ensures that the provided path points to a valid .set or .exp file.
40
+ If a directory is provided, it attempts to find a .set or .exp file within that directory.
41
+
42
+ Args:
43
+ path (Path | str): The path to the .set or .exp file, or a set directory.
44
+
45
+ Raises:
46
+ FileNotFoundError: If the provided path does not exist or no .set or .exp file is found in the directory.
47
+ ValueError: If the provided file is not a .set or .exp file.
48
+ FileNotFoundError: If no .set or .exp file is found in the provided directory.
49
+
50
+ Returns:
51
+ Path: The sanitized path to the .set or .exp file.
52
+ """
53
+ path = Path(path)
54
+ if not path.exists():
55
+ raise FileNotFoundError(f"File {path} does not exist.")
56
+
57
+ # if it's a set file already then we simply return it
58
+ if path.is_file():
59
+ if not path.suffix in [".set", ".exp"]:
60
+ raise ValueError(f"Provided set file {path} is not a .set or .exp file.")
61
+
62
+ # if it's a directory then we try to find a .set or .exp file
63
+ # associated to itself
64
+ else:
65
+ set_path = path.parent / (path.stem + ".set")
66
+ exp_path = path.parent / (path.stem + ".exp")
67
+ if set_path.exists():
68
+ path = set_path
69
+ elif exp_path.exists():
70
+ path = exp_path
71
+ else:
72
+ raise FileNotFoundError(f"No .set or .exp file found in directory {path}.")
73
+ return path
35
74
 
36
75
 
37
76
  class LVSet(): # numpydoc ignore=SA01
@@ -64,29 +103,26 @@ class LVSet(): # numpydoc ignore=SA01
64
103
  print(f"Number of frames in the set: {len(set)}")
65
104
  ```
66
105
  """
67
- set: Set | None = None
68
- frames: tuple[LVFrame, ...] | None = None
69
-
70
- def __init__(self, file: Path | str):
71
- file = Path(file)
106
+ def __init__(self, set_path: Path | str):
107
+ # sanitize file
108
+ set_path = sanitize_set_path(set_path)
72
109
 
73
- # verify provided file
74
- if not file.exists():
75
- raise FileNotFoundError(f"File {file} does not exist.")
76
- if not file.is_file():
77
- raise ValueError(f"Provided path {file} is not a file.")
78
- if not file.suffix in [".set", ".exp"]:
79
- raise ValueError(f"Provided file {file} is not a .set or .exp file.")
110
+ self.set_file: Path = set_path
111
+ """Path of the set_file."""
112
+ self.file: Path = set_path
113
+ self.properties: dict[setParser.SetProperty, Any] = self.get_properties()
80
114
 
81
- self.file = file
82
- self.properties = self.get_properties()
115
+ self.set: Set | None = None
116
+ """Holds the active set instance. If None, needs to be first opened with `open()`."""
117
+ self.frames: tuple[LVFrame, ...] | None = None
118
+ """Holds the frames of the currently opened set. If None, the set is not open."""
83
119
 
84
120
  def __repr__(self):
85
121
  if self.is_experiment():
86
- return f"<LVSet: {self.file.name}, experiment set, properties={len(self.properties)}>"
122
+ return f"<LVSet: {self.set_file.name}, experiment set, properties={len(self.properties)}>"
87
123
  if self.is_open():
88
- return f"<LVSet: {self.file.name}, {len(self)} frames, properties={len(self.properties)}>"
89
- return f"<LVSet: {self.file.name}, closed, properties={len(self.properties)}>"
124
+ return f"<LVSet: {self.set_file.name}, {len(self)} frames, properties={len(self.properties)}>"
125
+ return f"<LVSet: {self.set_file.name}, closed, properties={len(self.properties)}>"
90
126
 
91
127
 
92
128
  ## LOADER / SAVER
@@ -130,7 +166,7 @@ class LVSet(): # numpydoc ignore=SA01
130
166
  self.close()
131
167
  if self.is_experiment():
132
168
  raise ValueError(f"Cannot open an experiment set (`.exp`) directly.")
133
- self.set = lv.read_set(self.file)
169
+ self.set = lv.read_set(self.set_file)
134
170
 
135
171
  def close(self):
136
172
  """
@@ -149,7 +185,7 @@ class LVSet(): # numpydoc ignore=SA01
149
185
  """
150
186
  Check if the set is an experiment set (`.exp`).
151
187
  """
152
- return self.file.suffix == ".exp"
188
+ return self.set_file.suffix == ".exp"
153
189
 
154
190
  def get_folder(self, init=True) -> Path:
155
191
  """
@@ -165,7 +201,7 @@ class LVSet(): # numpydoc ignore=SA01
165
201
  Returns:
166
202
  Path: The folder path corresponding to the set file.
167
203
  """
168
- folder = self.file.with_suffix('')
204
+ folder = self.set_file.with_suffix('')
169
205
  if not folder.exists():
170
206
  if init:
171
207
  folder.mkdir(parents=True, exist_ok=True)
@@ -189,7 +225,7 @@ class LVSet(): # numpydoc ignore=SA01
189
225
  return None
190
226
 
191
227
  # get parent theorical path
192
- set_dir = self.file.parent
228
+ set_dir = self.set_file.parent
193
229
  parent_dir = set_dir.parent
194
230
 
195
231
  # find .set or .exp file if exists
@@ -233,7 +269,7 @@ class LVSet(): # numpydoc ignore=SA01
233
269
  list[LVSet]: A list of child sets.
234
270
  """
235
271
  children = []
236
- set_dir = self.file.parent
272
+ set_dir = self.set_file.parent
237
273
  for child_dir in set_dir.iterdir():
238
274
  if child_dir.is_dir():
239
275
  for suffix in [".set", ".exp"]:
@@ -286,11 +322,11 @@ class LVSet(): # numpydoc ignore=SA01
286
322
  """
287
323
  experiment = self.get_experiment()
288
324
  if experiment is None:
289
- warnings.warn(f"No experiment set found for {self.file}. Cannot retrieve calibration.")
325
+ warnings.warn(f"No experiment set found for {self.set_file}. Cannot retrieve calibration.")
290
326
  return None
291
327
 
292
328
  # get calibration file
293
- calibration_file = experiment.file.with_suffix("") / "Properties" / "Calibration" / "Calibration.xml"
329
+ calibration_file = experiment.set_file.with_suffix("") / "Properties" / "Calibration" / "Calibration.xml"
294
330
  if not calibration_file.exists():
295
331
  warnings.warn(f"Calibration file {calibration_file} does not exist. Cannot retrieve calibration.")
296
332
  return None
@@ -318,7 +354,7 @@ class LVSet(): # numpydoc ignore=SA01
318
354
  """
319
355
  Read the set file and display its content.
320
356
  """
321
- with open(self.file, 'r') as f:
357
+ with open(self.set_file, 'r') as f:
322
358
  return f.read().strip()
323
359
 
324
360
  def get_properties(self) -> dict[setParser.SetProperty, Any]:
@@ -328,7 +364,7 @@ class LVSet(): # numpydoc ignore=SA01
328
364
  Returns:
329
365
  dict[SetProperty, Any]: A dictionary containing the set properties and their values.
330
366
  """
331
- return setParser.read(self.file)
367
+ return setParser.read(self.set_file)
332
368
 
333
369
 
334
370
  ## READERS
@@ -469,11 +505,11 @@ if __name__ == "__main__":
469
505
  print(frame)
470
506
 
471
507
  parent = set.get_parent()
472
- print(parent.file if parent is not None else "No parent set found.")
508
+ print(parent.set_file if parent is not None else "No parent set found.")
473
509
 
474
510
  experiment = set.get_experiment()
475
511
  print(experiment)
476
- print(experiment.file if experiment is not None else "No experiment set found.")
512
+ print(experiment.set_file if experiment is not None else "No experiment set found.")
477
513
 
478
514
  calib = set.get_calibration()
479
515
  print(calib)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lvpyioTools
3
- Version: 2.6.2
3
+ Version: 2.7.0
4
4
  Summary: A set of tools to handle LabView files and data via the lvpyio library.
5
5
  Author-email: SimKDT <simon.cadet79+github@proton.me>
6
6
  License-Expression: MIT
@@ -8,6 +8,14 @@ Project-URL: Homepage, https://github.com/SimKDT/lvpyio-tools
8
8
  Project-URL: Issues, https://github.com/SimKDT/lvpyio-tools/issues
9
9
  Project-URL: Documentation, https://simkdt.github.io/lvpyio-tools
10
10
  Classifier: Programming Language :: Python :: 3.12
11
+ Classifier: Topic :: Scientific/Engineering
12
+ Classifier: Topic :: Scientific/Engineering :: Image Processing
13
+ Classifier: Topic :: Scientific/Engineering :: Visualization
14
+ Classifier: Topic :: Multimedia
15
+ Classifier: Topic :: Multimedia :: Graphics :: Presentation
16
+ Classifier: Topic :: Multimedia :: Graphics :: Viewers
17
+ Classifier: Topic :: Multimedia :: Video
18
+ Classifier: Topic :: Multimedia :: Video :: Display
11
19
  Requires-Python: >=3.12.3
12
20
  Description-Content-Type: text/markdown
13
21
  License-File: LICENSE
@@ -26,6 +34,7 @@ Dynamic: license-file
26
34
  [![License](https://img.shields.io/github/license/SimKDT/lvpyio-tools?label=License)](LICENSE)
27
35
  ![Code Size](https://img.shields.io/github/languages/code-size/SimKDT/lvpyio-tools?label=Code%20Size)
28
36
  [![PyPi Version](https://img.shields.io/pypi/v/lvpyioTools)](https://pypi.org/project/lvpyioTools/)
37
+ [![PyPi Downloads](https://img.shields.io/pypi/dm/lvpyioTools)](https://pypi.org/project/lvpyioTools/)
29
38
  [![Documentation](https://img.shields.io/badge/docs-blue?label=sphinx&logo=sphinx&logoColor=white)](https://simkdt.github.io/lvpyio-tools/)
30
39
 
31
40
  A collection of helper tools to manipulate lvpyio objects such as Sets by using the [lvpyio](https://pypi.org/project/lvpyio/) library.
File without changes
File without changes