コード例 #1
0
    def __libraryLoad(self, path, datamodel):
        PathLog.track(path)
        PathPreferences.setLastFileToolLibrary(path)
        # self.currenLib = path

        with open(path) as fp:
            library = json.load(fp)

        for toolBit in library['tools']:
            try:
                nr = toolBit['nr']
                bit = PathToolBit.findToolBit(toolBit['path'], path)
                if bit:
                    PathLog.track(bit)
                    tool = PathToolBit.Declaration(bit)
                    datamodel.appendRow(self._toolAdd(nr, tool, bit))
                else:
                    PathLog.error("Could not find tool #{}: {}".format(nr, toolBit['path']))
            except Exception as e:
                msg = "Error loading tool: {} : {}".format(toolBit['path'], e)
                FreeCAD.Console.PrintError(msg)
コード例 #2
0
 def test24(self):
     '''Find a tool library from a valid absolute path.'''
     path = PathToolBit.findToolBit(testToolBit())
     self.assertIsNot(path, None)
     self.assertEqual(path, testToolBit())
コード例 #3
0
 def test13(self):
     '''Not find a tool bit from an invalid absolute path.'''
     path = PathToolBit.findToolBit(testToolBit(TestInvalidDir))
     self.assertIsNone(path)
コード例 #4
0
 def test12(self):
     '''Find a relative path bit if it's local to a library path'''
     path = PathToolBit.findToolBit(TestToolBitName, testToolLibrary())
     self.assertIsNot(path, None)
     self.assertEqual(path, testToolBit())
コード例 #5
0
 def test11(self):
     '''Not find a relative path bit if not stored in default location'''
     path = PathToolBit.findToolBit(TestToolBitName)
     self.assertIsNone(path)
コード例 #6
0
 def test10(self):
     '''Find a tool bit from file name'''
     path = PathToolBit.findToolBit('5mm_Endmill.fctb')
     self.assertIsNot(path, None)
     self.assertNotEqual(path, '5mm_Endmill.fctb')
コード例 #7
0
 def test14(self):
     """Find a tool bit from a valid absolute path."""
     path = PathToolBit.findToolBit(testToolBit())
     self.assertIsNot(path, None)
     self.assertEqual(path, testToolBit())
コード例 #8
0
 def test10(self):
     """Find a tool bit from file name"""
     path = PathToolBit.findToolBit("5mm_Endmill.fctb")
     self.assertIsNot(path, None)
     self.assertNotEqual(path, "5mm_Endmill.fctb")