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

added a hook to add custom functions to SPARQL #723

Merged
merged 4 commits into from
May 29, 2017

Conversation

pchampin
Copy link
Contributor

@pchampin pchampin commented Mar 8, 2017

might be an answer to #274 .

My next plan is to provide an implementation of Virtuoso's bif: functions (sqrt, cos, sin...).

Copy link
Member

@joernhees joernhees left a 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 ?

else:
try:
return func(*e.expr)
except TypeError, ex:
Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Member

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

except TypeError, ex:
raise SPARQLError(*ex.args)
else:
raise SPARQLError('Unknown function %r"%e.iri')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something is weird here

Copy link
Contributor Author

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...

@joernhees joernhees added this to the rdflib 5.0.0 milestone Mar 9, 2017
@joernhees joernhees added enhancement New feature or request SPARQL labels Mar 9, 2017
raise SPARQLError(*ex.args)
if pair is None:
# no such function is registered
raise SPARQLError('Unknown function %r"%e.iri')
Copy link
Member

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what the... :-/ well spotted !

@joernhees
Copy link
Member

nice change, tests now work 👍

@gromgull
Copy link
Member

Sorry somehow I missed this! Looks very good - thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request SPARQL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants