Ejemplo n.º 1
0
Archivo: app.py Proyecto: fred3m/toyz
 def get_toyz_path(self, path, path_type):
     """
     Given a toyz path, return the root path for the toy.
     """
     import importlib
     toyz_info = path.split('/')
     toy_name = toyz_info[0]
     rel_path = toyz_info[1:-1]
     filename = toyz_info[-1]
     config = core.get_toyz_module(self.application.toyz_settings,
                                   self.get_user_id(), toy_name + '.config')
     if path_type == 'static':
         for root in config.static_paths:
             pathlist = [root] + rel_path
             fullpath = os.path.join(*pathlist)
             if os.path.isfile(os.path.join(fullpath, filename)):
                 return {'fullpath': fullpath, 'filename': filename}
         raise tornado.web.HTTPError(404)
     elif path_type == 'template':
         for root in config.template_paths:
             pathlist = [root] + rel_path
             fullpath = os.path.join(*pathlist)
             if os.path.isfile(os.path.join(fullpath, filename)):
                 toyz_info = {'fullpath': fullpath, 'filename': filename}
                 if path in config.render_functions:
                     toyz_info['render'] = config.render_functions[path]
                 return toyz_info
         raise tornado.web.HTTPError(404)
     else:
         raise ToyzWebError("Unrecognized path type '" + path_type + "'")
Ejemplo n.º 2
0
 def name_columns(self, columns=None):
     if columns is not None:
         self.columns = columns
     elif self.data_type=='pandas.core.frame.DataFrame':
         self.columns = self.data.columns.values.tolist()
     elif self.data_type=='numpy.ndarray':
         if len(self.data.dtype) == 0:
             columns = ['col-'+str(n) for n in range(self.data.shape[1])]
         else:
             columns = list(self.data.dtype.names)
     elif 'set_columns' in self.paths['data']['io_module']:
         module = core.get_toyz_module(
             session_vars.toyz_settings,
             self.user_id,
             self.paths['data']['set_columns']['module'])
         self.columns = getattr(module, self.paths['data']['set_columns']['fn'])(self.data)
     elif self.data_type!='list':
         raise ToyzDataError(
             'Could not recognize set_columns function for data type {0}'.format(
                 self.data_type))
     return self.columns
Ejemplo n.º 3
0
Archivo: app.py Proyecto: fred3m/toyz
 def get_toyz_path(self, path, path_type):
     """
     Given a toyz path, return the root path for the toy.
     """
     import importlib
     toyz_info = path.split('/')
     toy_name = toyz_info[0]
     rel_path = toyz_info[1:-1]
     filename = toyz_info[-1]
     config = core.get_toyz_module(
         self.application.toyz_settings, self.get_user_id(), toy_name+'.config')
     if path_type == 'static':
         for root in config.static_paths:
             pathlist = [root]+rel_path
             fullpath = os.path.join(*pathlist)
             if os.path.isfile(os.path.join(fullpath, filename)):
                 return {
                     'fullpath': fullpath,
                     'filename': filename
                 }
         raise tornado.web.HTTPError(404)
     elif path_type == 'template':
         for root in config.template_paths:
             pathlist = [root]+rel_path
             fullpath = os.path.join(*pathlist)
             if os.path.isfile(os.path.join(fullpath, filename)):
                 toyz_info = {
                     'fullpath': fullpath,
                     'filename': filename
                 }
                 if path in config.render_functions:
                     toyz_info['render'] = config.render_functions[path]
                 return toyz_info
         raise tornado.web.HTTPError(404)
     else:
         raise ToyzWebError("Unrecognized path type '"+path_type+"'")