Parse a line of gcode, stripping semicolon and parenthesis-separated comments from it. @param string line gcode line to read in @return tuple containing the non-comment portion of the command, and any comments
(line)
| 6 | |
| 7 | |
| 8 | def extract_comments(line): |
| 9 | """ |
| 10 | Parse a line of gcode, stripping semicolon and parenthesis-separated comments from it. |
| 11 | @param string line gcode line to read in |
| 12 | @return tuple containing the non-comment portion of the command, and any comments |
| 13 | """ |
| 14 | |
| 15 | # Anything after the first semicolon is a comment |
| 16 | semicolon_free_line, x, comment = line.partition(';') |
| 17 | |
| 18 | paren_count = 0 |
| 19 | command, x, paren_comment = semicolon_free_line.partition('(') |
| 20 | unified_comment = '%s%s' % (paren_comment, comment) |
| 21 | |
| 22 | return command, unified_comment |
| 23 | |
| 24 | |
| 25 | def parse_command(command): |