/usr/share/pyshared/mayavi/action/help.py is in mayavi2 4.1.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | """Actions for the help menu.
"""
# Authors: Gael Varoquaux <gael.varoquaux[at]normalesup.org>
# Prabhu Ramachandran
# Copyright (c) 2007-2008, Enthought, Inc.
# License: BSD Style.
# Standard library imports.
from os import path
import os
import sys
from os.path import join, dirname
# Enthought library imports.
from pyface.action.api import Action
from traitsui.api import auto_close_message
# Local imports
import mayavi.api
from mayavi.core.common import error
from mayavi.preferences.api import preference_manager
# To find the html documentation directory, first look under the
# standard place. If that directory doesn't exist, assume you
# are running from the source.
local_dir = dirname(mayavi.api.__file__)
# Varun Hiremath: set debian mayavi2 html docs directory
HTML_DIR='/usr/share/doc/mayavi2/docs/build/mayavi/html'
if not path.exists(HTML_DIR):
HTML_DIR = join(dirname(dirname(local_dir)),
'build', 'docs', 'html', 'mayavi')
if not path.exists(HTML_DIR):
HTML_DIR = None
def browser_open(url):
if sys.platform == 'darwin':
os.system('open %s &' % url)
else:
import webbrowser
if webbrowser._iscommand('firefox') and \
preference_manager.root.open_help_in_light_browser:
# Firefox is installed, let's use it, we know how to make it
# chromeless.
firefox = webbrowser.get('firefox')
firefox._invoke(['-chrome', url], remote=False, autoraise=True)
else:
webbrowser.open(url, autoraise=1)
def open_help_index():
""" Open the mayavi user manual index in a browser.
"""
# If the HTML_DIR was found, bring up the documentation in a
# web browser. Otherwise, bring up an error message.
if HTML_DIR:
auto_close_message("Opening help in web browser...")
browser_open(join(HTML_DIR, 'index.html'))
else:
error("Could not find the user guide in your installation " \
"or the source tree.")
def open_tvtk_docs():
""" Open the TVTK class browser.
"""
from tvtk.tools.tvtk_doc import TVTKClassChooser
TVTKClassChooser().edit_traits()
######################################################################
# `HelpIndex` class.
######################################################################
class HelpIndex(Action):
""" An action that pop up the help in a browser. """
tooltip = "The Mayavi2 user guide"
description = "The Mayavi2 user guide"
###########################################################################
# 'Action' interface.
###########################################################################
def perform(self, event):
""" Performs the action. """
open_help_index()
######################################################################
# `TVTKClassBrowser` class.
######################################################################
class TVTKClassBrowser(Action):
""" An action that opens the tvtk interactive class browser. """
tooltip = "The TVTK interactive class browser"
description = "The TVTK interactive class browser"
###########################################################################
# 'Action' interface.
###########################################################################
def perform(self, event):
""" Performs the action. """
open_tvtk_docs()
|