jupyter-analysis-tools 1.4.0__py3-none-any.whl → 1.4.3__py3-none-any.whl
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.
- jupyter_analysis_tools/__init__.py +1 -1
- jupyter_analysis_tools/utils.py +56 -9
- {jupyter_analysis_tools-1.4.0.dist-info → jupyter_analysis_tools-1.4.3.dist-info}/METADATA +25 -3
- {jupyter_analysis_tools-1.4.0.dist-info → jupyter_analysis_tools-1.4.3.dist-info}/RECORD +8 -8
- {jupyter_analysis_tools-1.4.0.dist-info → jupyter_analysis_tools-1.4.3.dist-info}/WHEEL +0 -0
- {jupyter_analysis_tools-1.4.0.dist-info → jupyter_analysis_tools-1.4.3.dist-info}/licenses/AUTHORS.rst +0 -0
- {jupyter_analysis_tools-1.4.0.dist-info → jupyter_analysis_tools-1.4.3.dist-info}/licenses/LICENSE +0 -0
- {jupyter_analysis_tools-1.4.0.dist-info → jupyter_analysis_tools-1.4.3.dist-info}/top_level.txt +0 -0
jupyter_analysis_tools/utils.py
CHANGED
|
@@ -106,27 +106,74 @@ def addEnvScriptsToPATH():
|
|
|
106
106
|
os.environ["PATH"] = sep.join(environPATH)
|
|
107
107
|
|
|
108
108
|
|
|
109
|
-
def networkdriveMapping(cmdOutput: str = None):
|
|
109
|
+
def networkdriveMapping(cmdOutput: str = None, resolveNames: bool = True):
|
|
110
110
|
"""Returns a dict of mapping drive letters to network paths (on Windows)."""
|
|
111
111
|
if isWindows():
|
|
112
112
|
if cmdOutput is None:
|
|
113
113
|
proc = subprocess.run(["net", "use"], capture_output=True, text=True, encoding="cp850")
|
|
114
114
|
cmdOutput = proc.stdout
|
|
115
|
+
|
|
116
|
+
def resolveFQDN(uncPath):
|
|
117
|
+
if not resolveNames:
|
|
118
|
+
return uncPath
|
|
119
|
+
parts = uncPath.split("\\")
|
|
120
|
+
idx = [i for i, part in enumerate(parts) if len(part)][0]
|
|
121
|
+
proc = subprocess.run(
|
|
122
|
+
["nslookup", parts[idx]], capture_output=True, text=True, encoding="cp850"
|
|
123
|
+
)
|
|
124
|
+
res = [line.split() for line in proc.stdout.splitlines() if line.startswith("Name:")]
|
|
125
|
+
if len(res) and len(res[0]) == 2:
|
|
126
|
+
parts[idx] = res[0][1]
|
|
127
|
+
return "\\".join(parts)
|
|
128
|
+
|
|
115
129
|
rows = [line.split() for line in cmdOutput.splitlines() if "Windows Network" in line]
|
|
116
|
-
rows =
|
|
117
|
-
|
|
118
|
-
|
|
130
|
+
rows = {
|
|
131
|
+
row[1]: resolveFQDN(row[2])
|
|
132
|
+
for row in rows
|
|
133
|
+
if row[1].endswith(":") and row[2].startswith(r"\\")
|
|
134
|
+
}
|
|
119
135
|
return rows
|
|
136
|
+
else: # Linux (tested) or macOS (untested)
|
|
137
|
+
if cmdOutput is None:
|
|
138
|
+
proc = subprocess.run(["mount"], capture_output=True, text=True)
|
|
139
|
+
cmdOutput = proc.stdout
|
|
140
|
+
|
|
141
|
+
def parse(line):
|
|
142
|
+
# position of last opening parenthesis, start of options list
|
|
143
|
+
lastParen = list(i for i, c in enumerate(line) if "(" == c)[-1]
|
|
144
|
+
line = line[:lastParen].strip()
|
|
145
|
+
spaces = list(i for i, c in enumerate(line) if " " == c)
|
|
146
|
+
fstype = line[spaces[-1] :].strip() # last remaining word is the filesystem type
|
|
147
|
+
line = line[: spaces[-2]].strip() # strip the 'type' indicator as well
|
|
148
|
+
sepIdx = line.find(" on /") # separates destination from mount point
|
|
149
|
+
dest = line[:sepIdx].strip()
|
|
150
|
+
mountpoint = line[sepIdx + 4 :].strip()
|
|
151
|
+
yield (mountpoint, dest, fstype)
|
|
152
|
+
|
|
153
|
+
return {
|
|
154
|
+
mp: dst
|
|
155
|
+
for line in cmdOutput.strip().splitlines()
|
|
156
|
+
for (mp, dst, fstype) in parse(line)
|
|
157
|
+
if fstype in ("nfs", "cifs", "sshfs", "afs", "ext4")
|
|
158
|
+
}
|
|
120
159
|
return {}
|
|
121
160
|
|
|
122
161
|
|
|
123
|
-
def makeNetworkdriveAbsolute(filepath, cmdOutput: str = None):
|
|
162
|
+
def makeNetworkdriveAbsolute(filepath, cmdOutput: str = None, resolveNames: bool = True):
|
|
124
163
|
"""Replaces the drive letter of the given path by the respective network path, if possible."""
|
|
125
|
-
if
|
|
126
|
-
|
|
164
|
+
if filepath.drive.startswith(r"\\"):
|
|
165
|
+
return filepath # it's a UNC path already
|
|
166
|
+
if isWindows():
|
|
167
|
+
drivemap = networkdriveMapping(cmdOutput=cmdOutput, resolveNames=resolveNames)
|
|
127
168
|
prefix = drivemap.get(filepath.drive, None)
|
|
128
169
|
if prefix is not None:
|
|
129
170
|
filepath = Path(prefix).joinpath(*filepath.parts[1:])
|
|
171
|
+
else: # Linux or macOS
|
|
172
|
+
drivemap = networkdriveMapping(cmdOutput=cmdOutput, resolveNames=resolveNames)
|
|
173
|
+
# search for the mountpoint, starting with the longest, most specific, first
|
|
174
|
+
for mp, target in sorted(drivemap.items(), key=lambda tup: len(tup[0]), reverse=True):
|
|
175
|
+
if filepath.is_relative_to(mp):
|
|
176
|
+
return Path(target).joinpath(filepath.relative_to(mp))
|
|
130
177
|
return filepath
|
|
131
178
|
|
|
132
179
|
|
|
@@ -152,7 +199,7 @@ def extract7z(fn, workdir=None):
|
|
|
152
199
|
assert os.path.isfile(os.path.join(workdir, fn)), "Provided 7z archive '{}' not found!".format(
|
|
153
200
|
fn
|
|
154
201
|
)
|
|
155
|
-
print(f"Extracting '{fn}':")
|
|
202
|
+
print(f"Extracting '{fn}': ")
|
|
156
203
|
proc = subprocess.run(
|
|
157
204
|
["7z", "x", fn],
|
|
158
205
|
cwd=workdir,
|
|
@@ -185,7 +232,7 @@ def setPackage(globalsdict):
|
|
|
185
232
|
sys.path.insert(0, searchpath)
|
|
186
233
|
globalsdict["__package__"] = path.name
|
|
187
234
|
globalsdict["__name__"] = path.name
|
|
188
|
-
print(f"Setting the current directory as package '{path.name}'
|
|
235
|
+
print(f"Setting the current directory as package '{path.name}': \n {path}.")
|
|
189
236
|
|
|
190
237
|
|
|
191
238
|
def grouper(iterable, n, fillvalue=None):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: jupyter-analysis-tools
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.3
|
|
4
4
|
Summary: Yet another Python library with helpers and utilities for data analysis and processing.
|
|
5
5
|
Author-email: Ingo Breßler <ingo.bressler@bam.de>, "Brian R. Pauw" <brian.pauw@bam.de>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -35,10 +35,10 @@ Requires-Dist: matplotlib
|
|
|
35
35
|
Requires-Dist: ipywidgets
|
|
36
36
|
Dynamic: license-file
|
|
37
37
|
|
|
38
|
-
# Jupyter Analysis Tools (v1.4.
|
|
38
|
+
# Jupyter Analysis Tools (v1.4.3)
|
|
39
39
|
|
|
40
40
|
[](https://pypi.org/project/jupyter-analysis-tools)
|
|
41
|
-
[](https://github.com/BAMresearch/jupyter-analysis-tools/compare/v1.4.3...main)
|
|
42
42
|
[](https://en.wikipedia.org/wiki/MIT_license)
|
|
43
43
|
[](https://pypi.org/project/jupyter-analysis-tools)
|
|
44
44
|
[](https://pypi.org/project/jupyter-analysis-tools#files)
|
|
@@ -97,6 +97,28 @@ are installed:
|
|
|
97
97
|
|
|
98
98
|
# CHANGELOG
|
|
99
99
|
|
|
100
|
+
## v1.4.3 (2025-08-01)
|
|
101
|
+
|
|
102
|
+
### Bug fixes
|
|
103
|
+
|
|
104
|
+
* **utils**: makeNetworkdriveAbsolute() should return input path if no changes needed ([`2ec96d7`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/2ec96d7066a3473c6d27a6e6d01c640f6c142346))
|
|
105
|
+
|
|
106
|
+
## v1.4.2 (2025-08-01)
|
|
107
|
+
|
|
108
|
+
### Bug fixes
|
|
109
|
+
|
|
110
|
+
* **utils**: makeNetworkdriveAbsolute() with FQDN resolution ([`f4591fb`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/f4591fb46dcfeafbb1f63c4323efbb8aea302a92))
|
|
111
|
+
|
|
112
|
+
## v1.4.1 (2025-08-01)
|
|
113
|
+
|
|
114
|
+
### Bug fixes
|
|
115
|
+
|
|
116
|
+
* **utils**: networkdriveMapping() for Linux, with tests ([`3f4deeb`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/3f4deebdf57cc9162121c26d5d7d8484f1f0ec63))
|
|
117
|
+
|
|
118
|
+
### Testing
|
|
119
|
+
|
|
120
|
+
* **utils**: remove debug output, should work now ([`1117c89`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/1117c89d4206c6880373e3b8765dff6e48d3ccd5))
|
|
121
|
+
|
|
100
122
|
## v1.4.0 (2025-07-28)
|
|
101
123
|
|
|
102
124
|
### Continuous integration
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
jupyter_analysis_tools/__init__.py,sha256=
|
|
1
|
+
jupyter_analysis_tools/__init__.py,sha256=ZWwqIRGKVRxOwNMzr6UyicWL5Y9elQGg373dGP1Mq08,398
|
|
2
2
|
jupyter_analysis_tools/analysis.py,sha256=AiAvUO648f0PYXqLfal1kDH926neasE5c1RYFu9wtYg,1768
|
|
3
3
|
jupyter_analysis_tools/binning.py,sha256=d6eXRC3IOnnJIF25OfEASyWedT71EX2nF7jAgGJ9suQ,14536
|
|
4
4
|
jupyter_analysis_tools/datalocations.py,sha256=BakfiZOMcBwp-_DAn7l57lGWZmZGNnk0j73V75nLBUA,4322
|
|
@@ -6,11 +6,11 @@ jupyter_analysis_tools/distrib.py,sha256=uyh2jXDdXR6dfd36CAoE5_psoFF0bfA6l1wletP
|
|
|
6
6
|
jupyter_analysis_tools/git.py,sha256=mqSk5nnAFrmk1_2KFuKVrDWOkRbGbAQOq2N1DfxhNpg,2216
|
|
7
7
|
jupyter_analysis_tools/plotting.py,sha256=X5Orrwiof-9MuYMKDJEXIlIt0K6bQT6ktFFjXKIVApI,1962
|
|
8
8
|
jupyter_analysis_tools/readdata.py,sha256=kHbGh7sp3lbpxuHASmCUVZsfH45JCIxMzgSnbq-Pgoo,6883
|
|
9
|
-
jupyter_analysis_tools/utils.py,sha256=
|
|
9
|
+
jupyter_analysis_tools/utils.py,sha256=c8q2-0v7wEjJ_3w5YTZdjFSf-RP1gPUpMJpv5KUyilU,8800
|
|
10
10
|
jupyter_analysis_tools/widgets.py,sha256=rA8qPvY9nS1OtykZwXtCTG29K-N_MYFVb5Aj8yK40_s,2996
|
|
11
|
-
jupyter_analysis_tools-1.4.
|
|
12
|
-
jupyter_analysis_tools-1.4.
|
|
13
|
-
jupyter_analysis_tools-1.4.
|
|
14
|
-
jupyter_analysis_tools-1.4.
|
|
15
|
-
jupyter_analysis_tools-1.4.
|
|
16
|
-
jupyter_analysis_tools-1.4.
|
|
11
|
+
jupyter_analysis_tools-1.4.3.dist-info/licenses/AUTHORS.rst,sha256=-twUESsY0XqFQ0MIC0ylKhglNwL8lyHmGXriM3RF-2s,93
|
|
12
|
+
jupyter_analysis_tools-1.4.3.dist-info/licenses/LICENSE,sha256=jRVl3hmCq0Qv1wifm-EelEKhFWecdoWdhcxSte4a1_c,1125
|
|
13
|
+
jupyter_analysis_tools-1.4.3.dist-info/METADATA,sha256=mwfPFJK0SJL_HGSfjiLbtWfMclgyQufodabdsqhKgu0,44709
|
|
14
|
+
jupyter_analysis_tools-1.4.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
15
|
+
jupyter_analysis_tools-1.4.3.dist-info/top_level.txt,sha256=ei_0x-BF85FLoJ_h67ySwDFowtqus_gI4_0GR466PEU,23
|
|
16
|
+
jupyter_analysis_tools-1.4.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
{jupyter_analysis_tools-1.4.0.dist-info → jupyter_analysis_tools-1.4.3.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
{jupyter_analysis_tools-1.4.0.dist-info → jupyter_analysis_tools-1.4.3.dist-info}/top_level.txt
RENAMED
|
File without changes
|