Christian Ebert avatar Christian Ebert committed ee532af

pybrowser: store browser program name in class attribute

Use util.progname and remove pybrowser.appname().

Comments (0)

Files changed (1)

muttils/pybrowser.py

         self.items = items             # urls
         if app is not None:
             self.ui.app = app
+        self.appname = util.progname(self.ui.app)
         if evalurl: # check remote url protocol scheme
             self.ui.proto = 'web'
             u = urlregex.urlregex(self.ui, uniq=False)
             u.urlobject(search=False)
             self.weburl_re = u.url_re
 
-    def appname(self):
-        '''Extracts (text)browser name from /path/to/name(.exe).'''
-        try:
-            return os.path.splitext(os.path.basename(self.ui.app))[0]
-        except AttributeError:
-            return ''
-
     def fixurl(self, url, cygpath):
         '''Adapts possibly short url to pass as browser argument.'''
         if not self.weburl_re or self.weburl_re.match(url):
             url = urlregex.webschemecomplete(url)
             gophers = 'lynx', 'firefox'
-            if url.startswith('gopher://') and self.appname() not in gophers:
+            if url.startswith('gopher://') and self.appname not in gophers:
                 # use gateway when browser is not gopher capable
                 url = url.replace('gopher://',
                                   'http://gopher.floodgap.com/gopher/gw?')
         '''Visit url(s).'''
         textbrowsers = 'w3m', 'lynx', 'links', 'elinks'
         notty, screen = False, False
-        app = self.appname()
-        tb = app in textbrowsers
+        tb = self.appname in textbrowsers
         if tb:
             notty = not util.termconnected()
             screen = 'STY' in os.environ
         self.items = [self.fixurl(url, cygpath) for url in self.items]
         # w3m does not need to be connected to terminal
         # but has to be connected if called into another screen instance
-        if screen or app in textbrowsers[1:] and notty:
+        if screen or self.appname in textbrowsers[1:] and notty:
             for url in self.items:
                 util.systemcall([self.ui.app, url], notty, screen)
         else:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.