Ejemplo n.º 1
0
 def compute(self):
     """ compute() -> None
     Use BatchDisplayCellEvent to display a serie of SVG files
     
     """
     if self.hasInputFromPort("File"):
         fileValue = self.getInputFromPort("File")
     else:
         fileValue = None
     if fileValue:
         batchDisplayEvent = BatchDisplayCellEvent()
         # FIXME: Will this work? there should be no
         # self.currentVersion in the module (there is a
         # self.version)
         batchDisplayEvent.vistrail = (self.vistrailName,
                                       self.currentVersion)
         f = open(fileValue.name, 'r')            
         for line in f.read().split('\n'):
             comps = line.split('|')
             if len(comps)==2:
                 e = DisplayCellEvent()        
                 e.sheetReference = StandardSingleCellSheetReference()
                 e.sheetReference.sheetName = comps[1]                    
                 e.cellType = SVGCellWidget
                 F = File()
                 from os.path import abspath, basename, dirname
                 F.name = (dirname(abspath(fileValue.name))+
                           '/'+basename(comps[0]))
                 e.inputPorts = (F,)
                 batchDisplayEvent.displayEvents.append(e)
         f.close()
         spreadsheetController.postEventToSpreadsheet(batchDisplayEvent)
Ejemplo n.º 2
0
def create_file_module(fname, f=None, module=None):

    if f is None:
        f = File()
    f.name = getFileRelativeToCurrentVT(fname)
    f.upToDate = True
    return f
Ejemplo n.º 3
0
 def compute(self):
     old_compute(self)
     fn = self.vtkInstance.GetFileName()
     if not fn:
         o = self.interpreter.filePool.create_file(suffix='.vtk')
         self.vtkInstance.SetFileName(o.name)
     else:
         o = File()
         o.name = fn
     self.vtkInstance.Write()
     self.setResult('file', o)
Ejemplo n.º 4
0
 def run_figure(self, code_str, graphics_dev, width, height, 
                excluded_inputs=set(['source'])):
     f, fname = tempfile.mkstemp(prefix='vtr', suffix='.' + graphics_dev)
     r_temp_files.append(fname)
     os.close(f)
     robjects.r[graphics_dev](file=fname, width=width, height=height)
     self.run_code(code_str, use_input=True, 
                   excluded_inputs=excluded_inputs)
     robjects.r['dev.off']()
     image_file = File()
     image_file.name = fname
     image_file.upToDate = True
     self.setResult('imageFile', image_file)
Ejemplo n.º 5
0
    def compute(self):
        file_ = self.getInputFromPort("file")

        config = ConfigParser()
        config.optionxform = str  # keep capital letter in model names
        config.read(file_.name)

        # read basic information
        variable_name = config.get('basic', 'variable_name')
        ref_filename = File()
        ref_filename.name = config.get('basic', 'ref_filename')
        self.setResult('variable_name', variable_name)
        self.setResult('ref_filename', ref_filename)

        # read model names
        file_names = []
        model_names = config.options('file_names')
        for model in model_names:
            file_names.append(config.get('file_names', model))

        self.setResult('file_names', file_names)
        self.setResult('model_names', model_names)
Ejemplo n.º 6
0
    def compute(self):
        file_ = self.getInputFromPort("file")
        
        config = ConfigParser()
        config.optionxform = str # keep capital letter in model names
        config.read(file_.name)
        
        # read basic information
        variable_name = config.get('basic', 'variable_name')
        ref_filename = File()
        ref_filename.name = config.get('basic', 'ref_filename')
        self.setResult('variable_name', variable_name)
        self.setResult('ref_filename', ref_filename)
        
        # read model names
        file_names = []
        model_names = config.options('file_names')
        for model in model_names:
            file_names.append(config.get('file_names', model))

        self.setResult('file_names', file_names);
        self.setResult('model_names', model_names);
Ejemplo n.º 7
0
def create_module(value, signature):
    """
    Creates a module for value, in order to do the type checking.
    """    
    if type(value)==bool:
        v_module = Boolean()
        return v_module
    elif type(value)==str:
        v_module = String()
        return v_module
    elif type(value)==int:
        if type(signature)==list:
            signature = signature[0]
        if signature[0]==Float().__class__:
            v_module = Float()
        else:
            v_module = Integer()
        return v_module
    elif type(value)==float:
        v_module = Float()
        return v_module
    elif type(value)==list:
        v_module = List()
        return v_module
    elif type(value)==file:
        v_module = File()
        return v_module
    elif type(value)==tuple:
        v_modules = ()
        for element in xrange(len(value)):
            v_modules += (create_module(value[element], signature[element]),)
        return v_modules
    else:
        debug.warning("Could not identify the type of the list element.")
        debug.warning("Type checking is not going to be done inside Fold module.")
        return None
Ejemplo n.º 8
0
def create_file_module(fname, f=None):
    if f is None:
        f = File()
    f.name = fname
    f.upToDate = True
    return f
Ejemplo n.º 9
0
def create_file_module(fname, f=None):
    if f is None:
        f = File()
    f.name = fname
    f.upToDate = True
    return f
Ejemplo n.º 10
0
 def translate_to_python(x):
     result = File()
     result.name = x
     result.setResult("value", result)
     return result
Ejemplo n.º 11
0
 def __init__(self):
     File.__init__(self)
Ejemplo n.º 12
0
 def set_result(self, path):
     persistent_path = File()
     persistent_path.name = path
     persistent_path.setResult('value', self)
     persistent_path.upToDate = True
     self.setResult("value", persistent_path)
Ejemplo n.º 13
0
 def compute(self):
     from csvDownload import convertNetCDFToCSV
     variable = self.getInputFromPort("variable")
     output = File()
     output.name = convertNetCDFToCSV(variable.data_file.name, variable.var_name)
     self.setResult("csv", output)
Ejemplo n.º 14
0
 def set_result(self, path):
     persistent_path = File()
     persistent_path.name = path
     persistent_path.setResult('value', self)
     persistent_path.upToDate = True
     self.setResult("value", persistent_path)