Skip to content

Commit 1c4e5b8

Browse files
committed
add symbiotic link
1 parent 60d99ca commit 1c4e5b8

6 files changed

Lines changed: 36 additions & 14 deletions

File tree

.DS_Store

0 Bytes
Binary file not shown.

Analysis/.DS_Store

0 Bytes
Binary file not shown.

Lab_Dash/.DS_Store

0 Bytes
Binary file not shown.

Lab_Misc/.DS_Store

2 KB
Binary file not shown.

Lab_Misc/Generate.py

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -104,22 +104,44 @@ def get_FilesInCurrFolder(self):
104104

105105
def get_FullPath(self, file):
106106
"""
107-
get_FullPath retruns path of the file
108-
109-
retruns path of the file until '01_Experimental' by connecting file name and the current directory
110-
111-
Parameters
112-
----------
113-
file : string
114-
name of the current file
115-
116-
Returns
117-
-------
118-
string
119-
path of the file
107+
get_FullPath returns path of the file
120108
"""
121109
path_to_file = os.getcwd()
122-
path_to_file = path_to_file[path_to_file.index(BaseFolderName):]
110+
111+
# Fall 1: Der BaseFolderName ist noch im Pfad (kein Symlink oder Symlink wurde nicht aufgelöst)
112+
if BaseFolderName in path_to_file:
113+
path_to_file = path_to_file[path_to_file.index(BaseFolderName):]
114+
else:
115+
# Fall 2: os.getcwd() hat einen Symlink zum physischen Ziel aufgelöst.
116+
# Wir rekonstruieren den logischen Pfad (01_Experimental/...), damit die Datenbank
117+
# und das Frontend wie gewohnt damit arbeiten können.
118+
try:
119+
base_path = get_BasePath()
120+
# Wir durchsuchen alle Experimentenpfade in der Datenbank...
121+
for ep in self.ExpPath_curr.objects.all():
122+
logical_exp_path = os.path.join(base_path, ep.Path)
123+
physical_exp_path = os.path.realpath(logical_exp_path)
124+
125+
# ... und prüfen, ob unser aktueller physischer Pfad zu diesem Experiment gehört
126+
if path_to_file == physical_exp_path or path_to_file.startswith(physical_exp_path + os.sep):
127+
128+
# Welcher Unterordner (z.B. Datum/Probe) ist das?
129+
rel_part = os.path.relpath(path_to_file, physical_exp_path)
130+
131+
# Den logischen Startpfad ab "01_Experimental" isolieren
132+
idx = logical_exp_path.find(BaseFolderName)
133+
if idx != -1:
134+
logical_base = logical_exp_path[idx:]
135+
136+
# Den Unterordner an den logischen Startpfad hängen
137+
if rel_part == '.':
138+
path_to_file = logical_base
139+
else:
140+
path_to_file = os.path.join(logical_base, rel_part)
141+
break
142+
except Exception as e:
143+
pass
144+
123145
path_to_file = os.path.join(path_to_file, file)
124146
path_to_file = path_to_file.replace('\\', '/')
125147

jupyter_config/.DS_Store

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)