Example #1
0
    def open_data_files(self, file_names=None):
        """
        Analyzes the files for correctness, then adds them to the list widget.

        :param ListType<StringType> file_names: The file names to be included in the list widget. If not included,
                                                this function will use a QtGui.QFileDialog.getOpenFileNames to open
                                                files.
        :returns: BooleanType -- **True** if files were opened, **False** otherwise.
        """
        if file_names is None:
            file_names = QtGui.QFileDialog.getOpenFileNames(
                self, 'Open data file', '.',
                "All types(*.h5 *.hkd *.log *.mat);;"
                "Pypore data files *.h5(*.h5);;"
                "Heka files *.hkd(*.hkd);;"
                "Chimera files *.log(*.log);;Gabys files *.mat(*.mat)")[0]
        if len(file_names) > 0:
            self.file_list_widget.clear()
        else:
            return
        are_files_opened = False
        open_dir = None
        for w in file_names:
            reader = get_reader_from_filename(w)
            # if 'error' in params:
            # TODO implement error handling in readers
            # pass
            # else:
            reader.close()
            are_files_opened = True
            item = FileListItem(w)
            open_dir = item.get_directory()
            self.file_list_widget.addItem(item)

        return are_files_opened
Example #2
0
class TestFileListItem(unittest.TestCase):
    def setUp(self):
        self.filename = os.path.abspath('hi.txt')
        self._set_item()

    def _set_item(self):
        self.item = FileListItem(self.filename)

    def tearDown(self):
        pass

    def test_file_list_item_simple_name(self):
        simple_name = self.item.get_simple_name()
        self.assertEqual(simple_name, 'hi.txt')

    def test_file_list_item_directory(self):
        directory = self.item.get_directory()
        self.assertEqual(directory, os.path.dirname(self.filename))

    def test_file_list_item_filename(self):
        check = self.item.get_file_name()
        self.assertEqual(check, self.filename)
Example #3
0
class TestFileListItem(unittest.TestCase):
    
    def setUp(self):
        self.filename = os.path.abspath('hi.txt')
        self._set_item()
        
    def _set_item(self):
        self.item = FileListItem(self.filename)
    
    def tearDown(self):
        pass
    
    def test_file_list_item_simple_name(self):
        simple_name = self.item.get_simple_name()
        self.assertEqual(simple_name, 'hi.txt')
        
    def test_file_list_item_directory(self):
        directory = self.item.get_directory()
        self.assertEqual(directory, os.path.dirname(self.filename))
        
    def test_file_list_item_filename(self):
        check = self.item.get_file_name()
        self.assertEqual(check, self.filename)
Example #4
0
    def open_data_files(self, file_names=None):
        """
        Analyzes the files for correctness, then adds them to the list widget.

        :param ListType<StringType> file_names: The file names to be included in the list widget. If not included,
                                                this function will use a QtGui.QFileDialog.getOpenFileNames to open
                                                files.
        :returns: BooleanType -- **True** if files were opened, **False** otherwise.
        """
        if file_names is None:
            file_names = QtGui.QFileDialog.getOpenFileNames(self,
                                                            'Open data file',
                                                            '.',
                                                            "All types(*.h5 *.hkd *.log *.mat);;"
                                                            "Pypore data files *.h5(*.h5);;"
                                                            "Heka files *.hkd(*.hkd);;"
                                                            "Chimera files *.log(*.log);;Gabys files *.mat(*.mat)")[0]
        if len(file_names) > 0:
            self.file_list_widget.clear()
        else:
            return
        are_files_opened = False
        open_dir = None
        for w in file_names:
            reader = get_reader_from_filename(w)
            # if 'error' in params:
            # TODO implement error handling in readers
            # pass
            # else:
            reader.close()
            are_files_opened = True
            item = FileListItem(w)
            open_dir = item.get_directory()
            self.file_list_widget.addItem(item)

        return are_files_opened
Example #5
0
    def open_event_databases(self, file_names=None):
        """
        Adds the files to the list widget.

        :param ListType<StringType> file_names: (Optional) List of file names to be added to the list widget. If not
                                                included, then a QtGui.QFileDialog will be opened to select files.
        """
        if file_names is None:
            file_names = QtGui.QFileDialog.getOpenFileNames(
                self, 'Open event database', '.', '*.h5')[0]

        if len(file_names) > 0:
            self.eventview_list_widget.clear()
        else:
            return
        for w in file_names:
            item = FileListItem(w)
            self.eventview_list_widget.addItem(item)
Example #6
0
 def _set_item(self):
     self.item = FileListItem(self.filename)
Example #7
0
 def _set_item(self):
     self.item = FileListItem(self.filename)