Esempio n. 1
0
    def __init__(self, data, name, editor, saved):
        EditorModels.SourceModel.__init__(self, data, name, editor, saved)

        contents = os.path.splitext(name)[0] + '.hhc'
        try:
            transport = Explorer.openEx(contents)
            data = transport.load()
        except ExplorerNodes.TransportError:
            transport = None
            data = ''
        self.contentsModel = EditorModels.SourceModel(data, contents, editor,
                                                      saved)
        self.contentsModel.transport = transport

        indexes = os.path.splitext(name)[0] + '.hhk'
        try:
            transport = Explorer.openEx(indexes)
            data = transport.load()
        except ExplorerNodes.TransportError:
            transport = None
            data = ''
        self.indexesModel = EditorModels.SourceModel(data, indexes, editor,
                                                     saved)
        self.indexesModel.transport = transport

        self.update()
Esempio n. 2
0
    def openAndHandleCategoryErrors(self, uri, catFile=''):
        if catFile:
            if uri.startswith('zip://') and uri.endswith('.zip'):
                openuri = uri +'://'+ catFile
            else:
                openuri = os.path.join(uri, catFile)
        else:
            openuri = uri

        try:
            prot, cat, res, _uri = Explorer.splitURI(openuri)

            if prot not in ExplorerNodes.fileOpenDlgProtReg:
                return None

            if catFile:
                res = os.path.dirname(res)
            return Explorer.getTransport(prot, cat, res, self.transports)
        except Explorer.TransportCategoryError, err:
            prot = string.split(uri, ':')[0]
            # bare protocol entered, route to right toplevel node
            if err.args[0] == _('Category not found') and err.args[1]==catFile:
                if prot == 'root':
                    self.open(self.transports)
                    return self.transports
                elif self.transportsByProtocol.has_key(prot):
                    node = self.transportsByProtocol[prot]
                    self.open(node)
                    return node
                else:
                    raise
            else:
                raise
Esempio n. 3
0
 def _addPyMods(self, pypath, prod=''):
     from Explorers import Explorer
     Explorer.listdirEx(pypath, '.zexp')
     mods = []
     fls = Explorer.listdirEx(pypath, '.py')
     for file in fls:
         mods.append(prod + (prod and '.') + os.path.splitext(file)[0])
     return mods
Esempio n. 4
0
 def _addPyMods(self, pypath, prod=''):
     from Explorers import Explorer
     Explorer.listdirEx(pypath, '.zexp')
     mods = []
     fls = Explorer.listdirEx(pypath, '.py')
     for file in fls:
         mods.append(prod +(prod and '.')+os.path.splitext(file)[0])
     return mods
Esempio n. 5
0
 def OnGetItemText(self, item, col):
     f = self.model.config.files[item]
     if col == 0:
         return ` item `
     elif col == 1:
         return os.path.basename(f)
     elif col == 2:
         return f
     elif Preferences.hbShowDocumentTitles and col == 3:
         if not self.cached[item]:
             title = ''
             try:
                 if os.path.splitext(f)[1].lower() not in ('.htm', '.html'):
                     return ''
                 docsDir = os.path.dirname(self.model.filename)
                 try:
                     data = Explorer.openEx(os.path.join(docsDir, f)).load()
                 except ExplorerNodes.TransportError:
                     return ''
                 fmtr = formatter.NullFormatter(formatter.NullWriter())
                 try:
                     HtmlDocDetailParser(fmtr, breakOnTitle=True).feed(data)
                 except BreakOnTitle, title:
                     return str(title)
                 except:
                     return ''
                 else:
                     return ''
             finally:
                 self.cached[item] = title
 def OnSaveHistory(self, event):
     fn, ok = self.editor.saveAsDlg('history.pcl', 'AllFiles')
     if ok:
         data = pickle.dumps(self.history)
         from Explorers import Explorer
         n = Explorer.openEx(fn)
         n.save(n.resourcepath, data)
Esempio n. 7
0
    def __init__(self, parent, editor, resourceFilename, imageName='',
          onlyIcons=False):
        self._init_ctrls(parent)

        from Explorers import Explorer

        model = PyResourceBitmapModel('', resourceFilename, editor, True)
        model.transport = Explorer.openEx(resourceFilename)
        model.load(notify=False)
        self.resources = PyResourceImagesSelectionView(self, model,
              listStyle=wx.LC_SMALL_ICON | wx.LC_ALIGN_TOP,
              imgLstStyle=wx.IMAGE_LIST_SMALL)
        self.resources.onlyIcons = onlyIcons

        self.boxSizerMain.Prepend(self.resources, 1,
                                  wx.LEFT|wx.RIGHT|wx.TOP|wx.GROW, 15)
        self.resources.refreshCtrl()

        if imageName:
            sel = -1
            for idx, r in zip(range(len(self.resources.imageSrcInfo)),
                              self.resources.imageSrcInfo):
                if r[0] == imageName:
                    sel = idx
                    break

            if sel != -1:
                self.resources.Select(sel)
                self.resources.EnsureVisible(sel)

        self.resources.SetFocus()
Esempio n. 8
0
 def OnSaveHistory(self, event):
     fn, ok = self.editor.saveAsDlg('history.pcl', 'AllFiles')
     if ok:
         data = pickle.dumps(self.history)
         from Explorers import Explorer
         n = Explorer.openEx(fn)
         n.save(n.resourcepath, data)
Esempio n. 9
0
    def OnEditIndex(self, event):
        if self.selected != -1:
            keyword, location, c = self.model.indexes[self.selected]

            docsDir = os.path.dirname(self.model.filename)
            try:
                data = Explorer.openEx(
                    os.path.join(docsDir,
                                 location.split('#')[0])).load()
            except ExplorerNodes.TransportLoadError:
                data = ''
            prs = parseHelpFile(data, HtmlDocDetailParser)
            dlg = createIndexDlg(None, keyword, location, prs.anchors)
            try:
                if dlg.ShowModal() != wx.ID_OK:
                    return

                res = dlg.GetResult()
            finally:
                dlg.Destroy()

            if res != (keyword, location):
                keyword, location = res
                self.model.indexes[self.selected] = (keyword, location, None)

                self.model.setModified('indexes')
                self.updateEditor()

                self.refreshCtrl()
Esempio n. 10
0
    def OnEditIndex(self, event):
        if self.selected != -1:
            keyword, location, c = self.model.indexes[self.selected]

            docsDir = os.path.dirname(self.model.filename)
            try:
                data = Explorer.openEx(
                      os.path.join(docsDir, location.split('#')[0])).load()
            except ExplorerNodes.TransportLoadError:
                data = ''
            prs = parseHelpFile(data, HtmlDocDetailParser)
            dlg = createIndexDlg(None, keyword, location, prs.anchors)
            try:
                if dlg.ShowModal() != wx.ID_OK:
                    return

                res = dlg.GetResult()
            finally:
                dlg.Destroy()

            if res != (keyword, location):
                keyword, location = res
                self.model.indexes[self.selected] = (keyword, location, None)

                self.model.setModified('indexes')
                self.updateEditor()

                self.refreshCtrl()
Esempio n. 11
0
    def __init__(self, parent, editor, resourceFilename, imageName='',
          onlyIcons=False):
        self._init_ctrls(parent)

        from Explorers import Explorer

        model = PyResourceBitmapModel('', resourceFilename, editor, True)
        model.transport = Explorer.openEx(resourceFilename)
        model.load(notify=False)
        self.resources = PyResourceImagesSelectionView(self, model,
              listStyle=wx.LC_SMALL_ICON | wx.LC_ALIGN_TOP,
              imgLstStyle=wx.IMAGE_LIST_SMALL)
        self.resources.onlyIcons = onlyIcons

        self.boxSizerMain.Prepend(self.resources, 1,
                                  wx.LEFT|wx.RIGHT|wx.TOP|wx.GROW, 15)
        self.resources.refreshCtrl()

        if imageName:
            sel = -1
            for idx, r in zip(range(len(self.resources.imageSrcInfo)),
                              self.resources.imageSrcInfo):
                if r[0] == imageName:
                    sel = idx
                    break

            if sel != -1:
                self.resources.Select(sel)
                self.resources.EnsureVisible(sel)

        self.resources.SetFocus()
Esempio n. 12
0
 def listImportFiles(self):
     if self.properties.has_key(
             'localpath') and self.properties['localpath']:
         from Explorers import Explorer
         return Explorer.listdirEx(self.properties['localpath'] + '/import',
                                   '.zexp')
     else:
         return []
Esempio n. 13
0
    def writeTimes(self):
        from StringIO import StringIO
        timesFile = StringIO('')  #open(self.getTTVFilename(), 'w')
        for start, end, desc in self.times:
            self.writeTimeEntry(timesFile, start, end, desc)
        timesFile.seek(0)

        uri = self.getTTVFilename()
        transp = Explorer.openEx(uri)
        transp.save(transp.currentFilename(), timesFile.read())
Esempio n. 14
0
    def writeTimes(self):
        from cStringIO import StringIO
        timesFile = StringIO('')#open(self.getTTVFilename(), 'w')
        for start, end, desc in self.times:
            self.writeTimeEntry(timesFile, start, end, desc)
        timesFile.seek(0)

        uri = self.getTTVFilename()
        transp = Explorer.openEx(uri)
        transp.save(transp.currentFilename(), timesFile.read())
Esempio n. 15
0
    def getFunctions(self, module):
        from Explorers import Explorer
        extPath = self.getExtPath(module)

        src = Explorer.openEx(extPath).load()
        sep = src.count('\r\n') < src.count('\n') and '\n' or '\r\n'
        srclines = src.split(sep)

        import moduleparse
        module = moduleparse.Module('test', srclines)

        return module.functions.keys()
Esempio n. 16
0
    def getFunctions(self, module):
        from Explorers import Explorer
        extPath = self.getExtPath(module)

        src = Explorer.openEx(extPath).load()
        sep = src.count('\r\n') < src.count('\n') and '\n' or '\r\n'
        srclines = src.split(sep)

        import moduleparse
        module = moduleparse.Module('test', srclines)

        return module.functions.keys()
Esempio n. 17
0
    def openTransportFromProperties(self):
        zopePath = self.properties['localpath']

        svr, name = self.getParentResource()
        res = svr.zoa.props.ExternalMethod(name)

        module = res['module']

        emf = ExtMethDlg.ExternalMethodFinder(zopePath)
        extPath = emf.getExtPath(module)

        from Explorers import Explorer
        return Explorer.openEx(extPath)
Esempio n. 18
0
    def openTransportFromProperties(self):
        zopePath = self.properties['localpath']

        svr, name = self.getParentResource()
        res = svr.zoa.props.ExternalMethod(name)

        module = res['module']

        emf = ExtMethDlg.ExternalMethodFinder(zopePath)
        extPath = emf.getExtPath(module)

        from Explorers import Explorer
        return Explorer.openEx(extPath)
Esempio n. 19
0
def doContentsDlg(title, text, docsDir):
    #text, anchor = (text.split('#')+[''])[:2]
    data = Explorer.openEx(os.path.join(docsDir, text.split('#')[0])).load()
    prs = parseHelpFile(data, HtmlDocDetailParser)
    if title is None:
        title = prs.title
    dlg = createContentsDlg(None, title, prs.title, text, prs.anchors)
    try:
        if dlg.ShowModal() != wx.ID_OK:
            return None, None

        title, location = dlg.GetResult()
    finally:
        dlg.Destroy()
    return title, location
Esempio n. 20
0
    def __init__(self, data, name, editor, saved):
        EditorModels.SourceModel.__init__(self, data, name, editor, saved)

        contents = os.path.splitext(name)[0]+'.hhc'
        try:
            transport = Explorer.openEx(contents)
            data = transport.load()
        except ExplorerNodes.TransportError:
            transport = None
            data = ''
        self.contentsModel = EditorModels.SourceModel(data, contents, editor, saved)
        self.contentsModel.transport = transport

        indexes = os.path.splitext(name)[0]+'.hhk'
        try:
            transport = Explorer.openEx(indexes)
            data = transport.load()
        except ExplorerNodes.TransportError:
            transport = None
            data = ''
        self.indexesModel = EditorModels.SourceModel(data, indexes, editor, saved)
        self.indexesModel.transport = transport

        self.update()
Esempio n. 21
0
def doContentsDlg(title, text, docsDir):
    #text, anchor = (text.split('#')+[''])[:2]
    data = Explorer.openEx(os.path.join(docsDir, text.split('#')[0])).load()
    prs = parseHelpFile(data, HtmlDocDetailParser)
    if title is None:
        title = prs.title
    dlg = createContentsDlg(None, title, prs.title, text, prs.anchors)
    try:
        if dlg.ShowModal() != wx.ID_OK:
            return None, None

        title, location = dlg.GetResult()
    finally:
        dlg.Destroy()
    return title, location
Esempio n. 22
0
    def OnDropFiles(self, x, y, files):
        docsDir = os.path.dirname(self.list.model.filename)

        for filename in files:
            data = Explorer.openEx(os.path.join(docsDir, filename)).load()
            prs = parseHelpFile(data, HtmlDocDetailParser)
            dlg = createIndexDlg(None, '', filename, prs.anchors)
            try:
                if dlg.ShowModal() != wx.ID_OK:
                    return

                keyword, location = dlg.GetResult()
            finally:
                dlg.Destroy()

            #item, flags = self.list.HitTest( (x, y) )
            self.list.model.indexes.append((keyword, location, None))

        self.list.model.setModified('indexes')
        self.list.updateEditor()

        self.list.refreshCtrl()
Esempio n. 23
0
    def OnDropFiles(self, x, y, files):
        docsDir = os.path.dirname(self.list.model.filename)

        for filename in files:
            data = Explorer.openEx(os.path.join(docsDir, filename)).load()
            prs = parseHelpFile(data, HtmlDocDetailParser)
            dlg = createIndexDlg(None, '', filename, prs.anchors)
            try:
                if dlg.ShowModal() != wx.ID_OK:
                    return

                keyword, location = dlg.GetResult()
            finally:
                dlg.Destroy()

            #item, flags = self.list.HitTest( (x, y) )
            self.list.model.indexes.append((keyword, location, None))

        self.list.model.setModified('indexes')
        self.list.updateEditor()

        self.list.refreshCtrl()
Esempio n. 24
0
 def OnGetItemText(self, item, col):
     f = self.model.config.files[item]
     if col == 0:
         return repr(item)
     elif col == 1:
         return os.path.basename(f)
     elif col == 2:
         return f
     elif Preferences.hbShowDocumentTitles and col == 3:
         if not self.cached[item]:
             title = ''
             try:
                 if os.path.splitext(f)[1].lower() not in ('.htm', '.html'):
                     return ''
                 docsDir = os.path.dirname(self.model.filename)
                 try: data = Explorer.openEx(os.path.join(docsDir, f)).load()
                 except ExplorerNodes.TransportError: return ''
                 fmtr = formatter.NullFormatter(formatter.NullWriter())
                 try: HtmlDocDetailParser(fmtr, breakOnTitle=True).feed(data)
                 except BreakOnTitle, title: return str(title)
                 except: return ''
                 else: return ''
             finally:
                 self.cached[item] = title
Esempio n. 25
0
 def OnInputDoubleClick(self, event):
     filename = self.editor.openFileDlg()
     if filename:
         from Explorers import Explorer
         self.inputPage.SetValue(Explorer.openEx(filename).load())
 def OnLoadHistory(self, event):
     fn = self.editor.openFileDlg('AllFiles')
     if fn:
         from Explorers import Explorer
         data = Explorer.openEx(fn).load()
         self.history = pickle.loads(data)
 def OnInputDoubleClick(self, event):
     filename = self.editor.openFileDlg()
     if filename:
         from Explorers import Explorer
         self.inputPage.SetValue(Explorer.openEx(filename).load())
Esempio n. 28
0
    def OnGotoSource(self, event=None):
        selection = self.getSelection()
        if selection != -1:
            entry = self.stack[selection]
            lineno = entry["lineno"]
            modname = entry["modname"]
            filename = entry["client_filename"]
            if not filename:
                return

            editor = self.debugger.editor
            editor.SetFocus()
            try:
                editor.openOrGotoModule(filename)
            except Explorer.TransportLoadError, err:
                serverPath = entry["filename"]
                if serverPath[0] == "<" and serverPath[-1] == ">":
                    wx.LogError(_("Not a source file: %s, probably an executed " "string.") % serverPath)
                    return

                res = wx.MessageBox(
                    _(
                        "Could not open file: %s.\n\nIf This is a "
                        "server path for which you\nhave not defined a mapping "
                        'click "Yes" to browse to the file to the mapping can '
                        'be computed.\nPress "No" to open the path dialog.'
                    )
                    % filename,
                    _("File Open Error, try to compute path?"),
                    wx.ICON_WARNING | wx.YES_NO | wx.CANCEL,
                )
                if res == wx.YES:
                    clientPath = editor.openFileDlg(curfile=os.path.basename(filename))
                    if clientPath:
                        clientPath = prevClientPath = Explorer.splitURI(clientPath)[2]
                        prevServerPath = serverPath
                        while 1:
                            serverPath, serverBase = os.path.split(serverPath)
                            clientPath, clientBase = os.path.split(clientPath)

                            if serverBase != clientBase:
                                paths = self.debugger.serverClientPaths[:]
                                paths.append((prevServerPath, prevClientPath))
                                if self.debugger.OnPathMappings(paths=paths):
                                    self.refreshClientFilenames()
                                break

                            if not serverPath or not clientPath:
                                wx.LogError(_("Paths are identical"))
                                break

                            prevClientPath = clientPath
                            prevServerPath = serverPath

                elif res == wx.NO:
                    if self.debugger.OnPathMappings():
                        self.refreshClientFilenames()
                return

            model = editor.getActiveModulePage().model
            view = model.getSourceView()
            if view is not None:
                view.focus()
                view.SetFocus()
                view.selectLine(lineno - 1)
Esempio n. 29
0
    def readTimes(self):
        from cStringIO import StringIO
        transp = Explorer.openEx(self.getTTVFilename())
        data = StringIO(transp.load())

        return map(lambda line: eval(line), data.readlines())
Esempio n. 30
0
    def OnGotoSource(self, event=None):
        selection = self.getSelection()
        if selection != -1:
            entry = self.stack[selection]
            lineno = entry['lineno']
            modname = entry['modname']
            filename = entry['client_filename']
            if not filename:
                return

            editor = self.debugger.editor
            editor.SetFocus()
            try:
                editor.openOrGotoModule(filename)
            except Explorer.TransportLoadError, err:
                serverPath = entry['filename']
                if serverPath[0] == '<' and serverPath[-1] == '>':
                    wx.LogError(
                        _('Not a source file: %s, probably an executed '
                          'string.') % serverPath)
                    return

                res = wx.MessageBox(
                    _('Could not open file: %s.\n\nIf This is a '
                      'server path for which you\nhave not defined a mapping '
                      'click "Yes" to browse to the file to the mapping can '
                      'be computed.\nPress "No" to open the path dialog.') %
                    filename, _('File Open Error, try to compute path?'),
                    wx.ICON_WARNING | wx.YES_NO | wx.CANCEL)
                if res == wx.YES:
                    clientPath = editor.openFileDlg(
                        curfile=os.path.basename(filename))
                    if clientPath:
                        clientPath = prevClientPath = Explorer.splitURI(
                            clientPath)[2]
                        prevServerPath = serverPath
                        while 1:
                            serverPath, serverBase = os.path.split(serverPath)
                            clientPath, clientBase = os.path.split(clientPath)

                            if serverBase != clientBase:
                                paths = self.debugger.serverClientPaths[:]
                                paths.append((prevServerPath, prevClientPath))
                                if self.debugger.OnPathMappings(paths=paths):
                                    self.refreshClientFilenames()
                                break

                            if not serverPath or not clientPath:
                                wx.LogError(_('Paths are identical'))
                                break

                            prevClientPath = clientPath
                            prevServerPath = serverPath

                elif res == wxNO:
                    if self.debugger.OnPathMappings():
                        self.refreshClientFilenames()
                return

            model = editor.getActiveModulePage().model
            view = model.getSourceView()
            if view is not None:
                view.focus()
                view.SetFocus()
                view.selectLine(lineno - 1)
Esempio n. 31
0
 def listImportFiles(self):
     if self.properties.has_key('localpath') and self.properties['localpath']:
         from Explorers import Explorer
         return Explorer.listdirEx(self.properties['localpath']+'/import', '.zexp')
     else:
         return []
Esempio n. 32
0
    def readTimes(self):
        from StringIO import StringIO
        transp = Explorer.openEx(self.getTTVFilename())
        data = StringIO(transp.load())

        return map(lambda line: eval(line), data.readlines())
Esempio n. 33
0
 def GetFilePath(self):
     prot, cat, res, uri = Explorer.splitURI(self.GetPath())
     assert prot == 'file', _('Only filesystem paths allowed')
     return res
Esempio n. 34
0
 def OnLoadHistory(self, event):
     fn = self.editor.openFileDlg('AllFiles')
     if fn:
         from Explorers import Explorer
         data = Explorer.openEx(fn).load()
         self.history = pickle.loads(data)