index
int64
0
731k
package
stringlengths
2
98
name
stringlengths
1
76
docstring
stringlengths
0
281k
code
stringlengths
4
1.07M
signature
stringlengths
2
42.8k
27,120
sqlobject.sqlbuilder
__floordiv__
null
def __floordiv__(self, other): return SQLConstant("FLOOR")(SQLOp("/", self, other))
(self, other)
27,121
sqlobject.sqlbuilder
__ge__
null
def __ge__(self, other): return SQLOp(">=", self, other)
(self, other)
27,122
sqlobject.sqlbuilder
__gt__
null
def __gt__(self, other): return SQLOp(">", self, other)
(self, other)
27,123
sqlobject.sqlbuilder
__init__
null
def __init__(self, expr): self.expr = expr
(self, expr)
27,124
sqlobject.sqlbuilder
__invert__
null
def __invert__(self): return SQLPrefix("NOT", self)
(self)
27,125
sqlobject.sqlbuilder
__le__
null
def __le__(self, other): return SQLOp("<=", self, other)
(self, other)
27,126
sqlobject.sqlbuilder
__lt__
null
def __lt__(self, other): return SQLOp("<", self, other)
(self, other)
27,127
sqlobject.sqlbuilder
__mod__
null
def __mod__(self, other): return SQLModulo(self, other)
(self, other)
27,128
sqlobject.sqlbuilder
__mul__
null
def __mul__(self, other): return SQLOp("*", self, other)
(self, other)
27,129
sqlobject.sqlbuilder
__ne__
null
def __ne__(self, other): if other is None: return ISNOTNULL(self) else: return SQLOp("<>", self, other)
(self, other)
27,130
sqlobject.sqlbuilder
__neg__
null
def __neg__(self): return SQLPrefix("-", self)
(self)
27,131
sqlobject.sqlbuilder
__or__
null
def __or__(self, other): return SQLOp("OR", self, other)
(self, other)
27,132
sqlobject.sqlbuilder
__pos__
null
def __pos__(self): return SQLPrefix("+", self)
(self)
27,133
sqlobject.sqlbuilder
__pow__
null
def __pow__(self, other): return SQLConstant("POW")(self, other)
(self, other)
27,134
sqlobject.sqlbuilder
__radd__
null
def __radd__(self, other): return SQLOp("+", other, self)
(self, other)
27,135
sqlobject.sqlbuilder
__rand__
null
def __rand__(self, other): return SQLOp("AND", other, self)
(self, other)
27,136
sqlobject.sqlbuilder
__rcmp__
null
def __rcmp__(self, other): raise VersionError("Python 2.1+ required")
(self, other)
27,137
sqlobject.sqlbuilder
__rdiv__
null
def __rdiv__(self, other): return SQLOp("/", other, self)
(self, other)
27,138
sqlobject.sqlbuilder
__repr__
null
def __repr__(self): try: return self.__sqlrepr__(None) except AssertionError: return '<%s %s>' % ( self.__class__.__name__, hex(id(self))[2:])
(self)
27,139
sqlobject.sqlbuilder
__rfloordiv__
null
def __rfloordiv__(self, other): return SQLConstant("FLOOR")(SQLOp("/", other, self))
(self, other)
27,140
sqlobject.sqlbuilder
__rmod__
null
def __rmod__(self, other): return SQLConstant("MOD")(other, self)
(self, other)
27,141
sqlobject.sqlbuilder
__rmul__
null
def __rmul__(self, other): return SQLOp("*", other, self)
(self, other)
27,142
sqlobject.sqlbuilder
__ror__
null
def __ror__(self, other): return SQLOp("OR", other, self)
(self, other)
27,143
sqlobject.sqlbuilder
__rpow__
null
def __rpow__(self, other): return SQLConstant("POW")(other, self)
(self, other)
27,144
sqlobject.sqlbuilder
__rsub__
null
def __rsub__(self, other): return SQLOp("-", other, self)
(self, other)
27,145
sqlobject.sqlbuilder
__rtruediv__
null
def __rtruediv__(self, other): return SQLOp("/", other, self)
(self, other)
27,146
sqlobject.sqlbuilder
__sqlrepr__
null
def __sqlrepr__(self, db): if isinstance(self.expr, DESC): return sqlrepr(self.expr.expr, db) return '%s DESC' % sqlrepr(self.expr, db)
(self, db)
27,148
sqlobject.sqlbuilder
__sub__
null
def __sub__(self, other): return SQLOp("-", self, other)
(self, other)
27,149
sqlobject.sqlbuilder
__truediv__
null
def __truediv__(self, other): return SQLOp("/", self, other)
(self, other)
27,150
sqlobject.sqlbuilder
components
null
def components(self): return []
(self)
27,151
sqlobject.sqlbuilder
contains
null
def contains(self, s): return CONTAINSSTRING(self, s)
(self, s)
27,152
sqlobject.sqlbuilder
endswith
null
def endswith(self, s): return ENDSWITH(self, s)
(self, s)
27,153
sqlobject.sqlbuilder
startswith
null
def startswith(self, s): return STARTSWITH(self, s)
(self, s)
27,154
sqlobject.sqlbuilder
tablesUsed
null
def tablesUsed(self, db): return self.tablesUsedSet(db)
(self, db)
27,155
sqlobject.sqlbuilder
tablesUsedImmediate
null
def tablesUsedImmediate(self): return []
(self)
27,156
sqlobject.sqlbuilder
tablesUsedSet
null
def tablesUsedSet(self, db): tables = set() for table in self.tablesUsedImmediate(): if hasattr(table, '__sqlrepr__'): table = sqlrepr(table, db) tables.add(table) for component in self.components(): tables.update(tablesUsedSet(component, db)) return tables
(self, db)
27,157
sqlobject.index
DatabaseIndex
This takes a variable number of parameters, each of which is a column for indexing. Each column may be a column object or the string name of the column (*not* the database name). You may also use dictionaries, to further customize the indexing of the column. The dictionary may have certain keys: 'column': The column object or string identifier. 'length': MySQL will only index the first N characters if this is given. For other databases this is ignored. 'expression': You can create an index based on an expression, e.g., 'lower(column)'. This can either be a string or a sqlbuilder expression. Further keys may be added to the column specs in the future. The class also take the keyword argument `unique`; if true then a UNIQUE index is created.
class DatabaseIndex(object): """ This takes a variable number of parameters, each of which is a column for indexing. Each column may be a column object or the string name of the column (*not* the database name). You may also use dictionaries, to further customize the indexing of the column. The dictionary may have certain keys: 'column': The column object or string identifier. 'length': MySQL will only index the first N characters if this is given. For other databases this is ignored. 'expression': You can create an index based on an expression, e.g., 'lower(column)'. This can either be a string or a sqlbuilder expression. Further keys may be added to the column specs in the future. The class also take the keyword argument `unique`; if true then a UNIQUE index is created. """ baseClass = SODatabaseIndex def __init__(self, *columns, **kw): kw['columns'] = columns self.kw = kw self.creationOrder = next(creationOrder) def setName(self, value): assert self.kw.get('name') is None, \ "You cannot change a name after it has already been set " \ "(from %s to %s)" % (self.kw['name'], value) self.kw['name'] = value def _get_name(self): return self.kw['name'] def _set_name(self, value): self.setName(value) name = property(_get_name, _set_name) def withClass(self, soClass): return self.baseClass(soClass=soClass, creationOrder=self.creationOrder, **self.kw) def __repr__(self): return '<%s %s %s>' % ( self.__class__.__name__, hex(abs(id(self)))[2:], self.kw)
(*columns, **kw)
27,158
sqlobject.index
__init__
null
def __init__(self, *columns, **kw): kw['columns'] = columns self.kw = kw self.creationOrder = next(creationOrder)
(self, *columns, **kw)
27,159
sqlobject.index
__repr__
null
def __repr__(self): return '<%s %s %s>' % ( self.__class__.__name__, hex(abs(id(self)))[2:], self.kw)
(self)
27,160
sqlobject.index
_get_name
null
def _get_name(self): return self.kw['name']
(self)
27,161
sqlobject.index
_set_name
null
def _set_name(self, value): self.setName(value)
(self, value)
27,162
sqlobject.index
setName
null
def setName(self, value): assert self.kw.get('name') is None, \ "You cannot change a name after it has already been set " \ "(from %s to %s)" % (self.kw['name'], value) self.kw['name'] = value
(self, value)
27,163
sqlobject.index
withClass
null
def withClass(self, soClass): return self.baseClass(soClass=soClass, creationOrder=self.creationOrder, **self.kw)
(self, soClass)
27,164
sqlobject.col
DateCol
null
class DateCol(Col): baseClass = SODateCol
(name=None, **kw)
27,171
sqlobject.col
DateTimeCol
null
class DateTimeCol(Col): baseClass = SODateTimeCol @staticmethod def now(): if default_datetime_implementation == DATETIME_IMPLEMENTATION: return datetime.datetime.now() elif default_datetime_implementation == MXDATETIME_IMPLEMENTATION: return mxDateTime.now() elif default_datetime_implementation == ZOPE_DATETIME_IMPLEMENTATION: return zopeDateTime.DateTimr() else: assert 0, ("No datetime implementation available " "(DATETIME_IMPLEMENTATION=%r)" % DATETIME_IMPLEMENTATION)
(name=None, **kw)
27,177
sqlobject.col
now
null
@staticmethod def now(): if default_datetime_implementation == DATETIME_IMPLEMENTATION: return datetime.datetime.now() elif default_datetime_implementation == MXDATETIME_IMPLEMENTATION: return mxDateTime.now() elif default_datetime_implementation == ZOPE_DATETIME_IMPLEMENTATION: return zopeDateTime.DateTimr() else: assert 0, ("No datetime implementation available " "(DATETIME_IMPLEMENTATION=%r)" % DATETIME_IMPLEMENTATION)
()
27,179
sqlobject.col
DecimalCol
null
class DecimalCol(Col): baseClass = SODecimalCol
(name=None, **kw)
27,186
sqlobject.col
DecimalStringCol
null
class DecimalStringCol(StringCol): baseClass = SODecimalStringCol
(name=None, **kw)
27,193
sqlobject.styles
MixedCaseUnderscoreStyle
This is the default style. Python attributes use mixedCase, while database columns use underscore_separated.
class MixedCaseUnderscoreStyle(Style): """ This is the default style. Python attributes use mixedCase, while database columns use underscore_separated. """ def pythonAttrToDBColumn(self, attr): return mixedToUnder(attr) def dbColumnToPythonAttr(self, col): return underToMixed(col) def pythonClassToDBTable(self, className): return className[0].lower() \ + mixedToUnder(className[1:]) def dbTableToPythonClass(self, table): return table[0].upper() \ + underToMixed(table[1:]) def pythonClassToDBTableReference(self, className): return self.tableReference(self.pythonClassToDBTable(className)) def tableReference(self, table): return table + "_id"
(pythonAttrToDBColumn=None, dbColumnToPythonAttr=None, pythonClassToDBTable=None, dbTableToPythonClass=None, idForTable=None, longID=False)
27,194
sqlobject.styles
__init__
null
def __init__(self, pythonAttrToDBColumn=None, dbColumnToPythonAttr=None, pythonClassToDBTable=None, dbTableToPythonClass=None, idForTable=None, longID=False): if pythonAttrToDBColumn: self.pythonAttrToDBColumn = \ lambda a, s=self: pythonAttrToDBColumn(s, a) if dbColumnToPythonAttr: self.dbColumnToPythonAttr = \ lambda a, s=self: dbColumnToPythonAttr(s, a) if pythonClassToDBTable: self.pythonClassToDBTable = \ lambda a, s=self: pythonClassToDBTable(s, a) if dbTableToPythonClass: self.dbTableToPythonClass = \ lambda a, s=self: dbTableToPythonClass(s, a) if idForTable: self.idForTable = lambda a, s=self: idForTable(s, a) self.longID = longID
(self, pythonAttrToDBColumn=None, dbColumnToPythonAttr=None, pythonClassToDBTable=None, dbTableToPythonClass=None, idForTable=None, longID=False)
27,195
sqlobject.styles
dbColumnToPythonAttr
null
def dbColumnToPythonAttr(self, col): return underToMixed(col)
(self, col)
27,196
sqlobject.styles
dbTableToPythonClass
null
def dbTableToPythonClass(self, table): return table[0].upper() \ + underToMixed(table[1:])
(self, table)
27,197
sqlobject.styles
idForTable
null
def idForTable(self, table): if self.longID: return self.tableReference(table) else: return 'id'
(self, table)
27,198
sqlobject.styles
instanceAttrToIDAttr
null
def instanceAttrToIDAttr(self, attr): return attr + "ID"
(self, attr)
27,199
sqlobject.styles
instanceIDAttrToAttr
null
def instanceIDAttrToAttr(self, attr): return attr[:-2]
(self, attr)
27,200
sqlobject.styles
pythonAttrToDBColumn
null
def pythonAttrToDBColumn(self, attr): return mixedToUnder(attr)
(self, attr)
27,201
sqlobject.styles
pythonClassToAttr
null
def pythonClassToAttr(self, className): return lowerword(className)
(self, className)
27,202
sqlobject.styles
pythonClassToDBTable
null
def pythonClassToDBTable(self, className): return className[0].lower() \ + mixedToUnder(className[1:])
(self, className)
27,203
sqlobject.styles
pythonClassToDBTableReference
null
def pythonClassToDBTableReference(self, className): return self.tableReference(self.pythonClassToDBTable(className))
(self, className)
27,204
sqlobject.styles
tableReference
null
def tableReference(self, table): return table + "_id"
(self, table)
27,205
sqlobject.col
EnumCol
null
class EnumCol(Col): baseClass = SOEnumCol
(name=None, **kw)
27,212
sqlobject.col
FloatCol
null
class FloatCol(Col): baseClass = SOFloatCol
(name=None, **kw)
27,219
sqlobject.col
ForeignKey
null
class ForeignKey(KeyCol): baseClass = SOForeignKey def __init__(self, foreignKey=None, **kw): super(ForeignKey, self).__init__(foreignKey=foreignKey, **kw)
(foreignKey=None, **kw)
27,220
sqlobject.col
__init__
null
def __init__(self, foreignKey=None, **kw): super(ForeignKey, self).__init__(foreignKey=foreignKey, **kw)
(self, foreignKey=None, **kw)
27,226
sqlobject.sqlbuilder
IN
null
def IN(item, list): from .sresults import SelectResults # Import here to avoid circular import if isinstance(list, SelectResults): query = list.queryForSelect() query.ops['items'] = [list.sourceClass.q.id] list = query if isinstance(list, Select): return INSubquery(item, list) else: return _IN(item, list)
(item, list)
27,227
sqlobject.col
IntCol
null
class IntCol(Col): baseClass = SOIntCol
(name=None, **kw)
27,234
sqlobject.col
JSONCol
null
class JSONCol(StringCol): baseClass = SOJSONCol
(name=None, **kw)
27,241
sqlobject.col
JsonbCol
null
class JsonbCol(Col): baseClass = SOJsonbCol
(name=None, **kw)
27,248
sqlobject.col
KeyCol
null
class KeyCol(Col): baseClass = SOKeyCol
(name=None, **kw)
27,255
sqlobject.sqlbuilder
LIKE
null
class LIKE(SQLExpression): op = "LIKE" def __init__(self, expr, string, escape=None): self.expr = expr self.string = string self.escape = escape def __sqlrepr__(self, db): escape = self.escape like = "%s %s (%s)" % (sqlrepr(self.expr, db), self.op, sqlrepr(self.string, db)) if escape is None: return "(%s)" % like else: return "(%s ESCAPE %s)" % (like, sqlrepr(escape, db)) def components(self): return [self.expr, self.string] def execute(self, executor): if not hasattr(self, '_regex'): # @@: Crude, not entirely accurate dest = self.string dest = dest.replace("%%", "\001") dest = dest.replace("*", "\002") dest = dest.replace("%", "*") dest = dest.replace("\001", "%") dest = dest.replace("\002", "[*]") self._regex = re.compile(fnmatch.translate(dest), re.I) return self._regex.search(execute(self.expr, executor))
(expr, string, escape=None)
27,266
sqlobject.sqlbuilder
__init__
null
def __init__(self, expr, string, escape=None): self.expr = expr self.string = string self.escape = escape
(self, expr, string, escape=None)
27,289
sqlobject.sqlbuilder
__sqlrepr__
null
def __sqlrepr__(self, db): escape = self.escape like = "%s %s (%s)" % (sqlrepr(self.expr, db), self.op, sqlrepr(self.string, db)) if escape is None: return "(%s)" % like else: return "(%s ESCAPE %s)" % (like, sqlrepr(escape, db))
(self, db)
27,293
sqlobject.sqlbuilder
components
null
def components(self): return [self.expr, self.string]
(self)
27,296
sqlobject.sqlbuilder
execute
null
def execute(self, executor): if not hasattr(self, '_regex'): # @@: Crude, not entirely accurate dest = self.string dest = dest.replace("%%", "\001") dest = dest.replace("*", "\002") dest = dest.replace("%", "*") dest = dest.replace("\001", "%") dest = dest.replace("\002", "[*]") self._regex = re.compile(fnmatch.translate(dest), re.I) return self._regex.search(execute(self.expr, executor))
(self, executor)
27,301
sqlobject.joins
ManyToMany
null
class ManyToMany(boundattributes.BoundFactory): factory_class = SOManyToMany __restrict_attributes__ = ( 'join', 'intermediateTable', 'joinColumn', 'otherColumn', 'createJoinTable') __unpackargs__ = ('join',) # Default values: intermediateTable = None joinColumn = None otherColumn = None createJoinTable = True
(*args, **kw)
27,302
sqlobject.declarative
__call__
null
def __call__(self, *args, **kw): kw['__alsocopy'] = self.__dict__ return self.__class__(*args, **kw)
(self, *args, **kw)
27,303
sqlobject.boundattributes
__classinit__
null
def __classinit__(cls, new_attrs): declarative.Declarative.__classinit__(cls, new_attrs) cls._all_attrs = cls._add_attrs(cls, new_attrs)
(cls, new_attrs)
27,304
sqlobject.declarative
__init__
null
def __init__(self, *args, **kw): if self.__unpackargs__ and self.__unpackargs__[0] == '*': assert len(self.__unpackargs__) == 2, \ "When using __unpackargs__ = ('*', varname), " \ "you must only provide a single variable name " \ "(you gave %r)" % self.__unpackargs__ name = self.__unpackargs__[1] if name in kw: raise TypeError( "keyword parameter '%s' was given by position and name" % name) kw[name] = args else: if len(args) > len(self.__unpackargs__): raise TypeError( '%s() takes at most %i arguments (%i given)' % (self.__class__.__name__, len(self.__unpackargs__), len(args))) for name, arg in zip(self.__unpackargs__, args): if name in kw: raise TypeError( "keyword parameter '%s' was given by position and name" % name) kw[name] = arg if '__alsocopy' in kw: for name, value in kw['__alsocopy'].items(): if name not in kw: if name in self.__mutableattributes__: value = copy.copy(value) kw[name] = value del kw['__alsocopy'] self.__instanceinit__(kw)
(self, *args, **kw)
27,305
sqlobject.boundattributes
__instanceinit__
null
def __instanceinit__(self, new_attrs): declarative.Declarative.__instanceinit__(self, new_attrs) self.__dict__['_all_attrs'] = self._add_attrs(self, new_attrs)
(self, new_attrs)
27,306
sqlobject.boundattributes
__setattr__
null
def __setattr__(self, name, value): self.__dict__['_all_attrs'] = self._add_attrs(self, {name: value}) self.__dict__[name] = value
(self, name, value)
27,307
sqlobject.boundattributes
_add_attrs
null
@staticmethod def _add_attrs(this_object, new_attrs): private = this_object._private_variables all_attrs = list(this_object._all_attrs) for key in new_attrs.keys(): if key.startswith('_') or key in private: continue if key not in all_attrs: all_attrs.append(key) return tuple(all_attrs)
(this_object, new_attrs)
27,308
sqlobject.declarative
_repr_vars
null
@staticmethod def _repr_vars(dictNames): names = [n for n in dictNames if not n.startswith('_') and n != 'declarative_count'] names.sort() return names
(dictNames)
27,309
sqlobject.boundattributes
make_object
null
def make_object(cls, added_class, attr_name, *args, **kw): return cls.factory_class(added_class, attr_name, *args, **kw)
(cls, added_class, attr_name, *args, **kw)
27,310
sqlobject.col
MediumIntCol
null
class MediumIntCol(Col): baseClass = SOMediumIntCol
(name=None, **kw)
27,317
sqlobject.styles
MixedCaseStyle
This style leaves columns as mixed-case, and uses long ID names (like ProductID instead of simply id).
class MixedCaseStyle(Style): """ This style leaves columns as mixed-case, and uses long ID names (like ProductID instead of simply id). """ def pythonAttrToDBColumn(self, attr): return capword(attr) def dbColumnToPythonAttr(self, col): return lowerword(col) def dbTableToPythonClass(self, table): return capword(table) def tableReference(self, table): return table + "ID"
(pythonAttrToDBColumn=None, dbColumnToPythonAttr=None, pythonClassToDBTable=None, dbTableToPythonClass=None, idForTable=None, longID=False)
27,319
sqlobject.styles
dbColumnToPythonAttr
null
def dbColumnToPythonAttr(self, col): return lowerword(col)
(self, col)
27,320
sqlobject.styles
dbTableToPythonClass
null
def dbTableToPythonClass(self, table): return capword(table)
(self, table)
27,324
sqlobject.styles
pythonAttrToDBColumn
null
def pythonAttrToDBColumn(self, attr): return capword(attr)
(self, attr)
27,326
sqlobject.styles
pythonClassToDBTable
null
def pythonClassToDBTable(self, className): return className
(self, className)
27,327
sqlobject.styles
tableReference
null
def tableReference(self, table): return table + "ID"
(self, table)
27,340
sqlobject.joins
MultipleJoin
null
class MultipleJoin(Join): baseClass = SOMultipleJoin
(otherClass=None, **kw)
27,341
sqlobject.joins
__init__
null
def __init__(self, otherClass=None, **kw): kw['otherClass'] = otherClass self.kw = kw self._joinMethodName = self.kw.pop('joinMethodName', None) self.creationOrder = next(creationOrder)
(self, otherClass=None, **kw)
27,342
sqlobject.joins
_get_joinMethodName
null
def _get_joinMethodName(self): return self._joinMethodName
(self)
27,343
sqlobject.joins
_set_joinMethodName
null
def _set_joinMethodName(self, value): assert self._joinMethodName == value or self._joinMethodName is None, \ "You have already given an explicit joinMethodName (%s), " \ "and you are now setting it to %s" % (self._joinMethodName, value) self._joinMethodName = value
(self, value)
27,344
sqlobject.joins
withClass
null
def withClass(self, soClass): if 'joinMethodName' in self.kw: self._joinMethodName = self.kw['joinMethodName'] del self.kw['joinMethodName'] return self.baseClass(creationOrder=self.creationOrder, soClass=soClass, joinDef=self, joinMethodName=self._joinMethodName, **self.kw)
(self, soClass)
27,345
sqlobject.sqlbuilder
NOT
null
def NOT(op): return SQLPrefix("NOT", op)
(op)
27,346
sqlobject.sqlbuilder
NoDefault
null
class NoDefault: pass
()
27,347
sqlobject.sqlbuilder
OR
null
def OR(*ops): if not ops: return None op1 = ops[0] ops = ops[1:] if ops: return SQLOp("OR", op1, OR(*ops)) else: return op1
(*ops)
27,348
sqlobject.joins
OneToMany
null
class OneToMany(boundattributes.BoundFactory): factory_class = SOOneToMany __restrict_attributes__ = ( 'join', 'joinColumn') __unpackargs__ = ('join',) # Default values: joinColumn = None
(*args, **kw)
27,357
sqlobject.col
PickleCol
null
class PickleCol(BLOBCol): baseClass = SOPickleCol
(name=None, **kw)