Commits

Christian Ebert  committed 7c3dffe

Handle cygwin in pybrowser only

* use find instead of re to detect platform
* merge format_path function into fixurl
* use util.pipeline to retrieve windows fs path
* no underscore in variable name

  • Participants
  • Parent commits cb65762

Comments (0)

Files changed (2)

File muttils/pybrowser.py

 # $Id$
 
-import os, webbrowser
+import os, platform, webbrowser
 from muttils import ui, urlregex, util
 
 class browser(object):
         self.ui = parentui or ui.ui()
         self.ui.updateconfig()
         self.items = items             # urls
+        self.cygpath = platform.system().find('CYGWIN') > -1
         if app is not None:
             self.ui.app = app
         if evalurl: # check remote url protocol scheme
                 # use gateway when browser is not gopher capable
                 url = url.replace('gopher://',
                                   'http://gopher.floodgap.com/gopher/gw?')
-        elif self.use_cygpath:
-            pass # regular Windows filesystem path expected, nothing to do
+        elif self.cygpath:
+            # cygwin expects windows filesystem path
+            url = util.pipeline(['cygpath', '-w', url]).rstrip()
         else: # local
             if url.startswith('file:'):
                 # drop scheme in favour of local path

File muttils/viewhtmlmsg.py

 
 import email, email.Errors, email.Iterators, email.Utils
 import os.path, re, shutil, sys, tempfile, time, urllib
-import subprocess, platform
 from muttils import pybrowser, ui, util
 
 class viewhtml(pybrowser.browser):
         self.keep = keep
         if self.keep is None:
             self.keep = self.ui.configint('html', 'keep', 3)
-        self.use_cygpath = re.match('CYGWIN', platform.system())
 
     def cleanup(self, tmpdir):
         if self.keep:
             fp = open(htmlfile, 'wb')
             fp.write(html)
             fp.close()
-            self.items = [self.format_path(htmlfile)]
+            self.items = [htmlfile]
             self.urlvisit()
             if self.keep:
                 time.sleep(self.keep)
         finally:
             self.cleanup(htmldir)
-
-    def format_path(self, p):
-        if self.use_cygpath:
-            proc = subprocess.Popen(["cygpath", "-w", p],
-                    shell=False, stdout=subprocess.PIPE)
-            p = proc.communicate()
-            print p
-            p = p[0].rstrip()
-        print p
-        return p