Typo: composible -> composable

This commit is contained in:
Daniele Varrazzo 2017-01-01 06:32:18 +01:00
parent ad2643266f
commit 828415d476
3 changed files with 17 additions and 17 deletions

View File

@ -30,7 +30,7 @@ import collections
from psycopg2 import extensions as ext
class Composible(object):
class Composable(object):
"""Base class for objects that can be used to compose an SQL string."""
def as_string(self, conn_or_curs):
raise NotImplementedError
@ -38,19 +38,19 @@ class Composible(object):
def __add__(self, other):
if isinstance(other, Composed):
return Composed([self]) + other
if isinstance(other, Composible):
if isinstance(other, Composable):
return Composed([self]) + Composed([other])
else:
return NotImplemented
class Composed(Composible):
class Composed(Composable):
def __init__(self, seq):
self._seq = []
for i in seq:
if not isinstance(i, Composible):
if not isinstance(i, Composable):
raise TypeError(
"Composed elements must be Composible, got %r instead" % i)
"Composed elements must be Composable, got %r instead" % i)
self._seq.append(i)
def __repr__(self):
@ -65,7 +65,7 @@ class Composed(Composible):
def __add__(self, other):
if isinstance(other, Composed):
return Composed(self._seq + other._seq)
if isinstance(other, Composible):
if isinstance(other, Composable):
return Composed(self._seq + [other])
else:
return NotImplemented
@ -92,7 +92,7 @@ class Composed(Composible):
return Composed(rv)
class SQL(Composible):
class SQL(Composable):
def __init__(self, wrapped):
if not isinstance(wrapped, basestring):
raise TypeError("SQL values must be strings")
@ -122,7 +122,7 @@ class SQL(Composible):
return Composed(rv)
class Identifier(Composible):
class Identifier(Composable):
def __init__(self, wrapped):
if not isinstance(wrapped, basestring):
raise TypeError("SQL identifiers must be strings")
@ -140,7 +140,7 @@ class Identifier(Composible):
return ext.quote_ident(self._wrapped, conn_or_curs)
class Literal(Composible):
class Literal(Composable):
def __init__(self, wrapped):
self._wrapped = wrapped
@ -170,7 +170,7 @@ class Literal(Composible):
return Composed([self] * n)
class Placeholder(Composible):
class Placeholder(Composable):
def __init__(self, name=None):
if isinstance(name, basestring):
if ')' in name:

View File

@ -267,7 +267,7 @@ _mogrify(PyObject *var, PyObject *fmt, cursorObject *curs, PyObject **new)
return 0;
}
/* Return 1 if `obj` is a `psycopg2.sql.Composible` instance, else 0
/* Return 1 if `obj` is a `psycopg2.sql.Composable` instance, else 0
* Set an exception and return -1 in case of error.
*/
RAISES_NEG static int
@ -278,7 +278,7 @@ _curs_is_composible(PyObject *obj)
PyObject *comp = NULL;
if (!(m = PyImport_ImportModule("psycopg2.sql"))) { goto exit; }
if (!(comp = PyObject_GetAttrString(m, "Composible"))) { goto exit; }
if (!(comp = PyObject_GetAttrString(m, "Composable"))) { goto exit; }
rv = PyObject_IsInstance(obj, comp);
exit:

View File

@ -117,7 +117,7 @@ class ComposeTests(ConnectingTestCase):
class IdentifierTests(ConnectingTestCase):
def test_class(self):
self.assert_(issubclass(sql.Identifier, sql.Composible))
self.assert_(issubclass(sql.Identifier, sql.Composable))
def test_init(self):
self.assert_(isinstance(sql.Identifier('foo'), sql.Identifier))
@ -140,7 +140,7 @@ class IdentifierTests(ConnectingTestCase):
class LiteralTests(ConnectingTestCase):
def test_class(self):
self.assert_(issubclass(sql.Literal, sql.Composible))
self.assert_(issubclass(sql.Literal, sql.Composable))
def test_init(self):
self.assert_(isinstance(sql.Literal('foo'), sql.Literal))
@ -164,7 +164,7 @@ class LiteralTests(ConnectingTestCase):
class SQLTests(ConnectingTestCase):
def test_class(self):
self.assert_(issubclass(sql.SQL, sql.Composible))
self.assert_(issubclass(sql.SQL, sql.Composable))
def test_init(self):
self.assert_(isinstance(sql.SQL('foo'), sql.SQL))
@ -202,7 +202,7 @@ class SQLTests(ConnectingTestCase):
class ComposedTest(ConnectingTestCase):
def test_class(self):
self.assert_(issubclass(sql.Composed, sql.Composible))
self.assert_(issubclass(sql.Composed, sql.Composable))
def test_repr(self):
obj = sql.Composed([sql.Literal("foo"), sql.Identifier("b'ar")])
@ -236,7 +236,7 @@ class ComposedTest(ConnectingTestCase):
class PlaceholderTest(ConnectingTestCase):
def test_class(self):
self.assert_(issubclass(sql.Placeholder, sql.Composible))
self.assert_(issubclass(sql.Placeholder, sql.Composable))
def test_alias(self):
self.assert_(sql.Placeholder is sql.PH)