Skip to content

Commit d2bd97f

Browse files
committed
returns the first path that is also writable by the user
1 parent e892b82 commit d2bd97f

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

validphys2/src/validphys/lhaindex.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,12 @@ def get_lha_datapath():
136136
The check for existence intends to solve problems where a previously filled `LHAPATH`
137137
or `LHAPDF_DATA_PATH` environment variable is pointing to a non-existent path or shared
138138
systems where LHAPDF might be compiled with hard-coded paths not available to all users.
139+
140+
We check whether the user is able to write to the path to skip situations in which the user
141+
cannot save grids to the LHAPDF folder but has its own data path (e.g., nix or a cluster).
139142
"""
140143
for lhapath in lhapdf.paths()[::-1]:
141-
if Path(lhapath).exists():
144+
if Path(lhapath).exists() and os.access(lhapath, os.W_OK):
142145
return lhapath
143146
return lhapdf.paths()[-1]
144147

0 commit comments

Comments
 (0)