Skip to content

Commit

Permalink
Whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
remram44 committed Dec 10, 2014
1 parent 6e3badd commit 68beea0
Show file tree
Hide file tree
Showing 14 changed files with 556 additions and 548 deletions.
24 changes: 12 additions & 12 deletions vistrails/packages/spreadsheet/analogy_api.py
Expand Up @@ -46,27 +46,27 @@ class SpreadsheetAnalogyObject(object):
SpreadsheetAnalogyObject provides a API functions to integrate
between the spreadsheet and the analogy. There will be only one
instance of the analogy object
"""
def __init__(self):
""" SpreadsheetAnalogyObject() -> SpreadsheetAnalogyObject
Initialize object properties
"""
pass

def isValid(self):
""" isValid() -> bool
""" isValid() -> bool
Is the current analogy object is valid and can be applied to
other pipeline
"""
return True

def createAnalogy(self, p1Info, p2Info):
""" createAnalogy(p1Info: tuple, p2Info) -> bool
""" createAnalogy(p1Info: tuple, p2Info) -> bool
p1Info, p2Info: (vistrailName, versionNumber, actions, pipeline)
Setup an analogy object from p1 to p2 given their info in
p1Info and p2Info. CAUTION: sometimes the actual 'pipeline' on
the spreadsheet is different than the one created from the
Expand All @@ -77,7 +77,7 @@ def createAnalogy(self, p1Info, p2Info):
This function should return a boolean saying if the analogy
has been successfully created or not.
"""
# (p1_vistrail, p1_number, p1_actions, p1_pipeline) = p1Info
# (p2_vistrail, p2_number, p2_actions, p2_pipeline) = p2Info
Expand All @@ -94,7 +94,7 @@ def applyAnalogy(self, pInfo):
the list of actions that has been applied. If no actions
given (i.e. []), this can not be put back to the builder. If
analogy is not applicable, this should return None
"""

(p1_locator, p1_number, p1_actions, p1_pipeline, p1_controller) = self._p1Info
Expand All @@ -115,18 +115,18 @@ def applyAnalogy(self, pInfo):
if controller.current_version != p3_number:
controller.change_selected_version(p3_number)
action = perform( vt, p1_number, p2_number, p3_number)

controller.add_new_action(action)
controller.perform_action(action)

new_version = controller.current_version
new_pipeline = vt.getPipeline(new_version)
return (controller.locator, new_version, [], new_pipeline, controller)

def __call__(self):
""" __call__() -> SpreadsheetAnalogy
Return self for calling method
"""
return self

Expand Down
41 changes: 23 additions & 18 deletions vistrails/packages/spreadsheet/basic_widgets.py
Expand Up @@ -53,20 +53,20 @@
from .spreadsheet_controller import spreadsheetController
from .spreadsheet_event import DisplayCellEvent

################################################################################

def widgetName():
""" widgetName() -> str
Identify the name of the package
"""
return 'Basic Widgets'


def registerWidget(reg, basicModules, basicWidgets):
""" registerWidget(reg: module_registry, basicModules: package,
basicWidgets:package) -> None
Register widgets with VisTrails registry
"""
reg.add_module(SheetReference)
reg.add_input_port(SheetReference, "MinRowCount", basicModules.Integer, True)
Expand Down Expand Up @@ -94,19 +94,20 @@ def registerWidget(reg, basicModules, basicWidgets):
basicModules.String, True)
reg.add_output_port(SingleCellSheetReference, "value",
SingleCellSheetReference)



class SheetReference(Module):
"""
SheetReference is a VisTrail Module that allows users to specify
which sheet (page) to put the visualiation on. This is as
well a wrapper to simply contain real sheet reference classes
"""
def compute(self):
""" compute() -> None
Store information on input ports and ready to be passed on to whoever
needs it
"""
ref = StandardSheetReference()
ref.minimumRowCount = self.force_get_input("MinRowCount", 1)
Expand All @@ -115,12 +116,13 @@ def compute(self):

self.set_output('value', ref)


class CellLocation(Module):
"""
CellLocation is a Vistrail Module that allow users to specify
where to put a visualization on a sheet, i.e. row, column
location
"""
class Location(object):
def __init__(self):
Expand All @@ -133,7 +135,7 @@ def __init__(self):
def compute(self):
""" compute() -> None
Translate input ports into (row, column) location
"""
loc = CellLocation.Location()

Expand Down Expand Up @@ -164,35 +166,36 @@ def set_row_col(row, col):

self.set_output('value', loc)


class SpreadsheetCell(NotCacheable, Module):
"""
SpreadsheetCell is a base class to other widget types. It provides
a simple protocol to dispatch information to the spreadsheet
cells. But it doesn't know how to display the information
itself. That should be done by the specific widget type.
"""
def __init__(self):
""" SpreadsheetCell() -> SpreadsheetCell
Initialize attributes
"""
Module.__init__(self)
self.location = None

def overrideLocation(self, location):
""" overrideLocation(location: CellLocation) -> None
""" overrideLocation(location: CellLocation) -> None
Make the cell always use this location instead of reading from
the port
"""
self.location = location

def createDisplayEvent(self, cellType, inputPorts):
""" display(cellType: python type, iputPorts: tuple) -> None
""" display(cellType: python type, iputPorts: tuple) -> None
Create a DisplayEvent with all the parameters from the cell
locations and inputs
"""
e = DisplayCellEvent()
e.vistrail = self.moduleInfo
Expand All @@ -218,7 +221,7 @@ def displayAndWait(self, cellType, inputPorts):
Keyword arguments:
cellType --- widget type, this is truely a python type
inputPorts --- a tuple of input data that cellType() will understand
"""
e = self.createDisplayEvent(cellType, inputPorts)
QtCore.QCoreApplication.processEvents()
Expand All @@ -231,6 +234,7 @@ def displayAndWait(self, cellType, inputPorts):

display = displayAndWait


class SpreadsheetModeConfig(OutputModeConfig):
mode_type = "spreadsheet"
_fields = [ConfigField('row', None, int),
Expand All @@ -241,6 +245,7 @@ class SpreadsheetModeConfig(OutputModeConfig):
ConfigField('rowSpan', None, int),
ConfigField('colSpan', None, int)]


class SpreadsheetMode(OutputMode):
mode_type = "spreadsheet"
priority = 3
Expand Down Expand Up @@ -325,12 +330,12 @@ class SingleCellSheetReference(SheetReference):
SingleCellSheetReference is a wrapper of StandardSingleCellSheetReference
that will allow users to dedicate a whole sheet to view a single
visualization by pass all other sheet control widgets.
"""
def compute(self):
""" compute() -> None
Store information from input ports into internal structure
"""
ref = StandardSingleCellSheetReference()
ref.sheetName = self.force_get_input("SheetName")
Expand Down
26 changes: 16 additions & 10 deletions vistrails/packages/spreadsheet/init.py
Expand Up @@ -49,29 +49,30 @@
from .spreadsheet_controller import spreadsheetController
from .spreadsheet_registry import spreadsheetRegistry

# This must be here because of VisTrails protocol

################################################################################
# This must be here because of VisTrails protocol

basicWidgets = None


def importReturnLast(name):
""" importReturnLast(name: str) -> package
Import a package whose name is specified in name and return right-most
package on the package name
"""
mod = __import__(name)
components = name.split('.')
for comp in components[1:]:
mod = getattr(mod, comp)
return mod


def addWidget(packagePath):
""" addWidget(packagePath: str) -> package
Add a new widget type to the spreadsheet registry supplying a
basic set of spreadsheet widgets
"""
try:
registry = get_module_registry()
Expand All @@ -88,31 +89,33 @@ def addWidget(packagePath):
widget = None
return widget


def importWidgetModules(basicWidgets):
""" importWidgetModules(basicWidgets: widget) -> None
Find all widget package under ./widgets/* to add to the spreadsheet registry
"""
packageName = __name__.lower().endswith('.init') and \
__name__[:-5] or __name__
widgetDir = os.path.join(
os.path.join(os.path.dirname(vistrails_root_directory()),
os.path.join(os.path.dirname(vistrails_root_directory()),
*packageName.split('.')),
'widgets')
candidates = os.listdir(widgetDir)
for folder in candidates:
if os.path.isdir(os.path.join(widgetDir, folder)) and folder != '.svn':
addWidget('.'.join([packageName, 'widgets', folder]))


def initialize(*args, **keywords):
""" initialize() -> None
Package-entry to initialize the package
"""
import vistrails.core.application
if not vistrails.core.application.is_running_gui():
raise RuntimeError, "GUI is not running. The Spreadsheet package requires the GUI"

# initialize widgets
debug.log('Loading Spreadsheet widgets...')
global basicWidgets
Expand All @@ -129,11 +132,12 @@ def initialize(*args, **keywords):
global spreadsheetWindow
spreadsheetWindow = spreadsheetController.findSpreadsheetWindow(show=False)


def menu_items():
"""menu_items() -> tuple of (str,function)
It returns a list of pairs containing text for the menu and a
callback function that will be executed when that menu item is selected.
"""
def show_spreadsheet():
spreadsheetWindow.show()
Expand All @@ -143,14 +147,16 @@ def show_spreadsheet():
lst.append(("Show Spreadsheet", show_spreadsheet))
return tuple(lst)


def finalize():
spreadsheetWindow = spreadsheetController.findSpreadsheetWindow()
### DO NOT ADD BACK spreadsheetWindow.destroy()
### That will crash VisTrails on Mac.
### That will crash VisTrails on Mac.
### It is not supposed to be called directly
spreadsheetWindow.cleanup()
spreadsheetWindow.deleteLater()


def handle_module_upgrade_request(controller, module_id, pipeline):
module_remap = {
'CellLocation': [
Expand Down

0 comments on commit 68beea0

Please sign in to comment.