-
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
added a hook to add custom functions to SPARQL #723
Conversation
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.
apart from the inline comments looks fine to me... @gromgull ?
rdflib/plugins/sparql/operators.py
Outdated
else: | ||
try: | ||
return func(*e.expr) | ||
except TypeError, ex: |
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.
this exception syntax is considered evil and hence was deprecated in py2, doesn't work in py3 anymore...
TypeError as ex
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.
I can fix it, but the same syntax was used in other places, that I didn't change, so I was not sure.
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.
might've been before 5.0.0, but py3 would always err in those cases as 5.0.0 doesn't use 2to3 anymore
rdflib/plugins/sparql/operators.py
Outdated
except TypeError, ex: | ||
raise SPARQLError(*ex.args) | ||
else: | ||
raise SPARQLError('Unknown function %r"%e.iri') |
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.
something is weird 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.
Granted, it is a bit cryptic. I rewrote it, hopefully it is less weird now...
rdflib/plugins/sparql/operators.py
Outdated
raise SPARQLError(*ex.args) | ||
if pair is None: | ||
# no such function is registered | ||
raise SPARQLError('Unknown function %r"%e.iri') |
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.
i think what you actually want is raise SPARQLError('Unknown function %r' % e.iri)
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.
what the... :-/ well spotted !
nice change, tests now work 👍 |
Sorry somehow I missed this! Looks very good - thanks! |
might be an answer to #274 .
My next plan is to provide an implementation of Virtuoso's
bif:
functions (sqrt, cos, sin...).