Пример #1
0
    def OnItemDocumentation(self, evt):
        """ Display the item's documentation on miniFrame.
		"""

        item = self.GetSelection()
        path = self.GetItemPyData(item)
        name = self.GetItemText(item)

        module = BlockFactory.GetModule(path)
        info = Container.CheckClass(path)

        if isinstance(info, tuple):
            doc = str(info)
        elif isinstance(module, tuple):
            doc = str(module)
        else:
            doc = inspect.getdoc(module)

        if doc:
            dlg = wx.lib.dialogs.ScrolledMessageDialog(
                self,
                doc,
                name,
                style=wx.OK | wx.ICON_EXCLAMATION | wx.DEFAULT_DIALOG_STYLE
                | wx.RESIZE_BORDER)
            dlg.CenterOnParent(wx.BOTH)
            dlg.ShowModal()
        else:
            wx.MessageBox(_('No documentation'), name,
                          wx.OK | wx.ICON_INFORMATION)
Пример #2
0
    def CheckItem(self, path):
        """ Check if the model is valide
		"""

        item = self.ItemDico[path]
        file_path = "".join([path, '.py'])

        ### try to find pyc files
        if not os.path.exists(file_path):
            file_path = "".join([path, '.pyc'])

        if os.path.exists(file_path):

            ### Check the class
            info = Container.CheckClass(file_path)

            ### there is error during the chek of class?
            if isinstance(info, tuple):

                ### if module are missing, we propose to install him with pip
                if ModuleNotFoundError in info:
                    package = info[1].name
                    if install_and_import(package):
                        wx.CallAfter(self.UpdateAll)

                ### else there is an error in the code of the model...
                else:

                    ### recompile if no error
                    info = recompile(path_to_module(file_path))

                    ### there is error during recompilation?
                    if isinstance(info, (Exception, str)):
                        ### Until it has parent, we redifine icon to inform user
                        while (item):
                            ### change image
                            self.SetItemImage(item, self.not_importedidx,
                                              wx.TreeItemIcon_Normal)
                            ### next parent item
                            item = self.GetItemParent(item)
                    else:
                        ### change image
                        self.SetItemImage(item, self.pythonfileidx,
                                          wx.TreeItemIcon_Normal)

                        #### Until it has parent, we redifine icon to inform user
                        while (item):
                            #### change image
                            self.SetItemImage(
                                item, self.fldropenidx if self.IsExpanded(item)
                                else self.fldridx, wx.TreeItemIcon_Normal)
                            #### next parent item
                            item = self.GetItemParent(item)
        else:
            sys.stdout.write("File %s is not checked!")
Пример #3
0
    def OnMotion(self, evt):
        """ Motion engine over item.
		"""
        item, flags = self.HitTest(evt.GetPosition())

        if (flags & wx.TREE_HITTEST_ONITEMLABEL) and not evt.LeftIsDown():

            path = self.GetItemData(item)

            if os.path.isdir(path):
                model_list = self.GetModelList(path)
                domain_list = self.GetDomainList(path)

                tip = '\n'.join(model_list) if model_list != [] else ""
                tip += '\n'
                tip += '\n'.join(domain_list) if domain_list != [] else ""

            ### is last item
            else:
                module = BlockFactory.GetModule(path)
                info = Container.CheckClass(path)

                if isinstance(info, tuple):
                    doc = str(info)
                elif isinstance(module, tuple):
                    doc = str(module)
                else:
                    doc = inspect.getdoc(module)

                tip = doc if doc is not None else _(
                    "No documentation for selected model.")

            ### add maccabe metric info
            if item in self.MetricDico:
                mcc = self.MetricDico[item]['mcc']
                tip = ''.join([tip, '\n', 'macCabe metric: %d' % mcc])

            self.SetToolTip(tip)

        else:
            self.SetToolTip(None)

        ### else the drag and drop dont run
        evt.Skip()
Пример #4
0
    def OnMotion(self, evt):
        """ Motion engine over item.
		"""
        item, flags = self.HitTest(evt.GetPosition())

        if (flags & wx.TREE_HITTEST_ONITEMLABEL) and not evt.LeftIsDown():

            path = self.GetItemPyData(item)

            if os.path.isdir(path):
                model_list = self.GetModelList(path)
                domain_list = self.GetDomainList(path)

                tip = '\n'.join(model_list) if model_list != [] else ""
                tip += '\n'
                tip += '\n'.join(domain_list) if domain_list != [] else ""

            ### is last item
            else:
                module = BlockFactory.GetModule(path)
                info = Container.CheckClass(path)

                if isinstance(info, tuple):
                    doc = str(info)
                elif isinstance(module, tuple):
                    doc = str(module)
                else:
                    doc = inspect.getdoc(module)

                tip = doc if doc is not None else _(
                    "No documentation for selected model.")

            try:
                txt = tip.decode('utf-8', 'ignore')
            except UnicodeEncodeError:
                sys.stdout.write("Unicode Error!\n")
            else:
                self.SetToolTip(wx.ToolTip(txt))

        else:
            self.SetToolTip(None)

        ### else the drag and drop dont run
        evt.Skip()
Пример #5
0
    def CheckItem(self, path):
        """ Check if the model is valide
		"""

        item = self.ItemDico[path]
        file_path = "".join([path, '.py'])

        ### Check the class
        info = Container.CheckClass(file_path)

        ### there is error during the chek of class ?
        if isinstance(info, tuple):
            ### recompile if no error
            info = recompile(path_to_module(file_path))

            ### there is error during recompilation ?
            if isinstance(info, (Exception, str)):
                ### Until it has parent, we redifine icon to inform user
                while (item):
                    ### change image
                    self.SetItemImage(item, self.not_importedidx,
                                      wx.TreeItemIcon_Normal)
                    ### next parent item
                    item = self.GetItemParent(item)
            else:
                ### change image
                self.SetItemImage(item, self.pythonfileidx,
                                  wx.TreeItemIcon_Normal)

                #### Until it has parent, we redifine icon to inform user
                while (item):
                    if self.IsExpanded(item):
                        #### change image
                        self.SetItemImage(item, self.fldropenidx,
                                          wx.TreeItemIcon_Normal)
                    else:
                        self.SetItemImage(item, self.fldridx,
                                          wx.TreeItemIcon_Normal)

                    #### next parent item
                    item = self.GetItemParent(item)
Пример #6
0
    def OnItemDocumentation(self, evt):
        """ Display the item's documentation on miniFrame.
		"""

        item = self.GetSelection()
        path = self.GetItemPyData(item)
        name = self.GetItemText(item)

        module = BlockFactory.GetModule(path)
        info = Container.CheckClass(path)

        if isinstance(info, tuple):
            doc = str(info)
        elif isinstance(module, tuple):
            doc = str(module)
        else:
            doc = inspect.getdoc(module)

        ### Add maccabe complexity measure
        doc += "".join(
            [_("\n\n MacCabe Complexity: %d") % self.MetricDico[item]['mcc']])

        if doc:
            dlg = wx.lib.dialogs.ScrolledMessageDialog(
                self,
                doc,
                _("%s Documentation") % name,
                style=wx.OK | wx.ICON_EXCLAMATION | wx.DEFAULT_DIALOG_STYLE
                | wx.RESIZE_BORDER)
            dlg.CenterOnParent(wx.BOTH)
            dlg.ShowModal()
        else:
            wx.MessageBox(
                _("No documentation! \n Please define the documentation of the model %s in the header of its python file."
                  ) % name,
                _("%s Documentation") % name, wx.OK | wx.ICON_INFORMATION)
Пример #7
0
    def InsertNewDomain(self, dName, parent, L=[]):
        """ Recurrent function that insert new Domain on library panel.
		"""

        ### first only for the root
        if dName not in list(self.ItemDico.keys()):

            label = os.path.basename(dName) if not dName.startswith(
                'http') else [a for a in dName.split('/') if a != ''][-1]
            id = self.InsertItemBefore(parent, 0, label)
            self.SetItemImage(id, self.fldridx, wx.TreeItemIcon_Normal)
            self.SetItemImage(id, self.fldropenidx, wx.TreeItemIcon_Expanded)
            self.SetItemBold(id)
            self.ItemDico.update({dName: id})
            self.SetPyData(id, dName)

        ### end
        if L == []:
            return
        else:
            item = L.pop(0)

            isunicode = isinstance(item, str)
            isstr = isinstance(item, str)
            isdict = isinstance(item, dict)

            ### element to insert in the list
            D = []
            ### if child is build from DEVSimPy
            if isstr:

                ### parent is retrieved from dict
                parent = self.ItemDico[dName]
                assert parent != None

                ### parent path
                parentPath = self.GetPyData(parent)
                come_from_net = parentPath.startswith('http')

                ### comma replace
                item = item.strip()

                ### suppression de l'extention su .cmd (model atomic lu à partir de __init__ donc pas d'extention)
                if item.endswith('.cmd'):
                    ### gestion de l'importation de module (.py) associé au .cmd si le fichier .py n'a jamais été decompresssé (pour edition par exemple)
                    if not come_from_net:
                        path = os.path.join(parentPath, item)
                        zf = Zip(path)
                        module = zf.GetModule()
                        image_file = zf.GetImage()
                    else:
                        path = "".join([parentPath, '/', item, '.py'])
                        module = load_module_from_net(path)

                    ### check error
                    error = isinstance(module, Exception)

                    ### change icon depending on the error and the presence of image in amd
                    if error:
                        img = self.not_importedidx
                    elif image_file is not None:
                        img = self.il.Add(image_file.ConvertToBitmap())
                    else:
                        img = self.coupledidx

                    ### insert into the tree
                    id = self.InsertItemBefore(parent, 0,
                                               os.path.splitext(item)[0], img,
                                               img)
                    self.SetPyData(id, path)

                    self.MetricDico.update(
                        {id: {
                            'mcc': 0.0,
                            'parent': parent
                        }})
                    s = sum([
                        d['mcc'] for id, d in self.MetricDico.items()
                        if d['parent'] == parent
                    ])
                    self.MetricDico.update(
                        {parent: {
                            'mcc': s,
                            'parent': None
                        }})

                elif item.endswith('.amd'):
                    ### gestion de l'importation de module (.py) associé au .amd si le fichier .py n'a jamais été decompresssé (pour edition par exemple)
                    if not come_from_net:
                        path = os.path.join(parentPath, item)
                        zf = Zip(path)
                        module = zf.GetModule()
                        image_file = zf.GetImage()
                    else:
                        path = "".join([parentPath, '/', item, '.py'])
                        module = load_module_from_net(path)

                    ### check error
                    error = isinstance(module, Exception)

                    ### change icon depending on the error and the presence of image in amd
                    if error:
                        img = self.not_importedidx
                    elif image_file is not None:
                        img = self.il.Add(image_file.ConvertToBitmap())
                    else:
                        img = self.atomicidx

                    mcc = GetMacCabeMetric(path)

                    ### insert in the tree
                    id = self.InsertItemBefore(parent, 0,
                                               os.path.splitext(item)[0], img,
                                               img)
                    self.SetPyData(id, path)

                    self.MetricDico.update(
                        {id: {
                            'mcc': mcc,
                            'parent': parent
                        }})
                    s = sum([
                        d['mcc'] for id, d in self.MetricDico.items()
                        if d['parent'] == parent
                    ])
                    self.MetricDico.update(
                        {parent: {
                            'mcc': s,
                            'parent': None
                        }})

                else:

                    path = os.path.join(parentPath, "".join(
                        [item, '.py'])) if not come_from_net else "".join(
                            [parentPath, '/', item, '.py'])

                    ### try for .pyc
                    ispyc = False
                    if not os.path.exists(path):
                        path = os.path.join(parentPath, "".join(
                            [item, '.pyc'])) if not come_from_net else "".join(
                                [parentPath, '/', item, '.pyc'])
                        ispyc = True

                    devs = Container.CheckClass(path)

                    #mcc = float(subprocess.check_output('python {} {}'.format('Complexity.py', path), shell = True))
                    mcc = GetMacCabeMetric(path)

                    error = isinstance(devs, tuple)
                    img = self.not_importedidx if error else self.pythoncfileidx if ispyc else self.pythonfileidx

                    ### insert in the tree
                    id = self.InsertItemBefore(parent, 0, item, img, img)
                    self.SetPyData(id, path)

                    self.MetricDico.update(
                        {id: {
                            'mcc': mcc,
                            'parent': parent
                        }})
                    s = sum([
                        d['mcc'] for id, d in self.MetricDico.items()
                        if d['parent'] == parent
                    ])
                    self.MetricDico.update(
                        {parent: {
                            'mcc': s,
                            'parent': None
                        }})

                ### error info back propagation
                if error:
                    while (parent):
                        self.SetItemImage(parent, self.not_importedidx,
                                          wx.TreeItemIcon_Normal)
                        ### next parent item
                        parent = self.GetItemParent(parent)

                ### insertion des donnees dans l'item et gestion du ItemDico
                self.ItemDico.update({os.path.join(
                    parentPath,
                    item,
                ): id})

            ### si le fils est un sous repertoire contenant au moins un fichier (all dans __init__.py different de [])
            elif isdict and list(item.values()) != [[]]:

                ### name to insert in the tree
                dName = os.path.basename(list(item.keys())[0])

                ### new parent
                parent = self.ItemDico[os.path.dirname(
                    list(item.keys())[0]
                )] if not dName.startswith('http') else self.ItemDico[list(
                    item.keys())[0].replace('/' + dName, '')]

                assert (parent != None)

                ### insert of the fName above the parent
                id = self.InsertItemBefore(parent, 0, dName)

                self.SetItemBold(id)

                self.SetItemImage(id, self.fldridx, wx.TreeItemIcon_Normal)
                self.SetItemImage(id, self.fldropenidx,
                                  wx.TreeItemIcon_Expanded)

                ### stockage du parent avec pour cle le chemin complet avec extention (pour l'import du moule dans le Dnd)
                self.ItemDico.update({list(item.keys())[0]: id})
                self.SetPyData(id, list(item.keys())[0])

                self.MetricDico.update({id: {'mcc': 0.0, 'parent': parent}})
                self.MetricDico.update({parent: {'mcc': 0.0, 'parent': None}})

                ### for the childrens of the sub-domain
                for elem in list(item.values())[0]:
                    # si elem simple (modèle couple ou atomic)
                    if isinstance(elem, str):
                        ### replace the spaces
                        elem = elem.strip()  #replace(' ','')

                        ### parent provisoir
                        p = self.ItemDico[list(item.keys())[0]]
                        assert (p != None)
                        come_from_net = list(item.keys())[0].startswith('http')
                        ### si model atomic
                        if elem.endswith('.cmd'):
                            ### gestion de l'importation de module (.py) associé au .amd si le fichier .py n'a jamais été decompresssé (pour edition par exemple)
                            if not come_from_net:
                                path = os.path.join(list(item.keys())[0], elem)
                                zf = Zip(path)
                                module = zf.GetModule()
                                image_file = zf.GetImage()
                            else:
                                path = "".join(
                                    [list(item.keys())[0], '/', elem, '.py'])
                                module = load_module_from_net(path)

                            ### check error
                            error = isinstance(module, Exception)

                            ### change icon depending on the error and the presence of image in amd
                            if error:
                                img = self.not_importedidx
                            elif image_file is not None:
                                img = self.il.Add(image_file.ConvertToBitmap())
                            else:
                                img = self.coupledidx

                            ### insertion dans le tree
                            id = self.InsertItemBefore(
                                p, 0,
                                os.path.splitext(elem)[0], img, img)
                            self.SetPyData(id, path)

                            self.MetricDico.update(
                                {id: {
                                    'mcc': 0.0,
                                    'parent': parent
                                }})
                            s = sum([
                                d['mcc'] for id, d in self.MetricDico.items()
                                if d['parent'] == parent
                            ])
                            self.MetricDico.update(
                                {parent: {
                                    'mcc': s,
                                    'parent': None
                                }})

                        elif elem.endswith('.amd'):
                            ### gestion de l'importation de module (.py) associé au .amd si le fichier .py n'a jamais été decompresssé (pour edition par exemple)
                            if not come_from_net:
                                path = os.path.join(list(item.keys())[0], elem)
                                zf = Zip(path)
                                module = zf.GetModule()
                                image_file = zf.GetImage()
                            else:
                                path = "".join(
                                    [list(item.keys())[0], '/', elem, '.py'])
                                module = load_module_from_net(path)

                            ### check error
                            error = isinstance(module, Exception)

                            ### change icon depending on the error and the presence of image in amd
                            if error:
                                img = self.not_importedidx
                            elif image_file is not None:
                                img = self.il.Add(image_file.ConvertToBitmap())
                            else:
                                img = self.atomicidx

                            mcc = GetMacCabeMetric(path)

                            ### insert in the tree
                            id = self.InsertItemBefore(
                                p, 0,
                                os.path.splitext(elem)[0], img, img)
                            self.SetPyData(id, path)

                            self.MetricDico.update(
                                {id: {
                                    'mcc': mcc,
                                    'parent': parent
                                }})
                            s = sum([
                                d['mcc'] for id, d in self.MetricDico.items()
                                if d['parent'] == parent
                            ])
                            self.MetricDico.update(
                                {parent: {
                                    'mcc': s,
                                    'parent': None
                                }})

                        else:

                            path = os.path.join(
                                list(item.keys())[0],
                                "".join([elem, '.py'])) if not list(item.keys(
                                ))[0].startswith('http') else list(
                                    item.keys())[0] + '/' + elem + '.py'
                            ### try for .pyc file
                            ispyc = False
                            if not os.path.exists(path):
                                path = os.path.join(
                                    list(item.keys())[0], "".join([
                                        elem, '.pyc'
                                    ])) if not list(item.keys(
                                    ))[0].startswith('http') else list(
                                        item.keys())[0] + '/' + elem + '.pyc'
                                ispyc = True

                            devs = Container.CheckClass(path)

                            mcc = GetMacCabeMetric(path)

                            error = isinstance(devs, tuple)
                            img = self.not_importedidx if error else self.pythoncfileidx if ispyc else self.pythonfileidx

                            ### insert in the tree
                            id = self.InsertItemBefore(p, 0, elem, img, img)
                            self.SetPyData(id, path)
                            self.MetricDico.update(
                                {id: {
                                    'mcc': mcc,
                                    'parent': parent
                                }})

                            s = sum([
                                d['mcc'] for id, d in self.MetricDico.items()
                                if d['parent'] == parent
                            ])
                            self.MetricDico.update(
                                {parent: {
                                    'mcc': s,
                                    'parent': None
                                }})

                        ### error info back propagation
                        if error:
                            ### insert error to the doc field
                            while (p):
                                self.SetItemImage(p, self.not_importedidx,
                                                  wx.TreeItemIcon_Normal)
                                ### next parent item
                                p = self.GetItemParent(p)

                        self.ItemDico.update(
                            {os.path.join(list(item.keys())[0], elem): id})

                    else:
                        ### in order to go up the information in the list
                        D.append(elem)

                ### update with whole name
                dName = list(item.keys())[0]

            ### for spash screen
            try:
                ### format the string depending the nature of the item
                if isdict:
                    item = " ".join([
                        os.path.basename(list(item.keys())[0]), 'from',
                        os.path.basename(os.path.dirname(list(item.keys())[0]))
                    ])
                else:
                    item = " ".join([item, 'from', os.path.basename(dName)])

                pub.sendMessage('object.added',
                                message='Loading %s domain...' % item)
            except:
                pass

            ### managment of the recursion
            if D != []:
                self.InsertNewDomain(dName, parent, D)

            try:
                self.SortChildren(parent)
            except:
                pass

            return self.InsertNewDomain(dName, parent, L)
Пример #8
0
    def InsertNewDomain(self, dName, parent, L=[]):
        """ Recurrent function that insert new Domain on library panel.
		"""

        ### first only for the root
        if dName not in self.ItemDico.keys():
            label = os.path.basename(
                dName) if not dName.startswith('http') else filter(
                    lambda a: a != '', dName.split('/'))[-1]
            id = self.InsertItemBefore(parent, 0, label)
            self.SetItemImage(id, self.fldridx, wx.TreeItemIcon_Normal)
            self.SetItemImage(id, self.fldropenidx, wx.TreeItemIcon_Expanded)
            self.SetItemBold(id)
            self.ItemDico.update({dName: id})
            self.SetPyData(id, dName)

        ### end
        if L == []:
            return
        else:
            item = L.pop(0)

            isunicode = isinstance(item, unicode)
            isstr = isinstance(item, str)
            isdict = isinstance(item, dict)

            assert not isunicode, _("Warning unicode item !")

            ### element to insert in the list
            D = []
            ### if child is build from DEVSimPy
            if isstr:

                ### parent is retrieved from dict
                parent = self.ItemDico[dName]
                assert parent != None

                ### parent path
                parentPath = self.GetPyData(parent)
                come_from_net = parentPath.startswith('http')

                ### comma replace
                item = item.strip()

                ### suppression de l'extention su .cmd (model atomic lu à partir de __init__ donc pas d'extention)
                if item.endswith('.cmd'):
                    ### gestion de l'importation de module (.py) associé au .cmd si le fichier .py n'a jamais été decompresssé (pour edition par exemple)
                    if not come_from_net:
                        path = os.path.join(parentPath, item)
                        zf = Zip(path)
                        module = zf.GetModule()
                        image_file = zf.GetImage()
                    else:
                        path = "".join([parentPath, '/', item, '.py'])
                        module = load_module_from_net(path)

                    ### check error
                    error = isinstance(module, Exception)

                    ### change icon depending on the error and the presence of image in amd
                    if error:
                        img = self.not_importedidx
                    elif image_file is not None:
                        img = self.il.Add(image_file.ConvertToBitmap())
                    else:
                        img = self.coupledidx

                    ### insert into the tree
                    id = self.InsertItemBefore(parent, 0,
                                               os.path.splitext(item)[0], img,
                                               img)
                    self.SetPyData(id, path)

                elif item.endswith('.amd'):
                    ### gestion de l'importation de module (.py) associé au .amd si le fichier .py n'a jamais été decompresssé (pour edition par exemple)
                    if not come_from_net:
                        path = os.path.join(parentPath, item)
                        zf = Zip(path)
                        module = zf.GetModule()
                        image_file = zf.GetImage()
                    else:
                        path = "".join([parentPath, '/', item, '.py'])
                        module = load_module_from_net(path)

                    ### check error
                    error = isinstance(module, Exception)

                    ### change icon depending on the error and the presence of image in amd
                    if error:
                        img = self.not_importedidx
                    elif image_file is not None:
                        img = self.il.Add(image_file.ConvertToBitmap())
                    else:
                        img = self.atomicidx

                    ### insertion dans le tree
                    id = self.InsertItemBefore(parent, 0,
                                               os.path.splitext(item)[0], img,
                                               img)
                    self.SetPyData(id, path)

                else:

                    path = os.path.join(parentPath, "".join(
                        [item, '.py'])) if not come_from_net else "".join(
                            [parentPath, '/', item, '.py'])

                    info = Container.CheckClass(path)

                    error = isinstance(info, tuple)
                    img = self.not_importedidx if error else self.pythonfileidx

                    ### insertion dans le tree
                    id = self.InsertItemBefore(parent, 0, item, img, img)
                    self.SetPyData(id, path)

                ### error info back propagation
                if error:
                    while (parent):
                        self.SetItemImage(parent, self.not_importedidx,
                                          wx.TreeItemIcon_Normal)
                        ### next parent item
                        parent = self.GetItemParent(parent)

                ### insertion des donnees dans l'item et gestion du ItemDico
                self.ItemDico.update({os.path.join(
                    parentPath,
                    item,
                ): id})

            ### si le fils est un sous repertoire contenant au moins un fichier (all dans __init__.py different de [])
            elif isdict and item.values() != [[]]:

                ### nom a inserer dans l'arbe
                dName = os.path.basename(item.keys()[0])

                ### nouveau parent
                parent = self.ItemDico[os.path.dirname(
                    item.keys()[0])] if not dName.startswith(
                        'http') else self.ItemDico[item.keys()[0].replace(
                            '/' + dName, '')]

                assert (parent != None)

                ### insertion de fName sous parent
                id = self.InsertItemBefore(parent, 0, dName)
                self.SetItemImage(id, self.fldridx, wx.TreeItemIcon_Normal)
                self.SetItemImage(id, self.fldropenidx,
                                  wx.TreeItemIcon_Expanded)

                ### stockage du parent avec pour cle le chemin complet avec extention (pour l'import du moule dans le Dnd)
                self.ItemDico.update({item.keys()[0]: id})
                self.SetPyData(id, item.keys()[0])

                ### pour les fils du sous domain
                for elem in item.values()[0]:
                    # si elem simple (modèle couple ou atomic)
                    if isstr:
                        ### remplacement des espaces
                        elem = elem.strip()  #replace(' ','')
                        ### parent provisoir
                        p = self.ItemDico[item.keys()[0]]

                        assert (p != None)

                        come_from_net = item.keys()[0].startswith('http')
                        ### si model atomic
                        if elem.endswith('.cmd'):
                            ### gestion de l'importation de module (.py) associé au .amd si le fichier .py n'a jamais été decompresssé (pour edition par exemple)
                            if not come_from_net:
                                path = os.path.join(item.keys()[0], elem)
                                zf = Zip(path)
                                module = zf.GetModule()
                                image_file = zf.GetImage()
                            else:
                                path = "".join(
                                    [item.keys()[0], '/', elem, '.py'])
                                module = load_module_from_net(path)

                            ### check error
                            error = isinstance(module, Exception)

                            ### change icon depending on the error and the presence of image in amd
                            if error:
                                img = self.not_importedidx
                            elif image_file is not None:
                                img = self.il.Add(image_file.ConvertToBitmap())
                            else:
                                img = self.coupledidx

                            ### insertion dans le tree
                            id = self.InsertItemBefore(
                                p, 0,
                                os.path.splitext(elem)[0], img, img)
                            self.SetPyData(id, path)

                        elif elem.endswith('.amd'):
                            ### gestion de l'importation de module (.py) associé au .amd si le fichier .py n'a jamais été decompresssé (pour edition par exemple)
                            if not come_from_net:
                                path = os.path.join(item.keys()[0], elem)
                                zf = Zip(path)
                                module = zf.GetModule()
                                image_file = zf.GetImage()
                            else:
                                path = "".join(
                                    [item.keys()[0], '/', elem, '.py'])
                                module = load_module_from_net(path)

                            ### check error
                            error = isinstance(module, Exception)

                            ### change icon depending on the error and the presence of image in amd
                            if error:
                                img = self.not_importedidx
                            elif image_file is not None:
                                img = self.il.Add(image_file.ConvertToBitmap())
                            else:
                                img = self.atomicidx

                            ### insertion dans le tree
                            id = self.InsertItemBefore(
                                p, 0,
                                os.path.splitext(elem)[0], img, img)
                            self.SetPyData(id, path)
                        else:

                            path = os.path.join(item.keys()[0], "".join(
                                [elem, '.py'])) if not item.keys(
                                )[0].startswith('http') else "".join(
                                    [item.keys()[0], '/', elem, '.py'])
                            info = Container.CheckClass(path)

                            error = isinstance(info, tuple)
                            img = self.not_importedidx if error else self.pythonfileidx

                            ### insertion dans le tree
                            id = self.InsertItemBefore(p, 0, elem, img, img)
                            self.SetPyData(id, path)

                        ### error info back propagation
                        if error:
                            ### insert error to the doc field
                            while (p):
                                self.SetItemImage(p, self.not_importedidx,
                                                  wx.TreeItemIcon_Normal)
                                ### next parent item
                                p = self.GetItemParent(p)

                        self.ItemDico.update({
                            os.path.join(item.keys()[0],
                                         os.path.splitext(elem)[0]):
                            id
                        })

                    else:
                        ### pour faire remonter l'info dans la liste
                        D.append(elem)

                ### mise a jour avec le nom complet
                dName = item.keys()[0]

            ### for spash screen
            try:
                ### format the string depending the nature of the item
                if isdict:
                    item = " ".join([
                        os.path.basename(item.keys()[0]), 'from',
                        os.path.basename(os.path.dirname(item.keys()[0]))
                    ])
                else:
                    item = " ".join([item, 'from', os.path.basename(dName)])

                pub.sendMessage('object.added',
                                message='Loading %s domain...' % item)
            except:
                pass

            ### gestion de la recursion
            if D != []:
                return self.InsertNewDomain(dName, parent, L + D)
            else:
                return self.InsertNewDomain(dName, parent, L)