Beispiel #1
0
 def buildFromSettings(self):
     """
     Populate _groups from settings file
     """
     self.log.detail("Build userGroups from settings ...")
     grpDict = pFile.readDictFile(self.settingsFile)
     self.buildChilds(grpDict)
Beispiel #2
0
    def loadProject(self, project):
        """
        Load given project

        :param project: Project (name--code)
        :type project: str
        """
        self.log.info("#--- Load Project: %r ---#" % project)
        #--- Check Project ---#
        projectFile = pFile.conformPath(
            os.path.join(self._fdn.__projectsPath__, project,
                         '%s.py' % project))
        if not os.path.exists(projectFile):
            raise ValueError("!!! Project %r not found !!!" % project)
        #--- Get Project ---#
        try:
            projectDict = pFile.readDictFile(projectFile)
        except:
            raise IOError("!!! Can not load project %r !!!" % project)
        #--- Load Project ---#
        if self._fdn.__user__ in projectDict['watchers']:
            self.update(**projectDict)
            self.log.info("---> Project %r successfully loaded" % project)
        else:
            raise ValueError("User %r is not set as projectUser in %s !" %
                             (self._fdn.__user__, project))
Beispiel #3
0
    def buildTree(self, treeName):
        """
        Refresh 'Projects' tree

        :param treeName: Tree widget name ('allProjects' or 'myProjects')
        :type treeName: str
        """
        #--- Get Projects ---#
        if treeName == 'allProjects':
            self.log.detail("Build 'All Projects' tree ...")
            projects = self._project.projects
            treeWidget = self.tw_allProjects
        else:
            self.log.detail("Build 'My Projects' tree ...")
            projects = self._users._user.userPinedProjects
            treeWidget = self.tw_myProjects
        #--- Populate Tree ---#
        treeWidget.clear()
        for project in projects:
            projectFile = pFile.conformPath(
                os.path.join(self._fdn.__projectsPath__, project,
                             '%s.py' % project))
            data = pFile.readDictFile(projectFile)
            newItem = self.new_projectItem(project, data, treeWidget)
            treeWidget.addTopLevelItem(newItem)
        #--- Refresh ---#
        self.rf_treeColumns(treeWidget)
        treeWidget.sortItems(0, QtCore.Qt.AscendingOrder)
Beispiel #4
0
    def buildTree(self, treeName):
        """
        Refresh 'Projects' tree

        :param treeName: Tree widget name ('allProjects' or 'myProjects')
        :type treeName: str
        """
        #--- Get Projects ---#
        if treeName == 'allProjects':
            self.log.detail("Build 'All Projects' tree ...")
            projects = self._project.projects
            treeWidget = self.tw_allProjects
        else:
            self.log.detail("Build 'My Projects' tree ...")
            projects = self._users._user.userPinedProjects
            treeWidget = self.tw_myProjects
        #--- Populate Tree ---#
        treeWidget.clear()
        for project in projects:
            projectFile = pFile.conformPath(os.path.join(self._fdn.__projectsPath__, project, '%s.py' % project))
            data = pFile.readDictFile(projectFile)
            newItem = self.new_projectItem(project, data, treeWidget)
            treeWidget.addTopLevelItem(newItem)
        #--- Refresh ---#
        self.rf_treeColumns(treeWidget)
        treeWidget.sortItems(0, QtCore.Qt.AscendingOrder)
Beispiel #5
0
    def loadProject(self, project):
        """
        Load given project

        :param project: Project (name--code)
        :type project: str
        """
        self.log.info("#--- Load Project: %r ---#" % project)
        #--- Check Project ---#
        projectFile = pFile.conformPath(os.path.join(self._fdn.__projectsPath__, project, '%s.py' % project))
        if not os.path.exists(projectFile):
            raise ValueError("!!! Project %r not found !!!" % project)
        #--- Get Project ---#
        try:
            projectDict = pFile.readDictFile(projectFile)
        except:
            raise IOError("!!! Can not load project %r !!!" % project)
        #--- Load Project ---#
        if self._fdn.__user__ in projectDict['watchers']:
            self.update(**projectDict)
            for ctxtObj in self.contexts:
                ctxtObj.buildEntities()
            self.log.info("---> Project %r successfully loaded" % project)
        else:
            raise ValueError("User %r is not set as projectUser in %s !" % (self._fdn.__user__, project))
Beispiel #6
0
 def buildContextsFromSettings(self):
     """
     Build Context object from project file
     """
     self.log.detail(">>> Build contexts from project file ...")
     projectDict = pFile.readDictFile(self.projectFile)
     self.buildContexts(*projectDict['contexts'])
Beispiel #7
0
 def buildFromSettings(self):
     """
     Populate _childs from settings file
     """
     projectDict = pFile.readDictFile(self._project.projectFile)
     ctxtDict = dict()
     for ctxt in projectDict['contexts']:
         if ctxt['contextName'] == self.contextName:
             ctxtDict = ctxt
     self.update(**ctxtDict)
Beispiel #8
0
 def buildEntities(self):
     """
     Build all entities from disk
     """
     self.entities = []
     if self.contextPath is not None:
         if os.path.exists(self.contextPath):
             contents = os.listdir(self.contextPath) or []
             for fld in contents:
                 if not fld.startswith('_') and not fld.startswith('.'):
                     path = pFile.conformPath(os.path.join(self.contextPath, fld))
                     entityFile = pFile.conformPath(os.path.join(path, '%s.py' % fld))
                     if os.path.exists(entityFile):
                         self.log.detail(">>> Build entity from file %s ..." % entityFile)
                         data = pFile.readDictFile(entityFile)
                         self.addEntity(self.newEntity(**data))
Beispiel #9
0
 def updateFromFile(self):
     if self.entityFile is not None:
         if os.path.exists(self.entityFile):
             entityData = pFile.readDictFile(self.entityFile)
             self.update(**entityData)
Beispiel #10
0
 def setDataFromUserFile(self):
     """
     Set user data from userFile
     """
     data = pFile.readDictFile(self.userFile)
     self.update(**data)