[hdf-compass] 234/295: add notebook to visualize plugin info
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Sun May 8 10:35:49 UTC 2016
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to branch debian/master
in repository hdf-compass.
commit 7d26c52777120af000767d7a925bd50b896625da
Author: giumas <giumas at yahoo.it>
Date: Tue Nov 3 00:41:35 2015 -0500
add notebook to visualize plugin info
---
hdf_compass/array_model/model.py | 8 ++++
hdf_compass/asc_model/model.py | 8 ++++
hdf_compass/bag_model/model.py | 8 ++++
hdf_compass/compass_model/model.py | 13 ++++++
hdf_compass/compass_viewer/frame.py | 74 +++++++++++++++++++++++++++++++++++
hdf_compass/filesystem_model/model.py | 8 ++++
hdf_compass/hdf5_model/model.py | 7 ++++
hdf_compass/hdf5rest_model/model.py | 11 +++++-
hdf_compass/opendap_model/model.py | 7 ++++
9 files changed, 143 insertions(+), 1 deletion(-)
diff --git a/hdf_compass/array_model/model.py b/hdf_compass/array_model/model.py
index ae43888..e6ad4e3 100644
--- a/hdf_compass/array_model/model.py
+++ b/hdf_compass/array_model/model.py
@@ -55,6 +55,14 @@ class ArrayStore(compass_model.Store):
Keys are array names as reported in DATA.
"""
+ @staticmethod
+ def plugin_name():
+ return "Array"
+
+ @staticmethod
+ def plugin_description():
+ return "A testing plugin used to evaluate the array visualization."
+
def __contains__(self, key):
if (key == '/') or (key is None):
log.debug("is root: %s" % key)
diff --git a/hdf_compass/asc_model/model.py b/hdf_compass/asc_model/model.py
index 67ec3d9..27eedcf 100644
--- a/hdf_compass/asc_model/model.py
+++ b/hdf_compass/asc_model/model.py
@@ -34,6 +34,14 @@ from hdf_compass.utils import url2path
class AsciiGrid(compass_model.Store):
""" A "data store" represented by an ascii grid file. """
+ @staticmethod
+ def plugin_name():
+ return "Ascii Grid"
+
+ @staticmethod
+ def plugin_description():
+ return "A plugin used to browse Ascii Grid."
+
file_extensions = {'ASC File': ['*.asc']}
def __contains__(self, key):
diff --git a/hdf_compass/bag_model/model.py b/hdf_compass/bag_model/model.py
index 707c97f..3339b8d 100644
--- a/hdf_compass/bag_model/model.py
+++ b/hdf_compass/bag_model/model.py
@@ -45,6 +45,14 @@ class BAGStore(compass_model.Store):
Keys are the full names of objects in the file.
"""
+ @staticmethod
+ def plugin_name():
+ return "BAG"
+
+ @staticmethod
+ def plugin_description():
+ return "A plugin used to browse Open Navigation Surface BAG files."
+
file_extensions = {'BAG File': ['*.bag']}
def __contains__(self, key):
diff --git a/hdf_compass/compass_model/model.py b/hdf_compass/compass_model/model.py
index c57f223..82d49a7 100644
--- a/hdf_compass/compass_model/model.py
+++ b/hdf_compass/compass_model/model.py
@@ -105,6 +105,19 @@ class Store(object):
__nodeclasses = None
+ @staticmethod
+ def plugin_name():
+ """ Short name for the plugin. """
+ raise NotImplementedError
+
+ @staticmethod
+ def plugin_description():
+ """ Plugin description.
+
+ Return useful info about the plugin as the main functionalities, the author, the support email (if any)
+ """
+ raise NotImplementedError
+
@classmethod
def push(cls, nodeclass):
""" Register a Node subclass.
diff --git a/hdf_compass/compass_viewer/frame.py b/hdf_compass/compass_viewer/frame.py
index a83924f..1d0ffdf 100644
--- a/hdf_compass/compass_viewer/frame.py
+++ b/hdf_compass/compass_viewer/frame.py
@@ -23,6 +23,7 @@ import os
import sys
from datetime import date
import wx
+import wx.richtext as rtc
from wx.lib.pubsub import pub
import logging
@@ -32,6 +33,7 @@ from .info import InfoPanel
ID_OPEN_RESOURCE = wx.NewId()
ID_CLOSE_FILE = wx.NewId()
+ID_PLUGIN_INFO = wx.NewId()
MAX_RECENT_FILES = 8
@@ -112,6 +114,7 @@ class BaseFrame(wx.Frame):
# moved to the main application menu by wxPython.
help_menu = wx.Menu()
help_menu.Append(wx.ID_HELP, "Online &Manual", "Open online documentation")
+ help_menu.Append(ID_PLUGIN_INFO, "&Plugin Info", "Information about the available plugins")
help_menu.Append(wx.ID_ABOUT, "&About HDFCompass", "Information about this program")
menubar.Append(help_menu, "&Help")
@@ -120,6 +123,7 @@ class BaseFrame(wx.Frame):
self.Bind(wx.EVT_MENU, self.on_file_open, id=wx.ID_OPEN)
self.Bind(wx.EVT_MENU, self.on_resource_open, id=ID_OPEN_RESOURCE)
self.Bind(wx.EVT_MENU, self.on_manual, id=wx.ID_HELP)
+ self.Bind(wx.EVT_MENU, self.on_plugin_info, id=ID_PLUGIN_INFO)
self.Bind(wx.EVT_MENU, self.on_about, id=wx.ID_ABOUT)
self.Bind(wx.EVT_MENU, self.on_exit, id=wx.ID_EXIT)
self.Bind(wx.EVT_MENU, self.on_close, id=wx.ID_CLOSE)
@@ -144,6 +148,11 @@ class BaseFrame(wx.Frame):
import webbrowser
webbrowser.open('http://hdf-compass.readthedocs.org/en/stable/')
+ def on_plugin_info(self, evt):
+ """ Open a tabs frame with info about the available plugins """
+ plug_info = PluginInfoFrame(self)
+ plug_info.Show()
+
def on_about(self, evt):
""" Display an "About" dialog """
info = wx.AboutDialogInfo()
@@ -430,3 +439,68 @@ class NodeFrame(BaseFrame):
# Post it directly to the App, or Container will intercept it!
pos = wx.GetTopLevelParent(self).GetPosition()
wx.PostEvent(wx.GetApp(), CompassOpenEvent(node_new, pos=pos))
+
+
+class PluginInfoFrame(wx.Frame):
+ icon_folder = os.path.abspath(os.path.join(os.path.dirname(__file__), 'icons'))
+
+ def __init__(self, parent):
+ # make that the plugin info is displayed in the middle of the screen
+ frame_w = 320
+ frame_h = 250
+ x = wx.SystemSettings.GetMetric(wx.SYS_SCREEN_X)//2 - frame_w//2
+ y = wx.SystemSettings.GetMetric(wx.SYS_SCREEN_Y)//2 - frame_h//2
+ wx.Frame.__init__(self, parent, title="Plugin Info", pos=(x, y), size=(frame_w, frame_h))
+
+ # Frame icon
+ ib = wx.IconBundle()
+ icon_32 = wx.EmptyIcon()
+ icon_32.CopyFromBitmap(wx.Bitmap(os.path.join(self.icon_folder, "favicon_32.png"), wx.BITMAP_TYPE_ANY))
+ ib.AddIcon(icon_32)
+ icon_48 = wx.EmptyIcon()
+ icon_48.CopyFromBitmap(wx.Bitmap(os.path.join(self.icon_folder, "favicon_48.png"), wx.BITMAP_TYPE_ANY))
+ ib.AddIcon(icon_48)
+ self.SetIcons(ib)
+
+ p = wx.Panel(self)
+ nb = wx.Notebook(p)
+
+ for store in compass_model.get_stores():
+ try:
+ print(store.plugin_name())
+ print(store.plugin_description())
+
+ pnl = wx.Panel(nb)
+ t = rtc.RichTextCtrl(pnl, -1, style=wx.TE_READONLY)
+ t.BeginFontSize(9)
+ t.BeginAlignment(wx.TEXT_ALIGNMENT_CENTRE)
+ t.BeginBold()
+ t.WriteText("Name: ")
+ t.EndBold()
+ t.BeginItalic()
+ t.WriteText(store.plugin_name())
+ t.EndItalic()
+ t.Newline()
+ t.Newline()
+ t.BeginBold()
+ t.WriteText("Description")
+ t.EndBold()
+ t.Newline()
+ t.BeginItalic()
+ t.WriteText(store.plugin_description())
+ t.EndItalic()
+ t.Newline()
+
+ #store.plugin_description(), style=wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_CENTER)
+ szr = wx.BoxSizer()
+ szr.Add(t, 1, wx.ALL|wx.EXPAND, 5)
+ pnl.SetSizer(szr)
+ nb.AddPage(pnl, store.plugin_name())
+
+ except NotImplementedError:
+ # skip not implemented plugin name/description
+ log.debug("Not implemented name/description for %s" % store)
+
+ sizer = wx.BoxSizer()
+ sizer.Add(nb, 1, wx.ALL | wx.EXPAND, 3)
+ p.SetSizer(sizer)
diff --git a/hdf_compass/filesystem_model/model.py b/hdf_compass/filesystem_model/model.py
index 12cac08..7c22bf4 100644
--- a/hdf_compass/filesystem_model/model.py
+++ b/hdf_compass/filesystem_model/model.py
@@ -36,6 +36,14 @@ class Filesystem(compass_model.Store):
Keys are absolute paths on the local file system.
"""
+ @staticmethod
+ def plugin_name():
+ return "Filesystem"
+
+ @staticmethod
+ def plugin_description():
+ return "A plugin used to browse local files and folders."
+
def __contains__(self, key):
return op.exists(key)
diff --git a/hdf_compass/hdf5_model/model.py b/hdf_compass/hdf5_model/model.py
index 6368265..0734c9f 100644
--- a/hdf_compass/hdf5_model/model.py
+++ b/hdf_compass/hdf5_model/model.py
@@ -45,6 +45,13 @@ class HDF5Store(compass_model.Store):
Keys are the full names of objects in the file.
"""
+ @staticmethod
+ def plugin_name():
+ return "HDF5"
+
+ @staticmethod
+ def plugin_description():
+ return "A plugin used to browse HDF5 files."
file_extensions = {'HDF5 File': ['*.hdf5', '*.h5']}
diff --git a/hdf_compass/hdf5rest_model/model.py b/hdf_compass/hdf5rest_model/model.py
index 5045b9a..1ee1b93 100644
--- a/hdf_compass/hdf5rest_model/model.py
+++ b/hdf_compass/hdf5rest_model/model.py
@@ -33,6 +33,7 @@ from hdf_compass.utils import url2path
from . import hdf5dtype
+
def get_json(endpoint, domain=None, uri=None):
# try to do a GET from the domain
@@ -54,7 +55,8 @@ def get_json(endpoint, domain=None, uri=None):
rsp_json = json.loads(rsp.text)
return rsp_json
-
+
+
def sort_key(name):
""" Sorting key for names in an HDF5 group.
@@ -78,6 +80,13 @@ class HDF5RestStore(compass_model.Store):
/datasets/<uuid>
/datatypes/<uuid>
"""
+ @staticmethod
+ def plugin_name():
+ return "HDF5 Rest"
+
+ @staticmethod
+ def plugin_description():
+ return "A plugin used to access HDF Services."
def __contains__(self, key):
if key in self.f:
diff --git a/hdf_compass/opendap_model/model.py b/hdf_compass/opendap_model/model.py
index 2a99740..e203e20 100644
--- a/hdf_compass/opendap_model/model.py
+++ b/hdf_compass/opendap_model/model.py
@@ -34,6 +34,13 @@ def check_key(key, dataset):
class Server(compass_model.Store):
""" Represents the remote OpENDAP server to be accessed """
+ @staticmethod
+ def plugin_name():
+ return "OpENDAP"
+
+ @staticmethod
+ def plugin_description():
+ return "A plugin used to access OpENDAP Servers."
def __contains__(self, key):
if '/' not in key:
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/hdf-compass.git
More information about the debian-science-commits
mailing list