chiark / gitweb /
Removed unused scripts.
authordaid <daid303@gmail.com>
Fri, 1 Jun 2012 10:26:00 +0000 (12:26 +0200)
committerdaid <daid303@gmail.com>
Fri, 1 Jun 2012 10:26:00 +0000 (12:26 +0200)
Cura/cura_sf/fabmetheus_utilities/fabmetheus_tools/alphabetize.py [deleted file]
Cura/cura_sf/fabmetheus_utilities/fabmetheus_tools/prepare.py [deleted file]
Cura/cura_sf/fabmetheus_utilities/fabmetheus_tools/wikifier.py [deleted file]

diff --git a/Cura/cura_sf/fabmetheus_utilities/fabmetheus_tools/alphabetize.py b/Cura/cura_sf/fabmetheus_utilities/fabmetheus_tools/alphabetize.py
deleted file mode 100644 (file)
index 379d2ef..0000000
+++ /dev/null
@@ -1,232 +0,0 @@
-"""
-Alphabetize is a script to alphabetize functions and signatures.
-
-"""
-
-from __future__ import absolute_import
-#Init has to be imported first because it has code to workaround the python bug where relative imports don't work if the module is imported as a main module.
-import __init__
-
-from fabmetheus_utilities import archive
-import cStringIO
-import os
-
-
-__author__ = 'Enrique Perez (perez_enrique@yahoo.com)'
-__date__ = '$Date: 2008/21/04 $'
-__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
-
-
-def addTogetherList(functionList, togetherLists):
-       'Add the togetherList to the togetherLists is the sorted is different.'
-       sortedList = functionList[:]
-       sortedList.sort(compareFunctionName)
-       togetherList = None
-       for functionIndex in xrange(len(functionList)):
-               function = functionList[functionIndex]
-               sorted = sortedList[functionIndex]
-               if function != sorted:
-                       together = (function, sorted)
-                       if togetherList == None:
-                               togetherList = []
-                               togetherLists.append(togetherList)
-                       togetherList.append(together)
-
-def compareFunctionName(first, second):
-       'Compare the function names.'
-       first = getConvertedName(first)
-       second = getConvertedName(second)
-       if first < second:
-               return -1
-       return first < second
-
-def getConvertedName(name):
-       'Get converted name with init at the beginning and main at the endCompare the function names.'
-       if name == 'def __init__':
-               return 'def !__init__'
-       if name == 'def main':
-               return 'def |main'
-       return name.lower()
-
-def getFunctionLists(fileName):
-       'Get the function lists in the file.'
-       fileText = archive.getFileText(fileName)
-       functionList = []
-       functionLists = [functionList]
-       lines = archive.getTextLines(fileText)
-       for line in lines:
-               lineStripped = line.strip()
-               if lineStripped.startswith('def '):
-                       bracketIndex = lineStripped.find('(')
-                       if bracketIndex > -1:
-                               lineStripped = lineStripped[: bracketIndex]
-                       functionList.append(lineStripped)
-               elif line.startswith('class'):
-                       functionList = []
-                       functionLists.append(functionList)
-       return functionLists
-
-def getFunctionsWithStringByFileName(fileName, searchString):
-       'Get the functions with the search string in the file.'
-       fileText = archive.getFileText(fileName)
-       functions = []
-       lines = archive.getTextLines(fileText)
-       for line in lines:
-               lineStripped = line.strip()
-#              if lineStripped.startswith('def ') and searchString in lineStripped and '=' in lineStripped:
-               if lineStripped.startswith('def ') and searchString in lineStripped:
-                       if '(self, ' not in lineStripped or lineStripped.count(',') > 1:
-                               functions.append(lineStripped[len('def ') :].strip())
-       functions.sort()
-       return functions
-
-def getFunctionsWithStringByFileNames(fileNames, searchString):
-       'Get the functions with the search string in the files.'
-       functions = []
-       for fileName in fileNames:
-               functions += getFunctionsWithStringByFileName(fileName, searchString)
-       functions.sort()
-       return functions
-
-def getParameterSequence(functionName):
-       'Get the parameter sequence.'
-       parameterDictionary = {}
-       parameterSequence = []
-       parameterText = functionName[functionName.find('(') + 1 :].replace('xmlElement', 'elementNode')
-       snippet = Snippet(0, parameterText)
-       strippedParameters = []
-       for parameter in snippet.parameters:
-               strippedParameter = parameter.strip()
-               if strippedParameter != 'self':
-                       strippedParameters.append(strippedParameter)
-       for parameterIndex, parameter in enumerate(strippedParameters):
-               parameterDictionary[parameter] = parameterIndex
-       sortedParameters = strippedParameters[:]
-       sortedParameters.sort()
-       for sortedParameter in sortedParameters:
-               parameterSequence.append(parameterDictionary[sortedParameter])
-       return parameterSequence
-
-def getSnippetsByFileName(fileName, functionName):
-       'Get the function signature snippets by the file name.'
-       fileText = archive.getFileText(fileName)
-       snippets = []
-       functionStart = functionName[: functionName.find('(') + 1]
-       tokenEnd = getTokenEnd(0, fileText, functionStart)
-       while tokenEnd != -1:
-               snippet = Snippet(tokenEnd, fileText)
-               snippets.append(snippet)
-               tokenEnd = getTokenEnd(snippet.characterIndex, fileText, functionStart)
-       return snippets
-
-def getTogetherLists(fileName):
-       'Get the lists of the unsorted and sorted functions in the file.'
-       functionLists = getFunctionLists(fileName)
-       togetherLists = []
-       for functionList in functionLists:
-               addTogetherList(functionList, togetherLists)
-       return togetherLists
-
-def getTokenEnd(characterIndex, fileText, token):
-       'Get the token end index for the file text and token.'
-       tokenIndex = fileText.find(token, characterIndex)
-       if tokenIndex == -1:
-               return -1
-       return tokenIndex + len(token)
-
-def printTogetherListsByFileNames(fileNames):
-       'Print the together lists of the file names, if the file name has a together list.'
-       for fileName in fileNames:
-               togetherLists = getTogetherLists(fileName)
-               if len(togetherLists) > 0:
-                       for togetherList in togetherLists:
-                               for together in togetherList:
-                                       function = together[0]
-                                       sorted = together[1]
-                       return
-
-
-class EndCharacterMonad:
-       'A monad to return the parent monad when it encounters the end character.'
-       def __init__(self, endCharacter, parentMonad):
-               'Initialize.'
-               self.endCharacter = endCharacter
-               self.parentMonad = parentMonad
-
-       def getNextMonad(self, character):
-               'Get the next monad.'
-               self.getSnippet().input.write(character)
-               if character == self.endCharacter:
-                       return self.parentMonad
-               return self
-
-       def getSnippet(self):
-               'Get the snippet.'
-               return self.parentMonad.getSnippet()
-
-
-class ParameterMonad:
-       'A monad to handle parameters.'
-       def __init__(self, snippet):
-               'Initialize.'
-               self.snippet = snippet
-
-       def addParameter(self):
-               'Add parameter to the snippet.'
-               parameterString = self.snippet.input.getvalue()
-               if len(parameterString) != 0:
-                       self.snippet.input = cStringIO.StringIO()
-                       self.snippet.parameters.append(parameterString)
-
-       def getNextMonad(self, character):
-               'Get the next monad.'
-               if character == '"':
-                       self.snippet.input.write(character)
-                       return EndCharacterMonad('"', self)
-               if character == '"':
-                       self.snippet.input.write(character)
-                       return EndCharacterMonad('"', self)
-               if character == '(':
-                       self.snippet.input.write(character)
-                       return EndCharacterMonad(')', self)
-               if character == ')':
-                       self.addParameter()
-                       return None
-               if character == ',':
-                       self.addParameter()
-                       return self
-               self.snippet.input.write(character)
-               return self
-
-       def getSnippet(self):
-               'Get the snippet.'
-               return self.snippet
-
-
-class Snippet:
-       'A class to get the variables for a function.'
-       def __init__(self, characterIndex, fileText):
-               'Initialize.'
-               self.characterIndex = characterIndex
-               self.input = cStringIO.StringIO()
-               self.parameters = []
-               monad = ParameterMonad(self)
-               for characterIndex in xrange(self.characterIndex, len(fileText)):
-                       character = fileText[characterIndex]
-                       monad = monad.getNextMonad(character)
-                       if monad == None:
-                               return
-
-       def __repr__(self):
-               'Get the string representation of this Snippet.'
-               return '%s %s' % (self.characterIndex, self.parameters)
-
-
-def main():
-       'Run main function.'
-#      printTogetherListsByFileNames(archive.getPythonFileNamesExceptInitRecursively('/home/enrique/Desktop/fabmetheus'))
-       functions = getFunctionsWithStringByFileNames(archive.getPythonFileNamesExceptInitRecursively('/home/enrique/Desktop/fabmetheus'), ', xmlElement')
-       print(functions)
-
-if __name__ == "__main__":
-       main()
diff --git a/Cura/cura_sf/fabmetheus_utilities/fabmetheus_tools/prepare.py b/Cura/cura_sf/fabmetheus_utilities/fabmetheus_tools/prepare.py
deleted file mode 100644 (file)
index bac2757..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-"""
-Prepare is a script to remove the generated files, run wikifier, and finally zip the package.
-
-"""
-
-from __future__ import absolute_import
-#Init has to be imported first because it has code to workaround the python bug where relative imports don't work if the module is imported as a main module.
-import __init__
-
-from fabmetheus_utilities import archive
-from fabmetheus_utilities.fabmetheus_tools import wikifier
-import os
-
-
-__author__ = 'Enrique Perez (perez_enrique@yahoo.com)'
-__date__ = '$Date: 2008/21/04 $'
-__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
-
-
-def prepareWikify():
-       'Remove generated files, then wikify the file comments.'
-       removeGeneratedFiles()
-       wikifier.main()
-       removeZip()
-
-def removeCSVFile(csvFilePath):
-       'Remove csv file.'
-       if 'alterations' in csvFilePath and 'example_' not in csvFilePath:
-               os.remove(csvFilePath)
-               print('removeGeneratedFiles deleted ' + csvFilePath)
-
-def removeGcodeFile(gcodeFilePath):
-       'Remove gcode file.'
-       if 'alterations' not in gcodeFilePath:
-               os.remove(gcodeFilePath)
-               print('removeGeneratedFiles deleted ' + gcodeFilePath)
-               return
-       if 'example_' not in gcodeFilePath:
-               os.remove(gcodeFilePath)
-               print('removeGeneratedFiles deleted ' + gcodeFilePath)
-
-def removeGeneratedFiles():
-       'Remove generated files.'
-       csvFilePaths = archive.getFilesWithFileTypesWithoutWordsRecursively(['csv'])
-       for csvFilePath in csvFilePaths:
-               removeCSVFile(csvFilePath)
-       gcodeFilePaths = archive.getFilesWithFileTypesWithoutWordsRecursively(['gcode'])
-       for gcodeFilePath in gcodeFilePaths:
-               removeGcodeFile(gcodeFilePath)
-       svgFilePaths = archive.getFilesWithFileTypesWithoutWordsRecursively(['svg'])
-       for svgFilePath in svgFilePaths:
-               removeSVGFile(svgFilePath)
-       xmlFilePaths = archive.getFilesWithFileTypesWithoutWordsRecursively(['xml'])
-       for xmlFilePath in xmlFilePaths:
-               removeXMLFile(xmlFilePath)
-       archive.removeBackupFilesByTypes(['gcode', 'svg', 'xml'])
-
-def removeSVGFile(svgFilePath):
-       'Remove svg file.'
-       if archive.getEndsWithList(svgFilePath, ['_bottom.svg', '_carve.svg', '_chop.svg', '_cleave.svg', '_scale.svg', '_vectorwrite.svg']):
-               os.remove(svgFilePath)
-               print('removeGeneratedFiles deleted ' + svgFilePath)
-
-def removeXMLFile(xmlFilePath):
-       'Remove xml file.'
-       if archive.getEndsWithList(xmlFilePath, ['_interpret.xml']):
-               os.remove(xmlFilePath)
-               print('removeGeneratedFiles deleted ' + xmlFilePath)
-
-def removeZip():
-       'Remove the zip file, then generate a new one.zip -r reprap_python_beanshell * -x \*.pyc \*~'
-       zipName = 'reprap_python_beanshell'
-       zipNameExtension = zipName + '.zip'
-       if zipNameExtension in os.listdir(os.getcwd()):
-               os.remove(zipNameExtension)
-       shellCommand = 'zip -r %s * -x \*.pyc \*~' % zipName
-       if os.system(shellCommand) != 0:
-               print('Failed to execute the following command in removeZip in prepare.')
-               print(shellCommand)
-
-def main():
-       'Run main function.'
-       prepareWikify()
-
-if __name__ == "__main__":
-       main()
diff --git a/Cura/cura_sf/fabmetheus_utilities/fabmetheus_tools/wikifier.py b/Cura/cura_sf/fabmetheus_utilities/fabmetheus_tools/wikifier.py
deleted file mode 100644 (file)
index 50e0233..0000000
+++ /dev/null
@@ -1,215 +0,0 @@
-"""
-Wikifier is a script to add spaces to the pydoc files and move them to the documentation folder.
-
-"""
-
-from __future__ import absolute_import
-#Init has to be imported first because it has code to workaround the python bug where relative imports don't work if the module is imported as a main module.
-import __init__
-
-from fabmetheus_utilities import archive
-from fabmetheus_utilities import gcodec
-from fabmetheus_utilities import settings
-import cStringIO
-import os
-
-
-__author__ = 'Enrique Perez (perez_enrique@yahoo.com)'
-__date__ = '$Date: 2008/21/04 $'
-__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
-
-
-globalWikiLinkStart = '[<a href='
-
-
-def addToHeadings(headingLineTable, headings, line):
-       'Add the line to the headings.'
-       for depth in xrange(4, -1, -1):
-               equalSymbolLength = depth + 2
-               if line[: equalSymbolLength] == '=' * equalSymbolLength:
-                       headings.append(Heading(depth).getFromLine(headingLineTable, line))
-                       return
-
-def getLinkLine(line):
-       'Get the link line with the wiki style link converted into a hypertext link.'
-       linkStartIndex = line.find(globalWikiLinkStart)
-       squareEndBracketIndex = line.find(']', linkStartIndex)
-       greaterThanIndex = line.find('>', linkStartIndex, squareEndBracketIndex)
-       greaterThanIndexPlusOne = greaterThanIndex + 1
-       closeATagIndex = line.find('</a>', greaterThanIndexPlusOne, squareEndBracketIndex)
-       linkText = line[closeATagIndex + len('</a>') + 1: squareEndBracketIndex]
-       linkLine = line[: linkStartIndex] + line[linkStartIndex + 1: greaterThanIndexPlusOne] + linkText + '</a>' + line[squareEndBracketIndex + 1 :]
-       return linkLine
-
-def getNavigationHypertext(fileText, transferredFileNameIndex, transferredFileNames):
-       'Get the hypertext help with navigation lines.'
-       helpTextEnd = fileText.find('</p>')
-       helpTextStart = fileText.find('<p>')
-       helpText = fileText[helpTextStart : helpTextEnd]
-       lines = archive.getTextLines(helpText)
-       headings = []
-       headingLineTable = {}
-       for line in lines:
-               addToHeadings(headingLineTable, headings, line)
-       headingsToBeenAdded = True
-       output = cStringIO.StringIO()
-       for line in lines:
-               if line[: 2] == '==':
-                       if headingsToBeenAdded:
-                               output.write('<br />\n')
-                               for heading in headings:
-                                       heading.addToOutput(output)
-                               output.write('<br />\n')
-                               headingsToBeenAdded = False
-                       if line in headingLineTable:
-                               line = headingLineTable[line]
-               if '&lt;a href=' in line:
-                       line = line.replace('&lt;', '<').replace('&gt;', '>')
-               while globalWikiLinkStart in line and ']' in line:
-                       line = getLinkLine(line)
-               output.write(line + '\n')
-       helpText = output.getvalue()
-       previousFileName = 'contents.html'
-       previousIndex = transferredFileNameIndex - 1
-       if previousIndex >= 0:
-               previousFileName = transferredFileNames[previousIndex]
-       previousLinkText = '<a href="%s">Previous</a>' % previousFileName
-       nextLinkText = getNextLinkText(transferredFileNames, transferredFileNameIndex + 1)
-       navigationLine = getNavigationLine('<a href="contents.html">Contents</a>', previousLinkText, nextLinkText)
-       helpText = navigationLine + helpText + '<br />\n<br />\n' + navigationLine + '<hr>\n'
-       return fileText[: helpTextStart] + helpText + fileText[helpTextEnd :]
-
-def getNavigationLine(contentsLinkText, previousLinkText, nextLinkText):
-       'Get the wrapped pydoc hypertext help.'
-       return '<p>\n%s / %s / %s\n</p>\n' % (previousLinkText, nextLinkText, contentsLinkText)
-
-def getNextLinkText(hypertextFiles, nextIndex):
-       'Get the next link text.'
-       nextFileName = 'contents.html'
-       if nextIndex < len(hypertextFiles):
-               nextFileName = hypertextFiles[nextIndex]
-       return '<a href="%s">Next</a>' % nextFileName
-
-def getWrappedHypertext(fileText, hypertextFileIndex, hypertextFiles):
-       'Get the wrapped pydoc hypertext help.'
-       helpTextEnd = fileText.find('</p>')
-       if helpTextEnd < 0:
-               print('Failed to find the helpTextEnd in getWrappedHypertext in docwrap.')
-       helpTextStart = fileText.find('<p>')
-       if helpTextStart < 0:
-               print('Failed to find the helpTextStart in getWrappedHypertext in docwrap.')
-       helpText = fileText[helpTextStart : helpTextEnd]
-       helpText = helpText.replace('&nbsp;', ' ')
-       return fileText[: helpTextStart] + helpText + fileText[helpTextEnd :]
-
-def readWriteDeleteHypertextHelp(documentDirectoryPath, hypertextFileIndex, hypertextFiles, transferredFileNames):
-       'Read the pydoc hypertext help documents, write them in the documentation folder then delete the originals.'
-       fileName = os.path.basename(hypertextFiles[hypertextFileIndex])
-       print('readWriteDeleteHypertextHelp ' + fileName)
-       filePath = os.path.join(documentDirectoryPath, fileName)
-       fileText = archive.getFileText(fileName)
-       fileText = getWrappedHypertext(fileText, hypertextFileIndex, hypertextFiles)
-       if fileText.find('This page is in the table of contents.') > - 1:
-               fileText = fileText.replace('This page is in the table of contents.', '')
-               transferredFileNames.append(fileName)
-       archive.writeFileText(filePath, fileText)
-       os.remove(fileName)
-
-def readWriteNavigationHelp(documentDirectoryPath, transferredFileNameIndex, transferredFileNames):
-       'Read the hypertext help documents, and add the navigation lines to them.'
-       fileName = os.path.basename(transferredFileNames[transferredFileNameIndex])
-       print('readWriteNavigationHelp ' + fileName)
-       filePath = os.path.join(documentDirectoryPath, fileName)
-       fileText = archive.getFileText(filePath)
-       fileText = getNavigationHypertext(fileText, transferredFileNameIndex, transferredFileNames)
-       archive.writeFileText(filePath, fileText)
-
-def removeFilesInDirectory(directoryPath):
-       'Remove all the files in a directory.'
-       fileNames = os.listdir(directoryPath)
-       for fileName in fileNames:
-               filePath = os.path.join(directoryPath, fileName)
-               os.remove(filePath)
-
-def writeContentsFile(documentDirectoryPath, hypertextFiles):
-       'Write the contents file.'
-       output = cStringIO.StringIO()
-       output.write('<html>\n  <head>\n    <title>Contents</title>\n  </head>\n  <body>\n')
-       navigationLine = getNavigationLine('Contents', 'Previous', getNextLinkText(hypertextFiles, 0))
-       output.write(navigationLine)
-       for hypertextFile in hypertextFiles:
-               writeContentsLine(hypertextFile, output)
-       output.write(navigationLine)
-       output.write('  </body>\n</html>\n')
-       filePath = os.path.join( documentDirectoryPath, 'contents.html')
-       archive.writeFileText(filePath, output.getvalue())
-
-def writeContentsLine(hypertextFile, output):
-       'Write a line of the contents file.'
-       summarizedFileName = hypertextFile[: hypertextFile.rfind('.')]
-       numberOfDots = summarizedFileName.count('.')
-       prefixSpaces = '&nbsp;&nbsp;' * numberOfDots
-       if numberOfDots > 0:
-               summarizedFileName = summarizedFileName[summarizedFileName.rfind('.') + 1 :]
-       capitalizedSummarizedFileName = settings.getEachWordCapitalized(summarizedFileName)
-       output.write('%s<a href="%s">%s</a><br>\n' % (prefixSpaces, hypertextFile, capitalizedSummarizedFileName))
-
-def writeHypertext():
-       'Run pydoc, then read, write and delete each of the files.'
-       shellCommand = 'pydoc -w ./'
-       commandResult = os.system(shellCommand)
-       if commandResult != 0:
-               print('Failed to execute the following command in writeHypertext in docwrap.')
-               print(shellCommand)
-       hypertextFiles = archive.getFilesWithFileTypeWithoutWords('html')
-       if len( hypertextFiles ) <= 0:
-               print('Failed to find any help files in writeHypertext in docwrap.')
-               return
-       documentDirectoryPath = archive.getAbsoluteFolderPath( hypertextFiles[0], 'documentation')
-       removeFilesInDirectory(documentDirectoryPath)
-       sortedReplaceFiles = []
-       for hypertextFile in hypertextFiles:
-               sortedReplaceFiles.append(hypertextFile.replace('.html', '. html'))
-       sortedReplaceFiles.sort()
-       hypertextFiles = []
-       for sortedReplaceFile in sortedReplaceFiles:
-               hypertextFiles.append(sortedReplaceFile.replace('. html', '.html'))
-       transferredFileNames = []
-       for hypertextFileIndex in xrange(len(hypertextFiles)):
-               readWriteDeleteHypertextHelp(documentDirectoryPath, hypertextFileIndex, hypertextFiles, transferredFileNames)
-       for transferredFileNameIndex in xrange(len(transferredFileNames)):
-               readWriteNavigationHelp(documentDirectoryPath, transferredFileNameIndex, transferredFileNames)
-       writeContentsFile(documentDirectoryPath, transferredFileNames)
-       print('%s files were wrapped.' % len(transferredFileNames))
-
-
-class Heading:
-       'A class to hold the heading and subheadings.'
-       def __init__(self, depth=0):
-               'Initialize.'
-               self.depth = depth
-
-       def addToOutput(self, output):
-               'Add to the output.'
-               line = '&nbsp;&nbsp;' * self.depth + '<a href="#%s">%s</a><br />\n' % (self.name, self.name)
-               output.write(line)
-
-       def getFromLine(self, headingLineTable, line):
-               'Get the heading from a line.'
-               heading = 'h%s' % (self.depth + 2)
-               nextLine = '\n<hr>\n'
-               if self.depth > 0:
-                       nextLine = '\n'
-               self.name = line.replace('=', '').replace('<br>', '')
-               name = self.name
-               headingLine = '<a name="%s" id="%s"></a><%s>%s</%s>%s' % (name, name, heading, name, heading, nextLine)
-               headingLineTable[line] = headingLine
-               return self
-
-
-def main():
-       'Display the craft dialog.'
-       writeHypertext()
-
-if __name__ == '__main__':
-       main()