_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q38700 | String.strlen | train | def strlen(self, name):
"""
Return the number of bytes stored in the value of the key
:param name: str the name of the redis key
:return: Future()
"""
with self.pipe as pipe:
return pipe.strlen(self.redis_key(name)) | python | {
"resource": ""
} |
q38701 | String.setbit | train | def setbit(self, name, offset, value):
"""
Flag the ``offset`` in the key as ``value``. Returns a boolean
indicating the previous value of ``offset``.
:param name: str the name of the redis key
:param offset: int
:param value:
:return: Future()
"""
... | python | {
"resource": ""
} |
q38702 | String.getbit | train | def getbit(self, name, offset):
"""
Returns a boolean indicating the value of ``offset`` in key
:param name: str the name of the redis key
:param offset: int
:return: Future()
"""
with self.pipe as pipe:
return pipe.getbit(self.redis_key(name), of... | python | {
"resource": ""
} |
q38703 | String.incr | train | def incr(self, name, amount=1):
"""
increment the value for key by 1
:param name: str the name of the redis key
:param amount: int
:return: Future()
"""
with self.pipe as pipe:
return pipe.incr(self.redis_key(name), amount=amount) | python | {
"resource": ""
} |
q38704 | Set.sunionstore | train | def sunionstore(self, dest, keys, *args):
"""
Store the union of sets specified by ``keys`` into a new
set named ``dest``. Returns the number of members in the new set.
"""
keys = [self.redis_key(k) for k in self._parse_values(keys, args)]
with self.pipe as pipe:
... | python | {
"resource": ""
} |
q38705 | Set.sadd | train | def sadd(self, name, values, *args):
"""
Add the specified members to the Set.
:param name: str the name of the redis key
:param values: a list of values or a simple value.
:return: Future()
"""
with self.pipe as pipe:
values = [self.valueparse.en... | python | {
"resource": ""
} |
q38706 | Set.scard | train | def scard(self, name):
"""
How many items in the set?
:param name: str the name of the redis key
:return: Future()
"""
with self.pipe as pipe:
return pipe.scard(self.redis_key(name)) | python | {
"resource": ""
} |
q38707 | Set.sismember | train | def sismember(self, name, value):
"""
Is the provided value is in the ``Set``?
:param name: str the name of the redis key
:param value: str
:return: Future()
"""
with self.pipe as pipe:
return pipe.sismember(self.redis_key(name),
... | python | {
"resource": ""
} |
q38708 | Set.srandmember | train | def srandmember(self, name, number=None):
"""
Return a random member of the set.
:param name: str the name of the redis key
:return: Future()
"""
with self.pipe as pipe:
f = Future()
res = pipe.srandmember(self.redis_key(name), number=number)
... | python | {
"resource": ""
} |
q38709 | Set.sscan_iter | train | def sscan_iter(self, name, match=None, count=None):
"""
Make an iterator using the SSCAN command so that the client doesn't
need to remember the cursor position.
``match`` allows for filtering the keys by pattern
``count`` allows for hint the minimum number of returns
... | python | {
"resource": ""
} |
q38710 | List.llen | train | def llen(self, name):
"""
Returns the length of the list.
:param name: str the name of the redis key
:return: Future()
"""
with self.pipe as pipe:
return pipe.llen(self.redis_key(name)) | python | {
"resource": ""
} |
q38711 | List.lrange | train | def lrange(self, name, start, stop):
"""
Returns a range of items.
:param name: str the name of the redis key
:param start: integer representing the start index of the range
:param stop: integer representing the size of the list.
:return: Future()
"""
... | python | {
"resource": ""
} |
q38712 | List.lpop | train | def lpop(self, name):
"""
Pop the first object from the left.
:param name: str the name of the redis key
:return: Future()
"""
with self.pipe as pipe:
f = Future()
res = pipe.lpop(self.redis_key(name))
def cb():
f... | python | {
"resource": ""
} |
q38713 | List.lrem | train | def lrem(self, name, value, num=1):
"""
Remove first occurrence of value.
Can't use redis-py interface. It's inconstistent between
redis.Redis and redis.StrictRedis in terms of the kwargs.
Better to use the underlying execute_command instead.
:param name: str the na... | python | {
"resource": ""
} |
q38714 | List.ltrim | train | def ltrim(self, name, start, end):
"""
Trim the list from start to end.
:param name: str the name of the redis key
:param start:
:param end:
:return: Future()
"""
with self.pipe as pipe:
return pipe.ltrim(self.redis_key(name), start, end) | python | {
"resource": ""
} |
q38715 | SortedSet.zadd | train | def zadd(self, name, members, score=1, nx=False,
xx=False, ch=False, incr=False):
"""
Add members in the set and assign them the score.
:param name: str the name of the redis key
:param members: a list of item or a single item
:param score: the score the assign ... | python | {
"resource": ""
} |
q38716 | SortedSet.zincrby | train | def zincrby(self, name, value, amount=1):
"""
Increment the score of the item by `value`
:param name: str the name of the redis key
:param value:
:param amount:
:return:
"""
with self.pipe as pipe:
return pipe.zincrby(self.redis_key(name),... | python | {
"resource": ""
} |
q38717 | SortedSet.zrevrank | train | def zrevrank(self, name, value):
"""
Returns the ranking in reverse order for the member
:param name: str the name of the redis key
:param member: str
"""
with self.pipe as pipe:
return pipe.zrevrank(self.redis_key(name),
... | python | {
"resource": ""
} |
q38718 | SortedSet.zcard | train | def zcard(self, name):
"""
Returns the cardinality of the SortedSet.
:param name: str the name of the redis key
:return: Future()
"""
with self.pipe as pipe:
return pipe.zcard(self.redis_key(name)) | python | {
"resource": ""
} |
q38719 | SortedSet.zscore | train | def zscore(self, name, value):
"""
Return the score of an element
:param name: str the name of the redis key
:param value: the element in the sorted set key
:return: Future()
"""
with self.pipe as pipe:
return pipe.zscore(self.redis_key(name),
... | python | {
"resource": ""
} |
q38720 | SortedSet.zremrangebyrank | train | def zremrangebyrank(self, name, min, max):
"""
Remove a range of element between the rank ``start`` and
``stop`` both included.
:param name: str the name of the redis key
:param min:
:param max:
:return: Future()
"""
with self.pipe as pipe:
... | python | {
"resource": ""
} |
q38721 | SortedSet.zremrangebyscore | train | def zremrangebyscore(self, name, min, max):
"""
Remove a range of element by between score ``min_value`` and
``max_value`` both included.
:param name: str the name of the redis key
:param min:
:param max:
:return: Future()
"""
with self.pipe a... | python | {
"resource": ""
} |
q38722 | SortedSet.zrank | train | def zrank(self, name, value):
"""
Returns the rank of the element.
:param name: str the name of the redis key
:param value: the element in the sorted set
"""
with self.pipe as pipe:
value = self.valueparse.encode(value)
return pipe.zrank(self.... | python | {
"resource": ""
} |
q38723 | SortedSet.zlexcount | train | def zlexcount(self, name, min, max):
"""
Return the number of items in the sorted set between the
lexicographical range ``min`` and ``max``.
:param name: str the name of the redis key
:param min: int or '-inf'
:param max: int or '+inf'
:return: Future()
... | python | {
"resource": ""
} |
q38724 | SortedSet.zrevrangebylex | train | def zrevrangebylex(self, name, max, min, start=None, num=None):
"""
Return the reversed lexicographical range of values from the sorted set
between ``max`` and ``min``.
If ``start`` and ``num`` are specified, then return a slice of the
range.
:param name: str the n... | python | {
"resource": ""
} |
q38725 | SortedSet.zremrangebylex | train | def zremrangebylex(self, name, min, max):
"""
Remove all elements in the sorted set between the
lexicographical range specified by ``min`` and ``max``.
Returns the number of elements removed.
:param name: str the name of the redis key
:param min: int or -inf
... | python | {
"resource": ""
} |
q38726 | SortedSet.zscan_iter | train | def zscan_iter(self, name, match=None, count=None,
score_cast_func=float):
"""
Make an iterator using the ZSCAN command so that the client doesn't
need to remember the cursor position.
``match`` allows for filtering the keys by pattern
``count`` allows for hi... | python | {
"resource": ""
} |
q38727 | Hash._value_encode | train | def _value_encode(cls, member, value):
"""
Internal method used to encode values into the hash.
:param member: str
:param value: multi
:return: bytes
"""
try:
field_validator = cls.fields[member]
except KeyError:
return cls.valuepa... | python | {
"resource": ""
} |
q38728 | Hash._value_decode | train | def _value_decode(cls, member, value):
"""
Internal method used to decode values from redis hash
:param member: str
:param value: bytes
:return: multi
"""
if value is None:
return None
try:
field_validator = cls.fields[member]
... | python | {
"resource": ""
} |
q38729 | Hash.hlen | train | def hlen(self, name):
"""
Returns the number of elements in the Hash.
:param name: str the name of the redis key
:return: Future()
"""
with self.pipe as pipe:
return pipe.hlen(self.redis_key(name)) | python | {
"resource": ""
} |
q38730 | Hash.hstrlen | train | def hstrlen(self, name, key):
"""
Return the number of bytes stored in the value of ``key``
within hash ``name``
"""
with self.pipe as pipe:
return pipe.hstrlen(self.redis_key(name), key) | python | {
"resource": ""
} |
q38731 | Hash.hset | train | def hset(self, name, key, value):
"""
Set ``member`` in the Hash at ``value``.
:param name: str the name of the redis key
:param value:
:param key: the member of the hash key
:return: Future()
"""
with self.pipe as pipe:
value = self._valu... | python | {
"resource": ""
} |
q38732 | Hash.hdel | train | def hdel(self, name, *keys):
"""
Delete one or more hash field.
:param name: str the name of the redis key
:param keys: on or more members to remove from the key.
:return: Future()
"""
with self.pipe as pipe:
m_encode = self.memberparse.encode
... | python | {
"resource": ""
} |
q38733 | Hash.hkeys | train | def hkeys(self, name):
"""
Returns all fields name in the Hash.
:param name: str the name of the redis key
:return: Future
"""
with self.pipe as pipe:
f = Future()
res = pipe.hkeys(self.redis_key(name))
def cb():
m_dec... | python | {
"resource": ""
} |
q38734 | Hash.hgetall | train | def hgetall(self, name):
"""
Returns all the fields and values in the Hash.
:param name: str the name of the redis key
:return: Future()
"""
with self.pipe as pipe:
f = Future()
res = pipe.hgetall(self.redis_key(name))
def cb():
... | python | {
"resource": ""
} |
q38735 | Hash.hget | train | def hget(self, name, key):
"""
Returns the value stored in the field, None if the field doesn't exist.
:param name: str the name of the redis key
:param key: the member of the hash
:return: Future()
"""
with self.pipe as pipe:
f = Future()
... | python | {
"resource": ""
} |
q38736 | Hash.hexists | train | def hexists(self, name, key):
"""
Returns ``True`` if the field exists, ``False`` otherwise.
:param name: str the name of the redis key
:param key: the member of the hash
:return: Future()
"""
with self.pipe as pipe:
return pipe.hexists(self.redis... | python | {
"resource": ""
} |
q38737 | Hash.hincrby | train | def hincrby(self, name, key, amount=1):
"""
Increment the value of the field.
:param name: str the name of the redis key
:param increment: int
:param field: str
:return: Future()
"""
with self.pipe as pipe:
return pipe.hincrby(self.redis_k... | python | {
"resource": ""
} |
q38738 | Hash.hmget | train | def hmget(self, name, keys, *args):
"""
Returns the values stored in the fields.
:param name: str the name of the redis key
:param fields:
:return: Future()
"""
member_encode = self.memberparse.encode
keys = [k for k in self._parse_values(keys, args)]... | python | {
"resource": ""
} |
q38739 | Hash.hmset | train | def hmset(self, name, mapping):
"""
Sets or updates the fields with their corresponding values.
:param name: str the name of the redis key
:param mapping: a dict with keys and values
:return: Future()
"""
with self.pipe as pipe:
m_encode = self.me... | python | {
"resource": ""
} |
q38740 | Wrapper.initialize | train | def initialize(self, emt_id, emt_pass):
"""Manual initialization of the interface attributes.
This is useful when the interface must be declare but initialized later
on with parsed configuration values.
Args:
emt_id (str): ID given by the server upon registration
... | python | {
"resource": ""
} |
q38741 | Wrapper.request_openbus | train | def request_openbus(self, service, endpoint, **kwargs):
"""Make a request to the given endpoint of the ``openbus`` server.
This returns the plain JSON (dict) response which can then be parsed
using one of the implemented types.
Args:
service (str): Service to fetch ('bus' o... | python | {
"resource": ""
} |
q38742 | Wrapper.request_parking | train | def request_parking(self, endpoint, url_args={}, **kwargs):
"""Make a request to the given endpoint of the ``parking`` server.
This returns the plain JSON (dict) response which can then be parsed
using one of the implemented types.
Args:
endpoint (str): Endpoint to send the... | python | {
"resource": ""
} |
q38743 | parseSearchTerm | train | def parseSearchTerm(term):
"""
Turn a string search query into a two-tuple of a search term and a
dictionary of search keywords.
"""
terms = []
keywords = {}
for word in term.split():
if word.count(':') == 1:
k, v = word.split(u':')
if k and v:
... | python | {
"resource": ""
} |
q38744 | gtpswd | train | def gtpswd(prompt, confirmPassword):
"""
Temporary wrapper for Twisted's getPassword until a version that supports
customizing the 'confirm' prompt is released.
"""
try:
return util.getPassword(prompt=prompt,
confirmPrompt=confirmPassword,
... | python | {
"resource": ""
} |
q38745 | Mantissa._createCert | train | def _createCert(self, hostname, serial):
"""
Create a self-signed X.509 certificate.
@type hostname: L{unicode}
@param hostname: The hostname this certificate should be valid for.
@type serial: L{int}
@param serial: The serial number the certificate should have.
... | python | {
"resource": ""
} |
q38746 | Mantissa.installSite | train | def installSite(self, siteStore, domain, publicURL, generateCert=True):
"""
Create the necessary items to run an HTTP server and an SSH server.
"""
certPath = siteStore.filesdir.child("server.pem")
if generateCert and not certPath.exists():
certPath.setContent(self._c... | python | {
"resource": ""
} |
q38747 | Tag.fetch | train | def fetch(self):
"""
Fetch & return a new `Tag` object representing the tag's current state
:rtype: Tag
:raises DOAPIError: if the API endpoint replies with an error (e.g., if
the tag no longer exists)
"""
api = self.doapi_manager
return api._tag(api.... | python | {
"resource": ""
} |
q38748 | Tag.add | train | def add(self, *resources):
"""
Apply the tag to one or more resources
:param resources: one or more `Resource` objects to which tags can be
applied
:return: `None`
:raises DOAPIError: if the API endpoint replies with an error
"""
self.doapi_manager.re... | python | {
"resource": ""
} |
q38749 | Tag.act_on_droplets | train | def act_on_droplets(self, **data):
r"""
Perform an arbitrary action on all of the droplets to which the tag is
applied. ``data`` will be serialized as JSON and POSTed to the proper
API endpoint. All currently-documented actions require the POST body
to be a JSON object containi... | python | {
"resource": ""
} |
q38750 | add_badge_roles | train | def add_badge_roles(app):
"""Add ``badge`` role to your sphinx documents. It can create
a colorful badge inline.
"""
from docutils.nodes import inline, make_id
from docutils.parsers.rst.roles import set_classes
def create_badge_role(color=None):
def badge_role(name, rawtext, text, linen... | python | {
"resource": ""
} |
q38751 | TaskManager.promise | train | def promise(cls, fn, *args, **kwargs):
"""
Used to build a task based on a callable function and the arguments.
Kick it off and start execution of the task.
:param fn: callable
:param args: tuple
:param kwargs: dict
:return: SynchronousTask or AsynchronousTask
... | python | {
"resource": ""
} |
q38752 | _interfacesToNames | train | def _interfacesToNames(interfaces):
"""
Convert from a list of interfaces to a unicode string of names suitable for
storage in the database.
@param interfaces: an iterable of Interface objects.
@return: a unicode string, a comma-separated list of names of interfaces.
@raise ConflictingNames: ... | python | {
"resource": ""
} |
q38753 | upgradeShare1to2 | train | def upgradeShare1to2(oldShare):
"Upgrader from Share version 1 to version 2."
sharedInterfaces = []
attrs = set(oldShare.sharedAttributeNames.split(u','))
for iface in implementedBy(oldShare.sharedItem.__class__):
if set(iface) == attrs or attrs == set('*'):
sharedInterfaces.append(i... | python | {
"resource": ""
} |
q38754 | getAuthenticatedRole | train | def getAuthenticatedRole(store):
"""
Get the base 'Authenticated' role for this store, which is the role that is
given to every user who is explicitly identified by a non-anonymous
username.
"""
def tx():
def addToEveryone(newAuthenticatedRole):
newAuthenticatedRole.becomeMem... | python | {
"resource": ""
} |
q38755 | getPrimaryRole | train | def getPrimaryRole(store, primaryRoleName, createIfNotFound=False):
"""
Get Role object corresponding to an identifier name. If the role name
passed is the empty string, it is assumed that the user is not
authenticated, and the 'Everybody' role is primary. If the role name
passed is non-empty, but... | python | {
"resource": ""
} |
q38756 | _linearize | train | def _linearize(interface):
"""
Return a list of all the bases of a given interface in depth-first order.
@param interface: an Interface object.
@return: a L{list} of Interface objects, the input in all its bases, in
subclass-to-base-class, depth-first order.
"""
L = [interface]
for bas... | python | {
"resource": ""
} |
q38757 | _commonParent | train | def _commonParent(zi1, zi2):
"""
Locate the common parent of two Interface objects.
@param zi1: a zope Interface object.
@param zi2: another Interface object.
@return: the rightmost common parent of the two provided Interface objects,
or None, if they have no common parent other than Interfac... | python | {
"resource": ""
} |
q38758 | _checkConflictingNames | train | def _checkConflictingNames(interfaces):
"""
Raise an exception if any of the names present in the given interfaces
conflict with each other.
@param interfaces: a list of Zope Interface objects.
@return: None
@raise ConflictingNames: if any of the attributes of the provided
interfaces are ... | python | {
"resource": ""
} |
q38759 | asAccessibleTo | train | def asAccessibleTo(role, query):
"""
Return an iterable which yields the shared proxies that are available to
the given role, from the given query.
This method is pending deprecation, and L{Role.asAccessibleTo} should be
preferred in new code.
@param role: The role to retrieve L{SharedProxy}s ... | python | {
"resource": ""
} |
q38760 | unShare | train | def unShare(sharedItem):
"""
Remove all instances of this item from public or shared view.
"""
sharedItem.store.query(Share, Share.sharedItem == sharedItem).deleteFromStore() | python | {
"resource": ""
} |
q38761 | randomEarlyShared | train | def randomEarlyShared(store, role):
"""
If there are no explicitly-published public index pages to display, find a
shared item to present to the user as first.
"""
for r in role.allRoles():
share = store.findFirst(Share, Share.sharedTo == r,
sort=Share.storeID... | python | {
"resource": ""
} |
q38762 | Role.allRoles | train | def allRoles(self, memo=None):
"""
Identify all the roles that this role is authorized to act as.
@param memo: used only for recursion. Do not pass this.
@return: an iterator of all roles that this role is a member of,
including itself.
"""
if memo is None:
... | python | {
"resource": ""
} |
q38763 | Share.sharedInterfaces | train | def sharedInterfaces():
"""
This attribute is the public interface for code which wishes to discover
the list of interfaces allowed by this Share. It is a list of
Interface objects.
"""
def get(self):
if not self.sharedInterfaceNames:
return (... | python | {
"resource": ""
} |
q38764 | every_minute | train | def every_minute(dt=datetime.datetime.utcnow(), fmt=None):
"""
Just pass on the given date.
"""
date = datetime.datetime(dt.year, dt.month, dt.day, dt.hour, dt.minute, 1, 0, dt.tzinfo)
if fmt is not None:
return date.strftime(fmt)
return date | python | {
"resource": ""
} |
q38765 | hourly | train | def hourly(dt=datetime.datetime.utcnow(), fmt=None):
"""
Get a new datetime object every hour.
"""
date = datetime.datetime(dt.year, dt.month, dt.day, dt.hour, 1, 1, 0, dt.tzinfo)
if fmt is not None:
return date.strftime(fmt)
return date | python | {
"resource": ""
} |
q38766 | weekly | train | def weekly(date=datetime.date.today()):
"""
Weeks start are fixes at Monday for now.
"""
return date - datetime.timedelta(days=date.weekday()) | python | {
"resource": ""
} |
q38767 | biweekly | train | def biweekly(date=datetime.date.today()):
"""
Every two weeks.
"""
return datetime.date(date.year, date.month, 1 if date.day < 15 else 15) | python | {
"resource": ""
} |
q38768 | monthly | train | def monthly(date=datetime.date.today()):
"""
Take a date object and return the first day of the month.
"""
return datetime.date(date.year, date.month, 1) | python | {
"resource": ""
} |
q38769 | semiyearly | train | def semiyearly(date=datetime.date.today()):
"""
Twice a year.
"""
return datetime.date(date.year, 1 if date.month < 7 else 7, 1) | python | {
"resource": ""
} |
q38770 | TabularDataModel.resort | train | def resort(self, attributeID, isAscending=None):
"""Sort by one of my specified columns, identified by attributeID
"""
if isAscending is None:
isAscending = self.defaultSortAscending
newSortColumn = self.columns[attributeID]
if newSortColumn.sortAttribute() is None:
... | python | {
"resource": ""
} |
q38771 | TabularDataModel.currentPage | train | def currentPage(self):
"""
Return a sequence of mappings of attribute IDs to column values, to
display to the user.
nextPage/prevPage will strive never to skip items whose column values
have not been returned by this method.
This is best explained by a demonstration. L... | python | {
"resource": ""
} |
q38772 | TabularDataModel._sortAttributeValue | train | def _sortAttributeValue(self, offset):
"""
return the value of the sort attribute for the item at
'offset' in the results of the last query, otherwise None.
"""
if self._currentResults:
pageStart = (self._currentResults[offset][
self.currentSortColumn.... | python | {
"resource": ""
} |
q38773 | XKeyboard.open_display | train | def open_display(self):
"""Establishes connection with X server and prepares objects
necessary to retrieve and send data.
"""
self.close_display() # Properly finish previous open_display()
XkbIgnoreExtension(False)
display_name = None
major = c_int(XkbMajorVe... | python | {
"resource": ""
} |
q38774 | XKeyboard.group_num | train | def group_num(self):
"""Current group number.
:getter: Returns current group number
:setter: Sets current group number
:type: int
"""
xkb_state = XkbStateRec()
XkbGetState(self._display, XkbUseCoreKbd, byref(xkb_state))
return xkb_state.group | python | {
"resource": ""
} |
q38775 | XKeyboard.group_symbol | train | def group_symbol(self):
"""Current group symbol.
:getter: Returns current group symbol
:setter: Sets current group symbol
:type: str
"""
s_mapping = {symdata.index: symdata.symbol for symdata in self._symboldata_list}
return s_mapping[self.group_num] | python | {
"resource": ""
} |
q38776 | _construct_register | train | def _construct_register(reg, default_reg):
"""Constructs a register dict."""
if reg:
x = dict((k, reg.get(k, d)) for k, d in default_reg.items())
else:
x = dict(default_reg)
return x | python | {
"resource": ""
} |
q38777 | PassingControl.pass_control_back | train | def pass_control_back(self, primary, secondary):
"""The address to which the controll is to be passed back.
Tells a potential controller device the address to which the control is
to be passed back.
:param primary: An integer in the range 0 to 30 representing the
primary ad... | python | {
"resource": ""
} |
q38778 | find_available_local_port | train | def find_available_local_port():
"""
Find a free port on localhost.
>>> 0 < find_available_local_port() < 65536
True
"""
infos = socket.getaddrinfo(None, 0, socket.AF_UNSPEC, socket.SOCK_STREAM)
family, proto, _, _, addr = next(iter(infos))
sock = socket.socket(family, proto)
sock.bind(addr)
addr, port = soc... | python | {
"resource": ""
} |
q38779 | Checker.assert_free | train | def assert_free(self, host, port=None):
"""
Assert that the given addr is free
in that all attempts to connect fail within the timeout
or raise a PortNotFree exception.
>>> free_port = find_available_local_port()
>>> Checker().assert_free('localhost', free_port)
>>> Checker().assert_free('127.0.0.1', fr... | python | {
"resource": ""
} |
q38780 | _FailedAnswer.redeliver | train | def redeliver(self):
"""
Re-deliver the answer to the consequence which previously handled it
by raising an exception.
This method is intended to be invoked after the code in question has
been upgraded. Since there are no buggy answer receivers in
production, nothing ca... | python | {
"resource": ""
} |
q38781 | MessageQueue.routeAnswer | train | def routeAnswer(self, originalSender, originalTarget, value, messageID):
"""
Route an incoming answer to a message originally sent by this queue.
"""
def txn():
qm = self._messageFromSender(originalSender, messageID)
if qm is None:
return
... | python | {
"resource": ""
} |
q38782 | MessageQueue._messageFromSender | train | def _messageFromSender(self, sender, messageID):
"""
Locate a previously queued message by a given sender and messageID.
"""
return self.store.findUnique(
_QueuedMessage,
AND(_QueuedMessage.senderUsername == sender.localpart,
_QueuedMessage.senderD... | python | {
"resource": ""
} |
q38783 | MessageQueue._verifySender | train | def _verifySender(self, sender):
"""
Verify that this sender is valid.
"""
if self.store.findFirst(
LoginMethod,
AND(LoginMethod.localpart == sender.localpart,
LoginMethod.domain == sender.domain,
LoginMethod.internal == True)) is N... | python | {
"resource": ""
} |
q38784 | MessageQueue.queueMessage | train | def queueMessage(self, sender, target, value,
consequence=None):
"""
Queue a persistent outgoing message.
@param sender: The a description of the shared item that is the sender
of the message.
@type sender: L{xmantissa.sharing.Identifier}
@param tar... | python | {
"resource": ""
} |
q38785 | _AMPExposer.expose | train | def expose(self, commandObject):
"""
Declare a method as being related to the given command object.
@param commandObject: a L{Command} subclass.
"""
thunk = super(_AMPExposer, self).expose(commandObject.commandName)
def thunkplus(function):
result = thunk(fun... | python | {
"resource": ""
} |
q38786 | _AMPExposer.responderForName | train | def responderForName(self, instance, commandName):
"""
When resolving a command to a method from the wire, the information
available is the command's name; look up a command.
@param instance: an instance of a class who has methods exposed via
this exposer's L{_AMPExposer.expose}... | python | {
"resource": ""
} |
q38787 | _AMPErrorExposer.expose | train | def expose(self, commandObject, exceptionType):
"""
Expose a function for processing a given AMP error.
"""
thunk = super(_AMPErrorExposer, self).expose(
(commandObject.commandName,
commandObject.errors.get(exceptionType)))
def thunkplus(function):
... | python | {
"resource": ""
} |
q38788 | AMPReceiver._boxFromData | train | def _boxFromData(self, messageData):
"""
A box.
@param messageData: a serialized AMP box representing either a message
or an error.
@type messageData: L{str}
@raise MalformedMessage: if the C{messageData} parameter does not parse
to exactly one AMP box.
... | python | {
"resource": ""
} |
q38789 | Consultant._get | train | def _get(self, resource, payload=None):
''' Wrapper around requests.get that shorten caller url and takes care
of errors '''
# Avoid dangerous default function argument `{}`
payload = payload or {}
# Build the request and return json response
return requests.get(
... | python | {
"resource": ""
} |
q38790 | Consultant._put | train | def _put(self, resource, payload=None):
''' Wrapper around requests.put that shorten caller url and takes care
of errors '''
# Avoid dangerous default function argument `{}`
payload = payload or {}
# Build the request and return json response
return requests.put(
... | python | {
"resource": ""
} |
q38791 | Database.table_names | train | def table_names(self):
"""Returns names of all tables in the database"""
query = "SELECT name FROM sqlite_master WHERE type='table'"
cursor = self.connection.execute(query)
results = cursor.fetchall()
return [result_tuple[0] for result_tuple in results] | python | {
"resource": ""
} |
q38792 | Database.drop_all_tables | train | def drop_all_tables(self):
"""Drop all tables in the database"""
for table_name in self.table_names():
self.execute_sql("DROP TABLE %s" % table_name)
self.connection.commit() | python | {
"resource": ""
} |
q38793 | Database.execute_sql | train | def execute_sql(self, sql, commit=False):
"""Log and then execute a SQL query"""
logger.info("Running sqlite query: \"%s\"", sql)
self.connection.execute(sql)
if commit:
self.connection.commit() | python | {
"resource": ""
} |
q38794 | Database.version | train | def version(self):
"""What's the version of this database? Found in metadata attached
by datacache when creating this database."""
query = "SELECT version FROM %s" % METADATA_TABLE_NAME
cursor = self.connection.execute(query)
version = cursor.fetchone()
if not version:
... | python | {
"resource": ""
} |
q38795 | Database._finalize_database | train | def _finalize_database(self, version):
"""
Create metadata table for database with version number.
Parameters
----------
version : int
Tag created database with user-specified version number
"""
require_integer(version, "version")
create_metad... | python | {
"resource": ""
} |
q38796 | Database._create_table | train | def _create_table(self, table_name, column_types, primary=None, nullable=()):
"""Creates a sqlite3 table from the given metadata.
Parameters
----------
column_types : list of (str, str) pairs
First element of each tuple is the column name, second element is the sqlite3 type... | python | {
"resource": ""
} |
q38797 | Database.create | train | def create(self, tables, version):
"""Do the actual work of creating the database, filling its tables with
values, creating indices, and setting the datacache version metadata.
Parameters
----------
tables : list
List of datacache.DatabaseTable objects
versi... | python | {
"resource": ""
} |
q38798 | Database._create_index | train | def _create_index(self, table_name, index_columns):
"""
Creates an index over multiple columns of a given table.
Parameters
----------
table_name : str
index_columns : iterable of str
Which columns should be indexed
"""
logger.info(
... | python | {
"resource": ""
} |
q38799 | MantissaViewHelper.locateChild | train | def locateChild(self, ctx, segments):
"""
Attempt to locate the child via the '.fragment' attribute, then fall
back to normal locateChild behavior.
"""
if self.fragment is not None:
# There are still a bunch of bogus subclasses of this class, which
# are u... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.