Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reader function is unable to process the url #26

Open
sviaro opened this issue Jul 4, 2023 · 1 comment
Open

Reader function is unable to process the url #26

sviaro opened this issue Jul 4, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@sviaro
Copy link
Collaborator

sviaro commented Jul 4, 2023

Calling the plug-in reader function on url results in error message instead of a file download:

File ~/Documents/GitHub/napari-flim-phasor-plotter/src/napari_flim_phasor_plotter/_reader.py:25, in napari_get_reader(path='https://zenodo.org/record/7656540/files/2a_FLIM_single_image.ptu')
     12 """A basic implementation of a Reader contribution.
     13 
     14 Parameters
   (...)
     23     same path or list of paths, and returns a list of layer data tuples.
     24 """
---> 25 file_extension = get_most_frequent_file_extension(path)
        path = 'https://zenodo.org/record/7656540/files/2a_FLIM_single_image.ptu'
     26 # If we recognize the format, we return the actual reader function

File ~/Documents/GitHub/napari-flim-phasor-plotter/src/napari_flim_phasor_plotter/_reader.py:126, in get_most_frequent_file_extension(path=PosixPath('https:/zenodo.org/record/7656540/files/2a_FLIM_single_image.ptu'))
    125 # Get most frequent file entension in path
--> 126 most_frequent_file_type = max(set(suffixes), key=suffixes.count)
    127 return most_frequent_file_type

UnboundLocalError: local variable 'suffixes' referenced before assignment
@sviaro sviaro added the bug Something isn't working label Jul 4, 2023
@zoccoler
Copy link
Owner

zoccoler commented Jul 6, 2023

Thanks for reporting! We need to add a condition that handles urls, nice catch!
Maybe using urlparse, from which we could get a path and then the file extension if it is a single file. It it is a .zip, then it is probably a folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants