本文整理汇总了Python中skeinforge_tools.skeinforge_utilities.gcodec.getFileText函数的典型用法代码示例。如果您正苦于以下问题:Python getFileText函数的具体用法?Python getFileText怎么用?Python getFileText使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getFileText函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: readPreferences
def readPreferences( archivablePreferences ):
"Set an archive to the preferences read from a file."
text = gcodec.getFileText( archivablePreferences.fileNamePreferences )
if text == '':
print( 'Since the preferences file:' )
print( archivablePreferences.fileNamePreferences )
print( 'does not exist, the default preferences will be written to that file.' )
text = gcodec.getFileText( os.path.join( 'defaults', os.path.basename( archivablePreferences.fileNamePreferences ) ) )
if text != '':
readPreferencesFromText( archivablePreferences, text )
writePreferences( archivablePreferences )
return
readPreferencesFromText( archivablePreferences, text )
示例2: getCraftedText
def getCraftedText( fileName, text = '', repository = None ):
"Get cleaved text."
if gcodec.getHasSuffix( fileName, '.svg' ):
if text == '':
text = gcodec.getFileText( fileName )
return text
return getCraftedTextFromFileName( fileName, repository = None )
示例3: getCarving
def getCarving( fileName = '' ):
"Get the triangle mesh for the stl file."
if fileName == '':
unmodified = gcodec.getFilesWithFileTypeWithoutWords( 'stl' )
if len( unmodified ) == 0:
print( "There is no stl file in this folder." )
return None
fileName = unmodified[ 0 ]
stlData = gcodec.getFileText( fileName, 'rb' )
if stlData == '':
return None
triangleMesh = triangle_mesh.TriangleMesh()
vertexIndexTable = {}
binarySolidworksHeaderErrorString = 'solid binary STL from Solid Edge, Unigraphics Solutions Inc.'
binarySolidworksHeaderError = stlData[ : len( binarySolidworksHeaderErrorString ) ] == binarySolidworksHeaderErrorString
if binarySolidworksHeaderError:
print( 'The solidworks file has the incorrect header:' )
print( binarySolidworksHeaderErrorString )
print( 'A binary stl should never start with the word "solid". Because this error is common the file is been parsed as binary regardless.' )
if ( stlData[ : 5 ] == 'solid' and not binarySolidworksHeaderError ):
addFacesGivenText( stlData, triangleMesh, vertexIndexTable )
else:
addFacesGivenBinary( stlData, triangleMesh, vertexIndexTable )
triangleMesh.setEdgesForAllFaces()
return triangleMesh
示例4: getCraftedText
def getCraftedText(fileName, text="", repository=None):
"Get chopped text."
if gcodec.getHasSuffix(fileName, ".svg"):
if text == "":
text = gcodec.getFileText(fileName)
return text
return getCraftedTextFromFileName(fileName, repository=None)
示例5: writeOutput
def writeOutput( fileName, gcodeText = '' ):
"Write statistics for a skeinforge gcode file, if 'Write Statistics File for Skeinforge Chain' is selected."
repository = settings.getReadRepository( StatisticRepository() )
if gcodeText == '':
gcodeText = gcodec.getFileText( fileName )
if repository.activateStatistic.value:
analyzeFileGivenText( fileName, gcodeText, repository )
示例6: addInitializationToOutput
def addInitializationToOutput( self ):
"Add initialization gcode to the output."
self.addFromUpperLowerFile( self.prefacePreferences.nameOfStartFile.value ) # Add a start file if it exists.
self.distanceFeedRate.addTagBracketedLine( 'creator', 'skeinforge' ) # GCode formatted comment
absoluteFilePathUntilDot = os.path.abspath( __file__ )[ : os.path.abspath( __file__ ).rfind( '.' ) ]
if absoluteFilePathUntilDot == '/home/enrique/Desktop/backup/babbleold/script/reprap/pyRepRap/skeinforge_tools/craft_plugins/preface': #check to see if this script is on Enrique's computer
gcodec.writeFileText( gcodec.getVersionFileName(), date.today().isoformat() )
versionText = gcodec.getFileText( gcodec.getVersionFileName() )
self.distanceFeedRate.addTagBracketedLine( 'version', versionText ) # GCode formatted comment
self.distanceFeedRate.addLine( '(<extruderInitialization>)' ) # GCode formatted comment
if self.prefacePreferences.setPositioningToAbsolute.value:
self.distanceFeedRate.addLine( 'G90' ) # Set positioning to absolute.
if self.prefacePreferences.setUnitsToMillimeters.value:
self.distanceFeedRate.addLine( 'G21' ) # Set units to millimeters.
if self.prefacePreferences.startAtHome.value:
self.distanceFeedRate.addLine( 'G28' ) # Start at home.
if self.prefacePreferences.turnExtruderOffAtStartUp.value:
self.distanceFeedRate.addLine( 'M103' ) # Turn extruder off.
self.distanceFeedRate.addTagBracketedLine( 'decimalPlacesCarried', self.distanceFeedRate.decimalPlacesCarried )
if self.prefacePreferences.extrusionDistanceAbsolutePreference.value:
self.distanceFeedRate.extrusionDistanceFormat = 'absolute'
if self.prefacePreferences.extrusionDistanceRelativePreference.value:
self.distanceFeedRate.extrusionDistanceFormat = 'relative'
if self.distanceFeedRate.extrusionDistanceFormat != '':
self.distanceFeedRate.addTagBracketedLine( 'extrusionDistanceFormat', self.distanceFeedRate.extrusionDistanceFormat )
self.distanceFeedRate.addTagBracketedLine( 'layerThickness', self.distanceFeedRate.getRounded( self.layerThickness ) )
self.distanceFeedRate.addTagBracketedLine( 'perimeterWidth', self.distanceFeedRate.getRounded( self.perimeterWidth ) )
self.distanceFeedRate.addTagBracketedLine( 'procedureDone', 'carve' )
self.distanceFeedRate.addTagBracketedLine( 'procedureDone', 'preface' )
self.distanceFeedRate.addLine( '(</extruderInitialization>)' ) # Initialization is finished, extrusion is starting.
self.distanceFeedRate.addLine( '(<extrusion>)' ) # Initialization is finished, extrusion is starting.
示例7: writeOutput
def writeOutput( fileName, gcodeText = '' ):
"Write a commented gcode file for a skeinforge gcode file, if 'Write Commented File for Skeinforge Chain' is selected."
repository = settings.getReadRepository( CommentRepository() )
if gcodeText == '':
gcodeText = gcodec.getFileText( fileName )
if repository.activateComment.value:
analyzeFileGivenText( fileName, gcodeText )
示例8: getCraftedText
def getCraftedText( fileName, text = '', chopPreferences = None ):
"Get chopped text."
if gcodec.getHasSuffix( fileName, '.svg' ):
if text == '':
text = gcodec.getFileText( fileName )
return text
return getCraftedTextFromFileName( fileName, chopPreferences = None )
示例9: readWriteDeleteHypertextHelp
def readWriteDeleteHypertextHelp( documentDirectoryPath, fileName ):
"Read the pydoc hypertext help documents, write them in the documentation folder then delete the originals."
print( fileName )
filePath = os.path.join( documentDirectoryPath, fileName )
fileText = gcodec.getFileText( fileName )
fileText = getWrappedHypertext( fileText )
gcodec.writeFileText( filePath, fileText )
os.remove( fileName )
示例10: writeOutput
def writeOutput( fileName, gcodeText = '' ):
"Write a commented gcode file for a skeinforge gcode file, if 'Write Commented File for Skeinforge Chain' is selected."
commentPreferences = CommentPreferences()
preferences.getReadRepository( commentPreferences )
if gcodeText == '':
gcodeText = gcodec.getFileText( fileName )
if commentPreferences.activateComment.value:
writeCommentFileGivenText( fileName, gcodeText )
示例11: writeOutput
def writeOutput( fileName, gcodeText = '' ):
"Write a skeinviewed gcode file for a skeinforge gcode file, if 'Activate Skeinview' is selected."
skeinviewPreferences = SkeinviewPreferences()
preferences.readPreferences( skeinviewPreferences )
if skeinviewPreferences.activateSkeinview.value:
if gcodeText == '':
gcodeText = gcodec.getFileText( fileName )
displaySkeinviewFileGivenText( gcodeText, skeinviewPreferences )
示例12: writeOutput
def writeOutput( fileName, gcodeText = '' ):
"Write a beholded gcode file for a skeinforge gcode file, if 'Activate Behold' is selected."
beholdPreferences = BeholdPreferences()
preferences.readPreferences( beholdPreferences )
if beholdPreferences.activateBehold.value:
if gcodeText == '':
gcodeText = gcodec.getFileText( fileName )
displayBeholdFileGivenText( gcodeText, beholdPreferences )
示例13: readWriteNavigationHelp
def readWriteNavigationHelp( documentDirectoryPath, transferredFileNameIndex, transferredFileNames ):
"Read the hypertext help documents, and add the navigation lines to them."
fileName = transferredFileNames[ transferredFileNameIndex ]
print( fileName )
filePath = os.path.join( documentDirectoryPath, fileName )
fileText = gcodec.getFileText( filePath )
fileText = getNavigationHypertext( fileText, transferredFileNameIndex, transferredFileNames )
gcodec.writeFileText( filePath, fileText )
示例14: writeOutput
def writeOutput( fileName, gcodeText = '' ):
"Write statistics for a skeinforge gcode file, if 'Write Statistics File for Skeinforge Chain' is selected."
statisticPreferences = StatisticPreferences()
preferences.getReadPreferences( statisticPreferences )
if gcodeText == '':
gcodeText = gcodec.getFileText( fileName )
if statisticPreferences.activateStatistic.value:
writeStatisticFileGivenText( fileName, gcodeText, statisticPreferences )
示例15: writeOutput
def writeOutput( fileName, gcodeText = '' ):
"Write scalable vector graphics for a skeinforge gcode file, if 'Write Scalable Vector Graphics for Skeinforge Chain' is selected."
vectorwritePreferences = VectorwritePreferences()
preferences.readPreferences( vectorwritePreferences )
if gcodeText == '':
gcodeText = gcodec.getFileText( fileName )
if vectorwritePreferences.activateVectorwrite.value:
writeVectorFileGivenText( fileName, gcodeText, vectorwritePreferences )