Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
import typing as t

from snsql._ast.ast import Query, Sql

from ..ast_walker import ASTWalker


class BaseTranslator(ASTWalker):
    """Base class for translators. Used to avoid code duplication."""

    def __init__(self, query: Query, **kwargs: t.Any) -> None:
        super().__init__(query, **kwargs)

    def transform_to_postgres(self, expr: Sql) -> Sql:
        raise NotImplementedError()

    def transform_to_dialect(self, expr: Sql) -> Sql:
        raise NotImplementedError()

    def to_postgres(self) -> None:
        self.transform = self.transform_to_postgres  # type: ignore
        self.run()

    def to_dialect(self) -> None:
        self.transform = self.transform_to_dialect  # type: ignore
        self.run()