Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Evan Edmond
fslpy
Commits
3cc49d72
Commit
3cc49d72
authored
9 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Some more convenience functions added to utils.webpage.
parent
e63781ee
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fsl/utils/webpage.py
+18
-4
18 additions, 4 deletions
fsl/utils/webpage.py
with
18 additions
and
4 deletions
fsl/utils/webpage.py
+
18
−
4
View file @
3cc49d72
...
@@ -12,7 +12,9 @@ The following functions are provided:
...
@@ -12,7 +12,9 @@ The following functions are provided:
.. autosummary::
.. autosummary::
:nosignatures:
:nosignatures:
fileToUrl
openPage
openPage
openFile
localHelpUrl
localHelpUrl
openLocalHelp
openLocalHelp
"""
"""
...
@@ -22,11 +24,26 @@ import os.path as op
...
@@ -22,11 +24,26 @@ import os.path as op
import
webbrowser
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
):
def
openPage
(
url
):
"""
Opens the given URL in the system-default web browser.
"""
"""
Opens the given URL in the system-default web browser.
"""
webbrowser
.
open
(
url
)
webbrowser
.
open
(
url
)
def
openFile
(
fileName
):
"""
Opens the given file in the system-default web browser.
"""
openPage
(
fileToUrl
(
fileName
))
def
localHelpUrl
(
toolName
):
def
localHelpUrl
(
toolName
):
"""
Checks the ``$FSLDIR`` to see if a local help page exists for the
"""
Checks the ``$FSLDIR`` to see if a local help page exists for the
FSL tool with the specified name.
FSL tool with the specified name.
...
@@ -40,10 +57,7 @@ def localHelpUrl(toolName):
...
@@ -40,10 +57,7 @@ def localHelpUrl(toolName):
localUrl
=
op
.
join
(
fsldir
,
'
doc
'
,
'
redirects
'
,
'
{}.html
'
.
format
(
toolName
))
localUrl
=
op
.
join
(
fsldir
,
'
doc
'
,
'
redirects
'
,
'
{}.html
'
.
format
(
toolName
))
if
op
.
exists
(
localUrl
):
if
op
.
exists
(
localUrl
):
import
urlparse
return
fileToUrl
(
localUrl
)
import
urllib
return
urlparse
.
urljoin
(
'
file:
'
,
urllib
.
pathname2url
(
localUrl
))
return
None
return
None
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment