Ejemplo n.º 1
0
    def OnItemExpanded(self, event):
        """
        Раскрытие узла по +.
        """
        item = event.GetItem()
        node = self.GetPyData(item)
        if node.__class__.__name__ == 'PrjImportSys' and not node.isBuild():
            try:
                # Затем построить дерево подсистемы
                sub_sys_dir = node.getPathInPrj()
                sub_sys_prj = ic_file.GetFilesByExt(sub_sys_dir, '.pro')[0]
                node.buildSubSysTree(sub_sys_prj)

                # Удалить все дочерние элементы
                self.DeleteChildren(item)

                # Построить ветку узлов дерева подсистемы
                for child in node.getChildren():
                    self.AddBranch(item, child)
            except:
                io_prnt.outErr(u'Open subsystem error')
                wx.MessageBox(u'Open subsystem error', u'ОШИБКА',
                              wx.OK | wx.ICON_ERROR)

        event.Skip()
Ejemplo n.º 2
0
def img2gif_tmp():
    app = wx.PySimpleApp()
    img_lib = icimglib.icImgLibResource()
    img_lib.createNewImgLib()
    png_files = ic_file.GetFilesByExt('./tmp/', '.png')
    for png_file in png_files:
        img_lib.addImg(png_file)
    img_lib.saveImgLib('new_img_lib.py')
Ejemplo n.º 3
0
 def _IsSubSysDir(self, Dir_):
     """
     Проверить, является ли папка папкой подсистемы.
     @param Dir_: Исследуемая папка.
     """
     is_dir = os.path.isdir(Dir_)
     is_init_file = os.path.exists(Dir_ + '/__init__.py')
     is_pro_file = bool(ic_file.GetFilesByExt(Dir_, '.pro'))
     return is_dir and is_init_file and is_pro_file
Ejemplo n.º 4
0
    def openRoles(self):
        """
        Открытие файлов ролей.
        """
        prj_dir = ic.icGet('PRJ_DIR')
        role_files = ic_file.GetFilesByExt(prj_dir, '.rol')
        # Сразу отфильтровать Pkl файлы
        role_files = [role_file for role_file in role_files if '_pkl.rol' not in role_file.lower()]

        for role_file in role_files:
            role_node_name = os.path.splitext(os.path.basename(role_file))[0]
            self._addChildRole(role_node_name)
Ejemplo n.º 5
0
def getRolesChoiceList():
    """
    Функция получения списка ролей, определенных в проекте.
    """
    prj_dir = ic_user.icGet('PRJ_DIR')
    role_files = ic_file.GetFilesByExt(prj_dir, '.rol')
    # Сразу отфильтровать Pkl файлы
    role_files = [
        role_file for role_file in role_files
        if '_pkl.rol' not in role_file.lower()
    ]
    # Получить только базовые имена файлов
    role_files = [
        ic_file.SplitExt(ic_file.BaseName(role_file))[0]
        for role_file in role_files
    ]
    return role_files
Ejemplo n.º 6
0
    def readRoles(self, PrjDir_=None, isSort_=False):
        """
        Чтение ролей из папки проекта.
        @param PrjDir_: Папка проекта.
        @param isSort_: Сортировать роли по имени?
        """
        if PrjDir_ is None:
            PrjDir_ = ic_user.icGet('PRJ_DIR')
        role_files = ic_file.GetFilesByExt(PrjDir_, '.rol')
        # Отфильтровать pickle файлы
        role_files = [role_file for role_file in role_files if role_file[-8:].lower() != '_pkl.rol']

        result = []
        for role_file in role_files:
            role_data = util.readAndEvalFile(role_file)
            role_spc = role_data[role_data.keys()[0]]
            role_name = role_spc['name']
            role_description = role_spc.get('description', u'') or u''
            result.append((role_name, role_description))
        if isSort_:
            result.sort()
        return result
Ejemplo n.º 7
0
    def newImpSys(self):
        """
        Добавить новую подсистему в словарь.
        @return: Возвращает в случае неудачи None,
            в случае успеха сформированный список.
        """
        prj_data = None
        # диалог выбора файла *.pro
        prj_file_name = ic_dlg.icFileDlg(
            self.getParentRoot().getParent().getIDEFrame(),
            u'Выберите подсистему', u'Project file (*.pro)|*.pro')
        if prj_file_name:
            # открыть файл *.pro
            prj_data = self.openPrjFile(prj_file_name)
            new_name = self.readPrjName(prj_data)
            if self.getParentRoot().prj_res_manager.isImpSubSys(new_name):
                ic_dlg.icMsgBox(
                    u'ВНИМАНИЕ',
                    u'Подсистема с таким наименованием уже сеществует!')
                return None
            else:
                # Скопировать в папку текущего проекта
                prj_dir = self._Parent.copySubSys(prj_file_name)
                self.imp_prj_file_name = ic_file.GetFilesByExt(
                    prj_dir, '.pro')[0]
                # добавить в список
                if self.imp_prj_file_name:
                    self.name = new_name
                    self.getParentRoot().prj_res_manager.newSubSys(
                        self.name, prj_file_name, prj_data[0]['__py__'])
                    # Инициализировать
                    self.Default()
                    # И инсталлировать
                    self._install()

        return self.getParentRoot().prj_res_manager.getImportSystems()