Skip to content

Commit

Permalink
Rename the package from "pg_query" to "pglast"
Browse files Browse the repository at this point in the history
This is to accommodate the gentle request made by libpg_query author (see issue #9).

Sorry for any inconvenience this may cause.
  • Loading branch information
lelit committed Jun 16, 2018
1 parent d107c1f commit 804fcdc
Show file tree
Hide file tree
Showing 60 changed files with 521 additions and 519 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# :Project: pg_query -- Travis CI configuration
# :Project: pglast -- Travis CI configuration
# :Created: lun 07 ago 2017 00:44:48 CEST
# :Author: Lele Gaifax <lele@metapensiero.it>
# :License: GNU General Public License version 3 or later
Expand Down
8 changes: 4 additions & 4 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ __ https://github.com/lfittl/libpg_query/issues/45

- Fix issue in the safety belt check performed by ``pgpp`` (`issue #4`__)

__ https://github.com/lelit/pg_query/issues/4
__ https://github.com/lelit/pglast/issues/4


0.24 (2018-03-02)
Expand Down Expand Up @@ -62,7 +62,7 @@ __ https://github.com/lelit/pg_query/issues/4
- New alternative printers for a set of *special functions*, activated by a new
``--special-functions`` option on ``pgpp`` (`issue #2`__)

__ https://github.com/lelit/pg_query/issues/2
__ https://github.com/lelit/pglast/issues/2


0.20 (2017-11-21)
Expand Down Expand Up @@ -116,7 +116,7 @@ __ https://github.com/lelit/pg_query/issues/2

- Fix indentation of boolean expressions in SELECT's targets (`issue #3`__)

__ https://github.com/lelit/pg_query/issues/3
__ https://github.com/lelit/pglast/issues/3


0.14 (2017-10-09)
Expand Down Expand Up @@ -175,7 +175,7 @@ __ https://github.com/lelit/pg_query/issues/3
- New ``compact_lists_margin`` option to produce a more compact representation when possible
(see `issue #1`__)

__ https://github.com/lelit/pg_query/issues/1
__ https://github.com/lelit/pglast/issues/1


0.7 (2017-08-10)
Expand Down
4 changes: 2 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ include docs/*.rst
include docs/*.py
include tests/*.py
include tools/*.py
recursive-include pg_query *.py *.pyx
recursive-include pglast *.py *.pyx
exclude libpg_query/*
include libpg_query/LICENSE libpg_query/Makefile libpg_query/pg_query.h
include libpglast/LICENSE libpg_query/Makefile libpg_query/pg_query.h
recursive-include libpg_query/src *.c *.h
prune libpg_query/examples
prune libpg_query/patches
Expand Down
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# :Project: pg_query -- Development Makefile
# :Project: pglast -- Development Makefile
# :Created: gio 03 ago 2017 14:52:45 CEST
# :Author: Lele Gaifax <lele@metapensiero.it>
# :License: GNU General Public License version 3 or later
Expand All @@ -25,21 +25,21 @@ help::
@printf "build\n\tbuild the module\n"

.PHONY: build
build: virtualenv enums keywords libpg_query/libpg_query.a pg_query/parser.c
build: virtualenv enums keywords libpg_query/libpg_query.a pglast/parser.c
$(PYTHON) setup.py build_ext --inplace

libpg_query/libpg_query.a: libpg_query/LICENSE
$(MAKE) -C libpg_query build

pg_query/parser.c: pg_query/parser.pyx
pglast/parser.c: pglast/parser.pyx
$(PYTHON) setup.py build_ext --inplace

help::
@printf "recythonize\n\tforce retranslation of the pyx module\n"

.PHONY: recythonize
recythonize:
touch pg_query/parser.pyx
touch pglast/parser.pyx
$(MAKE) build

help::
Expand All @@ -49,7 +49,7 @@ help::
clean:
$(MAKE) -C docs SPHINXBUILD=$(SPHINXBUILD) clean
$(MAKE) -C libpg_query clean
rm -f pg_query/*.so
rm -f pglast/*.so

help::
@printf "distclean\n\tremove anything superfluous\n"
Expand All @@ -62,7 +62,7 @@ distclean:: clean
help::
@printf "enums\n\textract Python enums from PG sources\n"

PY_ENUMS_DIR := pg_query/enums
PY_ENUMS_DIR := pglast/enums
PY_ENUMS := $(PY_ENUMS_DIR)/lockoptions.py $(PY_ENUMS_DIR)/nodes.py \
$(PY_ENUMS_DIR)/parsenodes.py $(PY_ENUMS_DIR)/primnodes.py \
$(PY_ENUMS_DIR)/pg_class.py
Expand All @@ -80,7 +80,7 @@ $(PY_ENUMS_DIR)/pg_class.py: $(PG_INCLUDE_DIR)/catalog/pg_class.h
help::
@printf "keywords\n\textract Python keyword sets from PG sources\n"

PY_KEYWORDS_DIR := pg_query
PY_KEYWORDS_DIR := pglast
PY_KEYWORDS := $(PY_KEYWORDS_DIR)/keywords.py

.PHONY: keywords
Expand All @@ -100,7 +100,7 @@ PG_NODES := $(PG_INCLUDE_DIR)/nodes/nodes.h $(PG_INCLUDE_DIR)/nodes/parsenodes.h
printers-doc: docs/ddl.rst docs/dml.rst

docs/ddl.rst docs/dml.rst: $(PG_NODES) tools/extract_printers_doc.py
docs/%.rst: pg_query/printers/%.py
docs/%.rst: pglast/printers/%.py
$(PYTHON) tools/extract_printers_doc.py $< $@ $(PG_NODES)

help::
Expand Down
4 changes: 2 additions & 2 deletions Makefile.release
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- mode: makefile-gmake; coding: utf-8 -*-
# :Project: pg_query -- Release targets
# :Project: pglast -- Release targets
# :Created: gio 03 ago 2017 14:53:18 CEST
# :Author: Lele Gaifax <lele@metapensiero.it>
# :License: GNU General Public License version 3 or later
# :Copyright: © 2017 Lele Gaifax
# :Copyright: © 2017, 2018 Lele Gaifax
#

BUMPER := $(VENVDIR)/bin/bump_version
Expand Down
4 changes: 2 additions & 2 deletions Makefile.virtualenv
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
# :Project: pg_query -- Virtualenv targets
# :Project: pglast -- Virtualenv targets
# :Created: gio 03 ago 2017 16:55:55 CEST
# :Author: Lele Gaifax <lele@metapensiero.it>
# :License: GNU General Public License version 3 or later
# :Copyright: © 2017 Lele Gaifax
# :Copyright: © 2017, 2018 Lele Gaifax
#

ACTIVATE_SCRIPT := $(VENVDIR)/bin/activate
Expand Down
41 changes: 21 additions & 20 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
.. -*- coding: utf-8 -*-
.. :Project: pg_query -- Pythonic wrapper around libpg_query
.. :Project: pglast -- PostgreSQL Languages AST
.. :Created: mer 02 ago 2017 14:49:24 CEST
.. :Author: Lele Gaifax <lele@metapensiero.it>
.. :License: GNU General Public License version 3 or later
.. :Copyright: © 2017, 2018 Lele Gaifax
..
==========
pg_query
==========
========
pglast
========

Pythonic wrapper around libpg_query and PostgreSQL prettifier
=============================================================
PostgreSQL Languages AST and statements prettifier
==================================================

:Author: Lele Gaifax
:Contact: lele@metapensiero.it
:License: `GNU General Public License version 3 or later`__
:Status: |build| |doc|

__ https://www.gnu.org/licenses/gpl.html
.. |build| image:: https://travis-ci.org/lelit/pg_query.svg?branch=master
:target: https://travis-ci.org/lelit/pg_query
.. |build| image:: https://travis-ci.org/lelit/pglast.svg?branch=master
:target: https://travis-ci.org/lelit/pglast
:alt: Build status
.. |doc| image:: https://readthedocs.org/projects/pg-query/badge/?version=latest
:target: https://readthedocs.org/projects/pg-query/builds/
.. |doc| image:: https://readthedocs.org/projects/pglast/badge/?version=latest
:target: https://readthedocs.org/projects/pglast/builds/
:alt: Documentation status

This is a Python 3 implementation of a wrapper to `libpg_query`__, a C library that repackages
the PostgreSQL__ language parser as a standalone static library.
This is a Python 3 module that exposes the *parse tree* of a PostgreSQL__ statement (extracted
by the almost standard PG parser repackaged as a standalone static library by `libpg_query`__)
as set of interconnected *nodes*, usually called an *abstract syntax tree*.

__ https://github.com/lfittl/libpg_query
__ https://www.postgresql.org/
__ https://github.com/lfittl/libpg_query

I needed a better SQL reformatter than the one implemented by `sqlparse`__, and was annoyed by
a few glitches (subselects__ in particular) that ruins the otherwise excellent job it does,
Expand Down Expand Up @@ -92,7 +93,7 @@ At the lower level the module exposes two libpg_query functions, ``parse_sql()``
``parse_plpgsql()``, that take respectively an ``SQL`` statement and a ``PLpgSQL`` statement
and return a *parse tree* as a hierarchy of Python dictionaries, lists and scalar values. In
some cases these scalars correspond to some C ``typedef enums``, that are automatically
extracted from the PostgreSQL headers mentioned above and are available as ``pg_query.enums``.
extracted from the PostgreSQL headers mentioned above and are available as ``pglast.enums``.

At a higher level that tree is represented by three Python classes, a ``Node`` that represents
a single node, a ``List`` that wraps a sequence of nodes and a ``Scalar`` for plain values such
Expand Down Expand Up @@ -120,15 +121,15 @@ Installation

As usual, the easiest way is with pip::

$ pip install pg_query
$ pip install pglast

Alternatively you can clone the repository::

$ git clone https://github.com/lelit/pg_query.git --recursive
$ git clone https://github.com/lelit/pglast.git --recursive

and install from there::

$ pip install ./pg_query
$ pip install ./pglast

Development
-----------
Expand All @@ -144,7 +145,7 @@ Examples of usage

* Parse an ``SQL`` statement and get its *AST* root node::

>>> from pg_query import Node, parse_sql
>>> from pglast import Node, parse_sql
>>> root = Node(parse_sql('SELECT foo FROM bar'))
>>> print(root)
None=[1*{RawStmt}]
Expand Down Expand Up @@ -232,15 +233,15 @@ Examples of usage

* Programmatically reformat a SQL statement::

>>> from pg_query import prettify
>>> from pglast import prettify
>>> print(prettify('delete from sometable where value is null'))
DELETE FROM sometable
WHERE value IS NULL

Documentation
-------------

Latest documentation is hosted by `Read the Docs`__ at http://pg-query.readthedocs.io/en/latest/
Latest documentation is hosted by `Read the Docs`__ at http://pglast.readthedocs.io/en/latest/

__ https://readthedocs.org/

Expand Down
4 changes: 2 additions & 2 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = python -msphinx
SPHINXPROJ = pg_query
SPHINXPROJ = pglast
SOURCEDIR = .
BUILDDIR = _build

Expand All @@ -17,4 +17,4 @@ help:
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
6 changes: 3 additions & 3 deletions docs/api.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.. -*- coding: utf-8 -*-
.. :Project: pg_query -- API documentation
.. :Project: pglast -- API documentation
.. :Created: gio 10 ago 2017 10:14:17 CEST
.. :Author: Lele Gaifax <lele@metapensiero.it>
.. :License: GNU General Public License version 3 or later
.. :Copyright: © 2017 Lele Gaifax
.. :Copyright: © 2017, 2018 Lele Gaifax
..
===================
Expand All @@ -12,7 +12,7 @@

This chapter briefly explains some implementation detail.

.. automodule:: pg_query
.. automodule:: pglast
:members: Error, prettify

.. toctree::
Expand Down
16 changes: 8 additions & 8 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# pg_query documentation build configuration file, created by
# pglast documentation build configuration file, created by
# sphinx-quickstart on Thu Aug 10 09:55:41 2017.
#
# This file is execfile()d with the current directory set to its
Expand Down Expand Up @@ -47,8 +47,8 @@
master_doc = 'index'

# General information about the project.
project = 'pg_query'
copyright = '2017, Lele Gaifax'
project = 'pglast'
copyright = '2017, 2018 Lele Gaifax'
author = 'Lele Gaifax'

# The version info for the project you're documenting, acts as replacement for
Expand Down Expand Up @@ -116,7 +116,7 @@
# -- Options for HTMLHelp output ------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'pg_querydoc'
htmlhelp_basename = 'pglastdoc'


# -- Options for LaTeX output ---------------------------------------------
Expand All @@ -143,7 +143,7 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'pg_query.tex', 'pg\\_query Documentation',
(master_doc, 'pglast.tex', 'pg\\_query Documentation',
'Lele Gaifax', 'manual'),
]

Expand All @@ -153,7 +153,7 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'pg_query', 'pg_query Documentation',
(master_doc, 'pglast', 'pglast Documentation',
[author], 1)
]

Expand All @@ -164,8 +164,8 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'pg_query', 'pg_query Documentation',
author, 'pg_query', 'One line description of project.',
(master_doc, 'pglast', 'pglast Documentation',
author, 'pglast', 'One line description of project.',
'Miscellaneous'),
]

Expand Down
6 changes: 3 additions & 3 deletions docs/ddl.rst
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
.. -*- coding: utf-8 -*-
.. :Project: pg_query -- DO NOT EDIT: generated automatically
.. :Project: pglast -- DO NOT EDIT: generated automatically
.. :Author: Lele Gaifax <lele@metapensiero.it>
.. :License: GNU General Public License version 3 or later
.. :Copyright: © 2017, 2018 Lele Gaifax
..
========================================================
:mod:`pg_query.printers.ddl` --- DDL printer functions
:mod:`pglast.printers.ddl` --- DDL printer functions
========================================================

.. module:: pg_query.printers.ddl
.. module:: pglast.printers.ddl
:synopsis: DDL printer functions

.. index:: ColumnDef
Expand Down
4 changes: 2 additions & 2 deletions docs/development.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.. -*- coding: utf-8 -*-
.. :Project: pg_query -- Development
.. :Project: pglast -- Development
.. :Created: gio 10 ago 2017 10:04:43 CEST
.. :Author: Lele Gaifax <lele@metapensiero.it>
.. :License: GNU General Public License version 3 or later
.. :Copyright: © 2017 Lele Gaifax
.. :Copyright: © 2017, 2018 Lele Gaifax
..
=============
Expand Down
6 changes: 3 additions & 3 deletions docs/dml.rst
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
.. -*- coding: utf-8 -*-
.. :Project: pg_query -- DO NOT EDIT: generated automatically
.. :Project: pglast -- DO NOT EDIT: generated automatically
.. :Author: Lele Gaifax <lele@metapensiero.it>
.. :License: GNU General Public License version 3 or later
.. :Copyright: © 2017, 2018 Lele Gaifax
..
========================================================
:mod:`pg_query.printers.dml` --- DML printer functions
:mod:`pglast.printers.dml` --- DML printer functions
========================================================

.. module:: pg_query.printers.dml
.. module:: pglast.printers.dml
:synopsis: DML printer functions

.. index:: A_ArrayExpr
Expand Down
Loading

0 comments on commit 804fcdc

Please sign in to comment.