コード例 #1
0
ファイル: damproject.py プロジェクト: 2Minutes/davos-dev
    def getLibrary(self, sSpace, sLibSection, owner="", dbNode=True, weak=False,
                   remember=True, tokens=None):
        logMsg(log='all')

        self._assertSpaceAndSection(sSpace, sLibSection)

        sFullLibName = DrcLibrary.makeFullName(owner, sSpace, sLibSection)
        drcLib = self.loadedLibraries.get(sFullLibName, None)

        if not drcLib:
            if tokens:
                sLibPath = self.getPath(sSpace, sLibSection, resVars=False, tokens=tokens)
            else:
                sLibPath = self.getPath(sSpace, sLibSection)

            drcLib = self.__libClass(sLibSection, sLibPath, sSpace, owner=owner,
                                     project=self, dbNode=dbNode, remember=remember)
            if weak:
                return drcLib

            if osp.isdir(sLibPath):
                return drcLib
            else:
                logMsg("No such '{}': '{}'.".format(sFullLibName, sLibPath),
                       warning=True)
                return None

        return drcLib
コード例 #2
0
ファイル: damproject.py プロジェクト: 2Minutes/davos-dev
    def _iterLibrariesSpaceAndSection(self, space=LIBRARY_SPACES, fullName=False):

        sSpaceList = argToTuple(space)

        for sLibSection in self.__confLibraries:
            for sSpace in sSpaceList:
                if fullName:
                    yield DrcLibrary.makeFullName(sSpace, sLibSection)
                else:
                    yield (sSpace, sLibSection)
コード例 #3
0
ファイル: damproject.py プロジェクト: 2Minutes/davos-dev
    def _checkLibraryPaths(self, noError=False):

        sMissingPathList = []

        sSamePathDct = {}

        for sSpace, sLibSection in self._iterLibrariesSpaceAndSection():

            sLibFullName = DrcLibrary.makeFullName(sSpace, sLibSection)
            sLibPath = self.getPath(sSpace, sLibSection)

            sSamePathDct.setdefault(normCase(sLibPath), []).append(sLibFullName)

            if not osp.isdir(sLibPath):

                if sSpace == "public":
                    msg = u"No such '{}': '{}'.".format(sLibFullName, sLibPath)
                    if noError:
                        logMsg(msg, warning=True)
                    else:
                        raise EnvironmentError(msg)
                elif sSpace == "private":
                    sMissingPathList.append((sLibFullName, sLibPath))

        sSamePathList = tuple((p, libs) for p, libs in sSamePathDct.iteritems() if len(libs) > 1)
        if sSamePathList:
            msgIter = (u"'{}': {}".format(p, libs) for p, libs in sSamePathList)
            msg = u"Libraries using the same path:\n\n    " + u"\n    ".join(msgIter)
            raise EnvironmentError(msg)

        if sMissingPathList:

            msgIter = (u"'{}': '{}'".format(n, p) for n, p in sMissingPathList)
            msg = u"No such libraries:\n" + u"\n".join(msgIter)

            sConfirm = confirmDialog(title='WARNING !',
                                     message=msg + u"\n\nShould I create them ?",
                                     button=['Yes', 'No'],
                                     defaultButton='No',
                                     cancelButton='No',
                                     dismissString='No',
                                     icon="warning")

            if sConfirm == 'No':
                return False

            for _, p in sMissingPathList:
                os.makedirs(p)

        return True
コード例 #4
0
ファイル: damproject.py プロジェクト: 2Minutes/davos-dev
 def listUiClasses(self):
     return DrcLibrary.listUiClasses()