Skip to content

Commit

Permalink
Rename AlgebraTranslator to _AlgebraTranslator
Browse files Browse the repository at this point in the history
This is mainly to avoid increasing our public interface. People should
be able to use `translateAlgebra` for most of their needs.

Also make slight change to the docstrings.
  • Loading branch information
aucampia committed Mar 26, 2023
1 parent 5c36643 commit 9e06fb8
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions rdflib/plugins/sparql/algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -955,17 +955,22 @@ class ExpressionNotCoveredException(Exception): # noqa: N818
pass


class AlgebraTranslator:
"""Translator of a Query's algebra to its equivalent SPARQL (string).
class _AlgebraTranslator:
"""
Translator of a Query's algebra to its equivalent SPARQL (string).
Coded as a class to support storage of state during the translation process,
without use of a file.
Coded as a class to support storage of state during the translation process, without
use of a file.
Anticipated Usage:
Anticipated Usage: translated_query = AlgebraTranslator(query).translateAlgebra()
.. code-block:: python
An external convenience function which wraps the above call, algebra.translateAlgebra(),
is supplied, so this class does not need to be referenced by client code at all in
normal use.
translated_query = _AlgebraTranslator(query).translateAlgebra()
An external convenience function which wraps the above call,
`translateAlgebra`, is supplied, so this class does not need to be
referenced by client code at all in normal use.
"""

def __init__(self, query_algebra: Query):
Expand Down Expand Up @@ -1655,12 +1660,13 @@ def translateAlgebra(self) -> str:

def translateAlgebra(query_algebra: Query) -> str:
"""
Translates a SPARQL 1.1 algebra tree into the corresponding query string.
:param query_algebra: An algebra returned by the function call algebra.translateQuery(parse_tree).
:return: The query form generated from the SPARQL 1.1 algebra tree for select queries.
:param query_algebra: An algebra returned by `translateQuery`.
:return: The query form generated from the SPARQL 1.1 algebra tree for
SELECT queries.
"""
query_from_algebra = AlgebraTranslator(
query_from_algebra = _AlgebraTranslator(
query_algebra=query_algebra
).translateAlgebra()
return query_from_algebra
Expand Down

0 comments on commit 9e06fb8

Please sign in to comment.