Skip to content

Commit

Permalink
more debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveDoyle2 committed Nov 12, 2024
1 parent 8410cd0 commit 8b48c70
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
15 changes: 8 additions & 7 deletions pyNastran/bdf/bdf_interface/include_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -65,14 +65,15 @@ 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'
msg += f' filename: {os.path.abspath(filename_raw)}\n'
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)}'
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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('%'))
Expand Down
4 changes: 2 additions & 2 deletions pyNastran/bdf/test/unit/test_read_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions pyNastran/dev/bdf_vectorized2/bdf_vectorized.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 8b48c70

Please sign in to comment.