Skip to content

Commit 5ff3143

Browse files
committed
Improved how database library labels are created.
Now libraries will not have empty labels if a leaf directory is directly specified by the user.
1 parent 231f664 commit 5ff3143

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

rmgpy/data/kinetics/database.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,16 @@ def load_libraries(self, path, libraries=None):
268268
for f in files:
269269
if f.lower() == 'reactions.py':
270270
library_file = os.path.join(root, f)
271-
label = os.path.dirname(library_file)[len(path) + 1:]
271+
dirname = os.path.dirname(library_file)
272+
if dirname == path:
273+
label = os.path.basename(dirname)
274+
else:
275+
label = os.path.relpath(dirname, path)
276+
277+
if not label:
278+
logging.warning(f"Empty label for {library_file}. Using 'default'.")
279+
label = "default"
280+
272281
logging.info(f'Loading kinetics library {label} from {library_file}...')
273282
library = KineticsLibrary(label=label)
274283
try:

0 commit comments

Comments
 (0)