diff --git a/pyNastran/bdf/bdf_interface/include_file.py b/pyNastran/bdf/bdf_interface/include_file.py index ef432ea60..4c586bd83 100644 --- a/pyNastran/bdf/bdf_interface/include_file.py +++ b/pyNastran/bdf/bdf_interface/include_file.py @@ -8,7 +8,7 @@ import posixpath from typing import Optional from pathlib import Path, PurePosixPath, PureWindowsPath -from pyNastran.utils import PathLike +from pyNastran.utils import print_bad_path, PathLike from pyNastran.bdf.errors import EnvironmentVariableError IS_WINDOWS = 'nt' in os.name @@ -65,6 +65,7 @@ def get_include_filename(card_lines: list[str], break elif debug: print(f'could not find {filename}') + print(print_bad_path(filename)) else: #if 1: msg = f'Could not find INCLUDE line:\n{card_lines}\n' @@ -72,7 +73,7 @@ def get_include_filename(card_lines: list[str], msg += f' include_dirs:\n - ' + '\n - '.join(str(val) for val in include_dirs) #if debug: msg += ' environment:' - for key, value in os.environ.items(): + for key, value in sorted(os.environ.items()): msg += f' {key}: {value!r}\n' #else: #msg += f' environment_keys: {list(key for key in os.environ)}' @@ -180,11 +181,11 @@ def split_tokens(tokens: tuple[str], is_windows: bool, for itoken, token in enumerate(tokens): # this is technically legal... # INCLUDE '/testdir/dir1/dir2/*/myfile.dat' - assert '*' not in token, '* in path not supported; tokens={tokens}' + assert '*' not in token, f'* in path not supported; tokens={tokens}' if is_windows: - assert '$' not in token, '$ in path not supported; tokens={tokens}' + assert '$' not in token, f'$ in path not supported; tokens={tokens}' else: - assert '%' not in token, '%% in path not supported; tokens={tokens}' + assert '%' not in token, f'%% in path not supported; tokens={tokens}' if itoken == 0 and is_mac_linux and ':' in token: tokensi, stokens = split_drive_token( @@ -228,8 +229,8 @@ def split_tokens(tokens: tuple[str], is_windows: bool, environment_variables = list(os.environ.keys()) environment_variables.sort() raise EnvironmentVariableError( - f"Can't find environment variable={repr(env_var)}" - f'\nenviron={environment_variables}\n' + f"Can't find environment variable={repr(env_var)}\n" + f'environ={environment_variables}\n' f'which is required for {repr(tokens)}') env_vari = os.path.expandvars('$' + env_var.strip('%')) diff --git a/pyNastran/bdf/test/unit/test_read_write.py b/pyNastran/bdf/test/unit/test_read_write.py index 17378b7c7..ba1214337 100644 --- a/pyNastran/bdf/test/unit/test_read_write.py +++ b/pyNastran/bdf/test/unit/test_read_write.py @@ -694,7 +694,7 @@ def test_dollar_envs(self): pth = "INCLUDE '%Satellite_V02_bddm%:Satellite_V02_Materiaux.blk'" pth2 = get_include_filename( - [pth], include_dirs=TEST_PATH, + [pth], include_dirs='', is_windows=True, debug=True) #print(pth2) @@ -706,7 +706,7 @@ def set_path_keys(paths: dict[str, Path]) -> None: """sets environment variables""" for key, path in paths.items(): assert os.path.exists(path), print_bad_path(path) - os.environ[key] = str(path) + os.environ[key] = os.path.abspath(path) if __name__ == '__main__': # pragma: no cover diff --git a/pyNastran/dev/bdf_vectorized2/bdf_vectorized.py b/pyNastran/dev/bdf_vectorized2/bdf_vectorized.py index 57ef752c3..75da31d05 100644 --- a/pyNastran/dev/bdf_vectorized2/bdf_vectorized.py +++ b/pyNastran/dev/bdf_vectorized2/bdf_vectorized.py @@ -1233,6 +1233,8 @@ def include_zip(self, bdf_filename: Optional[str]=None, log=self.log, debug=self.debug) main_lines = obj.get_main_lines(self.bdf_filename) all_lines, ilines = obj.lines_to_deck_lines(main_lines, make_ilines=make_ilines) + if not make_ilines: + ilines = None self._set_pybdf_attributes(obj, save_file_structure=False) return all_lines, ilines