From 3345982a49e3ae6c64a95d4caac01106c26d7f0e Mon Sep 17 00:00:00 2001 From: Craig Warren Date: Fri, 7 Feb 2020 11:47:17 +0000 Subject: [PATCH] Update reading of materials file to allow comments without double hashes. --- gprMax/input_cmds_geometry.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gprMax/input_cmds_geometry.py b/gprMax/input_cmds_geometry.py index 8c66b3cc..cf2085b4 100644 --- a/gprMax/input_cmds_geometry.py +++ b/gprMax/input_cmds_geometry.py @@ -78,7 +78,8 @@ def process_geometrycmds(geometry, G): geofile = tmp[4] matfile = tmp[5] - # See if material file exists at specified path and if not try input file directory + # See if material file exists at specified path and if not try input + # file directory if not os.path.isfile(matfile): matfile = os.path.abspath(os.path.join(G.inputdirectory, matfile)) @@ -87,8 +88,9 @@ def process_geometrycmds(geometry, G): # Read materials from file with open(matfile, 'r') as f: - # Strip out any newline characters and comments that must begin with double hashes - materials = [line.rstrip() + '{' + matstr + '}\n' for line in f if(not line.startswith('##') and line.rstrip('\n'))] + # Read any lines that begin with a hash. Strip out any newline + # characters and comments that must begin with double hashes. + materials = [line.rstrip() + '{' + matstr + '}\n' for line in f if(line.startswith('#') and not line.startswith('##') and line.rstrip('\n'))] # Check validity of command names singlecmdsimport, multicmdsimport, geometryimport = check_cmd_names(materials, checkessential=False)