<commit_before>import os
import sys
lib_path = os.path.abspath('../')
sys.path.append(lib_path)

import s3g
import optparse

parser = optparse.OptionParser()
parser.add_option("-i", "--inputfile", dest="input_file",
                  help="gcode file to read in", default=False)
parser.add_option("-o", "--outputfile", dest="output_file",
                  help="s3g file to write out", default=False)
parser.add_option("-m", "--machine_type", dest="machine",
                  help="machine type", default="ReplicatorDual")
parser.add_option("-s", "--gcode_start_end_sequences", dest="start_end_sequences",
                  help="run gcode start and end proceeses", default=True)
(options, args) = parser.parse_args()


s = s3g.s3g()
s.writer = s3g.Writer.FileWriter(open(options.output_file, 'w'))

parser = s3g.Gcode.GcodeParser()
parser.state.values["build_name"] = 'test'
parser.state.profile = s3g.Profile(options.machine)
parser.s3g = s
profile = s3g.Profile('ReplicatorDual')
parser.state.profile = profile

environment = {}

if options.start_end_sequences:
  for line in parser.state.profile.values['print_start_sequence']:
    parser.ExecuteLine(line, environment)

with open(options.input_file) as f:
  for line in f:
    parser.ExecuteLine(line, environment)

if options.start_end_sequences:
  for line in parser.state.profile.values['print_end_sequence']:
    parser.ExecuteLine(line, environment)<commit_msg>Bugfix: environment doesn't need to be passed to ExecuteLine.<commit_after>import os
import sys
lib_path = os.path.abspath('../')
sys.path.append(lib_path)

import s3g
import optparse

parser = optparse.OptionParser()
parser.add_option("-i", "--inputfile", dest="input_file",
                  help="gcode file to read in", default=False)
parser.add_option("-o", "--outputfile", dest="output_file",
                  help="s3g file to write out", default=False)
parser.add_option("-m", "--machine_type", dest="machine",
                  help="machine type", default="ReplicatorDual")
parser.add_option("-s", "--gcode_start_end_sequences", dest="start_end_sequences",
                  help="run gcode start and end proceeses", default=True)
(options, args) = parser.parse_args()


s = s3g.s3g()
s.writer = s3g.Writer.FileWriter(open(options.output_file, 'w'))

parser = s3g.Gcode.GcodeParser()
parser.state.values["build_name"] = 'test'
parser.state.profile = s3g.Profile(options.machine)
parser.s3g = s
profile = s3g.Profile('ReplicatorDual')
parser.state.profile = profile

if options.start_end_sequences:
  for line in parser.state.profile.values['print_start_sequence']:
    parser.ExecuteLine(line)

with open(options.input_file) as f:
  for line in f:
    print line
    parser.ExecuteLine(line)

if options.start_end_sequences:
  for line in parser.state.profile.values['print_end_sequence']:
    parser.ExecuteLine(line)
{'fraction_non_alphanumeric': 0.1406030855539972, 'fraction_numerical': 0.006311360448807854, 'mean_word_length': 4.413662239089184, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4869950', 'n_tokens_mistral': 939, 'n_tokens_neox': 925, 'n_words': 193}