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)
def test24(self): '''Find a tool library from a valid absolute path.''' path = PathToolBit.findToolBit(testToolBit()) self.assertIsNot(path, None) self.assertEqual(path, testToolBit())
def test13(self): '''Not find a tool bit from an invalid absolute path.''' path = PathToolBit.findToolBit(testToolBit(TestInvalidDir)) self.assertIsNone(path)
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())
def test11(self): '''Not find a relative path bit if not stored in default location''' path = PathToolBit.findToolBit(TestToolBitName) self.assertIsNone(path)
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')
def test14(self): """Find a tool bit from a valid absolute path.""" path = PathToolBit.findToolBit(testToolBit()) self.assertIsNot(path, None) self.assertEqual(path, testToolBit())
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")