@@ -245,11 +245,31 @@ def inspect_file(
245245 line_strip_no_comment = _remove_comments (True , line_strip ).strip ()
246246 line = _remove_comments (clear_comments , line )
247247
248- if line .upper ().startswith (("INCLUDE" , "GDFILE" , "IMPORT" )):
248+ toks = line .split ()
249+ is_pyaction = len (toks ) > 0 and toks [0 ] == "PYACTION"
250+
251+ if line .upper ().startswith (("INCLUDE" , "GDFILE" , "IMPORT" )) or is_pyaction :
249252 # Include keyword found!
250- logger .info ("%s%s" , indent , "FOUND INCLUDE FILE ==>" )
253+ if is_pyaction :
254+ logger .info ("%s%s" , indent , "FOUND PYACTION SCRIPT ==>" )
255+ else :
256+ logger .info ("%s%s" , indent , "FOUND INCLUDE FILE ==>" )
257+
251258 new_data_file += line
252259
260+ # For PYACTION, handle the first record separately,
261+ # before letting the common code handle the include
262+ if is_pyaction :
263+ while True :
264+ line = next (lines )
265+ line_strip = _normalize_line_endings (line ).strip ()
266+ line_strip = _remove_comments (clear_comments , line_strip )
267+ line_strip_no_comment = _remove_comments (True , line_strip ).strip ()
268+ line = _remove_comments (clear_comments , line )
269+ new_data_file += line
270+ if line_strip_no_comment .find ("/" ) >= 0 :
271+ break
272+
253273 # In the INCLUDE or GDFILE keyword, find the include path and
254274 # ignore comments, continuing iterating the same file handle
255275 # as in the outer loop:
@@ -294,10 +314,11 @@ def inspect_file(
294314 include_filename = _expand_filename (
295315 include_stripped , org_sim_loc
296316 )
297- if file_is_binary (include_filename ):
317+ if file_is_binary (include_filename ) or is_pyaction :
298318 logger .info (
299- "%sThe file %s seems to be binary; we'll simply copy "
300- "this file and skip scanning its contents." ,
319+ "%sThe file %s seems to be binary or a python file;"
320+ "we'll simply copy this file "
321+ "and skip scanning its contents." ,
301322 indent ,
302323 include_stripped ,
303324 )
0 commit comments