Skip to content

Commit

Permalink
Parse all lines in app file looking for shebangs to run commands. (#1…
Browse files Browse the repository at this point in the history
…5714)

fixed command parsing so that all lines in the file are parsed
  • Loading branch information
rlizzo committed Nov 17, 2022
1 parent ee517f3 commit 98bcb3d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/lightning_app/utilities/app_commands.py
Expand Up @@ -38,12 +38,13 @@ def _extract_commands_from_file(file_name: str) -> CommandLines:
file_lines = f.readlines()

for line_number, line in enumerate(file_lines):
if line.strip() in APP_COMMAND_LINES_TO_IGNORE:
line = line.strip()
if line in APP_COMMAND_LINES_TO_IGNORE:
continue

# stop parsing at first non-comment line at top of file
if not line.startswith("#"):
break
continue

# remove comment marker and any leading / trailing whitespaces
line = line.lstrip("#").strip()
Expand Down
2 changes: 1 addition & 1 deletion tests/tests_app/utilities/test_app_commands.py
Expand Up @@ -14,7 +14,7 @@
("multiple_commands.txt", ['echo "foo"', 'echo "bar"'], [1, 2]),
("commands_with_mixed_comments_1.txt", ['echo "foo"', 'echo "bar"'], [1, 3]),
("commands_with_mixed_comments_2.txt", ['echo "foo"', 'echo "bar"'], [2, 4]),
("command_after_first_non_comment_line.txt", ['echo "foo"'], [1]),
("command_after_first_non_comment_line.txt", ['echo "foo"', 'echo "bar"'], [2, 4]),
("bang_not_at_start_of_line.txt", ['echo "foo"'], [2]),
("space_between_bang_and_command.txt", ['echo "foo"'], [1]),
("multiple_spaces_between_band_and_command.txt", ['echo "foo"'], [1]),
Expand Down
@@ -1,3 +1,4 @@

# !echo "foo"
import lighting
# !echo "bar"

0 comments on commit 98bcb3d

Please sign in to comment.