repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
twisted/axiom | axiom/plugins/axiom_plugins.py | Upgrade.perform | def perform(self, store, count):
"""
Upgrade C{store} performing C{count} upgrades per transaction.
Also, catch any exceptions and print out something useful.
"""
self.count = count
try:
self.upgradeStore(store)
print 'Upgrade complete'
e... | python | def perform(self, store, count):
"""
Upgrade C{store} performing C{count} upgrades per transaction.
Also, catch any exceptions and print out something useful.
"""
self.count = count
try:
self.upgradeStore(store)
print 'Upgrade complete'
e... | [
"def",
"perform",
"(",
"self",
",",
"store",
",",
"count",
")",
":",
"self",
".",
"count",
"=",
"count",
"try",
":",
"self",
".",
"upgradeStore",
"(",
"store",
")",
"print",
"'Upgrade complete'",
"except",
"errors",
".",
"ItemUpgradeError",
"as",
"e",
":... | Upgrade C{store} performing C{count} upgrades per transaction.
Also, catch any exceptions and print out something useful. | [
"Upgrade",
"C",
"{",
"store",
"}",
"performing",
"C",
"{",
"count",
"}",
"upgrades",
"per",
"transaction",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/plugins/axiom_plugins.py#L67-L83 |
twisted/axiom | axiom/plugins/axiom_plugins.py | AxiomConsole.runcode | def runcode(self, code):
"""
Override L{code.InteractiveConsole.runcode} to run the code in a
transaction unless the local C{autocommit} is currently set to a true
value.
"""
if not self.locals.get('autocommit', None):
return self.locals['db'].transact(code.In... | python | def runcode(self, code):
"""
Override L{code.InteractiveConsole.runcode} to run the code in a
transaction unless the local C{autocommit} is currently set to a true
value.
"""
if not self.locals.get('autocommit', None):
return self.locals['db'].transact(code.In... | [
"def",
"runcode",
"(",
"self",
",",
"code",
")",
":",
"if",
"not",
"self",
".",
"locals",
".",
"get",
"(",
"'autocommit'",
",",
"None",
")",
":",
"return",
"self",
".",
"locals",
"[",
"'db'",
"]",
".",
"transact",
"(",
"code",
".",
"InteractiveConsol... | Override L{code.InteractiveConsole.runcode} to run the code in a
transaction unless the local C{autocommit} is currently set to a true
value. | [
"Override",
"L",
"{",
"code",
".",
"InteractiveConsole",
".",
"runcode",
"}",
"to",
"run",
"the",
"code",
"in",
"a",
"transaction",
"unless",
"the",
"local",
"C",
"{",
"autocommit",
"}",
"is",
"currently",
"set",
"to",
"a",
"true",
"value",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/plugins/axiom_plugins.py#L98-L106 |
twisted/axiom | axiom/plugins/axiom_plugins.py | Browse.namespace | def namespace(self):
"""
Return a dictionary representing the namespace which should be
available to the user.
"""
self._ns = {
'db': self.store,
'store': store,
'autocommit': False,
}
return self._ns | python | def namespace(self):
"""
Return a dictionary representing the namespace which should be
available to the user.
"""
self._ns = {
'db': self.store,
'store': store,
'autocommit': False,
}
return self._ns | [
"def",
"namespace",
"(",
"self",
")",
":",
"self",
".",
"_ns",
"=",
"{",
"'db'",
":",
"self",
".",
"store",
",",
"'store'",
":",
"store",
",",
"'autocommit'",
":",
"False",
",",
"}",
"return",
"self",
".",
"_ns"
] | Return a dictionary representing the namespace which should be
available to the user. | [
"Return",
"a",
"dictionary",
"representing",
"the",
"namespace",
"which",
"should",
"be",
"available",
"to",
"the",
"user",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/plugins/axiom_plugins.py#L137-L147 |
twisted/axiom | axiom/plugins/axiom_plugins.py | Create.addAccount | def addAccount(self, siteStore, username, domain, password):
"""
Create a new account in the given store.
@param siteStore: A site Store to which login credentials will be
added.
@param username: Local part of the username for the credentials to add.
@param domain: Domai... | python | def addAccount(self, siteStore, username, domain, password):
"""
Create a new account in the given store.
@param siteStore: A site Store to which login credentials will be
added.
@param username: Local part of the username for the credentials to add.
@param domain: Domai... | [
"def",
"addAccount",
"(",
"self",
",",
"siteStore",
",",
"username",
",",
"domain",
",",
"password",
")",
":",
"for",
"ls",
"in",
"siteStore",
".",
"query",
"(",
"userbase",
".",
"LoginSystem",
")",
":",
"break",
"else",
":",
"ls",
"=",
"self",
".",
... | Create a new account in the given store.
@param siteStore: A site Store to which login credentials will be
added.
@param username: Local part of the username for the credentials to add.
@param domain: Domain part of the username for the credentials to add.
@param password: Passw... | [
"Create",
"a",
"new",
"account",
"in",
"the",
"given",
"store",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/plugins/axiom_plugins.py#L191-L211 |
twisted/axiom | benchmark/benchlib.py | itemTypeWithSomeAttributes | def itemTypeWithSomeAttributes(attributeTypes):
"""
Create a new L{Item} subclass with L{numAttributes} integers in its
schema.
"""
class SomeItem(Item):
typeName = 'someitem_' + str(typeNameCounter())
for i, attributeType in enumerate(attributeTypes):
locals()['attr_' + ... | python | def itemTypeWithSomeAttributes(attributeTypes):
"""
Create a new L{Item} subclass with L{numAttributes} integers in its
schema.
"""
class SomeItem(Item):
typeName = 'someitem_' + str(typeNameCounter())
for i, attributeType in enumerate(attributeTypes):
locals()['attr_' + ... | [
"def",
"itemTypeWithSomeAttributes",
"(",
"attributeTypes",
")",
":",
"class",
"SomeItem",
"(",
"Item",
")",
":",
"typeName",
"=",
"'someitem_'",
"+",
"str",
"(",
"typeNameCounter",
"(",
")",
")",
"for",
"i",
",",
"attributeType",
"in",
"enumerate",
"(",
"at... | Create a new L{Item} subclass with L{numAttributes} integers in its
schema. | [
"Create",
"a",
"new",
"L",
"{",
"Item",
"}",
"subclass",
"with",
"L",
"{",
"numAttributes",
"}",
"integers",
"in",
"its",
"schema",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/benchmark/benchlib.py#L13-L22 |
twisted/axiom | benchmark/benchlib.py | createSomeItems | def createSomeItems(store, itemType, values, counter):
"""
Create some instances of a particular type in a store.
"""
for i in counter:
itemType(store=store, **values) | python | def createSomeItems(store, itemType, values, counter):
"""
Create some instances of a particular type in a store.
"""
for i in counter:
itemType(store=store, **values) | [
"def",
"createSomeItems",
"(",
"store",
",",
"itemType",
",",
"values",
",",
"counter",
")",
":",
"for",
"i",
"in",
"counter",
":",
"itemType",
"(",
"store",
"=",
"store",
",",
"*",
"*",
"values",
")"
] | Create some instances of a particular type in a store. | [
"Create",
"some",
"instances",
"of",
"a",
"particular",
"type",
"in",
"a",
"store",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/benchmark/benchlib.py#L25-L30 |
stephrdev/django-mongoforms | mongoforms/forms.py | MongoForm.save | def save(self, commit=True):
"""save the instance or create a new one.."""
# walk through the document fields
for field_name, field in iter_valid_fields(self._meta):
setattr(self.instance, field_name, self.cleaned_data.get(field_name))
if commit:
self.instance.s... | python | def save(self, commit=True):
"""save the instance or create a new one.."""
# walk through the document fields
for field_name, field in iter_valid_fields(self._meta):
setattr(self.instance, field_name, self.cleaned_data.get(field_name))
if commit:
self.instance.s... | [
"def",
"save",
"(",
"self",
",",
"commit",
"=",
"True",
")",
":",
"# walk through the document fields",
"for",
"field_name",
",",
"field",
"in",
"iter_valid_fields",
"(",
"self",
".",
"_meta",
")",
":",
"setattr",
"(",
"self",
".",
"instance",
",",
"field_na... | save the instance or create a new one.. | [
"save",
"the",
"instance",
"or",
"create",
"a",
"new",
"one",
".."
] | train | https://github.com/stephrdev/django-mongoforms/blob/6fa46824c438555c703f293d682ca92710938985/mongoforms/forms.py#L95-L105 |
twisted/axiom | axiom/item.py | transacted | def transacted(func):
"""
Return a callable which will invoke C{func} in a transaction using the
C{store} attribute of the first parameter passed to it. Typically this is
used to create Item methods which are automatically run in a transaction.
The attributes of the returned callable will resemble... | python | def transacted(func):
"""
Return a callable which will invoke C{func} in a transaction using the
C{store} attribute of the first parameter passed to it. Typically this is
used to create Item methods which are automatically run in a transaction.
The attributes of the returned callable will resemble... | [
"def",
"transacted",
"(",
"func",
")",
":",
"def",
"transactionified",
"(",
"item",
",",
"*",
"a",
",",
"*",
"*",
"kw",
")",
":",
"return",
"item",
".",
"store",
".",
"transact",
"(",
"func",
",",
"item",
",",
"*",
"a",
",",
"*",
"*",
"kw",
")"... | Return a callable which will invoke C{func} in a transaction using the
C{store} attribute of the first parameter passed to it. Typically this is
used to create Item methods which are automatically run in a transaction.
The attributes of the returned callable will resemble those of C{func} as
closely a... | [
"Return",
"a",
"callable",
"which",
"will",
"invoke",
"C",
"{",
"func",
"}",
"in",
"a",
"transaction",
"using",
"the",
"C",
"{",
"store",
"}",
"attribute",
"of",
"the",
"first",
"parameter",
"passed",
"to",
"it",
".",
"Typically",
"this",
"is",
"used",
... | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L403-L414 |
twisted/axiom | axiom/item.py | dependentItems | def dependentItems(store, tableClass, comparisonFactory):
"""
Collect all the items that should be deleted when an item or items
of a particular item type are deleted.
@param tableClass: An L{Item} subclass.
@param comparison: A one-argument callable taking an attribute and
returning an L{iaxi... | python | def dependentItems(store, tableClass, comparisonFactory):
"""
Collect all the items that should be deleted when an item or items
of a particular item type are deleted.
@param tableClass: An L{Item} subclass.
@param comparison: A one-argument callable taking an attribute and
returning an L{iaxi... | [
"def",
"dependentItems",
"(",
"store",
",",
"tableClass",
",",
"comparisonFactory",
")",
":",
"for",
"cascadingAttr",
"in",
"(",
"_cascadingDeletes",
".",
"get",
"(",
"tableClass",
",",
"[",
"]",
")",
"+",
"_cascadingDeletes",
".",
"get",
"(",
"None",
",",
... | Collect all the items that should be deleted when an item or items
of a particular item type are deleted.
@param tableClass: An L{Item} subclass.
@param comparison: A one-argument callable taking an attribute and
returning an L{iaxiom.IComparison} describing the items to
collect.
@return: An ... | [
"Collect",
"all",
"the",
"items",
"that",
"should",
"be",
"deleted",
"when",
"an",
"item",
"or",
"items",
"of",
"a",
"particular",
"item",
"type",
"are",
"deleted",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L419-L436 |
twisted/axiom | axiom/item.py | allowDeletion | def allowDeletion(store, tableClass, comparisonFactory):
"""
Returns a C{bool} indicating whether deletion of an item or items of a
particular item type should be allowed to proceed.
@param tableClass: An L{Item} subclass.
@param comparison: A one-argument callable taking an attribute and
retu... | python | def allowDeletion(store, tableClass, comparisonFactory):
"""
Returns a C{bool} indicating whether deletion of an item or items of a
particular item type should be allowed to proceed.
@param tableClass: An L{Item} subclass.
@param comparison: A one-argument callable taking an attribute and
retu... | [
"def",
"allowDeletion",
"(",
"store",
",",
"tableClass",
",",
"comparisonFactory",
")",
":",
"for",
"cascadingAttr",
"in",
"(",
"_disallows",
".",
"get",
"(",
"tableClass",
",",
"[",
"]",
")",
"+",
"_disallows",
".",
"get",
"(",
"None",
",",
"[",
"]",
... | Returns a C{bool} indicating whether deletion of an item or items of a
particular item type should be allowed to proceed.
@param tableClass: An L{Item} subclass.
@param comparison: A one-argument callable taking an attribute and
returning an L{iaxiom.IComparison} describing the items to
collect.
... | [
"Returns",
"a",
"C",
"{",
"bool",
"}",
"indicating",
"whether",
"deletion",
"of",
"an",
"item",
"or",
"items",
"of",
"a",
"particular",
"item",
"type",
"should",
"be",
"allowed",
"to",
"proceed",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L440-L460 |
twisted/axiom | axiom/item.py | declareLegacyItem | def declareLegacyItem(typeName, schemaVersion, attributes, dummyBases=()):
"""
Generate a dummy subclass of Item that will have the given attributes,
and the base Item methods, but no methods of its own. This is for use
with upgrading.
@param typeName: a string, the Axiom TypeName to have attribut... | python | def declareLegacyItem(typeName, schemaVersion, attributes, dummyBases=()):
"""
Generate a dummy subclass of Item that will have the given attributes,
and the base Item methods, but no methods of its own. This is for use
with upgrading.
@param typeName: a string, the Axiom TypeName to have attribut... | [
"def",
"declareLegacyItem",
"(",
"typeName",
",",
"schemaVersion",
",",
"attributes",
",",
"dummyBases",
"=",
"(",
")",
")",
":",
"if",
"(",
"typeName",
",",
"schemaVersion",
")",
"in",
"_legacyTypes",
":",
"return",
"_legacyTypes",
"[",
"typeName",
",",
"sc... | Generate a dummy subclass of Item that will have the given attributes,
and the base Item methods, but no methods of its own. This is for use
with upgrading.
@param typeName: a string, the Axiom TypeName to have attributes for.
@param schemaVersion: an int, the (old) version of the schema this is a pro... | [
"Generate",
"a",
"dummy",
"subclass",
"of",
"Item",
"that",
"will",
"have",
"the",
"given",
"attributes",
"and",
"the",
"base",
"Item",
"methods",
"but",
"no",
"methods",
"of",
"its",
"own",
".",
"This",
"is",
"for",
"use",
"with",
"upgrading",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L1094-L1126 |
twisted/axiom | axiom/item.py | empowerment | def empowerment(iface, priority=0):
"""
Class decorator for indicating a powerup's powerup interfaces.
The class will also be declared as implementing the interface.
@type iface: L{zope.interface.Interface}
@param iface: The powerup interface.
@type priority: int
@param priority: The prio... | python | def empowerment(iface, priority=0):
"""
Class decorator for indicating a powerup's powerup interfaces.
The class will also be declared as implementing the interface.
@type iface: L{zope.interface.Interface}
@param iface: The powerup interface.
@type priority: int
@param priority: The prio... | [
"def",
"empowerment",
"(",
"iface",
",",
"priority",
"=",
"0",
")",
":",
"def",
"_deco",
"(",
"cls",
")",
":",
"cls",
".",
"powerupInterfaces",
"=",
"(",
"tuple",
"(",
"getattr",
"(",
"cls",
",",
"'powerupInterfaces'",
",",
"(",
")",
")",
")",
"+",
... | Class decorator for indicating a powerup's powerup interfaces.
The class will also be declared as implementing the interface.
@type iface: L{zope.interface.Interface}
@param iface: The powerup interface.
@type priority: int
@param priority: The priority the powerup will be installed at. | [
"Class",
"decorator",
"for",
"indicating",
"a",
"powerup",
"s",
"powerup",
"interfaces",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L1147-L1165 |
twisted/axiom | axiom/item.py | Empowered.powerUp | def powerUp(self, powerup, interface=None, priority=0):
"""
Installs a powerup (e.g. plugin) on an item or store.
Powerups will be returned in an iterator when queried for using the
'powerupsFor' method. Normally they will be returned in order of
installation [this may change i... | python | def powerUp(self, powerup, interface=None, priority=0):
"""
Installs a powerup (e.g. plugin) on an item or store.
Powerups will be returned in an iterator when queried for using the
'powerupsFor' method. Normally they will be returned in order of
installation [this may change i... | [
"def",
"powerUp",
"(",
"self",
",",
"powerup",
",",
"interface",
"=",
"None",
",",
"priority",
"=",
"0",
")",
":",
"if",
"interface",
"is",
"None",
":",
"for",
"iface",
",",
"priority",
"in",
"powerup",
".",
"_getPowerupInterfaces",
"(",
")",
":",
"sel... | Installs a powerup (e.g. plugin) on an item or store.
Powerups will be returned in an iterator when queried for using the
'powerupsFor' method. Normally they will be returned in order of
installation [this may change in future versions, so please don't
depend on it]. Higher priorities... | [
"Installs",
"a",
"powerup",
"(",
"e",
".",
"g",
".",
"plugin",
")",
"on",
"an",
"item",
"or",
"store",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L213-L270 |
twisted/axiom | axiom/item.py | Empowered.powerDown | def powerDown(self, powerup, interface=None):
"""
Remove a powerup.
If no interface is specified, and the type of the object being
installed has a "powerupInterfaces" attribute (containing
either a sequence of interfaces, or a sequence of (interface,
priority) tuples), t... | python | def powerDown(self, powerup, interface=None):
"""
Remove a powerup.
If no interface is specified, and the type of the object being
installed has a "powerupInterfaces" attribute (containing
either a sequence of interfaces, or a sequence of (interface,
priority) tuples), t... | [
"def",
"powerDown",
"(",
"self",
",",
"powerup",
",",
"interface",
"=",
"None",
")",
":",
"if",
"interface",
"is",
"None",
":",
"for",
"interface",
",",
"priority",
"in",
"powerup",
".",
"_getPowerupInterfaces",
"(",
")",
":",
"self",
".",
"powerDown",
"... | Remove a powerup.
If no interface is specified, and the type of the object being
installed has a "powerupInterfaces" attribute (containing
either a sequence of interfaces, or a sequence of (interface,
priority) tuples), the target will be powered down with this
object on those i... | [
"Remove",
"a",
"powerup",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L273-L303 |
twisted/axiom | axiom/item.py | Empowered.powerupsFor | def powerupsFor(self, interface):
"""
Returns powerups installed using C{powerUp}, in order of descending
priority.
Powerups found to have been deleted, either during the course of this
powerupsFor iteration, during an upgrader, or previously, will not be
returned.
... | python | def powerupsFor(self, interface):
"""
Returns powerups installed using C{powerUp}, in order of descending
priority.
Powerups found to have been deleted, either during the course of this
powerupsFor iteration, during an upgrader, or previously, will not be
returned.
... | [
"def",
"powerupsFor",
"(",
"self",
",",
"interface",
")",
":",
"inMemoryPowerup",
"=",
"self",
".",
"_inMemoryPowerups",
".",
"get",
"(",
"interface",
",",
"None",
")",
"if",
"inMemoryPowerup",
"is",
"not",
"None",
":",
"yield",
"inMemoryPowerup",
"if",
"sel... | Returns powerups installed using C{powerUp}, in order of descending
priority.
Powerups found to have been deleted, either during the course of this
powerupsFor iteration, during an upgrader, or previously, will not be
returned. | [
"Returns",
"powerups",
"installed",
"using",
"C",
"{",
"powerUp",
"}",
"in",
"order",
"of",
"descending",
"priority",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L330-L359 |
twisted/axiom | axiom/item.py | Empowered.interfacesFor | def interfacesFor(self, powerup):
"""
Return an iterator of the interfaces for which the given powerup is
installed on this object.
This is not implemented for in-memory powerups. It will probably fail
in an unpredictable, implementation-dependent way if used on one.
""... | python | def interfacesFor(self, powerup):
"""
Return an iterator of the interfaces for which the given powerup is
installed on this object.
This is not implemented for in-memory powerups. It will probably fail
in an unpredictable, implementation-dependent way if used on one.
""... | [
"def",
"interfacesFor",
"(",
"self",
",",
"powerup",
")",
":",
"pc",
"=",
"_PowerupConnector",
"for",
"iface",
"in",
"self",
".",
"store",
".",
"query",
"(",
"pc",
",",
"AND",
"(",
"pc",
".",
"item",
"==",
"self",
",",
"pc",
".",
"powerup",
"==",
"... | Return an iterator of the interfaces for which the given powerup is
installed on this object.
This is not implemented for in-memory powerups. It will probably fail
in an unpredictable, implementation-dependent way if used on one. | [
"Return",
"an",
"iterator",
"of",
"the",
"interfaces",
"for",
"which",
"the",
"given",
"powerup",
"is",
"installed",
"on",
"this",
"object",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L361-L373 |
twisted/axiom | axiom/item.py | Empowered._getPowerupInterfaces | def _getPowerupInterfaces(self):
"""
Collect powerup interfaces this object declares that it can be
installed on.
"""
powerupInterfaces = getattr(self.__class__, "powerupInterfaces", ())
pifs = []
for x in powerupInterfaces:
if isinstance(x, type(Inter... | python | def _getPowerupInterfaces(self):
"""
Collect powerup interfaces this object declares that it can be
installed on.
"""
powerupInterfaces = getattr(self.__class__, "powerupInterfaces", ())
pifs = []
for x in powerupInterfaces:
if isinstance(x, type(Inter... | [
"def",
"_getPowerupInterfaces",
"(",
"self",
")",
":",
"powerupInterfaces",
"=",
"getattr",
"(",
"self",
".",
"__class__",
",",
"\"powerupInterfaces\"",
",",
"(",
")",
")",
"pifs",
"=",
"[",
"]",
"for",
"x",
"in",
"powerupInterfaces",
":",
"if",
"isinstance"... | Collect powerup interfaces this object declares that it can be
installed on. | [
"Collect",
"powerup",
"interfaces",
"this",
"object",
"declares",
"that",
"it",
"can",
"be",
"installed",
"on",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L376-L399 |
twisted/axiom | axiom/item.py | Item._currentlyValidAsReferentFor | def _currentlyValidAsReferentFor(self, store):
"""
Is this object currently valid as a reference? Objects which will be
deleted in this transaction, or objects which are not in the same store
are not valid. See attributes.reference.__get__.
"""
if store is None:
... | python | def _currentlyValidAsReferentFor(self, store):
"""
Is this object currently valid as a reference? Objects which will be
deleted in this transaction, or objects which are not in the same store
are not valid. See attributes.reference.__get__.
"""
if store is None:
... | [
"def",
"_currentlyValidAsReferentFor",
"(",
"self",
",",
"store",
")",
":",
"if",
"store",
"is",
"None",
":",
"# If your store is None, you can refer to whoever you want. I'm in",
"# a store but it doesn't matter that you're not.",
"return",
"True",
"if",
"self",
".",
"store... | Is this object currently valid as a reference? Objects which will be
deleted in this transaction, or objects which are not in the same store
are not valid. See attributes.reference.__get__. | [
"Is",
"this",
"object",
"currently",
"valid",
"as",
"a",
"reference?",
"Objects",
"which",
"will",
"be",
"deleted",
"in",
"this",
"transaction",
"or",
"objects",
"which",
"are",
"not",
"in",
"the",
"same",
"store",
"are",
"not",
"valid",
".",
"See",
"attri... | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L500-L514 |
twisted/axiom | axiom/item.py | Item._schemaPrepareInsert | def _schemaPrepareInsert(self, store):
"""
Prepare each attribute in my schema for insertion into a given store,
either by upgrade or by creation. This makes sure all references point
to this store and all relative paths point to this store's files
directory.
"""
... | python | def _schemaPrepareInsert(self, store):
"""
Prepare each attribute in my schema for insertion into a given store,
either by upgrade or by creation. This makes sure all references point
to this store and all relative paths point to this store's files
directory.
"""
... | [
"def",
"_schemaPrepareInsert",
"(",
"self",
",",
"store",
")",
":",
"for",
"name",
",",
"atr",
"in",
"self",
".",
"getSchema",
"(",
")",
":",
"atr",
".",
"prepareInsert",
"(",
"self",
",",
"store",
")"
] | Prepare each attribute in my schema for insertion into a given store,
either by upgrade or by creation. This makes sure all references point
to this store and all relative paths point to this store's files
directory. | [
"Prepare",
"each",
"attribute",
"in",
"my",
"schema",
"for",
"insertion",
"into",
"a",
"given",
"store",
"either",
"by",
"upgrade",
"or",
"by",
"creation",
".",
"This",
"makes",
"sure",
"all",
"references",
"point",
"to",
"this",
"store",
"and",
"all",
"re... | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L517-L525 |
twisted/axiom | axiom/item.py | Item.existingInStore | def existingInStore(cls, store, storeID, attrs):
"""Create and return a new instance from a row from the store."""
self = cls.__new__(cls)
self.__justCreated = False
self.__subinit__(__store=store,
storeID=storeID,
__everInserted=True)
... | python | def existingInStore(cls, store, storeID, attrs):
"""Create and return a new instance from a row from the store."""
self = cls.__new__(cls)
self.__justCreated = False
self.__subinit__(__store=store,
storeID=storeID,
__everInserted=True)
... | [
"def",
"existingInStore",
"(",
"cls",
",",
"store",
",",
"storeID",
",",
"attrs",
")",
":",
"self",
"=",
"cls",
".",
"__new__",
"(",
"cls",
")",
"self",
".",
"__justCreated",
"=",
"False",
"self",
".",
"__subinit__",
"(",
"__store",
"=",
"store",
",",
... | Create and return a new instance from a row from the store. | [
"Create",
"and",
"return",
"a",
"new",
"instance",
"from",
"a",
"row",
"from",
"the",
"store",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L647-L661 |
twisted/axiom | axiom/item.py | Item.getSchema | def getSchema(cls):
"""
return all persistent class attributes
"""
schema = []
for name, atr in cls.__attributes__:
atr = atr.__get__(None, cls)
if isinstance(atr, SQLAttribute):
schema.append((name, atr))
cls.getSchema = staticmeth... | python | def getSchema(cls):
"""
return all persistent class attributes
"""
schema = []
for name, atr in cls.__attributes__:
atr = atr.__get__(None, cls)
if isinstance(atr, SQLAttribute):
schema.append((name, atr))
cls.getSchema = staticmeth... | [
"def",
"getSchema",
"(",
"cls",
")",
":",
"schema",
"=",
"[",
"]",
"for",
"name",
",",
"atr",
"in",
"cls",
".",
"__attributes__",
":",
"atr",
"=",
"atr",
".",
"__get__",
"(",
"None",
",",
"cls",
")",
"if",
"isinstance",
"(",
"atr",
",",
"SQLAttribu... | return all persistent class attributes | [
"return",
"all",
"persistent",
"class",
"attributes"
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L668-L678 |
twisted/axiom | axiom/item.py | Item.persistentValues | def persistentValues(self):
"""
Return a dictionary of all attributes which will be/have been/are being
stored in the database.
"""
return dict((k, getattr(self, k)) for (k, attr) in self.getSchema()) | python | def persistentValues(self):
"""
Return a dictionary of all attributes which will be/have been/are being
stored in the database.
"""
return dict((k, getattr(self, k)) for (k, attr) in self.getSchema()) | [
"def",
"persistentValues",
"(",
"self",
")",
":",
"return",
"dict",
"(",
"(",
"k",
",",
"getattr",
"(",
"self",
",",
"k",
")",
")",
"for",
"(",
"k",
",",
"attr",
")",
"in",
"self",
".",
"getSchema",
"(",
")",
")"
] | Return a dictionary of all attributes which will be/have been/are being
stored in the database. | [
"Return",
"a",
"dictionary",
"of",
"all",
"attributes",
"which",
"will",
"be",
"/",
"have",
"been",
"/",
"are",
"being",
"stored",
"in",
"the",
"database",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L682-L687 |
twisted/axiom | axiom/item.py | Item.committed | def committed(self):
"""
Called after the database is brought into a consistent state with this
object.
"""
if self.__deleting:
self.deleted()
if not self.__legacy__:
self.store.objectCache.uncache(self.storeID, self)
self._... | python | def committed(self):
"""
Called after the database is brought into a consistent state with this
object.
"""
if self.__deleting:
self.deleted()
if not self.__legacy__:
self.store.objectCache.uncache(self.storeID, self)
self._... | [
"def",
"committed",
"(",
"self",
")",
":",
"if",
"self",
".",
"__deleting",
":",
"self",
".",
"deleted",
"(",
")",
"if",
"not",
"self",
".",
"__legacy__",
":",
"self",
".",
"store",
".",
"objectCache",
".",
"uncache",
"(",
"self",
".",
"storeID",
","... | Called after the database is brought into a consistent state with this
object. | [
"Called",
"after",
"the",
"database",
"is",
"brought",
"into",
"a",
"consistent",
"state",
"with",
"this",
"object",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L731-L741 |
twisted/axiom | axiom/item.py | Item.checkpoint | def checkpoint(self):
"""
Update the database to reflect in-memory changes made to this item; for
example, to make it show up in store.query() calls where it is now
valid, but was not the last time it was persisted to the database.
This is called automatically when in 'autocommi... | python | def checkpoint(self):
"""
Update the database to reflect in-memory changes made to this item; for
example, to make it show up in store.query() calls where it is now
valid, but was not the last time it was persisted to the database.
This is called automatically when in 'autocommi... | [
"def",
"checkpoint",
"(",
"self",
")",
":",
"if",
"self",
".",
"store",
"is",
"None",
":",
"raise",
"NotInStore",
"(",
"\"You can't checkpoint %r: not in a store\"",
"%",
"(",
"self",
",",
")",
")",
"if",
"self",
".",
"__deleting",
":",
"if",
"not",
"self"... | Update the database to reflect in-memory changes made to this item; for
example, to make it show up in store.query() calls where it is now
valid, but was not the last time it was persisted to the database.
This is called automatically when in 'autocommit mode' (i.e. not in a
transaction... | [
"Update",
"the",
"database",
"to",
"reflect",
"in",
"-",
"memory",
"changes",
"made",
"to",
"this",
"item",
";",
"for",
"example",
"to",
"make",
"it",
"show",
"up",
"in",
"store",
".",
"query",
"()",
"calls",
"where",
"it",
"is",
"now",
"valid",
"but",... | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L744-L817 |
twisted/axiom | axiom/upgrade.py | registerUpgrader | def registerUpgrader(upgrader, typeName, oldVersion, newVersion):
"""
Register a callable which can perform a schema upgrade between two
particular versions.
@param upgrader: A one-argument callable which will upgrade an object. It
is invoked with an instance of the old version of the object.
... | python | def registerUpgrader(upgrader, typeName, oldVersion, newVersion):
"""
Register a callable which can perform a schema upgrade between two
particular versions.
@param upgrader: A one-argument callable which will upgrade an object. It
is invoked with an instance of the old version of the object.
... | [
"def",
"registerUpgrader",
"(",
"upgrader",
",",
"typeName",
",",
"oldVersion",
",",
"newVersion",
")",
":",
"# assert (typeName, oldVersion, newVersion) not in _upgradeRegistry, \"duplicate upgrader\"",
"# ^ this makes the tests blow up so it's just disabled for now; perhaps we",
"# sho... | Register a callable which can perform a schema upgrade between two
particular versions.
@param upgrader: A one-argument callable which will upgrade an object. It
is invoked with an instance of the old version of the object.
@param typeName: The database typename for which this is an upgrader.
@par... | [
"Register",
"a",
"callable",
"which",
"can",
"perform",
"a",
"schema",
"upgrade",
"between",
"two",
"particular",
"versions",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/upgrade.py#L187-L204 |
twisted/axiom | axiom/upgrade.py | registerAttributeCopyingUpgrader | def registerAttributeCopyingUpgrader(itemType, fromVersion, toVersion, postCopy=None):
"""
Register an upgrader for C{itemType}, from C{fromVersion} to C{toVersion},
which will copy all attributes from the legacy item to the new item. If
postCopy is provided, it will be called with the new item after u... | python | def registerAttributeCopyingUpgrader(itemType, fromVersion, toVersion, postCopy=None):
"""
Register an upgrader for C{itemType}, from C{fromVersion} to C{toVersion},
which will copy all attributes from the legacy item to the new item. If
postCopy is provided, it will be called with the new item after u... | [
"def",
"registerAttributeCopyingUpgrader",
"(",
"itemType",
",",
"fromVersion",
",",
"toVersion",
",",
"postCopy",
"=",
"None",
")",
":",
"def",
"upgrader",
"(",
"old",
")",
":",
"newitem",
"=",
"old",
".",
"upgradeVersion",
"(",
"itemType",
".",
"typeName",
... | Register an upgrader for C{itemType}, from C{fromVersion} to C{toVersion},
which will copy all attributes from the legacy item to the new item. If
postCopy is provided, it will be called with the new item after upgrading.
@param itemType: L{axiom.item.Item} subclass
@param postCopy: a callable of one ... | [
"Register",
"an",
"upgrader",
"for",
"C",
"{",
"itemType",
"}",
"from",
"C",
"{",
"fromVersion",
"}",
"to",
"C",
"{",
"toVersion",
"}",
"which",
"will",
"copy",
"all",
"attributes",
"from",
"the",
"legacy",
"item",
"to",
"the",
"new",
"item",
".",
"If"... | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/upgrade.py#L206-L223 |
twisted/axiom | axiom/upgrade.py | registerDeletionUpgrader | def registerDeletionUpgrader(itemType, fromVersion, toVersion):
"""
Register an upgrader for C{itemType}, from C{fromVersion} to C{toVersion},
which will delete the item from the database.
@param itemType: L{axiom.item.Item} subclass
@return: None
"""
# XXX This should actually do something... | python | def registerDeletionUpgrader(itemType, fromVersion, toVersion):
"""
Register an upgrader for C{itemType}, from C{fromVersion} to C{toVersion},
which will delete the item from the database.
@param itemType: L{axiom.item.Item} subclass
@return: None
"""
# XXX This should actually do something... | [
"def",
"registerDeletionUpgrader",
"(",
"itemType",
",",
"fromVersion",
",",
"toVersion",
")",
":",
"# XXX This should actually do something more special so that a new table is",
"# not created and such.",
"def",
"upgrader",
"(",
"old",
")",
":",
"old",
".",
"deleteFromStore"... | Register an upgrader for C{itemType}, from C{fromVersion} to C{toVersion},
which will delete the item from the database.
@param itemType: L{axiom.item.Item} subclass
@return: None | [
"Register",
"an",
"upgrader",
"for",
"C",
"{",
"itemType",
"}",
"from",
"C",
"{",
"fromVersion",
"}",
"to",
"C",
"{",
"toVersion",
"}",
"which",
"will",
"delete",
"the",
"item",
"from",
"the",
"database",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/upgrade.py#L226-L239 |
twisted/axiom | axiom/upgrade.py | _hasExplicitOid | def _hasExplicitOid(store, table):
"""
Does the given table have an explicit oid column?
"""
return any(info[1] == 'oid' for info
in store.querySchemaSQL(
'PRAGMA *DATABASE*.table_info({})'.format(table))) | python | def _hasExplicitOid(store, table):
"""
Does the given table have an explicit oid column?
"""
return any(info[1] == 'oid' for info
in store.querySchemaSQL(
'PRAGMA *DATABASE*.table_info({})'.format(table))) | [
"def",
"_hasExplicitOid",
"(",
"store",
",",
"table",
")",
":",
"return",
"any",
"(",
"info",
"[",
"1",
"]",
"==",
"'oid'",
"for",
"info",
"in",
"store",
".",
"querySchemaSQL",
"(",
"'PRAGMA *DATABASE*.table_info({})'",
".",
"format",
"(",
"table",
")",
")... | Does the given table have an explicit oid column? | [
"Does",
"the",
"given",
"table",
"have",
"an",
"explicit",
"oid",
"column?"
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/upgrade.py#L258-L264 |
twisted/axiom | axiom/upgrade.py | _upgradeTableOid | def _upgradeTableOid(store, table, createTable, postCreate=lambda: None):
"""
Upgrade a table to have an explicit oid.
Must be called in a transaction to avoid corrupting the database.
"""
if _hasExplicitOid(store, table):
return
store.executeSchemaSQL(
'ALTER TABLE *DATABASE*.{... | python | def _upgradeTableOid(store, table, createTable, postCreate=lambda: None):
"""
Upgrade a table to have an explicit oid.
Must be called in a transaction to avoid corrupting the database.
"""
if _hasExplicitOid(store, table):
return
store.executeSchemaSQL(
'ALTER TABLE *DATABASE*.{... | [
"def",
"_upgradeTableOid",
"(",
"store",
",",
"table",
",",
"createTable",
",",
"postCreate",
"=",
"lambda",
":",
"None",
")",
":",
"if",
"_hasExplicitOid",
"(",
"store",
",",
"table",
")",
":",
"return",
"store",
".",
"executeSchemaSQL",
"(",
"'ALTER TABLE ... | Upgrade a table to have an explicit oid.
Must be called in a transaction to avoid corrupting the database. | [
"Upgrade",
"a",
"table",
"to",
"have",
"an",
"explicit",
"oid",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/upgrade.py#L268-L283 |
twisted/axiom | axiom/upgrade.py | upgradeSystemOid | def upgradeSystemOid(store):
"""
Upgrade the system tables to use explicit oid columns.
"""
store.transact(
_upgradeTableOid, store, 'axiom_types',
lambda: store.executeSchemaSQL(CREATE_TYPES))
store.transact(
_upgradeTableOid, store, 'axiom_objects',
lambda: store.ex... | python | def upgradeSystemOid(store):
"""
Upgrade the system tables to use explicit oid columns.
"""
store.transact(
_upgradeTableOid, store, 'axiom_types',
lambda: store.executeSchemaSQL(CREATE_TYPES))
store.transact(
_upgradeTableOid, store, 'axiom_objects',
lambda: store.ex... | [
"def",
"upgradeSystemOid",
"(",
"store",
")",
":",
"store",
".",
"transact",
"(",
"_upgradeTableOid",
",",
"store",
",",
"'axiom_types'",
",",
"lambda",
":",
"store",
".",
"executeSchemaSQL",
"(",
"CREATE_TYPES",
")",
")",
"store",
".",
"transact",
"(",
"_up... | Upgrade the system tables to use explicit oid columns. | [
"Upgrade",
"the",
"system",
"tables",
"to",
"use",
"explicit",
"oid",
"columns",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/upgrade.py#L287-L297 |
twisted/axiom | axiom/upgrade.py | upgradeExplicitOid | def upgradeExplicitOid(store):
"""
Upgrade a store to use explicit oid columns.
This allows VACUUMing the database without corrupting it.
This requires copying all of axiom_objects and axiom_types, as well as all
item tables that have not yet been upgraded. Consider VACUUMing the
database... | python | def upgradeExplicitOid(store):
"""
Upgrade a store to use explicit oid columns.
This allows VACUUMing the database without corrupting it.
This requires copying all of axiom_objects and axiom_types, as well as all
item tables that have not yet been upgraded. Consider VACUUMing the
database... | [
"def",
"upgradeExplicitOid",
"(",
"store",
")",
":",
"upgradeSystemOid",
"(",
"store",
")",
"for",
"typename",
",",
"version",
"in",
"store",
".",
"querySchemaSQL",
"(",
"LATEST_TYPES",
")",
":",
"cls",
"=",
"_typeNameToMostRecentClass",
"[",
"typename",
"]",
... | Upgrade a store to use explicit oid columns.
This allows VACUUMing the database without corrupting it.
This requires copying all of axiom_objects and axiom_types, as well as all
item tables that have not yet been upgraded. Consider VACUUMing the
database afterwards to reclaim space. | [
"Upgrade",
"a",
"store",
"to",
"use",
"explicit",
"oid",
"columns",
".",
"This",
"allows",
"VACUUMing",
"the",
"database",
"without",
"corrupting",
"it",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/upgrade.py#L301-L330 |
twisted/axiom | axiom/upgrade.py | _StoreUpgrade.checkUpgradePaths | def checkUpgradePaths(self):
"""
Check that all of the accumulated old Item types have a way to get
from their current version to the latest version.
@raise axiom.errors.NoUpgradePathAvailable: for any, and all, Items
that do not have a valid upgrade path
"""
... | python | def checkUpgradePaths(self):
"""
Check that all of the accumulated old Item types have a way to get
from their current version to the latest version.
@raise axiom.errors.NoUpgradePathAvailable: for any, and all, Items
that do not have a valid upgrade path
"""
... | [
"def",
"checkUpgradePaths",
"(",
"self",
")",
":",
"cantUpgradeErrors",
"=",
"[",
"]",
"for",
"oldVersion",
"in",
"self",
".",
"_oldTypesRemaining",
":",
"# We have to be able to get from oldVersion.schemaVersion to",
"# the most recent type.",
"currentType",
"=",
"_typeNam... | Check that all of the accumulated old Item types have a way to get
from their current version to the latest version.
@raise axiom.errors.NoUpgradePathAvailable: for any, and all, Items
that do not have a valid upgrade path | [
"Check",
"that",
"all",
"of",
"the",
"accumulated",
"old",
"Item",
"types",
"have",
"a",
"way",
"to",
"get",
"from",
"their",
"current",
"version",
"to",
"the",
"latest",
"version",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/upgrade.py#L51-L96 |
twisted/axiom | axiom/upgrade.py | _StoreUpgrade.queueTypeUpgrade | def queueTypeUpgrade(self, oldtype):
"""
Queue a type upgrade for C{oldtype}.
"""
if oldtype not in self._oldTypesRemaining:
self._oldTypesRemaining.append(oldtype) | python | def queueTypeUpgrade(self, oldtype):
"""
Queue a type upgrade for C{oldtype}.
"""
if oldtype not in self._oldTypesRemaining:
self._oldTypesRemaining.append(oldtype) | [
"def",
"queueTypeUpgrade",
"(",
"self",
",",
"oldtype",
")",
":",
"if",
"oldtype",
"not",
"in",
"self",
".",
"_oldTypesRemaining",
":",
"self",
".",
"_oldTypesRemaining",
".",
"append",
"(",
"oldtype",
")"
] | Queue a type upgrade for C{oldtype}. | [
"Queue",
"a",
"type",
"upgrade",
"for",
"C",
"{",
"oldtype",
"}",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/upgrade.py#L99-L104 |
twisted/axiom | axiom/upgrade.py | _StoreUpgrade.upgradeItem | def upgradeItem(self, thisItem):
"""
Upgrade a legacy item.
@raise axiom.errors.UpgraderRecursion: If the given item is already in
the process of being upgraded.
"""
sid = thisItem.storeID
if sid in self._currentlyUpgrading:
raise UpgraderRecursio... | python | def upgradeItem(self, thisItem):
"""
Upgrade a legacy item.
@raise axiom.errors.UpgraderRecursion: If the given item is already in
the process of being upgraded.
"""
sid = thisItem.storeID
if sid in self._currentlyUpgrading:
raise UpgraderRecursio... | [
"def",
"upgradeItem",
"(",
"self",
",",
"thisItem",
")",
":",
"sid",
"=",
"thisItem",
".",
"storeID",
"if",
"sid",
"in",
"self",
".",
"_currentlyUpgrading",
":",
"raise",
"UpgraderRecursion",
"(",
")",
"self",
".",
"_currentlyUpgrading",
"[",
"sid",
"]",
"... | Upgrade a legacy item.
@raise axiom.errors.UpgraderRecursion: If the given item is already in
the process of being upgraded. | [
"Upgrade",
"a",
"legacy",
"item",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/upgrade.py#L107-L121 |
twisted/axiom | axiom/upgrade.py | _StoreUpgrade.upgradeBatch | def upgradeBatch(self, n):
"""
Upgrade the entire store in batches, yielding after each batch.
@param n: Number of upgrades to perform per transaction
@type n: C{int}
@raise axiom.errors.ItemUpgradeError: if an item upgrade failed
@return: A generator that yields after... | python | def upgradeBatch(self, n):
"""
Upgrade the entire store in batches, yielding after each batch.
@param n: Number of upgrades to perform per transaction
@type n: C{int}
@raise axiom.errors.ItemUpgradeError: if an item upgrade failed
@return: A generator that yields after... | [
"def",
"upgradeBatch",
"(",
"self",
",",
"n",
")",
":",
"store",
"=",
"self",
".",
"store",
"def",
"_doBatch",
"(",
"itemType",
")",
":",
"upgradedAnything",
"=",
"False",
"for",
"theItem",
"in",
"store",
".",
"query",
"(",
"itemType",
",",
"limit",
"=... | Upgrade the entire store in batches, yielding after each batch.
@param n: Number of upgrades to perform per transaction
@type n: C{int}
@raise axiom.errors.ItemUpgradeError: if an item upgrade failed
@return: A generator that yields after each batch upgrade. This needs
to ... | [
"Upgrade",
"the",
"entire",
"store",
"in",
"batches",
"yielding",
"after",
"each",
"batch",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/upgrade.py#L135-L183 |
xzased/lvm2py | lvm2py/lv.py | LogicalVolume.open | def open(self):
"""
Obtains the lvm, vg_t and lv_t handle. Usually you would never need to use this
method unless you are doing operations using the ctypes function wrappers in
conversion.py
*Raises:*
* HandleError
"""
self.vg.open()
self._... | python | def open(self):
"""
Obtains the lvm, vg_t and lv_t handle. Usually you would never need to use this
method unless you are doing operations using the ctypes function wrappers in
conversion.py
*Raises:*
* HandleError
"""
self.vg.open()
self._... | [
"def",
"open",
"(",
"self",
")",
":",
"self",
".",
"vg",
".",
"open",
"(",
")",
"self",
".",
"__lvh",
"=",
"lvm_lv_from_uuid",
"(",
"self",
".",
"vg",
".",
"handle",
",",
"self",
".",
"uuid",
")",
"if",
"not",
"bool",
"(",
"self",
".",
"__lvh",
... | Obtains the lvm, vg_t and lv_t handle. Usually you would never need to use this
method unless you are doing operations using the ctypes function wrappers in
conversion.py
*Raises:*
* HandleError | [
"Obtains",
"the",
"lvm",
"vg_t",
"and",
"lv_t",
"handle",
".",
"Usually",
"you",
"would",
"never",
"need",
"to",
"use",
"this",
"method",
"unless",
"you",
"are",
"doing",
"operations",
"using",
"the",
"ctypes",
"function",
"wrappers",
"in",
"conversion",
"."... | train | https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/lv.py#L65-L78 |
xzased/lvm2py | lvm2py/lv.py | LogicalVolume.name | def name(self):
"""
Returns the logical volume name.
"""
self.open()
name = lvm_lv_get_name(self.__lvh)
self.close()
return name | python | def name(self):
"""
Returns the logical volume name.
"""
self.open()
name = lvm_lv_get_name(self.__lvh)
self.close()
return name | [
"def",
"name",
"(",
"self",
")",
":",
"self",
".",
"open",
"(",
")",
"name",
"=",
"lvm_lv_get_name",
"(",
"self",
".",
"__lvh",
")",
"self",
".",
"close",
"(",
")",
"return",
"name"
] | Returns the logical volume name. | [
"Returns",
"the",
"logical",
"volume",
"name",
"."
] | train | https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/lv.py#L107-L114 |
xzased/lvm2py | lvm2py/lv.py | LogicalVolume.is_active | def is_active(self):
"""
Returns True if the logical volume is active, False otherwise.
"""
self.open()
active = lvm_lv_is_active(self.__lvh)
self.close()
return bool(active) | python | def is_active(self):
"""
Returns True if the logical volume is active, False otherwise.
"""
self.open()
active = lvm_lv_is_active(self.__lvh)
self.close()
return bool(active) | [
"def",
"is_active",
"(",
"self",
")",
":",
"self",
".",
"open",
"(",
")",
"active",
"=",
"lvm_lv_is_active",
"(",
"self",
".",
"__lvh",
")",
"self",
".",
"close",
"(",
")",
"return",
"bool",
"(",
"active",
")"
] | Returns True if the logical volume is active, False otherwise. | [
"Returns",
"True",
"if",
"the",
"logical",
"volume",
"is",
"active",
"False",
"otherwise",
"."
] | train | https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/lv.py#L124-L131 |
xzased/lvm2py | lvm2py/lv.py | LogicalVolume.is_suspended | def is_suspended(self):
"""
Returns True if the logical volume is suspended, False otherwise.
"""
self.open()
susp = lvm_lv_is_suspended(self.__lvh)
self.close()
return bool(susp) | python | def is_suspended(self):
"""
Returns True if the logical volume is suspended, False otherwise.
"""
self.open()
susp = lvm_lv_is_suspended(self.__lvh)
self.close()
return bool(susp) | [
"def",
"is_suspended",
"(",
"self",
")",
":",
"self",
".",
"open",
"(",
")",
"susp",
"=",
"lvm_lv_is_suspended",
"(",
"self",
".",
"__lvh",
")",
"self",
".",
"close",
"(",
")",
"return",
"bool",
"(",
"susp",
")"
] | Returns True if the logical volume is suspended, False otherwise. | [
"Returns",
"True",
"if",
"the",
"logical",
"volume",
"is",
"suspended",
"False",
"otherwise",
"."
] | train | https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/lv.py#L134-L141 |
xzased/lvm2py | lvm2py/lv.py | LogicalVolume.size | def size(self, units="MiB"):
"""
Returns the logical volume size in the given units. Default units are MiB.
*Args:*
* units (str): Unit label ('MiB', 'GiB', etc...). Default is MiB.
"""
self.open()
size = lvm_lv_get_size(self.__lvh)
self.close(... | python | def size(self, units="MiB"):
"""
Returns the logical volume size in the given units. Default units are MiB.
*Args:*
* units (str): Unit label ('MiB', 'GiB', etc...). Default is MiB.
"""
self.open()
size = lvm_lv_get_size(self.__lvh)
self.close(... | [
"def",
"size",
"(",
"self",
",",
"units",
"=",
"\"MiB\"",
")",
":",
"self",
".",
"open",
"(",
")",
"size",
"=",
"lvm_lv_get_size",
"(",
"self",
".",
"__lvh",
")",
"self",
".",
"close",
"(",
")",
"return",
"size_convert",
"(",
"size",
",",
"units",
... | Returns the logical volume size in the given units. Default units are MiB.
*Args:*
* units (str): Unit label ('MiB', 'GiB', etc...). Default is MiB. | [
"Returns",
"the",
"logical",
"volume",
"size",
"in",
"the",
"given",
"units",
".",
"Default",
"units",
"are",
"MiB",
"."
] | train | https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/lv.py#L143-L154 |
xzased/lvm2py | lvm2py/lv.py | LogicalVolume.activate | def activate(self):
"""
Activates the logical volume.
*Raises:*
* HandleError
"""
self.open()
a = lvm_lv_activate(self.handle)
self.close()
if a != 0:
raise CommitError("Failed to activate LV.") | python | def activate(self):
"""
Activates the logical volume.
*Raises:*
* HandleError
"""
self.open()
a = lvm_lv_activate(self.handle)
self.close()
if a != 0:
raise CommitError("Failed to activate LV.") | [
"def",
"activate",
"(",
"self",
")",
":",
"self",
".",
"open",
"(",
")",
"a",
"=",
"lvm_lv_activate",
"(",
"self",
".",
"handle",
")",
"self",
".",
"close",
"(",
")",
"if",
"a",
"!=",
"0",
":",
"raise",
"CommitError",
"(",
"\"Failed to activate LV.\"",... | Activates the logical volume.
*Raises:*
* HandleError | [
"Activates",
"the",
"logical",
"volume",
"."
] | train | https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/lv.py#L156-L168 |
xzased/lvm2py | lvm2py/lv.py | LogicalVolume.deactivate | def deactivate(self):
"""
Deactivates the logical volume.
*Raises:*
* HandleError
"""
self.open()
d = lvm_lv_deactivate(self.handle)
self.close()
if d != 0:
raise CommitError("Failed to deactivate LV.") | python | def deactivate(self):
"""
Deactivates the logical volume.
*Raises:*
* HandleError
"""
self.open()
d = lvm_lv_deactivate(self.handle)
self.close()
if d != 0:
raise CommitError("Failed to deactivate LV.") | [
"def",
"deactivate",
"(",
"self",
")",
":",
"self",
".",
"open",
"(",
")",
"d",
"=",
"lvm_lv_deactivate",
"(",
"self",
".",
"handle",
")",
"self",
".",
"close",
"(",
")",
"if",
"d",
"!=",
"0",
":",
"raise",
"CommitError",
"(",
"\"Failed to deactivate L... | Deactivates the logical volume.
*Raises:*
* HandleError | [
"Deactivates",
"the",
"logical",
"volume",
"."
] | train | https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/lv.py#L170-L182 |
xzased/lvm2py | lvm2py/pv.py | PhysicalVolume.open | def open(self):
"""
Obtains the lvm, vg_t and pv_t handle. Usually you would never need to use this
method unless you are doing operations using the ctypes function wrappers in
conversion.py
*Raises:*
* HandleError
"""
self.vg.open()
self._... | python | def open(self):
"""
Obtains the lvm, vg_t and pv_t handle. Usually you would never need to use this
method unless you are doing operations using the ctypes function wrappers in
conversion.py
*Raises:*
* HandleError
"""
self.vg.open()
self._... | [
"def",
"open",
"(",
"self",
")",
":",
"self",
".",
"vg",
".",
"open",
"(",
")",
"self",
".",
"__pvh",
"=",
"lvm_pv_from_uuid",
"(",
"self",
".",
"vg",
".",
"handle",
",",
"self",
".",
"uuid",
")",
"if",
"not",
"bool",
"(",
"self",
".",
"__pvh",
... | Obtains the lvm, vg_t and pv_t handle. Usually you would never need to use this
method unless you are doing operations using the ctypes function wrappers in
conversion.py
*Raises:*
* HandleError | [
"Obtains",
"the",
"lvm",
"vg_t",
"and",
"pv_t",
"handle",
".",
"Usually",
"you",
"would",
"never",
"need",
"to",
"use",
"this",
"method",
"unless",
"you",
"are",
"doing",
"operations",
"using",
"the",
"ctypes",
"function",
"wrappers",
"in",
"conversion",
"."... | train | https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/pv.py#L69-L82 |
xzased/lvm2py | lvm2py/pv.py | PhysicalVolume.name | def name(self):
"""
Returns the physical volume device path.
"""
self.open()
name = lvm_pv_get_name(self.handle)
self.close()
return name | python | def name(self):
"""
Returns the physical volume device path.
"""
self.open()
name = lvm_pv_get_name(self.handle)
self.close()
return name | [
"def",
"name",
"(",
"self",
")",
":",
"self",
".",
"open",
"(",
")",
"name",
"=",
"lvm_pv_get_name",
"(",
"self",
".",
"handle",
")",
"self",
".",
"close",
"(",
")",
"return",
"name"
] | Returns the physical volume device path. | [
"Returns",
"the",
"physical",
"volume",
"device",
"path",
"."
] | train | https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/pv.py#L111-L118 |
xzased/lvm2py | lvm2py/pv.py | PhysicalVolume.mda_count | def mda_count(self):
"""
Returns the physical volume mda count.
"""
self.open()
mda = lvm_pv_get_mda_count(self.handle)
self.close()
return mda | python | def mda_count(self):
"""
Returns the physical volume mda count.
"""
self.open()
mda = lvm_pv_get_mda_count(self.handle)
self.close()
return mda | [
"def",
"mda_count",
"(",
"self",
")",
":",
"self",
".",
"open",
"(",
")",
"mda",
"=",
"lvm_pv_get_mda_count",
"(",
"self",
".",
"handle",
")",
"self",
".",
"close",
"(",
")",
"return",
"mda"
] | Returns the physical volume mda count. | [
"Returns",
"the",
"physical",
"volume",
"mda",
"count",
"."
] | train | https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/pv.py#L128-L135 |
xzased/lvm2py | lvm2py/pv.py | PhysicalVolume.size | def size(self, units="MiB"):
"""
Returns the physical volume size in the given units. Default units are MiB.
*Args:*
* units (str): Unit label ('MiB', 'GiB', etc...). Default is MiB.
"""
self.open()
size = lvm_pv_get_size(self.handle)
self.clos... | python | def size(self, units="MiB"):
"""
Returns the physical volume size in the given units. Default units are MiB.
*Args:*
* units (str): Unit label ('MiB', 'GiB', etc...). Default is MiB.
"""
self.open()
size = lvm_pv_get_size(self.handle)
self.clos... | [
"def",
"size",
"(",
"self",
",",
"units",
"=",
"\"MiB\"",
")",
":",
"self",
".",
"open",
"(",
")",
"size",
"=",
"lvm_pv_get_size",
"(",
"self",
".",
"handle",
")",
"self",
".",
"close",
"(",
")",
"return",
"size_convert",
"(",
"size",
",",
"units",
... | Returns the physical volume size in the given units. Default units are MiB.
*Args:*
* units (str): Unit label ('MiB', 'GiB', etc...). Default is MiB. | [
"Returns",
"the",
"physical",
"volume",
"size",
"in",
"the",
"given",
"units",
".",
"Default",
"units",
"are",
"MiB",
"."
] | train | https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/pv.py#L137-L148 |
xzased/lvm2py | lvm2py/pv.py | PhysicalVolume.dev_size | def dev_size(self, units="MiB"):
"""
Returns the device size in the given units. Default units are MiB.
*Args:*
* units (str): Unit label ('MiB', 'GiB', etc...). Default is MiB.
"""
self.open()
size = lvm_pv_get_dev_size(self.handle)
self.close... | python | def dev_size(self, units="MiB"):
"""
Returns the device size in the given units. Default units are MiB.
*Args:*
* units (str): Unit label ('MiB', 'GiB', etc...). Default is MiB.
"""
self.open()
size = lvm_pv_get_dev_size(self.handle)
self.close... | [
"def",
"dev_size",
"(",
"self",
",",
"units",
"=",
"\"MiB\"",
")",
":",
"self",
".",
"open",
"(",
")",
"size",
"=",
"lvm_pv_get_dev_size",
"(",
"self",
".",
"handle",
")",
"self",
".",
"close",
"(",
")",
"return",
"size_convert",
"(",
"size",
",",
"u... | Returns the device size in the given units. Default units are MiB.
*Args:*
* units (str): Unit label ('MiB', 'GiB', etc...). Default is MiB. | [
"Returns",
"the",
"device",
"size",
"in",
"the",
"given",
"units",
".",
"Default",
"units",
"are",
"MiB",
"."
] | train | https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/pv.py#L150-L161 |
xzased/lvm2py | lvm2py/pv.py | PhysicalVolume.free | def free(self, units="MiB"):
"""
Returns the free size in the given units. Default units are MiB.
*Args:*
* units (str): Unit label ('MiB', 'GiB', etc...). Default is MiB.
"""
self.open()
size = lvm_pv_get_free(self.handle)
self.close()
... | python | def free(self, units="MiB"):
"""
Returns the free size in the given units. Default units are MiB.
*Args:*
* units (str): Unit label ('MiB', 'GiB', etc...). Default is MiB.
"""
self.open()
size = lvm_pv_get_free(self.handle)
self.close()
... | [
"def",
"free",
"(",
"self",
",",
"units",
"=",
"\"MiB\"",
")",
":",
"self",
".",
"open",
"(",
")",
"size",
"=",
"lvm_pv_get_free",
"(",
"self",
".",
"handle",
")",
"self",
".",
"close",
"(",
")",
"return",
"size_convert",
"(",
"size",
",",
"units",
... | Returns the free size in the given units. Default units are MiB.
*Args:*
* units (str): Unit label ('MiB', 'GiB', etc...). Default is MiB. | [
"Returns",
"the",
"free",
"size",
"in",
"the",
"given",
"units",
".",
"Default",
"units",
"are",
"MiB",
"."
] | train | https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/pv.py#L163-L174 |
stephrdev/django-mongoforms | mongoforms/utils.py | mongoengine_validate_wrapper | def mongoengine_validate_wrapper(old_clean, new_clean):
"""
A wrapper function to validate formdata against mongoengine-field
validator and raise a proper django.forms ValidationError if there
are any problems.
"""
def inner_validate(value):
value = old_clean(value)
try:
... | python | def mongoengine_validate_wrapper(old_clean, new_clean):
"""
A wrapper function to validate formdata against mongoengine-field
validator and raise a proper django.forms ValidationError if there
are any problems.
"""
def inner_validate(value):
value = old_clean(value)
try:
... | [
"def",
"mongoengine_validate_wrapper",
"(",
"old_clean",
",",
"new_clean",
")",
":",
"def",
"inner_validate",
"(",
"value",
")",
":",
"value",
"=",
"old_clean",
"(",
"value",
")",
"try",
":",
"new_clean",
"(",
"value",
")",
"return",
"value",
"except",
"Vali... | A wrapper function to validate formdata against mongoengine-field
validator and raise a proper django.forms ValidationError if there
are any problems. | [
"A",
"wrapper",
"function",
"to",
"validate",
"formdata",
"against",
"mongoengine",
"-",
"field",
"validator",
"and",
"raise",
"a",
"proper",
"django",
".",
"forms",
"ValidationError",
"if",
"there",
"are",
"any",
"problems",
"."
] | train | https://github.com/stephrdev/django-mongoforms/blob/6fa46824c438555c703f293d682ca92710938985/mongoforms/utils.py#L5-L19 |
stephrdev/django-mongoforms | mongoforms/utils.py | iter_valid_fields | def iter_valid_fields(meta):
"""walk through the available valid fields.."""
# fetch field configuration and always add the id_field as exclude
meta_fields = getattr(meta, 'fields', ())
meta_exclude = getattr(meta, 'exclude', ())
meta_exclude += (meta.document._meta.get('id_field'),)
# walk th... | python | def iter_valid_fields(meta):
"""walk through the available valid fields.."""
# fetch field configuration and always add the id_field as exclude
meta_fields = getattr(meta, 'fields', ())
meta_exclude = getattr(meta, 'exclude', ())
meta_exclude += (meta.document._meta.get('id_field'),)
# walk th... | [
"def",
"iter_valid_fields",
"(",
"meta",
")",
":",
"# fetch field configuration and always add the id_field as exclude",
"meta_fields",
"=",
"getattr",
"(",
"meta",
",",
"'fields'",
",",
"(",
")",
")",
"meta_exclude",
"=",
"getattr",
"(",
"meta",
",",
"'exclude'",
"... | walk through the available valid fields.. | [
"walk",
"through",
"the",
"available",
"valid",
"fields",
".."
] | train | https://github.com/stephrdev/django-mongoforms/blob/6fa46824c438555c703f293d682ca92710938985/mongoforms/utils.py#L22-L41 |
twisted/axiom | axiom/dependency.py | dependsOn | def dependsOn(itemType, itemCustomizer=None, doc='',
indexed=True, whenDeleted=reference.NULLIFY):
"""
This function behaves like L{axiom.attributes.reference} but with
an extra behaviour: when this item is installed (via
L{axiom.dependency.installOn} on a target item, the
type named h... | python | def dependsOn(itemType, itemCustomizer=None, doc='',
indexed=True, whenDeleted=reference.NULLIFY):
"""
This function behaves like L{axiom.attributes.reference} but with
an extra behaviour: when this item is installed (via
L{axiom.dependency.installOn} on a target item, the
type named h... | [
"def",
"dependsOn",
"(",
"itemType",
",",
"itemCustomizer",
"=",
"None",
",",
"doc",
"=",
"''",
",",
"indexed",
"=",
"True",
",",
"whenDeleted",
"=",
"reference",
".",
"NULLIFY",
")",
":",
"frame",
"=",
"sys",
".",
"_getframe",
"(",
"1",
")",
"locals",... | This function behaves like L{axiom.attributes.reference} but with
an extra behaviour: when this item is installed (via
L{axiom.dependency.installOn} on a target item, the
type named here will be instantiated and installed on the target
as well.
For example::
class Foo(Item):
counte... | [
"This",
"function",
"behaves",
"like",
"L",
"{",
"axiom",
".",
"attributes",
".",
"reference",
"}",
"but",
"with",
"an",
"extra",
"behaviour",
":",
"when",
"this",
"item",
"is",
"installed",
"(",
"via",
"L",
"{",
"axiom",
".",
"dependency",
".",
"install... | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/dependency.py#L29-L64 |
twisted/axiom | axiom/dependency.py | uninstallFrom | def uninstallFrom(self, target):
"""
Remove this object from the target, as well as any dependencies
that it automatically installed which were not explicitly
"pinned" by calling "install", and raising an exception if
anything still depends on this.
"""
#did this class powerup on any interf... | python | def uninstallFrom(self, target):
"""
Remove this object from the target, as well as any dependencies
that it automatically installed which were not explicitly
"pinned" by calling "install", and raising an exception if
anything still depends on this.
"""
#did this class powerup on any interf... | [
"def",
"uninstallFrom",
"(",
"self",
",",
"target",
")",
":",
"#did this class powerup on any interfaces? powerdown if so.",
"target",
".",
"powerDown",
"(",
"self",
")",
"for",
"dc",
"in",
"self",
".",
"store",
".",
"query",
"(",
"_DependencyConnector",
",",
"_De... | Remove this object from the target, as well as any dependencies
that it automatically installed which were not explicitly
"pinned" by calling "install", and raising an exception if
anything still depends on this. | [
"Remove",
"this",
"object",
"from",
"the",
"target",
"as",
"well",
"as",
"any",
"dependencies",
"that",
"it",
"automatically",
"installed",
"which",
"were",
"not",
"explicitly",
"pinned",
"by",
"calling",
"install",
"and",
"raising",
"an",
"exception",
"if",
"... | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/dependency.py#L150-L172 |
twisted/axiom | axiom/dependency.py | installedOn | def installedOn(self):
"""
If this item is installed on another item, return the install
target. Otherwise return None.
"""
try:
return self.store.findUnique(_DependencyConnector,
_DependencyConnector.installee == self
... | python | def installedOn(self):
"""
If this item is installed on another item, return the install
target. Otherwise return None.
"""
try:
return self.store.findUnique(_DependencyConnector,
_DependencyConnector.installee == self
... | [
"def",
"installedOn",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"store",
".",
"findUnique",
"(",
"_DependencyConnector",
",",
"_DependencyConnector",
".",
"installee",
"==",
"self",
")",
".",
"target",
"except",
"ItemNotFound",
":",
"return",
... | If this item is installed on another item, return the install
target. Otherwise return None. | [
"If",
"this",
"item",
"is",
"installed",
"on",
"another",
"item",
"return",
"the",
"install",
"target",
".",
"Otherwise",
"return",
"None",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/dependency.py#L174-L184 |
twisted/axiom | axiom/dependency.py | installedDependents | def installedDependents(self, target):
"""
Return an iterable of things installed on the target that
require this item.
"""
for dc in self.store.query(_DependencyConnector,
_DependencyConnector.target == target):
depends = dependentsOf(dc.installee.__class__)
... | python | def installedDependents(self, target):
"""
Return an iterable of things installed on the target that
require this item.
"""
for dc in self.store.query(_DependencyConnector,
_DependencyConnector.target == target):
depends = dependentsOf(dc.installee.__class__)
... | [
"def",
"installedDependents",
"(",
"self",
",",
"target",
")",
":",
"for",
"dc",
"in",
"self",
".",
"store",
".",
"query",
"(",
"_DependencyConnector",
",",
"_DependencyConnector",
".",
"target",
"==",
"target",
")",
":",
"depends",
"=",
"dependentsOf",
"(",... | Return an iterable of things installed on the target that
require this item. | [
"Return",
"an",
"iterable",
"of",
"things",
"installed",
"on",
"the",
"target",
"that",
"require",
"this",
"item",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/dependency.py#L187-L196 |
twisted/axiom | axiom/dependency.py | installedUniqueRequirements | def installedUniqueRequirements(self, target):
"""
Return an iterable of things installed on the target that this item
requires and are not required by anything else.
"""
myDepends = dependentsOf(self.__class__)
#XXX optimize?
for dc in self.store.query(_DependencyConnector,
... | python | def installedUniqueRequirements(self, target):
"""
Return an iterable of things installed on the target that this item
requires and are not required by anything else.
"""
myDepends = dependentsOf(self.__class__)
#XXX optimize?
for dc in self.store.query(_DependencyConnector,
... | [
"def",
"installedUniqueRequirements",
"(",
"self",
",",
"target",
")",
":",
"myDepends",
"=",
"dependentsOf",
"(",
"self",
".",
"__class__",
")",
"#XXX optimize?",
"for",
"dc",
"in",
"self",
".",
"store",
".",
"query",
"(",
"_DependencyConnector",
",",
"_Depen... | Return an iterable of things installed on the target that this item
requires and are not required by anything else. | [
"Return",
"an",
"iterable",
"of",
"things",
"installed",
"on",
"the",
"target",
"that",
"this",
"item",
"requires",
"and",
"are",
"not",
"required",
"by",
"anything",
"else",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/dependency.py#L198-L227 |
twisted/axiom | axiom/dependency.py | installedRequirements | def installedRequirements(self, target):
"""
Return an iterable of things installed on the target that this
item requires.
"""
myDepends = dependentsOf(self.__class__)
for dc in self.store.query(_DependencyConnector,
_DependencyConnector.target == target):
... | python | def installedRequirements(self, target):
"""
Return an iterable of things installed on the target that this
item requires.
"""
myDepends = dependentsOf(self.__class__)
for dc in self.store.query(_DependencyConnector,
_DependencyConnector.target == target):
... | [
"def",
"installedRequirements",
"(",
"self",
",",
"target",
")",
":",
"myDepends",
"=",
"dependentsOf",
"(",
"self",
".",
"__class__",
")",
"for",
"dc",
"in",
"self",
".",
"store",
".",
"query",
"(",
"_DependencyConnector",
",",
"_DependencyConnector",
".",
... | Return an iterable of things installed on the target that this
item requires. | [
"Return",
"an",
"iterable",
"of",
"things",
"installed",
"on",
"the",
"target",
"that",
"this",
"item",
"requires",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/dependency.py#L229-L238 |
twisted/axiom | axiom/store.py | storeServiceSpecialCase | def storeServiceSpecialCase(st, pups):
"""
Adapt a store to L{IServiceCollection}.
@param st: The L{Store} to adapt.
@param pups: A list of L{IServiceCollection} powerups on C{st}.
@return: An L{IServiceCollection} which has all of C{pups} as children.
"""
if st.parent is not None:
... | python | def storeServiceSpecialCase(st, pups):
"""
Adapt a store to L{IServiceCollection}.
@param st: The L{Store} to adapt.
@param pups: A list of L{IServiceCollection} powerups on C{st}.
@return: An L{IServiceCollection} which has all of C{pups} as children.
"""
if st.parent is not None:
... | [
"def",
"storeServiceSpecialCase",
"(",
"st",
",",
"pups",
")",
":",
"if",
"st",
".",
"parent",
"is",
"not",
"None",
":",
"# If for some bizarre reason we're starting a substore's service, let's",
"# just assume that its parent is running its upgraders, rather than",
"# risk start... | Adapt a store to L{IServiceCollection}.
@param st: The L{Store} to adapt.
@param pups: A list of L{IServiceCollection} powerups on C{st}.
@return: An L{IServiceCollection} which has all of C{pups} as children. | [
"Adapt",
"a",
"store",
"to",
"L",
"{",
"IServiceCollection",
"}",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L112-L148 |
twisted/axiom | axiom/store.py | _schedulerServiceSpecialCase | def _schedulerServiceSpecialCase(empowered, pups):
"""
This function creates (or returns a previously created) L{IScheduler}
powerup.
If L{IScheduler} powerups were found on C{empowered}, the first of those
is given priority. Otherwise, a site L{Store} or a user L{Store} will
have any pre-exis... | python | def _schedulerServiceSpecialCase(empowered, pups):
"""
This function creates (or returns a previously created) L{IScheduler}
powerup.
If L{IScheduler} powerups were found on C{empowered}, the first of those
is given priority. Otherwise, a site L{Store} or a user L{Store} will
have any pre-exis... | [
"def",
"_schedulerServiceSpecialCase",
"(",
"empowered",
",",
"pups",
")",
":",
"from",
"axiom",
".",
"scheduler",
"import",
"_SiteScheduler",
",",
"_UserScheduler",
"# Give precedence to anything found in the store",
"for",
"pup",
"in",
"pups",
":",
"return",
"pup",
... | This function creates (or returns a previously created) L{IScheduler}
powerup.
If L{IScheduler} powerups were found on C{empowered}, the first of those
is given priority. Otherwise, a site L{Store} or a user L{Store} will
have any pre-existing L{IScheduler} powerup associated with them (on the
hac... | [
"This",
"function",
"creates",
"(",
"or",
"returns",
"a",
"previously",
"created",
")",
"L",
"{",
"IScheduler",
"}",
"powerup",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L981-L1006 |
twisted/axiom | axiom/store.py | _diffSchema | def _diffSchema(diskSchema, memorySchema):
"""
Format a schema mismatch for human consumption.
@param diskSchema: The on-disk schema.
@param memorySchema: The in-memory schema.
@rtype: L{bytes}
@return: A description of the schema differences.
"""
diskSchema = set(diskSchema)
memo... | python | def _diffSchema(diskSchema, memorySchema):
"""
Format a schema mismatch for human consumption.
@param diskSchema: The on-disk schema.
@param memorySchema: The in-memory schema.
@rtype: L{bytes}
@return: A description of the schema differences.
"""
diskSchema = set(diskSchema)
memo... | [
"def",
"_diffSchema",
"(",
"diskSchema",
",",
"memorySchema",
")",
":",
"diskSchema",
"=",
"set",
"(",
"diskSchema",
")",
"memorySchema",
"=",
"set",
"(",
"memorySchema",
")",
"diskOnly",
"=",
"diskSchema",
"-",
"memorySchema",
"memoryOnly",
"=",
"memorySchema",... | Format a schema mismatch for human consumption.
@param diskSchema: The on-disk schema.
@param memorySchema: The in-memory schema.
@rtype: L{bytes}
@return: A description of the schema differences. | [
"Format",
"a",
"schema",
"mismatch",
"for",
"human",
"consumption",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L1010-L1032 |
twisted/axiom | axiom/store.py | AtomicFile.close | def close(self):
"""
Close this file and commit it to its permanent location.
@return: a Deferred which fires when the file has been moved (and
backed up to tertiary storage, if necessary).
"""
now = time.time()
try:
file.close(self)
_mkdi... | python | def close(self):
"""
Close this file and commit it to its permanent location.
@return: a Deferred which fires when the file has been moved (and
backed up to tertiary storage, if necessary).
"""
now = time.time()
try:
file.close(self)
_mkdi... | [
"def",
"close",
"(",
"self",
")",
":",
"now",
"=",
"time",
".",
"time",
"(",
")",
"try",
":",
"file",
".",
"close",
"(",
"self",
")",
"_mkdirIfNotExists",
"(",
"self",
".",
"_destpath",
".",
"dirname",
"(",
")",
")",
"self",
".",
"finalpath",
"=",
... | Close this file and commit it to its permanent location.
@return: a Deferred which fires when the file has been moved (and
backed up to tertiary storage, if necessary). | [
"Close",
"this",
"file",
"and",
"commit",
"it",
"to",
"its",
"permanent",
"location",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L84-L100 |
twisted/axiom | axiom/store.py | BaseQuery.explain | def explain(self):
"""
A debugging API, exposing SQLite's I{EXPLAIN} statement.
While this is not a private method, you also probably don't have any
use for it unless you understand U{SQLite
opcodes<http://www.sqlite.org/opcode.html>} very well.
Once you do, it can be h... | python | def explain(self):
"""
A debugging API, exposing SQLite's I{EXPLAIN} statement.
While this is not a private method, you also probably don't have any
use for it unless you understand U{SQLite
opcodes<http://www.sqlite.org/opcode.html>} very well.
Once you do, it can be h... | [
"def",
"explain",
"(",
"self",
")",
":",
"return",
"(",
"[",
"self",
".",
"_sqlAndArgs",
"(",
"'SELECT'",
",",
"self",
".",
"_queryTarget",
")",
"[",
"0",
"]",
"]",
"+",
"self",
".",
"_runQuery",
"(",
"'EXPLAIN SELECT'",
",",
"self",
".",
"_queryTarget... | A debugging API, exposing SQLite's I{EXPLAIN} statement.
While this is not a private method, you also probably don't have any
use for it unless you understand U{SQLite
opcodes<http://www.sqlite.org/opcode.html>} very well.
Once you do, it can be handy to call this interactively to get ... | [
"A",
"debugging",
"API",
"exposing",
"SQLite",
"s",
"I",
"{",
"EXPLAIN",
"}",
"statement",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L232-L248 |
twisted/axiom | axiom/store.py | BaseQuery._computeFromClause | def _computeFromClause(self, tables):
"""
Generate the SQL string which follows the "FROM" string and before the
"WHERE" string in the final SQL statement.
"""
tableAliases = []
self.fromClauseParts = []
for table in tables:
# The indirect calls to sto... | python | def _computeFromClause(self, tables):
"""
Generate the SQL string which follows the "FROM" string and before the
"WHERE" string in the final SQL statement.
"""
tableAliases = []
self.fromClauseParts = []
for table in tables:
# The indirect calls to sto... | [
"def",
"_computeFromClause",
"(",
"self",
",",
"tables",
")",
":",
"tableAliases",
"=",
"[",
"]",
"self",
".",
"fromClauseParts",
"=",
"[",
"]",
"for",
"table",
"in",
"tables",
":",
"# The indirect calls to store.getTableName() will create the tables",
"# if needed. (... | Generate the SQL string which follows the "FROM" string and before the
"WHERE" string in the final SQL statement. | [
"Generate",
"the",
"SQL",
"string",
"which",
"follows",
"the",
"FROM",
"string",
"and",
"before",
"the",
"WHERE",
"string",
"in",
"the",
"final",
"SQL",
"statement",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L271-L298 |
twisted/axiom | axiom/store.py | BaseQuery._selectStuff | def _selectStuff(self, verb='SELECT'):
"""
Return a generator which yields the massaged results of this query with
a particular SQL verb.
For an attribute query, massaged results are of the type of that
attribute. For an item query, they are items of the type the query is
... | python | def _selectStuff(self, verb='SELECT'):
"""
Return a generator which yields the massaged results of this query with
a particular SQL verb.
For an attribute query, massaged results are of the type of that
attribute. For an item query, they are items of the type the query is
... | [
"def",
"_selectStuff",
"(",
"self",
",",
"verb",
"=",
"'SELECT'",
")",
":",
"sqlResults",
"=",
"self",
".",
"_runQuery",
"(",
"verb",
",",
"self",
".",
"_queryTarget",
")",
"for",
"row",
"in",
"sqlResults",
":",
"yield",
"self",
".",
"_massageData",
"(",... | Return a generator which yields the massaged results of this query with
a particular SQL verb.
For an attribute query, massaged results are of the type of that
attribute. For an item query, they are items of the type the query is
supposed to return.
@param verb: a str containi... | [
"Return",
"a",
"generator",
"which",
"yields",
"the",
"massaged",
"results",
"of",
"this",
"query",
"with",
"a",
"particular",
"SQL",
"verb",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L360-L375 |
twisted/axiom | axiom/store.py | BaseQuery.next | def next(self):
"""
This method is deprecated, a holdover from when queries were iterators,
rather than iterables.
@return: one element of massaged data.
"""
if self._selfiter is None:
warnings.warn(
"Calling 'next' directly on a query is depr... | python | def next(self):
"""
This method is deprecated, a holdover from when queries were iterators,
rather than iterables.
@return: one element of massaged data.
"""
if self._selfiter is None:
warnings.warn(
"Calling 'next' directly on a query is depr... | [
"def",
"next",
"(",
"self",
")",
":",
"if",
"self",
".",
"_selfiter",
"is",
"None",
":",
"warnings",
".",
"warn",
"(",
"\"Calling 'next' directly on a query is deprecated. \"",
"\"Perhaps you want to use iter(query).next(), or something \"",
"\"more expressive like store.findFi... | This method is deprecated, a holdover from when queries were iterators,
rather than iterables.
@return: one element of massaged data. | [
"This",
"method",
"is",
"deprecated",
"a",
"holdover",
"from",
"when",
"queries",
"were",
"iterators",
"rather",
"than",
"iterables",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L434-L448 |
twisted/axiom | axiom/store.py | ItemQuery.paginate | def paginate(self, pagesize=20):
"""
Split up the work of gathering a result set into multiple smaller
'pages', allowing very large queries to be iterated without blocking
for long periods of time.
While simply iterating C{paginate()} is very similar to iterating a
query... | python | def paginate(self, pagesize=20):
"""
Split up the work of gathering a result set into multiple smaller
'pages', allowing very large queries to be iterated without blocking
for long periods of time.
While simply iterating C{paginate()} is very similar to iterating a
query... | [
"def",
"paginate",
"(",
"self",
",",
"pagesize",
"=",
"20",
")",
":",
"sort",
"=",
"self",
".",
"sort",
"oc",
"=",
"list",
"(",
"sort",
".",
"orderColumns",
"(",
")",
")",
"if",
"not",
"oc",
":",
"# You can't have an unsorted pagination.",
"sort",
"=",
... | Split up the work of gathering a result set into multiple smaller
'pages', allowing very large queries to be iterated without blocking
for long periods of time.
While simply iterating C{paginate()} is very similar to iterating a
query directly, using this method allows the work to obtai... | [
"Split",
"up",
"the",
"work",
"of",
"gathering",
"a",
"result",
"set",
"into",
"multiple",
"smaller",
"pages",
"allowing",
"very",
"large",
"queries",
"to",
"be",
"iterated",
"without",
"blocking",
"for",
"long",
"periods",
"of",
"time",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L486-L572 |
twisted/axiom | axiom/store.py | ItemQuery._massageData | def _massageData(self, row):
"""
Convert a row into an Item instance by loading cached items or
creating new ones based on query results.
@param row: an n-tuple, where n is the number of columns specified by
my item type.
@return: an instance of the type specified by th... | python | def _massageData(self, row):
"""
Convert a row into an Item instance by loading cached items or
creating new ones based on query results.
@param row: an n-tuple, where n is the number of columns specified by
my item type.
@return: an instance of the type specified by th... | [
"def",
"_massageData",
"(",
"self",
",",
"row",
")",
":",
"result",
"=",
"self",
".",
"store",
".",
"_loadedItem",
"(",
"self",
".",
"tableClass",
",",
"row",
"[",
"0",
"]",
",",
"row",
"[",
"1",
":",
"]",
")",
"assert",
"result",
".",
"store",
"... | Convert a row into an Item instance by loading cached items or
creating new ones based on query results.
@param row: an n-tuple, where n is the number of columns specified by
my item type.
@return: an instance of the type specified by this query. | [
"Convert",
"a",
"row",
"into",
"an",
"Item",
"instance",
"by",
"loading",
"cached",
"items",
"or",
"creating",
"new",
"ones",
"based",
"on",
"query",
"results",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L574-L586 |
twisted/axiom | axiom/store.py | ItemQuery.getColumn | def getColumn(self, attributeName, raw=False):
"""
Get an L{iaxiom.IQuery} whose results will be values of a single
attribute rather than an Item.
@param attributeName: a L{str}, the name of a Python attribute, that
describes a column on the Item subclass that this query was spe... | python | def getColumn(self, attributeName, raw=False):
"""
Get an L{iaxiom.IQuery} whose results will be values of a single
attribute rather than an Item.
@param attributeName: a L{str}, the name of a Python attribute, that
describes a column on the Item subclass that this query was spe... | [
"def",
"getColumn",
"(",
"self",
",",
"attributeName",
",",
"raw",
"=",
"False",
")",
":",
"# XXX: 'raw' is undocumented because I think it's completely unused,",
"# and it's definitely untested. It should probably be removed when",
"# someone has the time. -glyph",
"# Quotient POP3 s... | Get an L{iaxiom.IQuery} whose results will be values of a single
attribute rather than an Item.
@param attributeName: a L{str}, the name of a Python attribute, that
describes a column on the Item subclass that this query was specified
for.
@return: an L{AttributeQuery} for the ... | [
"Get",
"an",
"L",
"{",
"iaxiom",
".",
"IQuery",
"}",
"whose",
"results",
"will",
"be",
"values",
"of",
"a",
"single",
"attribute",
"rather",
"than",
"an",
"Item",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L589-L616 |
twisted/axiom | axiom/store.py | ItemQuery.deleteFromStore | def deleteFromStore(self):
"""
Delete all the Items which are found by this query.
"""
if (self.limit is None and
not isinstance(self.sort, attributes.UnspecifiedOrdering)):
# The ORDER BY is pointless here, and SQLite complains about it.
return self.c... | python | def deleteFromStore(self):
"""
Delete all the Items which are found by this query.
"""
if (self.limit is None and
not isinstance(self.sort, attributes.UnspecifiedOrdering)):
# The ORDER BY is pointless here, and SQLite complains about it.
return self.c... | [
"def",
"deleteFromStore",
"(",
"self",
")",
":",
"if",
"(",
"self",
".",
"limit",
"is",
"None",
"and",
"not",
"isinstance",
"(",
"self",
".",
"sort",
",",
"attributes",
".",
"UnspecifiedOrdering",
")",
")",
":",
"# The ORDER BY is pointless here, and SQLite comp... | Delete all the Items which are found by this query. | [
"Delete",
"all",
"the",
"Items",
"which",
"are",
"found",
"by",
"this",
"query",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L628-L668 |
twisted/axiom | axiom/store.py | MultipleItemQuery._involvedTables | def _involvedTables(self):
"""
Return a list of tables involved in this query,
first checking that no required tables (those in
the query target) have been omitted from the comparison.
"""
# SQL and arguments
if self.comparison is not None:
tables = se... | python | def _involvedTables(self):
"""
Return a list of tables involved in this query,
first checking that no required tables (those in
the query target) have been omitted from the comparison.
"""
# SQL and arguments
if self.comparison is not None:
tables = se... | [
"def",
"_involvedTables",
"(",
"self",
")",
":",
"# SQL and arguments",
"if",
"self",
".",
"comparison",
"is",
"not",
"None",
":",
"tables",
"=",
"self",
".",
"comparison",
".",
"getInvolvedTables",
"(",
")",
"self",
".",
"args",
"=",
"self",
".",
"compari... | Return a list of tables involved in this query,
first checking that no required tables (those in
the query target) have been omitted from the comparison. | [
"Return",
"a",
"list",
"of",
"tables",
"involved",
"in",
"this",
"query",
"first",
"checking",
"that",
"no",
"required",
"tables",
"(",
"those",
"in",
"the",
"query",
"target",
")",
"have",
"been",
"omitted",
"from",
"the",
"comparison",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L711-L731 |
twisted/axiom | axiom/store.py | MultipleItemQuery._massageData | def _massageData(self, row):
"""
Convert a row into a tuple of Item instances, by slicing it
according to the number of columns for each instance, and then
proceeding as for ItemQuery._massageData.
@param row: an n-tuple, where n is the total number of columns
specified... | python | def _massageData(self, row):
"""
Convert a row into a tuple of Item instances, by slicing it
according to the number of columns for each instance, and then
proceeding as for ItemQuery._massageData.
@param row: an n-tuple, where n is the total number of columns
specified... | [
"def",
"_massageData",
"(",
"self",
",",
"row",
")",
":",
"offset",
"=",
"0",
"resultBits",
"=",
"[",
"]",
"for",
"i",
",",
"tableClass",
"in",
"enumerate",
"(",
"self",
".",
"tableClass",
")",
":",
"numAttrs",
"=",
"self",
".",
"schemaLengths",
"[",
... | Convert a row into a tuple of Item instances, by slicing it
according to the number of columns for each instance, and then
proceeding as for ItemQuery._massageData.
@param row: an n-tuple, where n is the total number of columns
specified by all the item types in this query.
@re... | [
"Convert",
"a",
"row",
"into",
"a",
"tuple",
"of",
"Item",
"instances",
"by",
"slicing",
"it",
"according",
"to",
"the",
"number",
"of",
"columns",
"for",
"each",
"instance",
"and",
"then",
"proceeding",
"as",
"for",
"ItemQuery",
".",
"_massageData",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L733-L759 |
twisted/axiom | axiom/store.py | _DistinctQuery.cloneQuery | def cloneQuery(self, limit=_noItem, sort=_noItem):
"""
Clone the original query which this distinct query wraps, and return a new
wrapper around that clone.
"""
newq = self.query.cloneQuery(limit=limit, sort=sort)
return self.__class__(newq) | python | def cloneQuery(self, limit=_noItem, sort=_noItem):
"""
Clone the original query which this distinct query wraps, and return a new
wrapper around that clone.
"""
newq = self.query.cloneQuery(limit=limit, sort=sort)
return self.__class__(newq) | [
"def",
"cloneQuery",
"(",
"self",
",",
"limit",
"=",
"_noItem",
",",
"sort",
"=",
"_noItem",
")",
":",
"newq",
"=",
"self",
".",
"query",
".",
"cloneQuery",
"(",
"limit",
"=",
"limit",
",",
"sort",
"=",
"sort",
")",
"return",
"self",
".",
"__class__"... | Clone the original query which this distinct query wraps, and return a new
wrapper around that clone. | [
"Clone",
"the",
"original",
"query",
"which",
"this",
"distinct",
"query",
"wraps",
"and",
"return",
"a",
"new",
"wrapper",
"around",
"that",
"clone",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L805-L811 |
twisted/axiom | axiom/store.py | _MultipleItemDistinctQuery.count | def count(self):
"""
Count the number of distinct results of the wrapped query.
@return: an L{int} representing the number of distinct results.
"""
if not self.query.store.autocommit:
self.query.store.checkpoint()
target = ', '.join([
tableClass.s... | python | def count(self):
"""
Count the number of distinct results of the wrapped query.
@return: an L{int} representing the number of distinct results.
"""
if not self.query.store.autocommit:
self.query.store.checkpoint()
target = ', '.join([
tableClass.s... | [
"def",
"count",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"query",
".",
"store",
".",
"autocommit",
":",
"self",
".",
"query",
".",
"store",
".",
"checkpoint",
"(",
")",
"target",
"=",
"', '",
".",
"join",
"(",
"[",
"tableClass",
".",
"store... | Count the number of distinct results of the wrapped query.
@return: an L{int} representing the number of distinct results. | [
"Count",
"the",
"number",
"of",
"distinct",
"results",
"of",
"the",
"wrapped",
"query",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L846-L863 |
twisted/axiom | axiom/store.py | AttributeQuery._massageData | def _massageData(self, row):
"""
Convert a raw database row to the type described by an attribute. For
example, convert a database integer into an L{extime.Time} instance for
an L{attributes.timestamp} attribute.
@param row: a 1-tuple, containing the in-database value from my
... | python | def _massageData(self, row):
"""
Convert a raw database row to the type described by an attribute. For
example, convert a database integer into an L{extime.Time} instance for
an L{attributes.timestamp} attribute.
@param row: a 1-tuple, containing the in-database value from my
... | [
"def",
"_massageData",
"(",
"self",
",",
"row",
")",
":",
"if",
"self",
".",
"raw",
":",
"return",
"row",
"[",
"0",
"]",
"return",
"self",
".",
"attribute",
".",
"outfilter",
"(",
"row",
"[",
"0",
"]",
",",
"_FakeItemForFilter",
"(",
"self",
".",
"... | Convert a raw database row to the type described by an attribute. For
example, convert a database integer into an L{extime.Time} instance for
an L{attributes.timestamp} attribute.
@param row: a 1-tuple, containing the in-database value from my
attribute.
@return: a value of th... | [
"Convert",
"a",
"raw",
"database",
"row",
"to",
"the",
"type",
"described",
"by",
"an",
"attribute",
".",
"For",
"example",
"convert",
"a",
"database",
"integer",
"into",
"an",
"L",
"{",
"extime",
".",
"Time",
"}",
"instance",
"for",
"an",
"L",
"{",
"a... | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L892-L905 |
twisted/axiom | axiom/store.py | AttributeQuery.sum | def sum(self):
"""
Return the sum of all the values returned by this query. If no results
are specified, return None.
Note: for non-numeric column types the result of this method will be
nonsensical.
@return: a number or None.
"""
res = self._runQuery('... | python | def sum(self):
"""
Return the sum of all the values returned by this query. If no results
are specified, return None.
Note: for non-numeric column types the result of this method will be
nonsensical.
@return: a number or None.
"""
res = self._runQuery('... | [
"def",
"sum",
"(",
"self",
")",
":",
"res",
"=",
"self",
".",
"_runQuery",
"(",
"'SELECT'",
",",
"'SUM(%s)'",
"%",
"(",
"self",
".",
"_queryTarget",
",",
")",
")",
"or",
"[",
"(",
"0",
",",
")",
"]",
"assert",
"len",
"(",
"res",
")",
"==",
"1",... | Return the sum of all the values returned by this query. If no results
are specified, return None.
Note: for non-numeric column types the result of this method will be
nonsensical.
@return: a number or None. | [
"Return",
"the",
"sum",
"of",
"all",
"the",
"values",
"returned",
"by",
"this",
"query",
".",
"If",
"no",
"results",
"are",
"specified",
"return",
"None",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L918-L931 |
twisted/axiom | axiom/store.py | AttributeQuery.average | def average(self):
"""
Return the average value (as defined by the AVG implementation in the
database) of the values specified by this query.
Note: for non-numeric column types the result of this method will be
nonsensical.
@return: a L{float} representing the 'average'... | python | def average(self):
"""
Return the average value (as defined by the AVG implementation in the
database) of the values specified by this query.
Note: for non-numeric column types the result of this method will be
nonsensical.
@return: a L{float} representing the 'average'... | [
"def",
"average",
"(",
"self",
")",
":",
"rslt",
"=",
"self",
".",
"_runQuery",
"(",
"'SELECT'",
",",
"'AVG(%s)'",
"%",
"(",
"self",
".",
"_queryTarget",
",",
")",
")",
"or",
"[",
"(",
"0",
",",
")",
"]",
"assert",
"len",
"(",
"rslt",
")",
"==",
... | Return the average value (as defined by the AVG implementation in the
database) of the values specified by this query.
Note: for non-numeric column types the result of this method will be
nonsensical.
@return: a L{float} representing the 'average' value of this column. | [
"Return",
"the",
"average",
"value",
"(",
"as",
"defined",
"by",
"the",
"AVG",
"implementation",
"in",
"the",
"database",
")",
"of",
"the",
"values",
"specified",
"by",
"this",
"query",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L934-L946 |
twisted/axiom | axiom/store.py | Store._attachChild | def _attachChild(self, child):
"attach a child database, returning an identifier for it"
self._childCounter += 1
databaseName = 'child_db_%d' % (self._childCounter,)
self._attachedChildren[databaseName] = child
# ATTACH DATABASE statements can't use bind paramaters, blech.
... | python | def _attachChild(self, child):
"attach a child database, returning an identifier for it"
self._childCounter += 1
databaseName = 'child_db_%d' % (self._childCounter,)
self._attachedChildren[databaseName] = child
# ATTACH DATABASE statements can't use bind paramaters, blech.
... | [
"def",
"_attachChild",
"(",
"self",
",",
"child",
")",
":",
"self",
".",
"_childCounter",
"+=",
"1",
"databaseName",
"=",
"'child_db_%d'",
"%",
"(",
"self",
".",
"_childCounter",
",",
")",
"self",
".",
"_attachedChildren",
"[",
"databaseName",
"]",
"=",
"c... | attach a child database, returning an identifier for it | [
"attach",
"a",
"child",
"database",
"returning",
"an",
"identifier",
"for",
"it"
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L1266-L1275 |
twisted/axiom | axiom/store.py | Store._startup | def _startup(self):
"""
Called during __init__. Check consistency of schema in database with
classes in memory. Load all Python modules for stored items, and load
version information for upgrader service to run later.
"""
typesToCheck = []
for oid, module, type... | python | def _startup(self):
"""
Called during __init__. Check consistency of schema in database with
classes in memory. Load all Python modules for stored items, and load
version information for upgrader service to run later.
"""
typesToCheck = []
for oid, module, type... | [
"def",
"_startup",
"(",
"self",
")",
":",
"typesToCheck",
"=",
"[",
"]",
"for",
"oid",
",",
"module",
",",
"typename",
",",
"version",
"in",
"self",
".",
"querySchemaSQL",
"(",
"_schema",
".",
"ALL_TYPES",
")",
":",
"if",
"self",
".",
"debug",
":",
"... | Called during __init__. Check consistency of schema in database with
classes in memory. Load all Python modules for stored items, and load
version information for upgrader service to run later. | [
"Called",
"during",
"__init__",
".",
"Check",
"consistency",
"of",
"schema",
"in",
"database",
"with",
"classes",
"in",
"memory",
".",
"Load",
"all",
"Python",
"modules",
"for",
"stored",
"items",
"and",
"load",
"version",
"information",
"for",
"upgrader",
"se... | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L1302-L1347 |
twisted/axiom | axiom/store.py | Store.findOrCreate | def findOrCreate(self, userItemClass, __ifnew=None, **attrs):
"""
Usage::
s.findOrCreate(userItemClass [, function] [, x=1, y=2, ...])
Example::
class YourItemType(Item):
a = integer()
b = text()
c = integer()
... | python | def findOrCreate(self, userItemClass, __ifnew=None, **attrs):
"""
Usage::
s.findOrCreate(userItemClass [, function] [, x=1, y=2, ...])
Example::
class YourItemType(Item):
a = integer()
b = text()
c = integer()
... | [
"def",
"findOrCreate",
"(",
"self",
",",
"userItemClass",
",",
"__ifnew",
"=",
"None",
",",
"*",
"*",
"attrs",
")",
":",
"andargs",
"=",
"[",
"]",
"for",
"k",
",",
"v",
"in",
"attrs",
".",
"iteritems",
"(",
")",
":",
"col",
"=",
"getattr",
"(",
"... | Usage::
s.findOrCreate(userItemClass [, function] [, x=1, y=2, ...])
Example::
class YourItemType(Item):
a = integer()
b = text()
c = integer()
def f(x):
print x, \"-- it's new!\"
s.findOrCreate(Y... | [
"Usage",
"::"
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L1386-L1425 |
twisted/axiom | axiom/store.py | Store.newFile | def newFile(self, *path):
"""
Open a new file somewhere in this Store's file area.
@param path: a sequence of path segments.
@return: an L{AtomicFile}.
"""
assert len(path) > 0, "newFile requires a nonzero number of segments"
if self.dbdir is None:
i... | python | def newFile(self, *path):
"""
Open a new file somewhere in this Store's file area.
@param path: a sequence of path segments.
@return: an L{AtomicFile}.
"""
assert len(path) > 0, "newFile requires a nonzero number of segments"
if self.dbdir is None:
i... | [
"def",
"newFile",
"(",
"self",
",",
"*",
"path",
")",
":",
"assert",
"len",
"(",
"path",
")",
">",
"0",
",",
"\"newFile requires a nonzero number of segments\"",
"if",
"self",
".",
"dbdir",
"is",
"None",
":",
"if",
"self",
".",
"filesdir",
"is",
"None",
... | Open a new file somewhere in this Store's file area.
@param path: a sequence of path segments.
@return: an L{AtomicFile}. | [
"Open",
"a",
"new",
"file",
"somewhere",
"in",
"this",
"Store",
"s",
"file",
"area",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L1439-L1456 |
twisted/axiom | axiom/store.py | Store._loadTypeSchema | def _loadTypeSchema(self):
"""
Load all of the stored schema information for all types known by this
store. It's important to load everything all at once (rather than
loading the schema for each type separately as it is needed) to keep
store opening fast. A single query with ma... | python | def _loadTypeSchema(self):
"""
Load all of the stored schema information for all types known by this
store. It's important to load everything all at once (rather than
loading the schema for each type separately as it is needed) to keep
store opening fast. A single query with ma... | [
"def",
"_loadTypeSchema",
"(",
"self",
")",
":",
"# Oops, need an index going the other way. This only happens once per",
"# store open, and it's based on data queried from the store, so there",
"# doesn't seem to be any broader way to cache and re-use the result.",
"# However, if we keyed the re... | Load all of the stored schema information for all types known by this
store. It's important to load everything all at once (rather than
loading the schema for each type separately as it is needed) to keep
store opening fast. A single query with many results is much faster
than many que... | [
"Load",
"all",
"of",
"the",
"stored",
"schema",
"information",
"for",
"all",
"types",
"known",
"by",
"this",
"store",
".",
"It",
"s",
"important",
"to",
"load",
"everything",
"all",
"at",
"once",
"(",
"rather",
"than",
"loading",
"the",
"schema",
"for",
... | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L1465-L1516 |
twisted/axiom | axiom/store.py | Store._checkTypeSchemaConsistency | def _checkTypeSchemaConsistency(self, actualType, onDiskSchema):
"""
Called for all known types at database startup: make sure that what we
know (in memory) about this type agrees with what is stored about this
type in the database.
@param actualType: A L{MetaItem} instance whic... | python | def _checkTypeSchemaConsistency(self, actualType, onDiskSchema):
"""
Called for all known types at database startup: make sure that what we
know (in memory) about this type agrees with what is stored about this
type in the database.
@param actualType: A L{MetaItem} instance whic... | [
"def",
"_checkTypeSchemaConsistency",
"(",
"self",
",",
"actualType",
",",
"onDiskSchema",
")",
":",
"# make sure that both the runtime and the database both know about this",
"# type; if they don't both know, we can't check that their views are",
"# consistent",
"try",
":",
"inMemoryS... | Called for all known types at database startup: make sure that what we
know (in memory) about this type agrees with what is stored about this
type in the database.
@param actualType: A L{MetaItem} instance which is associated with a
table in this store. The schema it defines in mem... | [
"Called",
"for",
"all",
"known",
"types",
"at",
"database",
"startup",
":",
"make",
"sure",
"that",
"what",
"we",
"know",
"(",
"in",
"memory",
")",
"about",
"this",
"type",
"agrees",
"with",
"what",
"is",
"stored",
"about",
"this",
"type",
"in",
"the",
... | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L1519-L1564 |
twisted/axiom | axiom/store.py | Store._prepareOldVersionOf | def _prepareOldVersionOf(self, typename, version, persistedSchema):
"""
Note that this database contains old versions of a particular type.
Create the appropriate dummy item subclass and queue the type to be
upgraded.
@param typename: The I{typeName} associated with the schema f... | python | def _prepareOldVersionOf(self, typename, version, persistedSchema):
"""
Note that this database contains old versions of a particular type.
Create the appropriate dummy item subclass and queue the type to be
upgraded.
@param typename: The I{typeName} associated with the schema f... | [
"def",
"_prepareOldVersionOf",
"(",
"self",
",",
"typename",
",",
"version",
",",
"persistedSchema",
")",
":",
"appropriateSchema",
"=",
"persistedSchema",
"[",
"typename",
",",
"version",
"]",
"# create actual attribute objects",
"dummyAttributes",
"=",
"{",
"}",
"... | Note that this database contains old versions of a particular type.
Create the appropriate dummy item subclass and queue the type to be
upgraded.
@param typename: The I{typeName} associated with the schema for which
to create a dummy item class.
@param version: The I{schema... | [
"Note",
"that",
"this",
"database",
"contains",
"old",
"versions",
"of",
"a",
"particular",
"type",
".",
"Create",
"the",
"appropriate",
"dummy",
"item",
"subclass",
"and",
"queue",
"the",
"type",
"to",
"be",
"upgraded",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L1568-L1595 |
twisted/axiom | axiom/store.py | Store.findUnique | def findUnique(self, tableClass, comparison=None, default=_noItem):
"""
Find an Item in the database which should be unique. If it is found,
return it. If it is not found, return 'default' if it was passed,
otherwise raise L{errors.ItemNotFound}. If more than one item is
found... | python | def findUnique(self, tableClass, comparison=None, default=_noItem):
"""
Find an Item in the database which should be unique. If it is found,
return it. If it is not found, return 'default' if it was passed,
otherwise raise L{errors.ItemNotFound}. If more than one item is
found... | [
"def",
"findUnique",
"(",
"self",
",",
"tableClass",
",",
"comparison",
"=",
"None",
",",
"default",
"=",
"_noItem",
")",
":",
"results",
"=",
"list",
"(",
"self",
".",
"query",
"(",
"tableClass",
",",
"comparison",
",",
"limit",
"=",
"2",
")",
")",
... | Find an Item in the database which should be unique. If it is found,
return it. If it is not found, return 'default' if it was passed,
otherwise raise L{errors.ItemNotFound}. If more than one item is
found, raise L{errors.DuplicateUniqueItem}.
@param comparison: implementor of L{iaxi... | [
"Find",
"an",
"Item",
"in",
"the",
"database",
"which",
"should",
"be",
"unique",
".",
"If",
"it",
"is",
"found",
"return",
"it",
".",
"If",
"it",
"is",
"not",
"found",
"return",
"default",
"if",
"it",
"was",
"passed",
"otherwise",
"raise",
"L",
"{",
... | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L1615-L1640 |
twisted/axiom | axiom/store.py | Store.findFirst | def findFirst(self, tableClass, comparison=None,
offset=None, sort=None, default=None):
"""
Usage::
s.findFirst(tableClass [, query arguments except 'limit'])
Example::
class YourItemType(Item):
a = integer()
b = text()... | python | def findFirst(self, tableClass, comparison=None,
offset=None, sort=None, default=None):
"""
Usage::
s.findFirst(tableClass [, query arguments except 'limit'])
Example::
class YourItemType(Item):
a = integer()
b = text()... | [
"def",
"findFirst",
"(",
"self",
",",
"tableClass",
",",
"comparison",
"=",
"None",
",",
"offset",
"=",
"None",
",",
"sort",
"=",
"None",
",",
"default",
"=",
"None",
")",
":",
"limit",
"=",
"1",
"for",
"item",
"in",
"self",
".",
"query",
"(",
"tab... | Usage::
s.findFirst(tableClass [, query arguments except 'limit'])
Example::
class YourItemType(Item):
a = integer()
b = text()
c = integer()
...
it = s.findFirst(YourItemType,
AND(You... | [
"Usage",
"::"
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L1643-L1670 |
twisted/axiom | axiom/store.py | Store.query | def query(self, tableClass, comparison=None,
limit=None, offset=None, sort=None):
"""
Return a generator of instances of C{tableClass},
or tuples of instances if C{tableClass} is a
tuple of classes.
Examples::
fastCars = s.query(Vehicle,
... | python | def query(self, tableClass, comparison=None,
limit=None, offset=None, sort=None):
"""
Return a generator of instances of C{tableClass},
or tuples of instances if C{tableClass} is a
tuple of classes.
Examples::
fastCars = s.query(Vehicle,
... | [
"def",
"query",
"(",
"self",
",",
"tableClass",
",",
"comparison",
"=",
"None",
",",
"limit",
"=",
"None",
",",
"offset",
"=",
"None",
",",
"sort",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"tableClass",
",",
"tuple",
")",
":",
"queryClass",
"=... | Return a generator of instances of C{tableClass},
or tuples of instances if C{tableClass} is a
tuple of classes.
Examples::
fastCars = s.query(Vehicle,
axiom.attributes.AND(
Vehicle.wheels == 4,
Vehicle.maxKPH > 200),
... | [
"Return",
"a",
"generator",
"of",
"instances",
"of",
"C",
"{",
"tableClass",
"}",
"or",
"tuples",
"of",
"instances",
"if",
"C",
"{",
"tableClass",
"}",
"is",
"a",
"tuple",
"of",
"classes",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L1672-L1722 |
twisted/axiom | axiom/store.py | Store.batchInsert | def batchInsert(self, itemType, itemAttributes, dataRows):
"""
Create multiple items in the store without loading
corresponding Python objects into memory.
the items' C{stored} callback will not be called.
Example::
myData = [(37, u"Fred", u"Wichita"),
... | python | def batchInsert(self, itemType, itemAttributes, dataRows):
"""
Create multiple items in the store without loading
corresponding Python objects into memory.
the items' C{stored} callback will not be called.
Example::
myData = [(37, u"Fred", u"Wichita"),
... | [
"def",
"batchInsert",
"(",
"self",
",",
"itemType",
",",
"itemAttributes",
",",
"dataRows",
")",
":",
"class",
"FakeItem",
":",
"pass",
"_NEEDS_DEFAULT",
"=",
"object",
"(",
")",
"# token for lookup failure",
"fakeOSelf",
"=",
"FakeItem",
"(",
")",
"fakeOSelf",
... | Create multiple items in the store without loading
corresponding Python objects into memory.
the items' C{stored} callback will not be called.
Example::
myData = [(37, u"Fred", u"Wichita"),
(28, u"Jim", u"Fresno"),
(43, u"Betty", u"Du... | [
"Create",
"multiple",
"items",
"in",
"the",
"store",
"without",
"loading",
"corresponding",
"Python",
"objects",
"into",
"memory",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L1731-L1779 |
twisted/axiom | axiom/store.py | Store.changed | def changed(self, item):
"""
An item in this store was changed. Add it to the current transaction's
list of changed items, if a transaction is currently underway, or raise
an exception if this L{Store} is currently in a state which does not
allow changes.
"""
if ... | python | def changed(self, item):
"""
An item in this store was changed. Add it to the current transaction's
list of changed items, if a transaction is currently underway, or raise
an exception if this L{Store} is currently in a state which does not
allow changes.
"""
if ... | [
"def",
"changed",
"(",
"self",
",",
"item",
")",
":",
"if",
"self",
".",
"_rejectChanges",
":",
"raise",
"errors",
".",
"ChangeRejected",
"(",
")",
"if",
"self",
".",
"transaction",
"is",
"not",
"None",
":",
"self",
".",
"transaction",
".",
"add",
"(",... | An item in this store was changed. Add it to the current transaction's
list of changed items, if a transaction is currently underway, or raise
an exception if this L{Store} is currently in a state which does not
allow changes. | [
"An",
"item",
"in",
"this",
"store",
"was",
"changed",
".",
"Add",
"it",
"to",
"the",
"current",
"transaction",
"s",
"list",
"of",
"changed",
"items",
"if",
"a",
"transaction",
"is",
"currently",
"underway",
"or",
"raise",
"an",
"exception",
"if",
"this",
... | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L1792-L1803 |
twisted/axiom | axiom/store.py | Store.transact | def transact(self, f, *a, **k):
"""
Execute C{f(*a, **k)} in the context of a database transaction.
Any changes made to this L{Store} by C{f} will be committed when C{f}
returns. If C{f} raises an exception, those changes will be reverted
instead.
If a transaction is a... | python | def transact(self, f, *a, **k):
"""
Execute C{f(*a, **k)} in the context of a database transaction.
Any changes made to this L{Store} by C{f} will be committed when C{f}
returns. If C{f} raises an exception, those changes will be reverted
instead.
If a transaction is a... | [
"def",
"transact",
"(",
"self",
",",
"f",
",",
"*",
"a",
",",
"*",
"*",
"k",
")",
":",
"if",
"self",
".",
"transaction",
"is",
"not",
"None",
":",
"return",
"f",
"(",
"*",
"a",
",",
"*",
"*",
"k",
")",
"if",
"self",
".",
"attachedToParent",
"... | Execute C{f(*a, **k)} in the context of a database transaction.
Any changes made to this L{Store} by C{f} will be committed when C{f}
returns. If C{f} raises an exception, those changes will be reverted
instead.
If a transaction is already in progress (in this thread - ie, if a
... | [
"Execute",
"C",
"{",
"f",
"(",
"*",
"a",
"**",
"k",
")",
"}",
"in",
"the",
"context",
"of",
"a",
"database",
"transaction",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L1821-L1860 |
twisted/axiom | axiom/store.py | Store._indexNameOf | def _indexNameOf(self, tableClass, attrname):
"""
Return the unqualified (ie, no database name) name of the given
attribute of the given table.
@type tableClass: L{MetaItem}
@param tableClass: The Python class associated with a table in the
database.
@param ... | python | def _indexNameOf(self, tableClass, attrname):
"""
Return the unqualified (ie, no database name) name of the given
attribute of the given table.
@type tableClass: L{MetaItem}
@param tableClass: The Python class associated with a table in the
database.
@param ... | [
"def",
"_indexNameOf",
"(",
"self",
",",
"tableClass",
",",
"attrname",
")",
":",
"return",
"\"axiomidx_%s_v%d_%s\"",
"%",
"(",
"tableClass",
".",
"typeName",
",",
"tableClass",
".",
"schemaVersion",
",",
"'_'",
".",
"join",
"(",
"attrname",
")",
")"
] | Return the unqualified (ie, no database name) name of the given
attribute of the given table.
@type tableClass: L{MetaItem}
@param tableClass: The Python class associated with a table in the
database.
@param attrname: A sequence of the names of the columns of the
... | [
"Return",
"the",
"unqualified",
"(",
"ie",
"no",
"database",
"name",
")",
"name",
"of",
"the",
"given",
"attribute",
"of",
"the",
"given",
"table",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L1972-L1989 |
twisted/axiom | axiom/store.py | Store.getTableName | def getTableName(self, tableClass):
"""
Retrieve the fully qualified name of the table holding items
of a particular class in this store. If the table does not
exist in the database, it will be created as a side-effect.
@param tableClass: an Item subclass
@raises axiom... | python | def getTableName(self, tableClass):
"""
Retrieve the fully qualified name of the table holding items
of a particular class in this store. If the table does not
exist in the database, it will be created as a side-effect.
@param tableClass: an Item subclass
@raises axiom... | [
"def",
"getTableName",
"(",
"self",
",",
"tableClass",
")",
":",
"if",
"not",
"(",
"isinstance",
"(",
"tableClass",
",",
"type",
")",
"and",
"issubclass",
"(",
"tableClass",
",",
"item",
".",
"Item",
")",
")",
":",
"raise",
"errors",
".",
"ItemClassesOnl... | Retrieve the fully qualified name of the table holding items
of a particular class in this store. If the table does not
exist in the database, it will be created as a side-effect.
@param tableClass: an Item subclass
@raises axiom.errors.ItemClassesOnly: if an object other than a
... | [
"Retrieve",
"the",
"fully",
"qualified",
"name",
"of",
"the",
"table",
"holding",
"items",
"of",
"a",
"particular",
"class",
"in",
"this",
"store",
".",
"If",
"the",
"table",
"does",
"not",
"exist",
"in",
"the",
"database",
"it",
"will",
"be",
"created",
... | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L2001-L2021 |
twisted/axiom | axiom/store.py | Store.getColumnName | def getColumnName(self, attribute):
"""
Retreive the fully qualified column name for a particular
attribute in this store. The attribute must be bound to an
Item subclass (its type must be valid). If the underlying
table does not exist in the database, it will be created as a
... | python | def getColumnName(self, attribute):
"""
Retreive the fully qualified column name for a particular
attribute in this store. The attribute must be bound to an
Item subclass (its type must be valid). If the underlying
table does not exist in the database, it will be created as a
... | [
"def",
"getColumnName",
"(",
"self",
",",
"attribute",
")",
":",
"if",
"attribute",
"not",
"in",
"self",
".",
"attrToColumnNameCache",
":",
"self",
".",
"attrToColumnNameCache",
"[",
"attribute",
"]",
"=",
"'.'",
".",
"join",
"(",
"(",
"self",
".",
"getTab... | Retreive the fully qualified column name for a particular
attribute in this store. The attribute must be bound to an
Item subclass (its type must be valid). If the underlying
table does not exist in the database, it will be created as a
side-effect.
@param tableClass: an Item s... | [
"Retreive",
"the",
"fully",
"qualified",
"column",
"name",
"for",
"a",
"particular",
"attribute",
"in",
"this",
"store",
".",
"The",
"attribute",
"must",
"be",
"bound",
"to",
"an",
"Item",
"subclass",
"(",
"its",
"type",
"must",
"be",
"valid",
")",
".",
... | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L2047-L2063 |
twisted/axiom | axiom/store.py | Store.getTypeID | def getTypeID(self, tableClass):
"""
Retrieve the typeID associated with a particular table in the
in-database schema for this Store. A typeID is an opaque integer
representing the Item subclass, and the associated table in this
Store's SQLite database.
@param tableClas... | python | def getTypeID(self, tableClass):
"""
Retrieve the typeID associated with a particular table in the
in-database schema for this Store. A typeID is an opaque integer
representing the Item subclass, and the associated table in this
Store's SQLite database.
@param tableClas... | [
"def",
"getTypeID",
"(",
"self",
",",
"tableClass",
")",
":",
"key",
"=",
"(",
"tableClass",
".",
"typeName",
",",
"tableClass",
".",
"schemaVersion",
")",
"if",
"key",
"in",
"self",
".",
"typenameAndVersionToID",
":",
"return",
"self",
".",
"typenameAndVers... | Retrieve the typeID associated with a particular table in the
in-database schema for this Store. A typeID is an opaque integer
representing the Item subclass, and the associated table in this
Store's SQLite database.
@param tableClass: a subclass of Item
@return: an integer | [
"Retrieve",
"the",
"typeID",
"associated",
"with",
"a",
"particular",
"table",
"in",
"the",
"in",
"-",
"database",
"schema",
"for",
"this",
"Store",
".",
"A",
"typeID",
"is",
"an",
"opaque",
"integer",
"representing",
"the",
"Item",
"subclass",
"and",
"the",... | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L2066-L2081 |
twisted/axiom | axiom/store.py | Store._justCreateTable | def _justCreateTable(self, tableClass):
"""
Execute the table creation DDL for an Item subclass.
Indexes are *not* created.
@type tableClass: type
@param tableClass: an Item subclass
"""
sqlstr = []
sqlarg = []
# needs to be calculated including... | python | def _justCreateTable(self, tableClass):
"""
Execute the table creation DDL for an Item subclass.
Indexes are *not* created.
@type tableClass: type
@param tableClass: an Item subclass
"""
sqlstr = []
sqlarg = []
# needs to be calculated including... | [
"def",
"_justCreateTable",
"(",
"self",
",",
"tableClass",
")",
":",
"sqlstr",
"=",
"[",
"]",
"sqlarg",
"=",
"[",
"]",
"# needs to be calculated including version",
"tableName",
"=",
"self",
".",
"_tableNameFor",
"(",
"tableClass",
".",
"typeName",
",",
"tableCl... | Execute the table creation DDL for an Item subclass.
Indexes are *not* created.
@type tableClass: type
@param tableClass: an Item subclass | [
"Execute",
"the",
"table",
"creation",
"DDL",
"for",
"an",
"Item",
"subclass",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L2084-L2111 |
twisted/axiom | axiom/store.py | Store._maybeCreateTable | def _maybeCreateTable(self, tableClass, key):
"""
A type ID has been requested for an Item subclass whose table was not
present when this Store was opened. Attempt to create the table, and
if that fails because another Store object (perhaps in another process)
has created the ta... | python | def _maybeCreateTable(self, tableClass, key):
"""
A type ID has been requested for an Item subclass whose table was not
present when this Store was opened. Attempt to create the table, and
if that fails because another Store object (perhaps in another process)
has created the ta... | [
"def",
"_maybeCreateTable",
"(",
"self",
",",
"tableClass",
",",
"key",
")",
":",
"try",
":",
"self",
".",
"_justCreateTable",
"(",
"tableClass",
")",
"except",
"errors",
".",
"TableAlreadyExists",
":",
"# Although we don't have a memory of this table from the last time... | A type ID has been requested for an Item subclass whose table was not
present when this Store was opened. Attempt to create the table, and
if that fails because another Store object (perhaps in another process)
has created the table, re-read the schema. When that's done, return
the typ... | [
"A",
"type",
"ID",
"has",
"been",
"requested",
"for",
"an",
"Item",
"subclass",
"whose",
"table",
"was",
"not",
"present",
"when",
"this",
"Store",
"was",
"opened",
".",
"Attempt",
"to",
"create",
"the",
"table",
"and",
"if",
"that",
"fails",
"because",
... | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L2114-L2176 |
twisted/axiom | axiom/store.py | Store._createIndexesFor | def _createIndexesFor(self, tableClass, extantIndexes):
"""
Create any indexes which don't exist and are required by the schema
defined by C{tableClass}.
@param tableClass: A L{MetaItem} instance which may define a schema
which includes indexes.
@param extantIndexes... | python | def _createIndexesFor(self, tableClass, extantIndexes):
"""
Create any indexes which don't exist and are required by the schema
defined by C{tableClass}.
@param tableClass: A L{MetaItem} instance which may define a schema
which includes indexes.
@param extantIndexes... | [
"def",
"_createIndexesFor",
"(",
"self",
",",
"tableClass",
",",
"extantIndexes",
")",
":",
"try",
":",
"indexes",
"=",
"_requiredTableIndexes",
"[",
"tableClass",
"]",
"except",
"KeyError",
":",
"indexes",
"=",
"set",
"(",
")",
"for",
"nam",
",",
"atr",
"... | Create any indexes which don't exist and are required by the schema
defined by C{tableClass}.
@param tableClass: A L{MetaItem} instance which may define a schema
which includes indexes.
@param extantIndexes: A container (anything which can be the right-hand
argument to ... | [
"Create",
"any",
"indexes",
"which",
"don",
"t",
"exist",
"and",
"are",
"required",
"by",
"the",
"schema",
"defined",
"by",
"C",
"{",
"tableClass",
"}",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L2179-L2217 |
twisted/axiom | axiom/store.py | Store.getItemByID | def getItemByID(self, storeID, default=_noItem, autoUpgrade=True):
"""
Retrieve an item by its storeID, and return it.
Note: most of the failure modes of this method are catastrophic and
should not be handled by application code. The only one that
application programmers should... | python | def getItemByID(self, storeID, default=_noItem, autoUpgrade=True):
"""
Retrieve an item by its storeID, and return it.
Note: most of the failure modes of this method are catastrophic and
should not be handled by application code. The only one that
application programmers should... | [
"def",
"getItemByID",
"(",
"self",
",",
"storeID",
",",
"default",
"=",
"_noItem",
",",
"autoUpgrade",
"=",
"True",
")",
":",
"if",
"not",
"isinstance",
"(",
"storeID",
",",
"(",
"int",
",",
"long",
")",
")",
":",
"raise",
"TypeError",
"(",
"\"storeID ... | Retrieve an item by its storeID, and return it.
Note: most of the failure modes of this method are catastrophic and
should not be handled by application code. The only one that
application programmers should be concerned with is KeyError. They are
listed for educational purposes.
... | [
"Retrieve",
"an",
"item",
"by",
"its",
"storeID",
"and",
"return",
"it",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L2220-L2325 |
twisted/axiom | axiom/store.py | Store.querySQL | def querySQL(self, sql, args=()):
"""For use with SELECT (or SELECT-like PRAGMA) statements.
"""
if self.debug:
result = timeinto(self.queryTimes, self._queryandfetch, sql, args)
else:
result = self._queryandfetch(sql, args)
return result | python | def querySQL(self, sql, args=()):
"""For use with SELECT (or SELECT-like PRAGMA) statements.
"""
if self.debug:
result = timeinto(self.queryTimes, self._queryandfetch, sql, args)
else:
result = self._queryandfetch(sql, args)
return result | [
"def",
"querySQL",
"(",
"self",
",",
"sql",
",",
"args",
"=",
"(",
")",
")",
":",
"if",
"self",
".",
"debug",
":",
"result",
"=",
"timeinto",
"(",
"self",
".",
"queryTimes",
",",
"self",
".",
"_queryandfetch",
",",
"sql",
",",
"args",
")",
"else",
... | For use with SELECT (or SELECT-like PRAGMA) statements. | [
"For",
"use",
"with",
"SELECT",
"(",
"or",
"SELECT",
"-",
"like",
"PRAGMA",
")",
"statements",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L2333-L2340 |
twisted/axiom | axiom/store.py | Store.createSQL | def createSQL(self, sql, args=()):
"""
For use with auto-committing statements such as CREATE TABLE or CREATE
INDEX.
"""
before = time.time()
self._execSQL(sql, args)
after = time.time()
if after - before > 2.0:
log.msg('Extremely long CREATE: ... | python | def createSQL(self, sql, args=()):
"""
For use with auto-committing statements such as CREATE TABLE or CREATE
INDEX.
"""
before = time.time()
self._execSQL(sql, args)
after = time.time()
if after - before > 2.0:
log.msg('Extremely long CREATE: ... | [
"def",
"createSQL",
"(",
"self",
",",
"sql",
",",
"args",
"=",
"(",
")",
")",
":",
"before",
"=",
"time",
".",
"time",
"(",
")",
"self",
".",
"_execSQL",
"(",
"sql",
",",
"args",
")",
"after",
"=",
"time",
".",
"time",
"(",
")",
"if",
"after",
... | For use with auto-committing statements such as CREATE TABLE or CREATE
INDEX. | [
"For",
"use",
"with",
"auto",
"-",
"committing",
"statements",
"such",
"as",
"CREATE",
"TABLE",
"or",
"CREATE",
"INDEX",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L2360-L2370 |
twisted/axiom | axiom/store.py | Store.executeSQL | def executeSQL(self, sql, args=()):
"""
For use with UPDATE or INSERT statements.
"""
sql = self._execSQL(sql, args)
result = self.cursor.lastRowID()
if self.executedThisTransaction is not None:
self.executedThisTransaction.append((result, sql, args))
... | python | def executeSQL(self, sql, args=()):
"""
For use with UPDATE or INSERT statements.
"""
sql = self._execSQL(sql, args)
result = self.cursor.lastRowID()
if self.executedThisTransaction is not None:
self.executedThisTransaction.append((result, sql, args))
... | [
"def",
"executeSQL",
"(",
"self",
",",
"sql",
",",
"args",
"=",
"(",
")",
")",
":",
"sql",
"=",
"self",
".",
"_execSQL",
"(",
"sql",
",",
"args",
")",
"result",
"=",
"self",
".",
"cursor",
".",
"lastRowID",
"(",
")",
"if",
"self",
".",
"executedT... | For use with UPDATE or INSERT statements. | [
"For",
"use",
"with",
"UPDATE",
"or",
"INSERT",
"statements",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L2388-L2396 |
swharden/PyOriginTools | scripts/update_version.py | updateVersion | def updateVersion(fname):
"""
given a filename to a file containing a __counter__ variable,
open it, read the count, add one, rewrite the file.
This:
__counter__=123
Becomes:
__counter__=124
"""
fname=os.path.abspath(fname)
if not os.path.exists(fname):
print("c... | python | def updateVersion(fname):
"""
given a filename to a file containing a __counter__ variable,
open it, read the count, add one, rewrite the file.
This:
__counter__=123
Becomes:
__counter__=124
"""
fname=os.path.abspath(fname)
if not os.path.exists(fname):
print("c... | [
"def",
"updateVersion",
"(",
"fname",
")",
":",
"fname",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"fname",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"fname",
")",
":",
"print",
"(",
"\"can not update version! file doesn't exist:\\n\"",
"... | given a filename to a file containing a __counter__ variable,
open it, read the count, add one, rewrite the file.
This:
__counter__=123
Becomes:
__counter__=124 | [
"given",
"a",
"filename",
"to",
"a",
"file",
"containing",
"a",
"__counter__",
"variable",
"open",
"it",
"read",
"the",
"count",
"add",
"one",
"rewrite",
"the",
"file",
"."
] | train | https://github.com/swharden/PyOriginTools/blob/536fb8e11234ffdc27e26b1800e0358179ca7d26/scripts/update_version.py#L4-L32 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.