diff --git a/.gitignore b/.gitignore index 8c1decb1..a4b53997 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ Untitled.ipynb .coverage Configuration/ Experimental_Results/ +venv/* # These are generated folders for cache .ipynb_checkpoints/ @@ -16,4 +17,4 @@ docs/source/_static/ docs/source/_templates/ JADE.egg-info/ jade.egg-info/ -build/ +build/ \ No newline at end of file diff --git a/jade/libmanager.py b/jade/libmanager.py index f7d01e53..43bf6f29 100644 --- a/jade/libmanager.py +++ b/jade/libmanager.py @@ -471,18 +471,20 @@ def select_lib(self, code: str = "mcnp") -> str: """ Prompt an library input selection with Xsdir availabilty check - Returns + Parameters ------- - lib : str - Library to assess. code: str, optional code for which the library is selected. default is MCNP + Returns + ------- + lib : str + Library to assess. """ error = ( CRED + """ - Error: {} + Error: Library {} with code {} The selected library is not available. """ + CEND @@ -492,28 +494,31 @@ def select_lib(self, code: str = "mcnp") -> str: while True: i += 1 lib = input(" Select library (e.g. 31c or 99c-31c): ") - if lib in self.libraries[code]: - break + for library in self.libraries.values(): + if lib in library: + return lib - elif lib[0] == "{": + if len(lib)>0 and lib[0] == "{": libs = json.loads(lib) # all libraries should be available tocheck = list(libs.values()) tocheck.extend(list(libs.keys())) - flag = True + flag = False for val in tocheck: - if val not in self.libraries[code]: - print(error.format(val)) - flag = False + for library in self.libraries.values(): + if val in library: + flag = True if flag: break + else: + print(error.format(val, code)) elif "-" in lib: libs = lib.split("-") flag = True for val in libs: if val not in self.libraries[code]: - print(error.format(val)) + print(error.format(val, code)) flag = False if flag: break @@ -525,7 +530,7 @@ def select_lib(self, code: str = "mcnp") -> str: break else: - print(error.format(lib)) + print(error.format(val, code)) if i > 10: raise ValueError("Too many wrong inputs")