[Python-modules-commits] [asyncpg] 01/03: import asyncpg_0.6.3.orig.tar.gz

Piotr Ożarowski piotr at moszumanska.debian.org
Fri Oct 28 17:06:57 UTC 2016


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

piotr pushed a commit to branch master
in repository asyncpg.

commit 161aca35666bdda7a645ec6894c1fd5940edb44e
Author: Piotr Ożarowski <ozarow at gmail.com>
Date:   Fri Oct 28 10:29:29 2016 +0200

    import asyncpg_0.6.3.orig.tar.gz
---
 LICENSE                               |   189 +
 MANIFEST.in                           |     5 +
 Makefile                              |    45 +
 PKG-INFO                              |    19 +
 README.rst                            |    87 +
 asyncpg.egg-info/PKG-INFO             |    19 +
 asyncpg.egg-info/SOURCES.txt          |    85 +
 asyncpg.egg-info/dependency_links.txt |     1 +
 asyncpg.egg-info/top_level.txt        |     1 +
 asyncpg/__init__.py                   |    14 +
 asyncpg/_testbase.py                  |   153 +
 asyncpg/cluster.py                    |   521 +
 asyncpg/compat.py                     |    20 +
 asyncpg/connection.py                 |   676 +
 asyncpg/cursor.py                     |   254 +
 asyncpg/exceptions/__init__.py        |  1097 +
 asyncpg/exceptions/_base.py           |   109 +
 asyncpg/introspection.py              |   134 +
 asyncpg/pool.py                       |   311 +
 asyncpg/prepared_stmt.py              |   210 +
 asyncpg/protocol/__init__.py          |     8 +
 asyncpg/protocol/buffer.pxd           |   131 +
 asyncpg/protocol/buffer.pyx           |   614 +
 asyncpg/protocol/codecs/__init__.py   |     0
 asyncpg/protocol/codecs/array.pyx     |   366 +
 asyncpg/protocol/codecs/base.pxd      |   152 +
 asyncpg/protocol/codecs/base.pyx      |   529 +
 asyncpg/protocol/codecs/bits.pyx      |    62 +
 asyncpg/protocol/codecs/bytea.pyx     |    48 +
 asyncpg/protocol/codecs/datetime.pyx  |   306 +
 asyncpg/protocol/codecs/float.pyx     |    49 +
 asyncpg/protocol/codecs/geometry.pyx  |   198 +
 asyncpg/protocol/codecs/hstore.pyx    |    80 +
 asyncpg/protocol/codecs/int.pyx       |    79 +
 asyncpg/protocol/codecs/json.pyx      |    42 +
 asyncpg/protocol/codecs/misc.pyx      |   108 +
 asyncpg/protocol/codecs/money.pyx     |    20 +
 asyncpg/protocol/codecs/network.pyx   |   105 +
 asyncpg/protocol/codecs/numeric.pyx   |    28 +
 asyncpg/protocol/codecs/range.pyx     |   149 +
 asyncpg/protocol/codecs/record.pyx    |    56 +
 asyncpg/protocol/codecs/text.pyx      |    67 +
 asyncpg/protocol/codecs/tsearch.pyx   |    26 +
 asyncpg/protocol/codecs/txid.pyx      |    68 +
 asyncpg/protocol/codecs/uuid.pyx      |    31 +
 asyncpg/protocol/consts.pxi           |    12 +
 asyncpg/protocol/coreproto.pxd        |   146 +
 asyncpg/protocol/coreproto.pyx        |   668 +
 asyncpg/protocol/debug.h              |     3 +
 asyncpg/protocol/debug.pxd            |     3 +
 asyncpg/protocol/encodings.pyx        |    63 +
 asyncpg/protocol/hton.pxd             |    84 +
 asyncpg/protocol/pgtypes.pxi          |   182 +
 asyncpg/protocol/prepared_stmt.pxd    |    37 +
 asyncpg/protocol/prepared_stmt.pyx    |   307 +
 asyncpg/protocol/protocol.c           | 64144 ++++++++++++++++++++++++++++++++
 asyncpg/protocol/protocol.pxd         |    62 +
 asyncpg/protocol/protocol.pyx         |   491 +
 asyncpg/protocol/python.pxd           |    22 +
 asyncpg/protocol/record/__init__.pxd  |    16 +
 asyncpg/protocol/record/recordobj.c   |   951 +
 asyncpg/protocol/record/recordobj.h   |    52 +
 asyncpg/protocol/settings.pxd         |    25 +
 asyncpg/protocol/settings.pyx         |    55 +
 asyncpg/transaction.py                |   212 +
 asyncpg/types.py                      |   412 +
 docs/api/index.rst                    |   329 +
 docs/conf.py                          |    92 +
 docs/examples.rst                     |    47 +
 docs/index.rst                        |    29 +
 docs/installation.rst                 |    57 +
 performance.png                       |   Bin 0 -> 18433 bytes
 setup.cfg                             |     5 +
 setup.py                              |   193 +
 tests/test_cancellation.py            |    96 +
 tests/test_codecs.py                  |   862 +
 tests/test_connect.py                 |   371 +
 tests/test_cursor.py                  |   151 +
 tests/test_exceptions.py              |    34 +
 tests/test_execute.py                 |    99 +
 tests/test_listeners.py               |    76 +
 tests/test_pool.py                    |   150 +
 tests/test_prepare.py                 |   397 +
 tests/test_record.py                  |   289 +
 tests/test_test.py                    |    35 +
 tests/test_timeout.py                 |   122 +
 tests/test_transaction.py             |   141 +
 87 files changed, 78794 insertions(+)

diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..418b71e
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,189 @@
+   Copyright (c) 2016-present MagicStack Inc.  http://magic.io
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..e4cfbc3
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,5 @@
+recursive-include docs *.py *.rst
+recursive-include examples *.py
+recursive-include tests *.py *.pem
+recursive-include asyncpg *.pyx *.pxd *.pxi *.py *.c *.h
+include LICENSE README.rst Makefile performance.png
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..8e8d826
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,45 @@
+.PHONY: compile debug test clean all
+
+
+PYTHON ?= python
+
+
+all: compile
+
+
+clean:
+	rm -fr dist/ doc/_build/
+	rm -fr asyncpg/protocol/*.c asyncpg/protocol/*.html
+	rm -fr asyncpg/protocol/*.so build *.egg-info
+	rm -fr asyncpg/protocol/codecs/*.html
+	find . -name '__pycache__' | xargs rm -rf
+
+
+compile:
+	$(PYTHON) setup.py build_ext --inplace --cython-always
+
+
+debug:
+	$(PYTHON) setup.py build_ext --inplace --debug \
+		--cython-always \
+		--cython-annotate \
+		--cython-directives linetrace=True \
+		--define ASYNCPG_DEBUG,CYTHON_TRACE,CYTHON_TRACE_NOGIL
+
+
+test:
+	PYTHONASYNCIODEBUG=1 $(PYTHON) -m unittest discover -s tests
+	$(PYTHON) -m unittest discover -s tests
+	USE_UVLOOP=1 $(PYTHON) -m unittest discover -s tests
+
+
+sdist: clean compile test
+	$(PYTHON) setup.py sdist
+
+
+release: clean compile test
+	$(PYTHON) setup.py sdist upload
+
+
+htmldocs:
+	$(MAKE) -C docs html
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644
index 0000000..e7dcf27
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,19 @@
+Metadata-Version: 1.1
+Name: asyncpg
+Version: 0.6.3
+Summary: An asyncio PosgtreSQL driver
+Home-page: UNKNOWN
+Author: MagicStack Inc
+Author-email: hello at magic.io
+License: Apache License, Version 2.0
+Description: UNKNOWN
+Platform: POSIX
+Classifier: License :: OSI Approved :: Apache Software License
+Classifier: Intended Audience :: Developers
+Classifier: Programming Language :: Python :: 3 :: Only
+Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3.6
+Classifier: Operating System :: POSIX
+Classifier: Operating System :: MacOS :: MacOS X
+Classifier: Development Status :: 4 - Beta
+Provides: asyncpg
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..ce60883
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,87 @@
+asyncpg -- A fast PostgreSQL Database Client Library for Python/asyncio
+=======================================================================
+
+.. image:: https://travis-ci.org/MagicStack/asyncpg.svg?branch=master
+    :target: https://travis-ci.org/MagicStack/asyncpg
+
+.. image:: https://ci.appveyor.com/api/projects/status/9rwppnxphgc8bqoj/branch/master?svg=true
+    :target: https://ci.appveyor.com/project/magicstack/asyncpg
+
+.. image:: https://img.shields.io/pypi/v/asyncpg.svg
+    :target: https://pypi.python.org/pypi/asyncpg
+
+**asyncpg** is a database interface library designed specifically for
+PostgreSQL and Python/asyncio.  asyncpg is an efficient, clean implementation
+of PostgreSQL server binary protocol for use with Python's ``asyncio``
+framework.  You can read more about asyncpg in an introductory blog post
+`here <http://magic.io/blog/asyncpg-1m-rows-from-postgres-to-python/>`_.
+
+
+Documentation
+-------------
+
+The project documentation can be found
+`here <https://magicstack.github.io/asyncpg/current/>`_.
+
+
+Performance
+-----------
+
+In our testing asyncpg is, on average, **3x** faster than psycopg2
+(and its asyncio variant -- aiopg).
+
+.. image:: performance.png
+    :target: http://magic.io/blog/asyncpg-1m-rows-from-postgres-to-python/
+
+The above results are a geometric mean of benchmarks obtained with PostgreSQL
+`client driver benchmarking toolbench <https://github.com/MagicStack/pgbench>`_.
+
+
+Features
+--------
+
+asyncpg implements PostgreSQL server protocol natively and exposes its
+features directly, as opposed to hiding them behind a generic facade
+like DB-API.
+
+This enables asyncpg to have easy-to-use support for:
+
+* **prepared statements**
+* **scrollable cursors**
+* **partial iteration** on query results
+* automatic encoding and decoding of composite types, arrays,
+  and any combination of those
+* straightforward support for custom data types
+
+
+Installation
+------------
+
+asyncpg requires Python 3.5 and is available on PyPI.
+Use pip to install it::
+
+    $ pip install asyncpg
+
+
+Basic Usage
+-----------
+
+.. code-block:: python
+
+    import asyncio
+    import asyncpg
+
+    async def run():
+        conn = await asyncpg.connect(user='user', password='password',
+                                     database='database', host='127.0.0.1')
+        values = await conn.fetch('''SELECT * FROM mytable''')
+        await conn.close()
+
+    loop = asyncio.get_event_loop()
+    loop.run_until_complete(run())
+
+
+License
+-------
+
+asyncpg is developed and distributed under the Apache 2.0 license.
diff --git a/asyncpg.egg-info/PKG-INFO b/asyncpg.egg-info/PKG-INFO
new file mode 100644
index 0000000..e7dcf27
--- /dev/null
+++ b/asyncpg.egg-info/PKG-INFO
@@ -0,0 +1,19 @@
+Metadata-Version: 1.1
+Name: asyncpg
+Version: 0.6.3
+Summary: An asyncio PosgtreSQL driver
+Home-page: UNKNOWN
+Author: MagicStack Inc
+Author-email: hello at magic.io
+License: Apache License, Version 2.0
+Description: UNKNOWN
+Platform: POSIX
+Classifier: License :: OSI Approved :: Apache Software License
+Classifier: Intended Audience :: Developers
+Classifier: Programming Language :: Python :: 3 :: Only
+Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3.6
+Classifier: Operating System :: POSIX
+Classifier: Operating System :: MacOS :: MacOS X
+Classifier: Development Status :: 4 - Beta
+Provides: asyncpg
diff --git a/asyncpg.egg-info/SOURCES.txt b/asyncpg.egg-info/SOURCES.txt
new file mode 100644
index 0000000..fc196ec
--- /dev/null
+++ b/asyncpg.egg-info/SOURCES.txt
@@ -0,0 +1,85 @@
+LICENSE
+MANIFEST.in
+Makefile
+README.rst
+performance.png
+setup.py
+asyncpg/__init__.py
+asyncpg/_testbase.py
+asyncpg/cluster.py
+asyncpg/compat.py
+asyncpg/connection.py
+asyncpg/cursor.py
+asyncpg/introspection.py
+asyncpg/pool.py
+asyncpg/prepared_stmt.py
+asyncpg/transaction.py
+asyncpg/types.py
+asyncpg.egg-info/PKG-INFO
+asyncpg.egg-info/SOURCES.txt
+asyncpg.egg-info/dependency_links.txt
+asyncpg.egg-info/top_level.txt
+asyncpg/exceptions/__init__.py
+asyncpg/exceptions/_base.py
+asyncpg/protocol/__init__.py
+asyncpg/protocol/buffer.pxd
+asyncpg/protocol/buffer.pyx
+asyncpg/protocol/consts.pxi
+asyncpg/protocol/coreproto.pxd
+asyncpg/protocol/coreproto.pyx
+asyncpg/protocol/debug.h
+asyncpg/protocol/debug.pxd
+asyncpg/protocol/encodings.pyx
+asyncpg/protocol/hton.pxd
+asyncpg/protocol/pgtypes.pxi
+asyncpg/protocol/prepared_stmt.pxd
+asyncpg/protocol/prepared_stmt.pyx
+asyncpg/protocol/protocol.c
+asyncpg/protocol/protocol.pxd
+asyncpg/protocol/protocol.pyx
+asyncpg/protocol/python.pxd
+asyncpg/protocol/settings.pxd
+asyncpg/protocol/settings.pyx
+asyncpg/protocol/codecs/__init__.py
+asyncpg/protocol/codecs/array.pyx
+asyncpg/protocol/codecs/base.pxd
+asyncpg/protocol/codecs/base.pyx
+asyncpg/protocol/codecs/bits.pyx
+asyncpg/protocol/codecs/bytea.pyx
+asyncpg/protocol/codecs/datetime.pyx
+asyncpg/protocol/codecs/float.pyx
+asyncpg/protocol/codecs/geometry.pyx
+asyncpg/protocol/codecs/hstore.pyx
+asyncpg/protocol/codecs/int.pyx
+asyncpg/protocol/codecs/json.pyx
+asyncpg/protocol/codecs/misc.pyx
+asyncpg/protocol/codecs/money.pyx
+asyncpg/protocol/codecs/network.pyx
+asyncpg/protocol/codecs/numeric.pyx
+asyncpg/protocol/codecs/range.pyx
+asyncpg/protocol/codecs/record.pyx
+asyncpg/protocol/codecs/text.pyx
+asyncpg/protocol/codecs/tsearch.pyx
+asyncpg/protocol/codecs/txid.pyx
+asyncpg/protocol/codecs/uuid.pyx
+asyncpg/protocol/record/__init__.pxd
+asyncpg/protocol/record/recordobj.c
+asyncpg/protocol/record/recordobj.h
+docs/conf.py
+docs/examples.rst
+docs/index.rst
+docs/installation.rst
+docs/api/index.rst
+tests/test_cancellation.py
+tests/test_codecs.py
+tests/test_connect.py
+tests/test_cursor.py
+tests/test_exceptions.py
+tests/test_execute.py
+tests/test_listeners.py
+tests/test_pool.py
+tests/test_prepare.py
+tests/test_record.py
+tests/test_test.py
+tests/test_timeout.py
+tests/test_transaction.py
\ No newline at end of file
diff --git a/asyncpg.egg-info/dependency_links.txt b/asyncpg.egg-info/dependency_links.txt
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/asyncpg.egg-info/dependency_links.txt
@@ -0,0 +1 @@
+
diff --git a/asyncpg.egg-info/top_level.txt b/asyncpg.egg-info/top_level.txt
new file mode 100644
index 0000000..5789edd
--- /dev/null
+++ b/asyncpg.egg-info/top_level.txt
@@ -0,0 +1 @@
+asyncpg
diff --git a/asyncpg/__init__.py b/asyncpg/__init__.py
new file mode 100644
index 0000000..5488318
--- /dev/null
+++ b/asyncpg/__init__.py
@@ -0,0 +1,14 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+from .connection import connect  # NOQA
+from .exceptions import *  # NOQA
+from .pool import create_pool  # NOQA
+from .types import *  # NOQA
+
+
+__all__ = ('connect', 'create_pool') + exceptions.__all__  # NOQA
diff --git a/asyncpg/_testbase.py b/asyncpg/_testbase.py
new file mode 100644
index 0000000..b45f18b
--- /dev/null
+++ b/asyncpg/_testbase.py
@@ -0,0 +1,153 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+import asyncio
+import atexit
+import contextlib
+import functools
+import inspect
+import logging
+import os
+import time
+import unittest
+
+
+from asyncpg import cluster as pg_cluster
+from asyncpg import pool as pg_pool
+
+
+ at contextlib.contextmanager
+def silence_asyncio_long_exec_warning():
+    def flt(log_record):
+        msg = log_record.getMessage()
+        return not msg.startswith('Executing ')
+
+    logger = logging.getLogger('asyncio')
+    logger.addFilter(flt)
+    try:
+        yield
+    finally:
+        logger.removeFilter(flt)
+
+
+class TestCaseMeta(type(unittest.TestCase)):
+
+    @staticmethod
+    def _iter_methods(bases, ns):
+        for base in bases:
+            for methname in dir(base):
+                if not methname.startswith('test_'):
+                    continue
+
+                meth = getattr(base, methname)
+                if not inspect.iscoroutinefunction(meth):
+                    continue
+
+                yield methname, meth
+
+        for methname, meth in ns.items():
+            if not methname.startswith('test_'):
+                continue
+
+            if not inspect.iscoroutinefunction(meth):
+                continue
+
+            yield methname, meth
+
+    def __new__(mcls, name, bases, ns):
+        for methname, meth in mcls._iter_methods(bases, ns):
+            @functools.wraps(meth)
+            def wrapper(self, *args, __meth__=meth, **kwargs):
+                self.loop.run_until_complete(__meth__(self, *args, **kwargs))
+            ns[methname] = wrapper
+
+        return super().__new__(mcls, name, bases, ns)
+
+
+class TestCase(unittest.TestCase, metaclass=TestCaseMeta):
+
+    def setUp(self):
+        if os.environ.get('USE_UVLOOP'):
+            import uvloop
+            asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
+
+        loop = asyncio.new_event_loop()
+        asyncio.set_event_loop(None)
+        self.loop = loop
+
+    def tearDown(self):
+        self.loop.close()
+        asyncio.set_event_loop(None)
+
+    @contextlib.contextmanager
+    def assertRunUnder(self, delta):
+        st = time.monotonic()
+        try:
+            yield
+        finally:
+            if time.monotonic() - st > delta:
+                raise AssertionError(
+                    'running block took longer than {}'.format(delta))
+
+
+_default_cluster = None
+
+
+def _start_cluster(server_settings={}):
+    global _default_cluster
+
+    if _default_cluster is None:
+        pg_host = os.environ.get('PGHOST')
+        if pg_host:
+            # Using existing cluster, assuming it is initialized and running
+            _default_cluster = pg_cluster.RunningCluster()
+        else:
+            _default_cluster = pg_cluster.TempCluster()
+            _default_cluster.init()
+            _default_cluster.trust_local_connections()
+            _default_cluster.start(port='dynamic',
+                                   server_settings=server_settings)
+            atexit.register(_shutdown_cluster, _default_cluster)
+
+    return _default_cluster
+
+
+def _shutdown_cluster(cluster):
+    cluster.stop()
+    cluster.destroy()
+
+
+class ClusterTestCase(TestCase):
+    def setUp(self):
+        super().setUp()
+        self.cluster = _start_cluster({
+            'log_connections': 'on'
+        })
+
+    def create_pool(self, **kwargs):
+        conn_spec = self.cluster.get_connection_spec()
+        conn_spec.update(kwargs)
+        return pg_pool.create_pool(loop=self.loop, **conn_spec)
+
+
+class ConnectedTestCase(ClusterTestCase):
+
+    def getExtraConnectOptions(self):
+        return {}
+
+    def setUp(self):
+        super().setUp()
+        opts = self.getExtraConnectOptions()
+        self.con = self.loop.run_until_complete(
+            self.cluster.connect(database='postgres', loop=self.loop, **opts))
+
+    def tearDown(self):
+        try:
+            self.loop.run_until_complete(self.con.close())
+            self.con = None
+        finally:
+            super().tearDown()
diff --git a/asyncpg/cluster.py b/asyncpg/cluster.py
new file mode 100644
index 0000000..93ac64e
--- /dev/null
+++ b/asyncpg/cluster.py
@@ -0,0 +1,521 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+import asyncio
+import errno
+import os
+import os.path
+import platform
+import random
+import re
+import shutil
+import socket
+import subprocess
+import tempfile
+import time
+
+import asyncpg
+
+
+_system = platform.uname().system
+
+if _system == 'Windows':
+    def platform_exe(name):
+        if name.endswith('.exe'):
+            return name
+        return name + '.exe'
+else:
+    def platform_exe(name):
+        return name
+
+
+if _system == 'Linux':
+    def ensure_dead_with_parent():
+        import ctypes
+        import signal
+
+        try:
+            PR_SET_PDEATHSIG = 1
+            libc = ctypes.CDLL(ctypes.util.find_library('c'))
+            libc.prctl(PR_SET_PDEATHSIG, signal.SIGKILL)
+        except Exception as e:
+            print(e)
+else:
+    ensure_dead_with_parent = None
+
+
+def find_available_port(port_range=(49152, 65535), max_tries=1000):
+    low, high = port_range
+
+    port = low
+    try_no = 0
+
+    while try_no < max_tries:
+        try_no += 1
+        port = random.randint(low, high)
+        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+        try:
+            sock.bind(('127.0.0.1', port))
+        except socket.error as e:
+            if e.errno == errno.EADDRINUSE:
+                continue
+        finally:
+            sock.close()
+
+        break
+    else:
+        port = None
+
+    return port
+
+
+class ClusterError(Exception):
+    pass
+
+
+class Cluster:
+    def __init__(self, data_dir, *, pg_config_path=None):
+        self._data_dir = data_dir
+        self._pg_config_path = pg_config_path
+        self._pg_config = None
+        self._pg_config_data = None
+        self._pg_ctl = None
+        self._daemon_pid = None
+        self._daemon_process = None
+        self._connection_addr = None
+        self._connection_spec_override = None
+
+    def is_managed(self):
+        return True
+
+    def get_data_dir(self):
+        return self._data_dir
+
+    def get_status(self):
+        if self._pg_ctl is None:
+            self._init_env()
+
+        process = subprocess.run(
+            [self._pg_ctl, 'status', '-D', self._data_dir],
+            stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+        stdout, stderr = process.stdout, process.stderr
+
+        if process.returncode == 4 or not os.listdir(self._data_dir):
+            return 'not-initialized'
+        elif process.returncode == 3:
+            return 'stopped'
+        elif process.returncode == 0:
+            r = re.match(r'.*PID:\s+(\d+).*', stdout.decode())
+            if not r:
+                raise ClusterError(
+                    'could not parse pg_ctl status output: {}'.format(
+                        stdout.decode()))
+            self._daemon_pid = int(r.group(1))
+            return self._test_connection(timeout=0)
+        else:
+            raise ClusterError(
+                'pg_ctl status exited with status {:d}: {}'.format(
+                    process.returncode, stderr))
+
+    async def connect(self, loop=None, **kwargs):
+        conn_info = self.get_connection_spec()
+        conn_info.update(kwargs)
+        return await asyncpg.connect(loop=loop, **conn_info)
+
+    def init(self, **settings):
+        """Initialize cluster."""
+        if self.get_status() != 'not-initialized':
+            raise ClusterError(
+                'cluster in {!r} has already been initialized'.format(
+                    self._data_dir))
+
+        if settings:
+            extra_args = ['-o'] + ['--{}={}'.format(k, v)
+                                   for k, v in settings.items()]
+        else:
+            extra_args = []
+
+        process = subprocess.run(
+            [self._pg_ctl, 'init', '-D', self._data_dir] + extra_args,
+            stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+
+        output = process.stdout
+
+        if process.returncode != 0:
+            raise ClusterError(
+                'pg_ctl init exited with status {:d}:\n{}'.format(
+                    process.returncode, output.decode()))
+
+        return output.decode()
+
+    def start(self, wait=60, *, server_settings={}, **opts):
+        """Start the cluster."""
+        status = self.get_status()
+        if status == 'running':
+            return
+        elif status == 'not-initialized':
+            raise ClusterError(
+                'cluster in {!r} has not been initialized'.format(
+                    self._data_dir))
+
+        port = opts.pop('port', None)
+        if port == 'dynamic':
+            port = find_available_port()
+
+        extra_args = ['--{}={}'.format(k, v) for k, v in opts.items()]
+        extra_args.append('--port={}'.format(port))
+
+        if 'unix_socket_directories' not in server_settings:
+            server_settings['unix_socket_directories'] = '/tmp'
+
+        for k, v in server_settings.items():
+            extra_args.extend(['-c', '{}={}'.format(k, v)])
+
+        if _system == 'Windows':
+            # On Windows we have to use pg_ctl as direct execution
+            # of postgres daemon under an Administrative account
+            # is not permitted and there is no easy way to drop
+            # privileges.
+            process = subprocess.run(
+                [self._pg_ctl, 'start', '-D', self._data_dir,
+                 '-o', ' '.join(extra_args)],
+                stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
+            stderr = process.stderr
+
+            if process.returncode != 0:
+                raise ClusterError(
+                    'pg_ctl start exited with status {:d}: {}'.format(
+                        process.returncode, stderr.decode()))
+        else:
+            self._daemon_process = \
+                subprocess.Popen(
+                    [self._postgres, '-D', self._data_dir, *extra_args],
+                    stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
+                    preexec_fn=ensure_dead_with_parent)
+
+            self._daemon_pid = self._daemon_process.pid
+
+        self._test_connection(timeout=wait)
+
+    def reload(self):
+        """Reload server configuration."""
+        status = self.get_status()
+        if status != 'running':
+            raise ClusterError('cannot reload: cluster is not running')
+
+        process = subprocess.run(
+            [self._pg_ctl, 'reload', '-D', self._data_dir],
+            stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+
+        stderr = process.stderr
... 78407 lines suppressed ...

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



More information about the Python-modules-commits mailing list