Changeset 1502

Show
Ignore:
Timestamp:
07/22/08 21:11:29 (5 weeks ago)
Author:
rob
Message:

Added url parameter to attemptOpen so that the url can be modified in place rather than the buffer's url
* FIXME: maybe buffer can be removed entirely from attemptOpen

Location:
trunk/peppy
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/peppy/dired_menu.py

    r1301 r1502  
    162162        return [] 
    163163 
    164     def attemptOpen(self, buffer): 
     164    def attemptOpen(self, buffer, url): 
    165165        # use a copy of the url because don't want to change the buffer's url 
    166166        # unless it turns out that we want to change the scheme 
    167         refcopy = vfs.get_reference(unicode(buffer.url)) 
     167        refcopy = vfs.get_reference(unicode(url)) 
    168168        #print "url = %s" % str(refcopy) 
    169169        if refcopy.scheme == "file" and vfs.exists(refcopy) and vfs.get_size(refcopy) > 0: 
     
    171171            refcopy.scheme = "tar" 
    172172            if vfs.exists(refcopy): 
    173                 # OK, we do a bit of a trick here: rewrite the url in the 
    174                 # buffer object to change the scheme to tar: 
    175                 buffer.url.scheme = "tar" 
     173                # OK, we do a bit of a trick here: rewrite the url to change 
     174                # the scheme to tar: 
     175                url.scheme = "tar" 
    176176                return (DiredMode, []) 
    177177        return (None, []) 
  • trunk/peppy/hsi/hsi_major_mode_proxy.py

    r1501 r1502  
    1212    """HSI viewer plugin to register modes and user interface. 
    1313    """ 
    14     def attemptOpen(self, buffer): 
    15         url = buffer.raw_url 
     14    def attemptOpen(self, buffer, url): 
    1615        assert self.dprint("Trying to open url: %s" % repr(unicode(url))) 
    1716        try: 
  • trunk/peppy/major.py

    r1501 r1502  
    11981198            cls.dprint("checking plugin %s" % str(plugin.__class__.__mro__)) 
    11991199            cls.current_modes.extend(plugin.getMajorModes()) 
    1200         dprint("Currently active major modes: %s" % str(cls.current_modes)) 
     1200        cls.dprint("Currently active major modes: %s" % str(cls.current_modes)) 
    12011201        cls.ignored_modes = set() 
    12021202     
     
    12091209    @classmethod 
    12101210    def ignoreMode(cls, mode): 
    1211         dprint("Ignoring mode %s" % mode) 
     1211        cls.dprint("Ignoring mode %s" % mode) 
    12121212        cls.skipped_modes.add(mode) 
    12131213 
    12141214    @classmethod 
    1215     def match(cls, buffer, magic_size=None): 
     1215    def match(cls, buffer, magic_size=None, url=None): 
    12161216        app = wx.GetApp() 
    12171217        if magic_size is None: 
    12181218            magic_size = app.classprefs.magic_size 
     1219        if url is None: 
     1220            url = buffer.raw_url 
    12191221 
    12201222        plugins = app.plugin_manager.getActivePluginObjects() 
     
    12221224         
    12231225        # Try to match a specific protocol 
    1224         modes = cls.scanProtocol(buffer.raw_url) 
     1226        modes = cls.scanProtocol(url) 
    12251227        cls.dprint("scanProtocol matches %s" % modes) 
    12261228        if modes: 
     
    12301232        # generate a list of possible modes 
    12311233        try: 
    1232             metadata = vfs.get_metadata(buffer.raw_url) 
     1234            metadata = vfs.get_metadata(url) 
    12331235        except: 
    12341236            metadata = {'mimetype': None, 
     
    12371239                        'description': None, 
    12381240                        } 
    1239         modes, binary_modes = cls.scanURL(buffer.raw_url, metadata) 
     1241        modes, binary_modes = cls.scanURL(url, metadata) 
    12401242        cls.dprint("scanURL matches %s (binary: %s) using metadata %s" % (modes, binary_modes, metadata)) 
    12411243 
     
    13031305        # As a last resort to open a specific mode, attempt to open it 
    13041306        # with any third-party openers that have been registered 
    1305         mode = cls.attemptOpen(plugins, buffer) 
     1307        mode = cls.attemptOpen(plugins, buffer, url) 
    13061308        cls.dprint("attemptOpen matches %s" % mode) 
    13071309        if mode: 
     
    14911493     
    14921494    @classmethod 
    1493     def attemptOpen(cls, plugins, buffer): 
     1495    def attemptOpen(cls, plugins, buffer, url): 
    14941496        """Use the mode's attemptOpen method to see if it recognizes the url. 
    14951497         
     
    15011503        for plugin in plugins: 
    15021504            try: 
    1503                 exact, generics = plugin.attemptOpen(buffer) 
     1505                exact, generics = plugin.attemptOpen(buffer, url) 
    15041506                if exact: 
    15051507                    return exact 
  • trunk/peppy/yapsy/plugins.py

    r1235 r1502  
    310310        return 
    311311     
    312     def attemptOpen(self, buffer): 
     312    def attemptOpen(self, buffer, url): 
    313313        """Last resort to major mode matching: attempting to open the url. 
    314314 
     
    319319 
    320320        buffer: the Buffer object to attempt to load 
     321         
     322        url: the user specified URL (which may be different from the buffer's 
     323        idea of what the URL is if the buffer already exists and we're trying 
     324        to create a new view using a different major mode) 
    321325 
    322326        @returns: tuple (exact, generic_list) where when exact is not None the