gcode_reader.read ================= .. py:module:: gcode_reader.read Functions --------- .. autoapisummary:: gcode_reader.read.apply_word_abstractions gcode_reader.read.read_gcode_file gcode_reader.read.read_gcode_line Module Contents --------------- .. py:function:: apply_word_abstractions(word_map: dict, words: dict) -> dict Translates a dictionary of G-code words into abstract command concepts. Uses a word map to reverse-map concrete G-code words (e.g., 'X', 'F') into their abstract representations (e.g., 'location', 'feed_rate'). Modifies `words` in-place by adding the abstract keys, then returns it. :param word_map: A dictionary mapping abstract concepts to their G-code word representations. See `syntax.flavors` for examples. :type word_map: dict :param words: Parsed G-code words from a single line. :type words: dict :returns: The same `words` dict, with abstract keys added. :rtype: dict .. py:function:: read_gcode_file(filepath: str, flavor: str = 'default', encoding='utf-8') Reads a G-code file into a set of clean dictionaries of words :param filepath: Path (absolute or relative) to a G-code program file :type filepath: str :param flavor: Syntax definition for line. Defaults to "default". :type flavor: str, optional :param encoding: File encoding. Defaults to 'utf-8'. :type encoding: str, optional :returns: All lines as clean dictionary of words :rtype: Generator[dict] .. py:function:: read_gcode_line(line: str, named_parameters: dict = {}, flavor: str = 'default') Reads a G-code line into a clean dictionary of words and comments :param line: Un-processed line (block) from a G-code program :type line: str :param flavor: Syntax definition for line. Defaults to "default". :type flavor: str, optional :returns: Words and comments :rtype: dict