示例#1
0
def test_get_all_readers_gives_napari():
    npe2_readers, npe1_readers = get_all_readers()
    assert len(npe1_readers) == 1
    assert len(npe2_readers) == 1
    assert 'napari' in npe2_readers
    assert npe2_readers['napari'] == 'napari (npe2)'
    assert 'builtins' in npe1_readers
    assert npe1_readers['builtins'] == 'builtins (npe1)'
示例#2
0
def test_get_all_readers(tmp_plugin: DynamicPlugin):
    tmp2 = tmp_plugin.spawn(register=True)

    @tmp_plugin.contribute.reader(filename_patterns=['*.fake'])
    def read_tif(path):
        ...

    @tmp2.contribute.reader(filename_patterns=['.fake2'])
    def read_all(path):
        ...

    npe2_readers, npe1_readers = get_all_readers()
    assert len(npe2_readers) == 2
    assert len(npe1_readers) == 0
示例#3
0
    def __init__(self, parent=None, npe2_readers=None, npe1_readers=None):
        super().__init__(parent=parent)

        npe2, npe1 = get_all_readers()
        if npe2_readers is None:
            npe2_readers = npe2
        if npe1_readers is None:
            npe1_readers = npe1

        self._npe2_readers = npe2_readers
        self._npe1_readers = npe1_readers

        self._table = QTableWidget()
        self._table.setShowGrid(False)
        self._set_up_table()
        self._edit_row = self._make_new_preference_row()
        self._populate_table()

        instructions = QLabel(
            trans.
            _('Enter a filename pattern to associate with a reader e.g. "*.tif" for all TIFF files.'
              ) + trans.
            _('Available readers will be filtered to those compatible with your pattern. Hover over a reader to see what patterns it accepts.'
              ) + trans.
            _('\n\nPreference saving for folder readers is not supported, so these readers are not shown.'
              ) + trans.
            _('\n\nFor documentation on valid filename patterns, see https://docs.python.org/3/library/fnmatch.html'
              ))
        instructions.setWordWrap(True)
        instructions.setOpenExternalLinks(True)

        layout = QVBoxLayout()
        instructions.setSizePolicy(QSizePolicy.MinimumExpanding,
                                   QSizePolicy.Expanding)
        layout.addWidget(instructions)
        layout.addWidget(self._edit_row)
        layout.addWidget(self._table)
        self.setLayout(layout)
示例#4
0
def test_get_all_readers_gives_napari(builtins):
    npe2_readers, npe1_readers = get_all_readers()
    assert len(npe1_readers) == 0
    assert len(npe2_readers) == 1
    assert 'napari' in npe2_readers
示例#5
0
def test_get_all_readers_gives_npe1(mock_npe2_pm):
    """When there's no npe2 files, get_all_readers returns npe1 builtins"""
    npe2_readers, npe1_readers = get_all_readers()
    assert len(npe2_readers) == 0
    assert 'builtins' in npe1_readers
示例#6
0
def test_get_all_readers(mock_npe2_pm, tmp_reader):
    tmp_reader(mock_npe2_pm, 'reader-1')
    tmp_reader(mock_npe2_pm, 'reader-2')
    npe2_readers, npe1_readers = get_all_readers()
    assert len(npe2_readers) == 2
    assert len(npe1_readers) == 1