Beispiel #1
0
    def Create(jobname = None):
        import PathScripts
        import PathUtils

        obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", "TC")
        PathScripts.PathLoadTool.LoadTool(obj)
        PathScripts.PathLoadTool._ViewProviderLoadTool(obj.ViewObject)

        PathUtils.addToJob(obj, jobname)
Beispiel #2
0
    def Create():
        # FreeCADGui.addModule("PathScripts.PathLoadTool")
        # import Path
        import PathScripts
        import PathUtils

        obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", "TC")
        PathScripts.PathLoadTool.LoadTool(obj)
        PathScripts.PathLoadTool._ViewProviderLoadTool(obj.ViewObject)

        PathUtils.addToProject(obj)
Beispiel #3
0
    def Create():
        # FreeCADGui.addModule("PathScripts.PathLoadTool")
        # import Path
        import PathScripts
        import PathUtils

        obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", "TC")
        PathScripts.PathLoadTool.LoadTool(obj)
        PathScripts.PathLoadTool._ViewProviderLoadTool(obj.ViewObject)

        PathUtils.addToProject(obj)
Beispiel #4
0
    def copyTools(self):
        tools = []
        model = self.form.ToolsList.model()
        for i in range(model.rowCount()):
            item = model.item(i, 0)
            if item.checkState():
                item = model.index(i, 1)
                tools.append(item.data())
        if len(tools) == 0:
            return

        targets = self.TLM.getLists()
        currList = "<Main>"

        for target in targets:
            if target == currList:
                targets.remove(target)

        if len(targets) == 0:
            FreeCAD.Console.PrintWarning("no place to go")
            return
        elif len(targets) == 1:
            targetlist = targets[0]
        else:
            form = FreeCADGui.PySideUic.loadUi(":/panels/DlgToolCopy.ui")
            form.cboTarget.addItems(targets)
            r = form.exec_()
            if r is False:
                return None
            else:
                targetlist = form.cboTarget.currentText()

        for toolnum in tools:
            tool = self.TLM.getTool(currList, int(toolnum))
            PathLog.debug('tool: {}, toolnum: {}'.format(tool, toolnum))
            for i in FreeCAD.ActiveDocument.findObjects("Path::Feature"):
                if isinstance(i.Proxy, PathScripts.PathJob.ObjectPathJob
                              ) and i.Label == targetlist:

                    label = "T{}: {}".format(toolnum, tool.Name)
                    obj = FreeCAD.ActiveDocument.addObject(
                        "Path::FeaturePython", label)
                    PathScripts.PathLoadTool.LoadTool(obj)
                    PathScripts.PathLoadTool._ViewProviderLoadTool(
                        obj.ViewObject)
                    PathUtils.addToJob(obj, targetlist)
                    FreeCAD.activeDocument().recompute()
                    newtool = tool.copy()
                    obj.Tooltable.setTool(int(toolnum), newtool)
                    obj.ToolNumber = int(toolnum)
                    #obj.recompute()
        FreeCAD.ActiveDocument.recompute()
    def copyTools(self):
        tools = []
        model = self.form.ToolsList.model()
        for i in range(model.rowCount()):
            item = model.item(i, 0)
            if item.checkState():
                item = model.index(i, 1)
                tools.append(item.data())
        if len(tools) == 0:
            return

        targets = self.TLM.getLists()
        currList = "<Main>"

        for target in targets:
            if target == currList:
                targets.remove(target)

        if len(targets) == 0:
            FreeCAD.Console.PrintWarning("no place to go")
            return
        elif len(targets) == 1:
            targetlist = targets[0]
        else:
            form = FreeCADGui.PySideUic.loadUi(":/panels/DlgToolCopy.ui")
            form.cboTarget.addItems(targets)
            r = form.exec_()
            if r is False:
                return None
            else:
                targetlist = form.cboTarget.currentText()

        for toolnum in tools:
            tool = self.TLM.getTool(currList, int(toolnum))
            PathLog.debug('tool: {}, toolnum: {}'.format(tool, toolnum))
            for i in FreeCAD.ActiveDocument.findObjects("Path::Feature"):
                if isinstance(i.Proxy, PathScripts.PathJob.ObjectPathJob) and i.Label == targetlist:

                    label = "T{}: {}".format(toolnum, tool.Name)
                    obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython",label)
                    PathScripts.PathLoadTool.LoadTool(obj)
                    PathScripts.PathLoadTool._ViewProviderLoadTool(obj.ViewObject)
                    PathUtils.addToJob(obj, targetlist)
                    FreeCAD.activeDocument().recompute()
                    newtool = tool.copy()
                    obj.Tooltable.setTool(int(toolnum), newtool)
                    obj.ToolNumber = int(toolnum)
                    #obj.recompute()
        FreeCAD.ActiveDocument.recompute()
Beispiel #6
0
    def execute(self, obj):

        tool = PathUtils.getTool(obj, obj.ToolNumber)
        if tool is not None:
            obj.Label = obj.Name + ": " + tool.Name
        else:
            obj.Label = obj.Name + ": UNDEFINED TOOL"

        commands = ""
        commands += "(" + obj.Label + ")"+'\n'
        commands += 'M6T'+str(obj.ToolNumber)+'\n'

        if obj.SpindleDir == 'Forward':
            commands += 'M3S' + str(obj.SpindleSpeed) + '\n'

        else:
            commands += 'M4S' + str(obj.SpindleSpeed) + '\n'

        # print output
        if commands == "":
            commands += "(No commands processed)"


        path = Path.Path(commands)
        obj.Path = path
        if obj.ViewObject:
            obj.ViewObject.Visibility = True
Beispiel #7
0
    def execute(self, obj):

        tool = PathUtils.getTool(obj, obj.ToolNumber)
        if tool is not None:
            obj.Label = obj.Name + ": " + tool.Name
        else:
            obj.Label = obj.Name + ": UNDEFINED TOOL"

        commands = ""
        commands += "(" + obj.Label + ")" + '\n'
        commands += 'M6T' + str(obj.ToolNumber) + '\n'

        if obj.SpindleDir == 'Forward':
            commands += 'M3S' + str(obj.SpindleSpeed) + '\n'

        else:
            commands += 'M4S' + str(obj.SpindleSpeed) + '\n'

        # print output
        if commands == "":
            commands += "(No commands processed)"

        path = Path.Path(commands)
        obj.Path = path
        if obj.ViewObject:
            obj.ViewObject.Visibility = True
 def onChanged(self, obj, prop):
     if prop == "ToolNumber" and not 'Restore' in obj.State:
         job = PathUtils.findParentJob(obj)
         if job is not None:
             for g in job.Group:
                 if not(isinstance(g.Proxy, PathScripts.PathLoadTool.LoadTool)):
                     g.touch()
Beispiel #9
0
 def onChanged(self, obj, prop):
     mode = 2
     obj.setEditorMode('Placement', mode)
     # if prop == "ToolNumber":
     proj = PathUtils.findProj()
     for g in proj.Group:
         if not(isinstance(g.Proxy, PathScripts.PathLoadTool.LoadTool)):
             g.touch()
Beispiel #10
0
 def allow(self, doc, obj, sub):
     PathLog.debug('obj: {} sub: {}'.format(obj, sub))
     if hasattr(obj, "Shape"):
         obj = obj.Shape
         subobj = obj.getElement(sub)
         return PathUtils.isDrillable(obj, subobj)
     else:
         return False
Beispiel #11
0
 def onChanged(self, obj, prop):
     mode = 2
     obj.setEditorMode('Placement', mode)
     # if prop == "ToolNumber":
     proj = PathUtils.findProj()
     for g in proj.Group:
         if not (isinstance(g.Proxy, PathScripts.PathLoadTool.LoadTool)):
             g.touch()
Beispiel #12
0
 def onChanged(self, obj, prop):
     if prop == "ToolNumber" and not 'Restore' in obj.State:
         job = PathUtils.findParentJob(obj)
         if job is not None:
             for g in job.Group:
                 if not (isinstance(g.Proxy,
                                    PathScripts.PathLoadTool.LoadTool)):
                     g.touch()
Beispiel #13
0
 def allow(self, doc, obj, sub):
     PathLog.debug('obj: {} sub: {}'.format(obj, sub))
     if hasattr(obj, "Shape"):
         obj = obj.Shape
         subobj = obj.getElement(sub)
         return PathUtils.isDrillable(obj, subobj)
     else:
         return False
Beispiel #14
0
 def onChanged(self, obj, prop):
     mode = 2
     obj.setEditorMode('Placement', mode)
     # if prop == "ToolNumber":
     job = PathUtils.findParentJob(obj)
     if job is not None:
         for g in job.Group:
             if not(isinstance(g.Proxy, PathScripts.PathLoadTool.LoadTool)):
                 g.touch()
Beispiel #15
0
    def changeTool(self):
        myJob = PathUtils.findParentJob(self.obj)
        newtool = self.form.cboToolSelect.currentText()

        tooltable = myJob.Tooltable
        for number, tool in tooltable.Tools.iteritems():
            if tool.Name == newtool:
                self.obj.ToolNumber = number
        self.setFields()
    def changeTool(self):
        myJob = PathUtils.findParentJob(self.obj)
        newtool = self.form.cboToolSelect.currentText()

        tooltable = myJob.Tooltable
        for number, tool in tooltable.Tools.iteritems():
            if tool.Name == newtool:
                self.obj.ToolNumber = number
        self.setFields()
Beispiel #17
0
    def checkCopy(self):
        self.form.btnCopyTools.setEnabled(False)
        model = self.form.ToolsList.model()
        for i in range(model.rowCount()):
            item = model.item(i, 0)
            if item.checkState():
                self.form.btnCopyTools.setEnabled(True)

        if len(PathUtils.GetJobs()) == 0:
            self.form.btnCopyTools.setEnabled(False)
Beispiel #18
0
    def Create(jobname=None, assignViewProvider=True, tool=None, toolNumber=1):
        PathLog.track("tool: {} with toolNumber: {}".format(tool, toolNumber))

        import PathScripts
        import PathUtils

        obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", "Default Tool")
        PathScripts.PathLoadTool.LoadTool(obj)
        if assignViewProvider:
            PathScripts.PathLoadTool._ViewProviderLoadTool(obj.ViewObject)

        if tool is None:
            tool = Path.Tool()
            tool.Diameter = 5.0
            tool.Name = "Default Tool"
            tool.CuttingEdgeHeight = 15.0
            tool.ToolType = "EndMill"
            tool.Material = "HighSpeedSteel"
        obj.Tooltable.setTool(toolNumber, tool)
        obj.ToolNumber = toolNumber
        PathUtils.addToJob(obj, jobname)
Beispiel #19
0
def gen_android_mk(mkfile, pathes, suffix=(
    "c",
    "cpp",
), exclude=()):
    utils = PathUtils.PathUtils(COCOS_ROOT)
    filelst = utils.find_files(pathes, suffix, exclude)

    # generate file list string
    filestrio = cStringIO.StringIO()
    mkfilepath = os.path.dirname(os.path.join(COCOS_ROOT, mkfile))
    for filename in filelst:
        filestrio.write(' \\\n')
        filepath = os.path.relpath(filename, mkfilepath)
        filestrio.write(filepath.replace('\\', '/'))
    filestrio.write('\n')

    # read mk file
    file = open(os.path.join(COCOS_ROOT, mkfile))
    mkstrio = cStringIO.StringIO()
    rep = re.compile("\s*LOCAL_SRC_FILES\s*:=")
    try:
        # read lines before encounter "LOCAL_EXPORT_C_INCLUDES"
        for line in file:
            if rep.match(line):
                mkstrio.write("LOCAL_SRC_FILES :=")
                break
            else:
                mkstrio.write(line)
    #mkstrio.write('\n')

    # write file list
        mkstrio.write(filestrio.getvalue())

        # write remaining lines
        delete = True if line[len(line) - 2] == '\\' else False
        for line in file:
            if delete:
                delete = True if line[len(line) - 2] == '\\' else False
            else:
                mkstrio.write(line)


#mkstrio.write('\n')
    finally:
        file.close()

    file = open(os.path.join(COCOS_ROOT, mkfile), "w")
    file.write(mkstrio.getvalue())
    file.close()

    filestrio.close()
    mkstrio.close()
Beispiel #20
0
    def Create(jobname=None, assignViewProvider=True, tool=None, toolNumber=1):
        PathLog.track("tool: {} with toolNumber: {}".format(tool, toolNumber))

        import PathScripts
        import PathUtils

        obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython",
                                               "Default Tool")
        PathScripts.PathLoadTool.LoadTool(obj)
        if assignViewProvider:
            PathScripts.PathLoadTool._ViewProviderLoadTool(obj.ViewObject)

        if tool is None:
            tool = Path.Tool()
            tool.Diameter = 5.0
            tool.Name = "Default Tool"
            tool.CuttingEdgeHeight = 15.0
            tool.ToolType = "EndMill"
            tool.Material = "HighSpeedSteel"
        obj.Tooltable.setTool(toolNumber, tool)
        obj.ToolNumber = toolNumber
        PathUtils.addToJob(obj, jobname)
Beispiel #21
0
    def Activated(self):
        FreeCAD.ActiveDocument.openTransaction(translate("Path_LoadTool", "Create Tool Controller Object"))
        snippet = '''
import Path, PathScripts
from PathScripts import PathUtils, PathLoadTool

obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython","TC")
PathScripts.PathLoadTool.LoadTool(obj)
PathScripts.PathLoadTool._ViewProviderLoadTool(obj.ViewObject)

PathUtils.addToProject(obj)
'''
        FreeCADGui.doCommand(snippet)
        FreeCAD.ActiveDocument.commitTransaction()
        FreeCAD.ActiveDocument.recompute()
Beispiel #22
0
    def onChanged(self, obj, prop):
        PathLog.track('prop: {}  state: {}'.format(prop, obj.State))

        if 'Restore' not in obj.State:
            if prop == "ToolNumber":
                toolitem = obj.Tooltable.Tools.popitem()
                oldtoolnum = toolitem[0]
                tool = toolitem[1]
                obj.Tooltable.deleteTool(oldtoolnum)
                obj.Tooltable.setTool(obj.ToolNumber, tool)
            else:
                job = PathUtils.findParentJob(obj)
                if job is not None:
                    for g in job.Group:
                        if not (isinstance(g.Proxy,
                                           PathScripts.PathLoadTool.LoadTool)):
                            g.touch()
Beispiel #23
0
    def execute(self, obj):

        tool = PathUtils.getTool(obj, obj.ToolNumber)
        if tool is not None:
            obj.Label = obj.Name + ": " + tool.Name
        else:
            obj.Label = obj.Name + ": UNDEFINED TOOL"

        commands = ""
        commands += "(" + obj.Label + ")"+'\n'
        commands += 'M6T'+str(obj.ToolNumber)+'\n'

        if obj.SpindleDir == 'Forward':
            commands += 'M3S' + str(obj.SpindleSpeed) + '\n'

        else:
            commands += 'M4S' + str(obj.SpindleSpeed) + '\n'
Beispiel #24
0
    def onChanged(self, obj, prop):
        PathLog.track('prop: {}  state: {}'.format(prop, obj.State))


        if 'Restore' not in obj.State:
            if prop == "ToolNumber":
                toolitem = obj.Tooltable.Tools.popitem()
                oldtoolnum = toolitem[0]
                tool = toolitem[1]
                obj.Tooltable.deleteTool(oldtoolnum)
                obj.Tooltable.setTool(obj.ToolNumber, tool)
            else:
                job = PathUtils.findParentJob(obj)
                if job is not None:
                    for g in job.Group:
                        if not(isinstance(g.Proxy, PathScripts.PathLoadTool.LoadTool)):
                            g.touch()
Beispiel #25
0
    def setFields(self):
        self.form.cboToolSelect.blockSignals(True)

        self.form.vertFeed.setText(str(self.obj.VertFeed.Value))
        self.form.horizFeed.setText(str(self.obj.HorizFeed.Value))
        self.form.vertRapid.setText(str(self.obj.VertRapid.Value))
        self.form.horizRapid.setText(str(self.obj.HorizRapid.Value))

        self.form.spindleSpeed.setValue(self.obj.SpindleSpeed)
        self.form.tcoName.setText(str(self.obj.Label))

        index = self.form.cboSpindleDirection.findText(
            self.obj.SpindleDir, QtCore.Qt.MatchFixedString)
        if index >= 0:
            self.form.cboSpindleDirection.setCurrentIndex(index)
        myJob = PathUtils.findParentJob(self.obj)

        #populate the toolselector and select correct tool
        self.form.cboToolSelect.clear()
        tooltable = myJob.Tooltable
        for number, tool in tooltable.Tools.iteritems():
            self.form.cboToolSelect.addItem(tool.Name)

        try:
            tool = myJob.Tooltable.Tools[self.obj.ToolNumber]
            self.form.txtToolType.setText(tool.ToolType)
            self.form.txtToolMaterial.setText(tool.Material)
            self.form.txtToolDiameter.setText(str(tool.Diameter))

            index = self.form.cboToolSelect.findText(
                tool.Name, QtCore.Qt.MatchFixedString)
            if index >= 0:
                self.form.cboToolSelect.setCurrentIndex(index)

        except:
            self.form.cboToolSelect.setCurrentIndex(-1)
            self.form.txtToolType.setText("UNDEFINED")
            self.form.txtToolMaterial.setText("UNDEFINED")
            self.form.txtToolDiameter.setText("UNDEFINED")
        self.form.cboToolSelect.blockSignals(False)

        radius = tool.Diameter / 2
        length = tool.CuttingEdgeHeight
        t = Part.makeCylinder(radius, length)
        self.toolrep.Shape = t
    def Activated(self):
        FreeCAD.ActiveDocument.openTransaction(translate("Current Tool","Tool Number to Load"))
        FreeCADGui.addModule("PathScripts.PathLoadTool")
        snippet = '''
import Path
import PathScripts
from PathScripts import PathProject, PathUtils
prjexists = False
obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython","Tool")
PathScripts.PathLoadTool.LoadTool(obj)

PathScripts.PathLoadTool._ViewProviderLoadTool(obj.ViewObject)

PathUtils.addToProject(obj)
'''
        FreeCADGui.doCommand(snippet)
        FreeCAD.ActiveDocument.commitTransaction()
        FreeCAD.ActiveDocument.recompute()
Beispiel #27
0
    def Activated(self):
        FreeCAD.ActiveDocument.openTransaction(translate("Current Tool","Tool Number to Load"))
        FreeCADGui.addModule("PathScripts.PathLoadTool")
        snippet = '''
import Path
import PathScripts
from PathScripts import PathProject, PathUtils
prjexists = False
obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython","Tool")
PathScripts.PathLoadTool.LoadTool(obj)

PathScripts.PathLoadTool._ViewProviderLoadTool(obj.ViewObject)

PathUtils.addToProject(obj)
'''
        FreeCADGui.doCommand(snippet)
        FreeCAD.ActiveDocument.commitTransaction()
        FreeCAD.ActiveDocument.recompute()
    def setFields(self):
        self.form.cboToolSelect.blockSignals(True)

        self.form.vertFeed.setText(str(self.obj.VertFeed.Value))
        self.form.horizFeed.setText(str(self.obj.HorizFeed.Value))
        self.form.vertRapid.setText(str(self.obj.VertRapid.Value))
        self.form.horizRapid.setText(str(self.obj.HorizRapid.Value))

        self.form.spindleSpeed.setValue(self.obj.SpindleSpeed)
        self.form.tcoName.setText(str(self.obj.Label))

        index = self.form.cboSpindleDirection.findText(self.obj.SpindleDir, QtCore.Qt.MatchFixedString)
        if index >= 0:
            self.form.cboSpindleDirection.setCurrentIndex(index)
        myJob = PathUtils.findParentJob(self.obj)

        #populate the toolselector and select correct tool
        self.form.cboToolSelect.clear()
        tooltable = myJob.Tooltable
        for number, tool in tooltable.Tools.iteritems():
            self.form.cboToolSelect.addItem(tool.Name)

        try:
            tool = myJob.Tooltable.Tools[self.obj.ToolNumber]
            self.form.txtToolType.setText(tool.ToolType)
            self.form.txtToolMaterial.setText(tool.Material)
            self.form.txtToolDiameter.setText(str(tool.Diameter))

            index = self.form.cboToolSelect.findText(tool.Name, QtCore.Qt.MatchFixedString)
            if index >= 0:
                self.form.cboToolSelect.setCurrentIndex(index)

        except:
            self.form.cboToolSelect.setCurrentIndex(-1)
            self.form.txtToolType.setText("UNDEFINED")
            self.form.txtToolMaterial.setText("UNDEFINED")
            self.form.txtToolDiameter.setText("UNDEFINED")
        self.form.cboToolSelect.blockSignals(False)

        radius = tool.Diameter / 2
        length = tool.CuttingEdgeHeight
        t = Part.makeCylinder(radius, length)
        self.toolrep.Shape = t
    def __init__(self, config=None):
        '''
        Constructor
        '''        
        self.restrictionEnzymeList = list()
        self.speciesList = list()
        resDir = os.path.join(PathUtils.getCwd(), "res")
        
        self.SPSUMHandler = KazusaSPSUMHandler(resDir)
        
        if config:
            self.loadConfig(config)
        
        self.possibleOptimizationStrategies = ["Fastest Codons", "Adapt Speed To Source", "Random Adapt To Target"]
        self.optimizer = None
        
#         self.speciesList.append(("1234", "Testus specius"))
        
        self.sourceSequence = ""
        self.optimizedSequence = ""
Beispiel #30
0
    def execute(self, obj):
#        if obj.ToolNumber != 0:

        tool = PathUtils.getTool(obj, obj.ToolNumber)
        if tool is not None:
            obj.Label = obj.Name + ": (" + tool.Name + ")"
        else:
            obj.Label = obj.Name + ": (UNDEFINED TOOL)"


        commands = ""
        commands = 'M6T'+str(obj.ToolNumber)+'\n'

        if obj.SpindleDir == 'Forward':
            commands += 'M3S' + str(obj.SpindleSpeed) + '\n'

        else:
            commands += 'M4S' + str(obj.SpindleSpeed) + '\n'

        obj.Path = Path.Path(commands)
Beispiel #31
0
    def setFields(self):
        self.form.vertFeed.setText(str(self.obj.VertFeed.Value))
        self.form.horizFeed.setText(str(self.obj.HorizFeed.Value))
        self.form.spindleSpeed.setValue(self.obj.SpindleSpeed)
        self.form.tcoName.setText(str(self.obj.Label))

        index = self.form.cboSpindleDirection.findText(self.obj.SpindleDir, QtCore.Qt.MatchFixedString)
        if index >= 0:
            self.form.cboSpindleDirection.setCurrentIndex(index)
        # Populate the tool list
        mach = PathUtils.findMachine()
        try:
            tool = mach.Tooltable.Tools[self.obj.ToolNumber]
            self.form.txtToolName.setText(tool.Name)
            self.form.txtToolType.setText(tool.ToolType)
            self.form.txtToolMaterial.setText(tool.Material)
            self.form.txtToolDiameter.setText(str(tool.Diameter))
        except:
            self.form.txtToolName.setText("UNDEFINED")
            self.form.txtToolType.setText("UNDEFINED")
            self.form.txtToolMaterial.setText("UNDEFINED")
            self.form.txtToolDiameter.setText("UNDEFINED")
Beispiel #32
0
def main():

    print ".......VARIABLES......."
    print "COCOS_ROOT:",
    print COCOS_ROOT
    print "H_DIR:",
    print H_DIR
    print "CXX_DIR:",
    print CXX_DIR
    print "EXCLUDE:",
    print EXCLUDE
    print ".......VARIABLES END......"

    utils = PathUtils.PathUtils(COCOS_ROOT)
    # save the .h file for search
    hfiles = utils.find_files(H_DIR, ("h",), EXCLUDE)
    # save the .cpp and .mm file for search
    cxxfiles = utils.find_files(CXX_DIR, ("cpp", "mm"))

    print "search class declarations"
    # the class set, ignore the namespace
    classes = set()
    for file in hfiles:
        collect_class_name(file, classes)
    print "search end"

    # generate example rep:
    # (\W+|^)(?P<keyWord>\S*(?:Class1|Class2|class3)\s*(?:\*+|\s+)\s*)\w+\s*=(?!\s*(?:0|NULL|nullptr)\s*\W)
    # examples:
    # Class1* c = new Class1() ; //match
    # Class1* c;                 //not match
    # Class1* c = nullptr;       //not match
    # Class1* c = nullptrabc;    //match
    # Class1 c;                  //not match
    # Class1 c = Class1();       //match
    def gen_rep(keyWord):
        s = cStringIO.StringIO()
        s.write("(?:\W+|^)(?P<")
        s.write(keyWord)
        s.write(">(?:")

        # add classes want to match
        first = True
        for cls in classes:
            if first:
                first = False
            else:
                s.write("|")

            s.write(cls)

        s.write(")\s*(?:\*+|\s+)\s*)\w+\s*=(?!\s*(?:")

        # let nullptr assignment not to convert
        first = True
        for nullptr in NULL_PTR:
            if first:
                first = False
            else:
                s.write("|")

            s.write(nullptr)

        s.write(")\s*\W)")

        result = s.getvalue()
        s.close()

        print "generated regular expression is:"
        print result
        return re.compile(result)
	
    repWord = "change"
    rep = gen_rep(repWord)


    print "scan and edit the .cxx files..."
    # scan the cxx files
    for file in cxxfiles:
        change_local_classvarname_to_auto(os.path.join(COCOS_ROOT, file), rep, repWord)
 	
    print "success!"
Beispiel #33
0
'''
Created on 14.02.2015

@author: David
'''
from OptimizerApp import OptimizerApp
from OptimizerMainWindow import OptimizerMainWindow
import SeqUtils
import os, sys
import PathUtils

if __name__ == '__main__':

    #     print(SeqUtils.getRemainderSuffix("AAAACCA"))
    configFile = os.path.join(PathUtils.getCwd(), "config.ini")
    print(configFile)
    myOptimizer = OptimizerApp(configFile)
    myOptimizerGUI = OptimizerMainWindow(myOptimizer)
#     gui = Tk()
#     gui.mainloop()
#     myOptimizer.testPrint()
'''
Created on 14.02.2015

@author: David
'''
from OptimizerApp import OptimizerApp
from OptimizerMainWindow import OptimizerMainWindow
import SeqUtils
import os, sys
import PathUtils

if __name__ == '__main__':
    
#     print(SeqUtils.getRemainderSuffix("AAAACCA"))
    configFile = os.path.join(PathUtils.getCwd(), "config.ini")
    print(configFile)
    myOptimizer = OptimizerApp(configFile)
    myOptimizerGUI = OptimizerMainWindow(myOptimizer)
#     gui = Tk()
#     gui.mainloop()
#     myOptimizer.testPrint()