[Python-modules-commits] [python-pgspecial] 01/03: Import python-pgspecial_1.5.0.orig.tar.gz

ChangZhuo Chen czchen at moszumanska.debian.org
Sat Jul 2 03:03:06 UTC 2016


This is an automated email from the git hooks/post-receive script.

czchen pushed a commit to branch master
in repository python-pgspecial.

commit d641d05667f06b0d76f9d23138179c45a933f608
Author: ChangZhuo Chen (陳昌倬) <czchen at debian.org>
Date:   Sat Jul 2 10:58:31 2016 +0800

    Import python-pgspecial_1.5.0.orig.tar.gz
---
 PKG-INFO                                           |   2 +-
 pgspecial.egg-info/PKG-INFO                        |   2 +-
 pgspecial.egg-info/SOURCES.txt                     |   4 +--
 pgspecial.egg-info/pbr.json                        |   1 -
 pgspecial/__init__.py                              |   2 +-
 pgspecial/dbcommands.py                            |  30 +++++++++++++++++++++
 tests/.cache/v/cache/lastfailed                    |   4 +--
 .../test_specials.cpython-27-PYTEST.pyc            | Bin 16944 -> 19685 bytes
 tests/__pycache__/test_tm.cpython-27-PYTEST.pyc    | Bin 2301 -> 0 bytes
 tests/conftest.pyc                                 | Bin 1573 -> 1488 bytes
 tests/dbutils.pyc                                  | Bin 2591 -> 2506 bytes
 tests/test_specials.py                             |  19 +++++++++++++
 12 files changed, 54 insertions(+), 10 deletions(-)

diff --git a/PKG-INFO b/PKG-INFO
index 2f14cab..859d210 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: pgspecial
-Version: 1.4.0
+Version: 1.5.0
 Summary: Meta-commands handler for Postgres Database.
 Home-page: http://pgcli.com
 Author: Amjith Ramanujam
diff --git a/pgspecial.egg-info/PKG-INFO b/pgspecial.egg-info/PKG-INFO
index 2f14cab..859d210 100644
--- a/pgspecial.egg-info/PKG-INFO
+++ b/pgspecial.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: pgspecial
-Version: 1.4.0
+Version: 1.5.0
 Summary: Meta-commands handler for Postgres Database.
 Home-page: http://pgcli.com
 Author: Amjith Ramanujam
diff --git a/pgspecial.egg-info/SOURCES.txt b/pgspecial.egg-info/SOURCES.txt
index b9bccc0..df6e337 100644
--- a/pgspecial.egg-info/SOURCES.txt
+++ b/pgspecial.egg-info/SOURCES.txt
@@ -9,7 +9,6 @@ pgspecial/namedqueries.py
 pgspecial.egg-info/PKG-INFO
 pgspecial.egg-info/SOURCES.txt
 pgspecial.egg-info/dependency_links.txt
-pgspecial.egg-info/pbr.json
 pgspecial.egg-info/requires.txt
 pgspecial.egg-info/top_level.txt
 pgspecial/help/__init__.py
@@ -21,5 +20,4 @@ tests/dbutils.pyc
 tests/pytest.ini
 tests/test_specials.py
 tests/.cache/v/cache/lastfailed
-tests/__pycache__/test_specials.cpython-27-PYTEST.pyc
-tests/__pycache__/test_tm.cpython-27-PYTEST.pyc
\ No newline at end of file
+tests/__pycache__/test_specials.cpython-27-PYTEST.pyc
\ No newline at end of file
diff --git a/pgspecial.egg-info/pbr.json b/pgspecial.egg-info/pbr.json
deleted file mode 100644
index 56bde1b..0000000
--- a/pgspecial.egg-info/pbr.json
+++ /dev/null
@@ -1 +0,0 @@
-{"is_release": false, "git_version": "77fb297"}
\ No newline at end of file
diff --git a/pgspecial/__init__.py b/pgspecial/__init__.py
index ba8ff4b..0ad4548 100644
--- a/pgspecial/__init__.py
+++ b/pgspecial/__init__.py
@@ -1,5 +1,5 @@
 __all__ = []
-__version__ = '1.4.0'
+__version__ = '1.5.0'
 
 
 def export(defn):
diff --git a/pgspecial/dbcommands.py b/pgspecial/dbcommands.py
index 0390b3c..2f54ac3 100644
--- a/pgspecial/dbcommands.py
+++ b/pgspecial/dbcommands.py
@@ -74,6 +74,36 @@ def list_roles(cur, pattern, verbose):
         return [(None, cur, headers, cur.statusmessage)]
 
 
+ at special_command('\\db', '\\db[+] [pattern]', 'List tablespaces.')
+def list_tablestpaces(cur, pattern, **_):
+    """
+    Returns (title, rows, headers, status)
+    """
+
+    cur.execute("SELECT EXISTS(SELECT * FROM pg_proc WHERE proname = 'pg_tablespace_location')")
+    (is_location,) = cur.fetchone()
+
+    sql = '''SELECT n.spcname AS "Name",
+    pg_catalog.pg_get_userbyid(n.spcowner) AS "Owner",'''
+
+    sql += " pg_catalog.pg_tablespace_location(n.oid)" if is_location else " 'Not supported'"
+    sql += ''' AS "Location"
+    FROM pg_catalog.pg_tablespace n'''
+
+    params = []
+    if pattern:
+        _, tbsp = sql_name_pattern(pattern)
+        sql += " WHERE n.spcname ~ %s"
+        params.append(tbsp)
+
+    sql = cur.mogrify(sql + " ORDER BY 1", params)
+    log.debug(sql)
+    cur.execute(sql)
+
+    headers = [x[0] for x in cur.description] if cur.description else None
+    return [(None, cur, headers, cur.statusmessage)]
+
+
 @special_command('\\dn', '\\dn[+] [pattern]', 'List schemas.')
 def list_schemas(cur, pattern, verbose):
     """
diff --git a/tests/.cache/v/cache/lastfailed b/tests/.cache/v/cache/lastfailed
index 0ba23c8..9e26dfe 100644
--- a/tests/.cache/v/cache/lastfailed
+++ b/tests/.cache/v/cache/lastfailed
@@ -1,3 +1 @@
-{
-  "test_specials.py::test_create_file": true
-}
\ No newline at end of file
+{}
\ No newline at end of file
diff --git a/tests/__pycache__/test_specials.cpython-27-PYTEST.pyc b/tests/__pycache__/test_specials.cpython-27-PYTEST.pyc
index 7b70013..c82d663 100644
Binary files a/tests/__pycache__/test_specials.cpython-27-PYTEST.pyc and b/tests/__pycache__/test_specials.cpython-27-PYTEST.pyc differ
diff --git a/tests/__pycache__/test_tm.cpython-27-PYTEST.pyc b/tests/__pycache__/test_tm.cpython-27-PYTEST.pyc
deleted file mode 100644
index 59882be..0000000
Binary files a/tests/__pycache__/test_tm.cpython-27-PYTEST.pyc and /dev/null differ
diff --git a/tests/conftest.pyc b/tests/conftest.pyc
index 6dfaf25..31ea58c 100644
Binary files a/tests/conftest.pyc and b/tests/conftest.pyc differ
diff --git a/tests/dbutils.pyc b/tests/dbutils.pyc
index 320ad9b..d4c3bd2 100644
Binary files a/tests/dbutils.pyc and b/tests/dbutils.pyc differ
diff --git a/tests/test_specials.py b/tests/test_specials.py
index 0f5451c..aab0f54 100644
--- a/tests/test_specials.py
+++ b/tests/test_specials.py
@@ -72,6 +72,25 @@ def test_slash_dT(executor):
 
 
 @dbtest
+def test_slash_db(executor):
+    """List all tablespaces."""
+    title, rows, header, status = executor('\db')
+    assert title is None
+    assert header == ['Name', 'Owner', 'Location']
+    assert 'pg_default' in rows[0]
+
+
+ at dbtest
+def test_slash_db_name(executor):
+    """List tablespace by name."""
+    title, rows, header, status = executor('\db pg_default')
+    assert title is None
+    assert header == ['Name', 'Owner', 'Location']
+    assert 'pg_default' in rows[0]
+    assert status == 'SELECT 1'
+
+
+ at dbtest
 def test_slash_df(executor):
     results = executor('\df')
     title = None

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-pgspecial.git



More information about the Python-modules-commits mailing list