-
Notifications
You must be signed in to change notification settings - Fork 558
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
Autodetect parse() format #1046
Conversation
@tgbugs what do you think? I hope I've resolved your concerns. |
# "expicitly specify one with the format argument." % source) | ||
format = "application/rdf+xml" | ||
try: | ||
format = rdflib.util.guess_format(source.file.name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Under what circumstances are you seeing these errors? I'm guessing when source.file.name is None
for the TypeError and probably ... when not hasattr(source, 'file')
? If that is the case then an explicit test (if statement) for the presence and non-Noneness of the values would be much clearer here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tgbugs I've adopted your suggestion for more of a look-before-you-leap approach with an explicit if-statement guard, ensuring that source.file.name
is an accessible path and is a string before attempting a call to guess_format
.
@nicholascar merged in master, and I hope I addressed the comments from @tgbugs with my last commit. Also, I thought I'd note here that the more recent PR #1064 is an alternative solution to the same underlying issue. |
Addresses #981
rdflib.util.guess_format
to guess and try to apply format based on file extensionClose #981