cellpy 1.0.1.post3__tar.gz → 1.0.2a2__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 (92) hide show
  1. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/PKG-INFO +1 -1
  2. cellpy-1.0.2a2/cellpy/_version.py +1 -0
  3. cellpy-1.0.2a2/cellpy/internals/core.py +171 -0
  4. cellpy-1.0.1.post3/cellpy/internals/core.py → cellpy-1.0.2a2/cellpy/internals/otherpath.py +1366 -913
  5. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy.egg-info/PKG-INFO +1 -1
  6. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy.egg-info/SOURCES.txt +1 -0
  7. cellpy-1.0.1.post3/cellpy/_version.py +0 -1
  8. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/AUTHORS.md +0 -0
  9. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/CONTRIBUTING.md +0 -0
  10. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/HISTORY.md +0 -0
  11. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/LICENSE.md +0 -0
  12. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/MANIFEST.in +0 -0
  13. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/README.md +0 -0
  14. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/__init__.py +0 -0
  15. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/cli.py +0 -0
  16. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/exceptions.py +0 -0
  17. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/internals/__init__.py +0 -0
  18. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/log.py +0 -0
  19. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/logging.json +0 -0
  20. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/parameters/.cellpy_prms_default.conf +0 -0
  21. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/parameters/__init__.py +0 -0
  22. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/parameters/internal_settings.py +0 -0
  23. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/parameters/legacy/__init__.py +0 -0
  24. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/parameters/legacy/update_headers.py +0 -0
  25. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/parameters/prmreader.py +0 -0
  26. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/parameters/prms.py +0 -0
  27. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/readers/__init__.py +0 -0
  28. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/readers/cellreader.py +0 -0
  29. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/readers/core.py +0 -0
  30. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/readers/dbreader.py +0 -0
  31. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/readers/do.py +0 -0
  32. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/readers/filefinder.py +0 -0
  33. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/readers/instruments/__init__.py +0 -0
  34. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/readers/instruments/arbin_res.py +0 -0
  35. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/readers/instruments/arbin_sql.py +0 -0
  36. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/readers/instruments/arbin_sql_7.py +0 -0
  37. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/readers/instruments/arbin_sql_csv.py +0 -0
  38. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/readers/instruments/arbin_sql_h5.py +0 -0
  39. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/readers/instruments/arbin_sql_xlsx.py +0 -0
  40. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/readers/instruments/base.py +0 -0
  41. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/readers/instruments/biologics_mpr.py +0 -0
  42. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/readers/instruments/configurations/__init__.py +0 -0
  43. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/readers/instruments/configurations/maccor_txt_one.py +0 -0
  44. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/readers/instruments/configurations/maccor_txt_three.py +0 -0
  45. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/readers/instruments/configurations/maccor_txt_two.py +0 -0
  46. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/readers/instruments/configurations/maccor_txt_zero.py +0 -0
  47. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/readers/instruments/configurations/neware_txt_zero.py +0 -0
  48. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/readers/instruments/custom.py +0 -0
  49. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/readers/instruments/ext_nda_reader.py +0 -0
  50. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/readers/instruments/loader_specific_modules/__init__.py +0 -0
  51. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/readers/instruments/loader_specific_modules/biologic_file_format.py +0 -0
  52. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/readers/instruments/local_instrument.py +0 -0
  53. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/readers/instruments/maccor_txt.py +0 -0
  54. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/readers/instruments/neware_txt.py +0 -0
  55. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/readers/instruments/neware_xlsx.py +0 -0
  56. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/readers/instruments/pec_csv.py +0 -0
  57. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/readers/instruments/processors/__init__.py +0 -0
  58. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/readers/instruments/processors/post_processors.py +0 -0
  59. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/readers/instruments/processors/pre_processors.py +0 -0
  60. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/readers/sql_dbreader.py +0 -0
  61. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/utils/__init__.py +0 -0
  62. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/utils/batch.py +0 -0
  63. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/utils/batch_tools/__init__.py +0 -0
  64. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/utils/batch_tools/batch_analyzers.py +0 -0
  65. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/utils/batch_tools/batch_core.py +0 -0
  66. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/utils/batch_tools/batch_experiments.py +0 -0
  67. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/utils/batch_tools/batch_exporters.py +0 -0
  68. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/utils/batch_tools/batch_helpers.py +0 -0
  69. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/utils/batch_tools/batch_journals.py +0 -0
  70. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/utils/batch_tools/batch_plotters.py +0 -0
  71. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/utils/batch_tools/batch_reporters.py +0 -0
  72. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/utils/batch_tools/dumpers.py +0 -0
  73. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/utils/batch_tools/engines.py +0 -0
  74. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/utils/batch_tools/sqlite_from_excel_db.py +0 -0
  75. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/utils/collectors.py +0 -0
  76. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/utils/diagnostics.py +0 -0
  77. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/utils/easyplot.py +0 -0
  78. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/utils/example_data.py +0 -0
  79. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/utils/helpers.py +0 -0
  80. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/utils/ica.py +0 -0
  81. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/utils/live.py +0 -0
  82. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/utils/ocv_rlx.py +0 -0
  83. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/utils/plotutils.py +0 -0
  84. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy/utils/processor.py +0 -0
  85. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy.egg-info/dependency_links.txt +0 -0
  86. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy.egg-info/entry_points.txt +0 -0
  87. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy.egg-info/not-zip-safe +0 -0
  88. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy.egg-info/requires.txt +0 -0
  89. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/cellpy.egg-info/top_level.txt +0 -0
  90. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/pyproject.toml +0 -0
  91. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/setup.cfg +0 -0
  92. {cellpy-1.0.1.post3 → cellpy-1.0.2a2}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cellpy
3
- Version: 1.0.1.post3
3
+ Version: 1.0.2a2
4
4
  Summary: Extract and manipulate data from battery data testers.
5
5
  Home-page: https://github.com/jepegit/cellpy
6
6
  Author: Jan Petter Maehlen
@@ -0,0 +1 @@
1
+ __version__ = "1.0.2a2"
@@ -0,0 +1,171 @@
1
+ """This module contains div classes etc that are not really connected to cellpy."""
2
+
3
+ from dataclasses import dataclass
4
+ import fnmatch
5
+ import logging
6
+ import os
7
+ import pathlib
8
+ import shutil
9
+ import stat
10
+ import sys
11
+ import tempfile
12
+ import time
13
+ import warnings
14
+ from typing import (
15
+ Any,
16
+ Tuple,
17
+ Dict,
18
+ List,
19
+ Union,
20
+ TypeVar,
21
+ Generator,
22
+ Optional,
23
+ Iterable,
24
+ Callable,
25
+ Type,
26
+ cast,
27
+ )
28
+
29
+ import fabric
30
+
31
+ from cellpy.exceptions import UnderDefined
32
+ from cellpy.internals import otherpath
33
+ from cellpy.internals.otherpath import (
34
+ URI_PREFIXES,
35
+ IMPLEMENTED_PROTOCOLS,
36
+ ENV_VAR_CELLPY_KEY_FILENAME,
37
+ ENV_VAR_CELLPY_PASSWORD,
38
+ )
39
+
40
+ OtherPath = otherpath.get_otherpath_class()
41
+
42
+
43
+ def check_connection(
44
+ p=None,
45
+ ):
46
+ """Check if the connection works.
47
+
48
+ This is a helper function for cellpy v1.0 only and should be removed in later versions after
49
+ the OtherPath class has been updated to work with python >= 3.12.
50
+
51
+ Args:
52
+ p (str, pathlib.Path or OtherPath, optional): The path to check. Defaults to prms.Paths.rawdatadir.
53
+
54
+ """
55
+ # Note: users run this function from helpers.py
56
+ from pprint import pprint
57
+
58
+ logging.debug("checking connection")
59
+ if p is None:
60
+ print("No path given. Checking rawdatadir from prms.")
61
+
62
+ # need to import prms here to avoid circular imports:
63
+ from cellpy import prms
64
+
65
+ p = prms.Paths.rawdatadir
66
+
67
+ # recreating the OtherPath object to OtherPath since core is imported in the top __init__.py
68
+ # file resulting in isinstance(p, OtherPath) to be False
69
+ p = OtherPath(p)
70
+ logging.debug(f"p: {p}")
71
+
72
+ print("\nCollecting connection information:")
73
+
74
+ if not p.is_external:
75
+ print(f" - {p} is not external. Returning.")
76
+ return {}
77
+
78
+ info = {
79
+ "is_external": p.is_external,
80
+ "uri_prefix": p.uri_prefix,
81
+ "location": p.location,
82
+ "raw_path": p.raw_path,
83
+ "full_path": p.full_path,
84
+ "host": p.location,
85
+ }
86
+
87
+ uri_prefix = p.uri_prefix.replace("//", "")
88
+ info["uri_prefix"] = uri_prefix
89
+ if uri_prefix not in URI_PREFIXES:
90
+ print(f" - uri_prefix {uri_prefix} not recognized")
91
+ if uri_prefix not in IMPLEMENTED_PROTOCOLS:
92
+ print(f" - uri_prefix {uri_prefix.replace(':', '')} not implemented yet")
93
+
94
+ password = os.getenv(ENV_VAR_CELLPY_PASSWORD, None)
95
+ info["password"] = "********" if password is not None else None
96
+
97
+ key_filename = os.getenv(ENV_VAR_CELLPY_KEY_FILENAME, None)
98
+ if password is None and key_filename is None:
99
+ print(
100
+ f" - You must define either {ENV_VAR_CELLPY_PASSWORD} "
101
+ f"or {ENV_VAR_CELLPY_KEY_FILENAME} environment variables."
102
+ )
103
+ if key_filename is not None:
104
+ key_filename = pathlib.Path(key_filename).expanduser().resolve()
105
+ info["key_filename"] = str(key_filename)
106
+ if not pathlib.Path(key_filename).is_file():
107
+ print(f" - Could not find key file {key_filename}")
108
+ else:
109
+ print(" - Using password")
110
+
111
+ for k, v in info.items():
112
+ print(f" {k}: {v}")
113
+
114
+ print("\nChecking connection:")
115
+ connect_kwargs, host = p.connection_info()
116
+
117
+ path_separator = "/" # only supports unix-like systems
118
+ with fabric.Connection(host, connect_kwargs=connect_kwargs) as conn:
119
+ try:
120
+ t1 = time.perf_counter()
121
+ try:
122
+ sftp_conn = conn.sftp()
123
+ except Exception as e:
124
+ print(f" - Could not connect to {host}")
125
+ print(f" {e}")
126
+ return info
127
+
128
+ print(f" connecting [{time.perf_counter() - t1:.2f} seconds] OK")
129
+ sftp_conn.chdir(p.raw_path)
130
+ print(f" chdir [{time.perf_counter() - t1:.2f} seconds] OK")
131
+ files = [
132
+ f"{p.raw_path}{path_separator}{f}"
133
+ for f in sftp_conn.listdir()
134
+ if not stat.S_ISDIR(sftp_conn.stat(f).st_mode)
135
+ ]
136
+ print(f" listing files [{time.perf_counter() - t1:.2f} seconds] OK")
137
+ sub_dirs = [
138
+ f"{p.raw_path}{path_separator}{f}"
139
+ for f in sftp_conn.listdir()
140
+ if stat.S_ISDIR(sftp_conn.stat(f).st_mode)
141
+ ]
142
+ n_files = len(files)
143
+ n_sub_dirs = len(sub_dirs)
144
+ info["number_of_files"] = n_files
145
+ info["number_of_sub_directories"] = n_sub_dirs
146
+ print(f" found {n_files} files and {n_sub_dirs} sub directories")
147
+
148
+ except FileNotFoundError as e:
149
+ print(
150
+ f" - FileNotFoundError: Could not perform directory listing in {p.raw_path} on {host}."
151
+ f"\n {e}"
152
+ )
153
+
154
+ return info
155
+
156
+
157
+ def _check():
158
+ print("Testing OtherPath-connection")
159
+ # info = check_connection()
160
+ p0 = "scp://odin/home/jepe@ad.ife.no/projects"
161
+ # info = check_connection(p0)
162
+ p1 = "scp://odin/home/jepe@ad.ife.no/this-folder-does-not-exist"
163
+ # info = check_connection(p1)
164
+ p2 = pathlib.Path(".").resolve()
165
+ info = check_connection(p2)
166
+
167
+
168
+ if __name__ == "__main__":
169
+ print("------------------")
170
+ logging.debug("testing OtherPath")
171
+ _check()