MCPcopy Create free account
hub / github.com/AstroPrint/AstroBox / extract_comments

Function extract_comments

src/ext/makerbot_driver/Gcode/Utils.py:8–22  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

6
7
8def 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
25def parse_command(command):

Callers 1

parse_lineFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected