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

fix case if the handle function inside get_data is ill defined #461

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

RonHildebrandt
Copy link
Contributor

I had the problem that, I renamed a function and forgot it at another position. This was the case, as the name in:

self.extensions = {".yml": self.handle_eln_file}
was different from the defined in the new created MultiformatReader.

Therefore: "self.extensions.get(extension, lambda _: {})(file_path)" was None and then failed in updateing the template. Not sure if this is needed to catch this case (should be avoidable if you know what you do).

@lukaspie
Copy link
Collaborator

I don't quite understand how "self.extensions.get(extension, lambda _: {})(file_path)" can be None. That can only happen if the the function that is defined for that extension returns None, becaus if the extension is not in self.extensions, the statement above use the lambda function that always returns an empty dict. So when exactly does this happen?

@RonHildebrandt
Copy link
Contributor Author

This issue was related to "I have no Idea what I'm doing exactly" - Yea, I forgot to rename a function in my Multiformat reader, and was wondering about this.
(i.e. I set for a specific file type a specific definiton to handle this file, but I forgot to define it (or in my case, i did not rename both definitions)). NOt sure if you want to catch this case.

Think you can judge this better if it is necessary. Usually, this error should not occur

@lukaspie
Copy link
Collaborator

@RonHildebrandt so you are saying this would occur if you were using e.g.

self.extensions = {
    ".txt": self.handle_txt
}

and then handle_txt is not defined in the reader?

In that case, wouldn't there be an attribute/name error when you invoke the reader? So it wouldn't even run?

I still don't quite understand how self.extensions.get(extension, lambda _: {})(file_path) can ever be None. If the extension is not in self.extensions, this call would return the lambda function lambda _: {}.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants