Make Toolbit find Bit files relative to the current library directory
This commit is contained in:
@@ -27,8 +27,8 @@ import glob
|
||||
import os
|
||||
import PathScripts.PathLog as PathLog
|
||||
|
||||
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
|
||||
#PathLog.trackModule()
|
||||
# PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
|
||||
# PathLog.trackModule()
|
||||
|
||||
DefaultFilePath = "DefaultFilePath"
|
||||
DefaultJobTemplate = "DefaultJobTemplate"
|
||||
@@ -152,7 +152,9 @@ def searchPathsTool(sub='Bit'):
|
||||
paths = []
|
||||
|
||||
if 'Bit' == sub:
|
||||
paths.append("{}/Bit".format(os.path.dirname(lastPathToolLibrary())))
|
||||
paths.append(lastPathToolBit())
|
||||
|
||||
if 'Library' == sub:
|
||||
paths.append(lastPathToolLibrary())
|
||||
if 'Shape' == sub:
|
||||
|
||||
@@ -59,16 +59,19 @@ ParameterTypeConstraint = {
|
||||
|
||||
|
||||
def _findTool(path, typ, dbg=False):
|
||||
if os.path.exists(path):
|
||||
# PathLog.track("Path: {} typ: {}".format(path, typ))
|
||||
if os.path.exists(path): # absolute reference
|
||||
if dbg:
|
||||
PathLog.debug("Found {} at {}".format(typ, path))
|
||||
return path
|
||||
|
||||
def searchFor(pname, fname):
|
||||
# PathLog.debug("pname: {} fname: {}".format(pname, fname))
|
||||
if dbg:
|
||||
PathLog.debug("Looking for {}".format(pname))
|
||||
if fname:
|
||||
for p in PathPreferences.searchPathsTool(typ):
|
||||
PathLog.track(p)
|
||||
f = os.path.join(p, fname)
|
||||
if dbg:
|
||||
PathLog.debug(" Checking {}".format(f))
|
||||
@@ -77,6 +80,7 @@ def _findTool(path, typ, dbg=False):
|
||||
PathLog.debug(" Found {} at {}".format(typ, f))
|
||||
return f
|
||||
if pname and os.path.sep != pname:
|
||||
PathLog.track(pname)
|
||||
ppname, pfname = os.path.split(pname)
|
||||
ffname = os.path.join(pfname, fname) if fname else pfname
|
||||
return searchFor(ppname, ffname)
|
||||
@@ -94,6 +98,7 @@ def findShape(path):
|
||||
|
||||
|
||||
def findBit(path):
|
||||
PathLog.track(path)
|
||||
if path.endswith('.fctb'):
|
||||
return _findTool(path, 'Bit')
|
||||
return _findTool("{}.fctb".format(path), 'Bit')
|
||||
|
||||
@@ -229,6 +229,9 @@ class ModelFactory(object):
|
||||
if lib == "":
|
||||
lib = PathPreferences.lastFileToolLibrary()
|
||||
|
||||
if lib == "" or lib is None:
|
||||
return model
|
||||
|
||||
if os.path.isfile(lib): # An individual library is wanted
|
||||
self.__libraryLoad(lib, model)
|
||||
|
||||
@@ -250,9 +253,13 @@ class ToolBitSelector(object):
|
||||
return ['#', 'Tool']
|
||||
|
||||
def curLib(self):
|
||||
libfile = os.path.split(PathPreferences.lastFileToolLibrary())[1]
|
||||
libName = os.path.splitext(libfile)[0]
|
||||
return libName
|
||||
libfile = PathPreferences.lastFileToolLibrary()
|
||||
if libfile is None or libfile == "":
|
||||
return ""
|
||||
else:
|
||||
libfile = os.path.split(PathPreferences.lastFileToolLibrary())[1]
|
||||
libfile = os.path.splitext(libfile)[0]
|
||||
return libfile
|
||||
|
||||
def loadData(self):
|
||||
PathLog.track()
|
||||
|
||||
Reference in New Issue
Block a user