From 3cc49d723213526101b94c734af1731d19d1e6a0 Mon Sep 17 00:00:00 2001
From: Paul McCarthy <pauld.mccarthy@gmail.com>
Date: Tue, 5 Apr 2016 23:10:26 +0100
Subject: [PATCH] Some more convenience functions added to utils.webpage.

---
 fsl/utils/webpage.py | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/fsl/utils/webpage.py b/fsl/utils/webpage.py
index c532ec23d..962c6444f 100644
--- a/fsl/utils/webpage.py
+++ b/fsl/utils/webpage.py
@@ -12,7 +12,9 @@ The following functions are provided:
 .. autosummary::
    :nosignatures:
 
+   fileToUrl
    openPage
+   openFile
    localHelpUrl
    openLocalHelp
 """
@@ -22,11 +24,26 @@ import os.path as op
 import            webbrowser
 
 
+def fileToUrl(fileName):
+    """Converts a file path to a URL. """
+    
+    import urlparse
+    import urllib
+    return urlparse.urljoin(
+        'file:', urllib.pathname2url(fileName))
+
+
+
 def openPage(url):
     """Opens the given URL in the system-default web browser."""
     webbrowser.open(url)
 
 
+def openFile(fileName):
+    """Opens the given file in the system-default web browser."""
+    openPage(fileToUrl(fileName))
+
+
 def localHelpUrl(toolName):
     """Checks the ``$FSLDIR`` to see if a local help page exists for the
     FSL tool with the specified name.
@@ -40,10 +57,7 @@ def localHelpUrl(toolName):
     localUrl = op.join(fsldir, 'doc', 'redirects', '{}.html'.format(toolName))
 
     if op.exists(localUrl):
-        import urlparse
-        import urllib
-        return urlparse.urljoin(
-            'file:', urllib.pathname2url(localUrl)) 
+        return fileToUrl(localUrl)
 
     return None
 
-- 
GitLab