<commit_before># coding=utf-8
from __future__ import absolute_import

__author__ = "<NAME> <<EMAIL>>, <NAME> <<EMAIL>>"
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
__copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms of the AGPLv3 License"

import logging
import re

class GcodeFlavors(object):
	REPRAP = "reprap"
	TEACUP = "teacup"
	MAKERWARE = "makerware"
	SAILFISH = "sailfish"
	MACH3 = "mach3"
	NO_EXTRUSION = "no-extrusion"

class FillPatterns(object):
	ARCHIMEDEANCHORDS = "archimedeanchords"
	RECTILINEAR = "rectilinear"
	FLOWSNAKE = "flowsnake"
	OCTAGRAMSPIRAL = "octagramspiral"
	HILBERTCURVE = "hilbertcurve"
	LINE = "line"
	CONCENTRIC = "concentric"
	HONEYCOMB = "honeycomb"
	HONEYCOMB_3D = "3dhoneycomb"

class SupportPatterns(object):
	HONEYCOMB = "honeycomb"
	RECTILINEAR = "rectilinear"
	RECTILINEAR_GRID = "rectilinear-grid"

class SeamPositions(object):
	RANDOM = "random"
	ALIGNED = "aligned"
	NEAREST = "nearest"

class Profile(object):

	regex_strip_comments = re.compile(";.*$", flags=re.MULTILINE)

	@classmethod
	def from_slic3r_ini(cls, path):
		import os
		if not os.path.exists(path) or not os.path.isfile(path):
			return None

		result = dict()
		display_name = None
		description = None
		with open(path) as f:
			for line in f:
				if "#" in line:
					if line.startswith("# Name: "):
						display_name = line[len("# Name: "):]
					elif line.startswith("# Description: "):
						description = line[len("# Description: "):]
					line = line[0:line.find("#")]
				split_line = line.split("=", 1)
				if len(split_line) != 2:
					continue
				key, v = map(str.strip, split_line)

				result[key] = v

		# merge it with our default settings, the imported profile settings taking precedence
		return result, display_name, description

	@classmethod
	def to_slic3r_ini(cls, profile, path, display_name=None, description=None):
		with open(path, "w") as f:
			if display_name is not None:
				f.write("# Name: " + display_name + "\n")
			if description is not None:
				f.write("# Description: " + description + "\n")
			for key in sorted(profile.keys()):
				if key.startswith("_"):
					continue

				value = profile[key]
				if isinstance(value, bool):
					value = "true" if value else "false"
				elif isinstance(value, (tuple, list)):
					value = ",".join(map(str, value))
				f.write(key + " = " + str(value) + "\n")

	def __init__(self, profile, printer_profile, posX, posY, overrides=None):
		self._profile = profile
		self._printer_profile = printer_profile
		self._pos_x = posX
		self._pos_y = posY
		self._overrides = overrides

	def get(self, key):
		print "foo"
		if key == "print_center":
			width = self._printer_profile["volume"]["width"]
			depth = self._printer_profile["volume"]["depth"]
			circular = self._printer_profile["volume"]["formFactor"] == "circular"

			if self._pos_x:
				x = self._pos_x
			else:
				x = width / 2.0 if not circular else 0.0
			if self._pos_y:<commit_msg>remove a dummy print statement<commit_after># coding=utf-8
from __future__ import absolute_import

__author__ = "<NAME> <<EMAIL>>, <NAME> <<EMAIL>>"
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
__copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms of the AGPLv3 License"

import logging
import re

class GcodeFlavors(object):
	REPRAP = "reprap"
	TEACUP = "teacup"
	MAKERWARE = "makerware"
	SAILFISH = "sailfish"
	MACH3 = "mach3"
	NO_EXTRUSION = "no-extrusion"

class FillPatterns(object):
	ARCHIMEDEANCHORDS = "archimedeanchords"
	RECTILINEAR = "rectilinear"
	FLOWSNAKE = "flowsnake"
	OCTAGRAMSPIRAL = "octagramspiral"
	HILBERTCURVE = "hilbertcurve"
	LINE = "line"
	CONCENTRIC = "concentric"
	HONEYCOMB = "honeycomb"
	HONEYCOMB_3D = "3dhoneycomb"

class SupportPatterns(object):
	HONEYCOMB = "honeycomb"
	RECTILINEAR = "rectilinear"
	RECTILINEAR_GRID = "rectilinear-grid"

class SeamPositions(object):
	RANDOM = "random"
	ALIGNED = "aligned"
	NEAREST = "nearest"

class Profile(object):

	regex_strip_comments = re.compile(";.*$", flags=re.MULTILINE)

	@classmethod
	def from_slic3r_ini(cls, path):
		import os
		if not os.path.exists(path) or not os.path.isfile(path):
			return None

		result = dict()
		display_name = None
		description = None
		with open(path) as f:
			for line in f:
				if "#" in line:
					if line.startswith("# Name: "):
						display_name = line[len("# Name: "):]
					elif line.startswith("# Description: "):
						description = line[len("# Description: "):]
					line = line[0:line.find("#")]
				split_line = line.split("=", 1)
				if len(split_line) != 2:
					continue
				key, v = map(str.strip, split_line)

				result[key] = v

		# merge it with our default settings, the imported profile settings taking precedence
		return result, display_name, description

	@classmethod
	def to_slic3r_ini(cls, profile, path, display_name=None, description=None):
		with open(path, "w") as f:
			if display_name is not None:
				f.write("# Name: " + display_name + "\n")
			if description is not None:
				f.write("# Description: " + description + "\n")
			for key in sorted(profile.keys()):
				if key.startswith("_"):
					continue

				value = profile[key]
				if isinstance(value, bool):
					value = "true" if value else "false"
				elif isinstance(value, (tuple, list)):
					value = ",".join(map(str, value))
				f.write(key + " = " + str(value) + "\n")

	def __init__(self, profile, printer_profile, posX, posY, overrides=None):
		self._profile = profile
		self._printer_profile = printer_profile
		self._pos_x = posX
		self._pos_y = posY
		self._overrides = overrides

	def get(self, key):
		if key == "print_center":
			width = self._printer_profile["volume"]["width"]
			depth = self._printer_profile["volume"]["depth"]
			circular = self._printer_profile["volume"]["formFactor"] == "circular"

			if self._pos_x:
				x = self._pos_x
			else:
				x = width / 2.0 if not circular else 0.0
			if self._pos_y:
{'fraction_non_alphanumeric': 0.1337102943622152, 'fraction_numerical': 0.006319640778313654, 'mean_word_length': 4.024227234753551, 'pattern_counts': {'":': 2, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3487347', 'n_tokens_mistral': 2438, 'n_tokens_neox': 2156, 'n_words': 541}