# Path: skeinforge_application/skeinforge_utilities/skeinforge_craft.py
# def getChainText( fileName, procedure ):
# def getChainTextFromProcedures(fileName, procedures, text):
# def getCraftModule(pluginName):
# def getCraftPreferences(pluginName):
# def getCraftValue(preferenceName, preferences):
# def getLastModule():
# def getNewRepository():
# def getPluginFileNames():
# def getPluginsDirectoryPath():
# def getProcedures(procedure, text):
# def getReadCraftSequence():
# def writeChainTextWithNounMessage(fileName, procedure, shouldAnalyze=True):
# def writeOutput(fileName, shouldAnalyze=True):
# def writeSVGTextWithNounMessage(fileName, repository, shouldAnalyze=True):
# 	def addToDialog( self, gridPosition ):
# 	def getFromRadioPlugins( self, radioPlugins, repository ):
# 	def save(self):
# 	def setRadioButtons(self):
# 	def __init__(self):
# 	def execute(self):
# def main():
# class CraftRadioButtonsSaveListener:
# class CraftRepository:


import __init__
import cStringIO
import os
import sys
import time
from fabmetheus_utilities.fabmetheus_tools import fabmetheus_interpret
from fabmetheus_utilities import archive
from fabmetheus_utilities import euclidean
from fabmetheus_utilities import gcodec
from fabmetheus_utilities import intercircle
from fabmetheus_utilities import settings
from skeinforge_application.skeinforge_utilities import skeinforge_analyze
from skeinforge_application.skeinforge_utilities import skeinforge_craft
from skeinforge_application.skeinforge_utilities import skeinforge_polyfile
from skeinforge_application.skeinforge_utilities import skeinforge_profile
			return None
	return None

def sendOutputTo(outputTo, text):
	'Send output to a file or a standard output.'
	if outputTo.endswith('stderr'):
		sys.stderr.write(text)
		sys.stderr.write('\n')
		sys.stderr.flush()
		return
	if outputTo.endswith('stdout'):
		sys.stdout.write(text)
		sys.stdout.write('\n')
		sys.stdout.flush()
		return
	archive.writeFileText(outputTo, text)

def writeOutput(fileName, shouldAnalyze=True):
	'Export a gcode linear move file.'
	if fileName == '':
		return None
	repository = ExportRepository()
	settings.getReadRepository(repository)
	startTime = time.time()
	print('File ' + archive.getSummarizedFileName(fileName) + ' is being chain exported.')
	fileNameSuffix = fileName[: fileName.rfind('.')]
	if repository.addExportSuffix.value:
		fileNameSuffix += '_export'
	gcodeText = gcodec.getGcodeFileText(fileName, '')
	procedures = skeinforge_craft.getProcedures('export', gcodeText)

# Path: skeinforge_application/skeinforge_utilities/skeinforge_craft.py
# def getChainText( fileName, procedure ):
# def getChainTextFromProcedures(fileName, procedures, text):
# def getCraftModule(pluginName):
# def getCraftPreferences(pluginName):
# def getCraftValue(preferenceName, preferences):
# def getLastModule():
# def getNewRepository():
# def getPluginFileNames():
# def getPluginsDirectoryPath():
# def getProcedures(procedure, text):
# def getReadCraftSequence():
# def writeChainTextWithNounMessage(fileName, procedure, shouldAnalyze=True):
# def writeOutput(fileName, shouldAnalyze=True):
# def writeSVGTextWithNounMessage(fileName, repository, shouldAnalyze=True):
# 	def addToDialog( self, gridPosition ):
# 	def getFromRadioPlugins( self, radioPlugins, repository ):
# 	def save(self):
# 	def setRadioButtons(self):
# 	def __init__(self):
# 	def execute(self):
# def main():
# class CraftRadioButtonsSaveListener:
# class CraftRepository:


# Path: skeinforge_application/skeinforge_plugins/craft_plugins/export.py
import __init__
import cStringIO
import os
import sys
import time
from fabmetheus_utilities.fabmetheus_tools import fabmetheus_interpret
from fabmetheus_utilities import archive
from fabmetheus_utilities import euclidean
from fabmetheus_utilities import gcodec
from fabmetheus_utilities import intercircle
from fabmetheus_utilities import settings
from skeinforge_application.skeinforge_utilities import skeinforge_analyze
from skeinforge_application.skeinforge_utilities import skeinforge_craft
from skeinforge_application.skeinforge_utilities import skeinforge_polyfile
from skeinforge_application.skeinforge_utilities import skeinforge_profile

			return None
	return None

def sendOutputTo(outputTo, text):
	'Send output to a file or a standard output.'
	if outputTo.endswith('stderr'):
		sys.stderr.write(text)
		sys.stderr.write('\n')
		sys.stderr.flush()
		return
	if outputTo.endswith('stdout'):
		sys.stdout.write(text)
		sys.stdout.write('\n')
		sys.stdout.flush()
		return
	archive.writeFileText(outputTo, text)

def writeOutput(fileName, shouldAnalyze=True):
	'Export a gcode linear move file.'
	if fileName == '':
		return None
	repository = ExportRepository()
	settings.getReadRepository(repository)
	startTime = time.time()
	print('File ' + archive.getSummarizedFileName(fileName) + ' is being chain exported.')
	fileNameSuffix = fileName[: fileName.rfind('.')]
	if repository.addExportSuffix.value:
		fileNameSuffix += '_export'
	gcodeText = gcodec.getGcodeFileText(fileName, '')
	procedures = skeinforge_craft.getProcedures('export', gcodeText)

	gcodeText = skeinforge_craft.getChainTextFromProcedures(fileName, procedures[: -1], gcodeText)