Ejemplo n.º 1
0
 def checkURI(self, uri):
     if isArchiveURI(uri): return uri in self._archive_list.keys()
     elif isPyFileURI(uri):
         (aname, fname) = splitPyFile(uri)
         try: archive = self._archive_list["zip://"+aname]
         except: return False
         return fname in archive.getFileList("*.py")
Ejemplo n.º 2
0
    def addURI(self, uri):
        if self.getItemByURI(uri, self._d_root): return

        if isPyFileURI(uri):
            (ar, py) = splitPyFile(uri)
            item = self.getItemByURI("zip://"+ar, self._d_root)
            fitem = self.AppendItem(item, py)
            self.SetPyData(fitem, ("File", uri))
            self.SetItemImage(fitem, self._bmp_module, wx.TreeItemIcon_Normal)
            self.SetItemImage(fitem, self._bmp_module, wx.TreeItemIcon_Expanded)
        elif isArchiveURI(uri):
            path = getArchive(uri)
            item = self.AppendItem(self._d_root, path)
            self.SetPyData(item, ("Archive",uri))
            self.SetItemImage(item, self._bmp_class, wx.TreeItemIcon_Normal)
            self.SetItemImage(item, self._bmp_class_open, wx.TreeItemIcon_Expanded)
        else: raise Exception("Unkonw URI %s"%uri)
Ejemplo n.º 3
0
 def deleteURI(self, uri):
     if isArchiveURI(uri):
         if not uri in self._archive_list.keys():
             raise Exception("Unknown archive %s"%uri)
         aname = getArchive(uri)
         path = os.path.join(self._base_path, aname)
         os.unlink(path)
         del self._archive_list[uri]
     elif isPyFileURI(uri):
         (aname, fname) = splitPyFile(uri)
         if not "zip://"+aname in self._archive_list.keys():
             raise Exception("Unknown archive zip://%s"%aname)
         archive = self._archive_list["zip://"+aname]
         if not fname in archive.getFileList("*.py"):
             raise Exception("Unknown file %s in zip://%s"%(fname, aname))
         archive.deleteFile(fname)
     else:
         raise Exception("Invalid URI %s?"%uri)
Ejemplo n.º 4
0
 def saveURI(self, uri, data=""):
     # save "zip://archive-name.zip" will creat a new archive
     if isArchiveURI(uri):
         if uri in self._archive_list.keys():
             return
         archive = getArchive(uri)
         path = os.path.join(self._base_path, archive)
         ZipFile(path,"w")
         self._archive_list[uri] = eDevModelArchive(path)
     # save "zip://archive-name.zip/path/to/python-file.py creates a new 
     # python file with given content or overrides existing ones
     elif isPyFileURI(uri):
         self._logger.debug("save pyfile %s"%uri)
         (aname, fname) = splitPyFile(uri)
         try: archive = self._archive_list["zip://"+aname]
         except: raise Exception("Archive zip://&s not found"%aname)
         if not fname in archive.getFileList("*.py"):
             archive.createFile(fname, data)
         else:
             archive.writeFile(fname, data)
     else: raise Exception("Unable to write %s: Invalid URI?"%uri)