_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q38500 | Cache.fetch | train | def fetch(
self,
url,
filename=None,
decompress=False,
force=False,
timeout=None,
use_wget_if_available=True):
"""
Return the local path to the downloaded copy of a given URL.
Don't download the file again if it'... | python | {
"resource": ""
} |
q38501 | Cache.local_path | train | def local_path(self, url, filename=None, decompress=False, download=False):
"""
What will the full local path be if we download the given file?
"""
if download:
return self.fetch(url=url, filename=filename, decompress=decompress)
else:
filename = self.loca... | python | {
"resource": ""
} |
q38502 | connect_redis | train | def connect_redis(redis_client, name=None, transaction=False):
"""
Connect your redis-py instance to redpipe.
Example:
.. code:: python
redpipe.connect_redis(redis.StrictRedis(), name='users')
Do this during your application bootstrapping.
You can also pass a redis-py-cluster insta... | python | {
"resource": ""
} |
q38503 | ConnectionManager.connect | train | def connect(cls, pipeline_method, name=None):
"""
Low level logic to bind a callable method to a name.
Don't call this directly unless you know what you are doing.
:param pipeline_method: callable
:param name: str optional
:return: None
"""
new_pool = pip... | python | {
"resource": ""
} |
q38504 | ConnectionManager.connect_redis | train | def connect_redis(cls, redis_client, name=None, transaction=False):
"""
Store the redis connection in our connector instance.
Do this during your application bootstrapping.
We call the pipeline method of the redis client.
The ``redis_client`` can be either a redis or redisclus... | python | {
"resource": ""
} |
q38505 | remoteIndexer1to2 | train | def remoteIndexer1to2(oldIndexer):
"""
Previously external application code was responsible for adding a
RemoteListener to a batch work source as a reliable listener. This
precluded the possibility of the RemoteListener resetting itself
unilaterally. With version 2, RemoteListener takes control of... | python | {
"resource": ""
} |
q38506 | remoteIndexer2to3 | train | def remoteIndexer2to3(oldIndexer):
"""
The documentType keyword was added to all indexable items. Indexes need to
be regenerated for this to take effect. Also, PyLucene no longer stores
the text of messages it indexes, so deleting and re-creating the indexes
will make them much smaller.
"""
... | python | {
"resource": ""
} |
q38507 | pyLuceneIndexer4to5 | train | def pyLuceneIndexer4to5(old):
"""
Copy attributes, reset index due because information about deleted
documents has been lost, and power up for IFulltextIndexer so other code
can find this item.
"""
new = old.upgradeVersion(PyLuceneIndexer.typeName, 4, 5,
indexCount=o... | python | {
"resource": ""
} |
q38508 | RemoteIndexer.reset | train | def reset(self):
"""
Process everything all over again.
"""
self.indexCount = 0
indexDir = self.store.newDirectory(self.indexDirectory)
if indexDir.exists():
indexDir.remove()
for src in self.getSources():
src.removeReliableListener(self)
... | python | {
"resource": ""
} |
q38509 | RemoteIndexer._flush | train | def _flush(self):
"""
Deal with pending result-affecting things.
This should always be called before issuing a search.
"""
remove = self.store.query(_RemoveDocument)
documentIdentifiers = list(remove.getColumn("documentIdentifier"))
if VERBOSE:
log.ms... | python | {
"resource": ""
} |
q38510 | _SQLiteIndex.add | train | def add(self, document):
"""
Add a document to the database.
"""
docid = int(document.uniqueIdentifier())
text = u' '.join(document.textParts())
self.store.executeSQL(self.addSQL, (docid, text)) | python | {
"resource": ""
} |
q38511 | _SQLiteIndex.remove | train | def remove(self, docid):
"""
Remove a document from the database.
"""
docid = int(docid)
self.store.executeSQL(self.removeSQL, (docid,)) | python | {
"resource": ""
} |
q38512 | _SQLiteIndex.search | train | def search(self, term, keywords=None, sortAscending=True):
"""
Search the database.
"""
if sortAscending:
direction = 'ASC'
else:
direction = 'DESC'
return [_SQLiteResultWrapper(r[0]) for r in
self.store.querySQL(self.searchSQL % (... | python | {
"resource": ""
} |
q38513 | SQLiteIndexer._getStore | train | def _getStore(self):
"""
Get the Store used for FTS.
If it does not exist, it is created and initialised.
"""
storeDir = self.store.newDirectory(self.indexDirectory)
if not storeDir.exists():
store = Store(storeDir)
self._initStore(store)
... | python | {
"resource": ""
} |
q38514 | SingleType.dump | train | def dump(self, value):
"""Dumps the value to string.
:returns: Returns the stringified version of the value.
:raises: TypeError, ValueError
"""
value = self.__convert__(value)
self.__validate__(value)
return self.__serialize__(value) | python | {
"resource": ""
} |
q38515 | Integer.simulate | train | def simulate(self):
"""Generates a random integer in the available range."""
min_ = (-sys.maxsize - 1) if self._min is None else self._min
max_ = sys.maxsize if self._max is None else self._max
return random.randint(min_, max_) | python | {
"resource": ""
} |
q38516 | String.simulate | train | def simulate(self):
"""Returns a randomly constructed string.
Simulate randomly constructs a string with a length between min and
max. If min is not present, a minimum length of 1 is assumed, if max
is not present a maximum length of 10 is used.
"""
min_ = 1 if self._min... | python | {
"resource": ""
} |
q38517 | Stream.simulate | train | def simulate(self):
"""Simulates a stream of types."""
# Simulates zero to 10 types
return [t.simulate() for t in itertools.islice(self, random.choice(range(10)))] | python | {
"resource": ""
} |
q38518 | ExcelDAM.__findRange | train | def __findRange(self, excelLib, start, end):
''' return low and high as excel range '''
inc = 1
low = 0
high = 0
dates = excelLib.readCol(0, 1)
for index, date in enumerate(dates):
if int(start) <= int(date):
low = index + inc
... | python | {
"resource": ""
} |
q38519 | SR850.snap | train | def snap(self, *args):
"""Records multiple values at once.
It takes two to six arguments specifying which values should be
recorded together. Valid arguments are 'x', 'y', 'r', 'theta',
'aux1', 'aux2', 'aux3', 'aux4', 'frequency', 'trace1', 'trace2',
'trace3' and 'trace4'.
... | python | {
"resource": ""
} |
q38520 | SR850.fit | train | def fit(self, range, function=None):
"""Fits a function to the active display's data trace within a
specified range of the time window.
E.g.::
# Fit's a gaussian to the first 30% of the time window.
lockin.fit(range=(0, 30), function='gauss')
:param start: The ... | python | {
"resource": ""
} |
q38521 | SR850.calculate_statistics | train | def calculate_statistics(self, start, stop):
"""Starts the statistics calculation.
:param start: The left limit of the time window in percent.
:param stop: The right limit of the time window in percent.
.. note::
The calculation takes some time. Check the status byte to se... | python | {
"resource": ""
} |
q38522 | SR850.calculate | train | def calculate(self, operation=None, trace=None, constant=None, type=None):
"""Starts the calculation.
The calculation operates on the trace graphed in the active display.
The math operation is defined by the :attr:`~.SR850.math_operation`,
the second argument by the :attr:`~.SR850.math_... | python | {
"resource": ""
} |
q38523 | Mark.bin | train | def bin(self):
"""The bin index of this mark.
:returns: An integer bin index or None if the mark is inactive.
"""
bin = self._query(('MBIN?', Integer, Integer), self.idx)
return None if bin == -1 else bin | python | {
"resource": ""
} |
q38524 | MarkList.active | train | def active(self):
"""The indices of the active marks."""
# TODO avoid direct usage of transport object.
marks = tuple(int(x) for x in transport.ask('MACT').split(','))
return marks[1:] | python | {
"resource": ""
} |
q38525 | Connection.put_and_track | train | def put_and_track(self, url, payload, refresh_rate_sec=1):
"""
Put and track progress, displaying progress bars.
May display the wrong progress if 2 things post/put on the same
procedure name at the same time.
"""
if not url.startswith('/v1/procedures'):
rais... | python | {
"resource": ""
} |
q38526 | Connection.post_and_track | train | def post_and_track(self, url, payload, refresh_rate_sec=1):
"""
Post and track progress, displaying progress bars.
May display the wrong progress if 2 things post/put on the same
procedure name at the same time.
"""
if not url.startswith('/v1/procedures'):
ra... | python | {
"resource": ""
} |
q38527 | StringEndpointPort._makeService | train | def _makeService(self):
"""
Construct a service for the endpoint as described.
"""
if self._endpointService is None:
_service = service
else:
_service = self._endpointService
return _service(
self.description.encode('ascii'), self.facto... | python | {
"resource": ""
} |
q38528 | ListOptions.postOptions | train | def postOptions(self):
"""
Display details about the ports which already exist.
"""
store = self.parent.parent.getStore()
port = None
factories = {}
for portType in [TCPPort, SSLPort, StringEndpointPort]:
for port in store.query(portType):
... | python | {
"resource": ""
} |
q38529 | DeleteOptions._delete | train | def _delete(self, store, portIDs):
"""
Try to delete the ports with the given store IDs.
@param store: The Axiom store from which to delete items.
@param portIDs: A list of Axiom store IDs for TCPPort or SSLPort items.
@raise L{SystemExit}: If one of the store IDs does not ide... | python | {
"resource": ""
} |
q38530 | DeleteOptions.postOptions | train | def postOptions(self):
"""
Delete the ports specified with the port-identifier option.
"""
if self.portIdentifiers:
store = self.parent.parent.getStore()
store.transact(self._delete, store, self.portIdentifiers)
print "Deleted."
raise Syste... | python | {
"resource": ""
} |
q38531 | absl_flags | train | def absl_flags():
"""
Extracts absl-py flags that the user has specified and outputs their
key-value mapping.
By default, extracts only those flags in the current __package__
and mainfile.
Useful to put into a trial's param_map.
"""
# TODO: need same thing for argparse
flags_dict =... | python | {
"resource": ""
} |
q38532 | pipeline | train | def pipeline(pipe=None, name=None, autoexec=False, exit_handler=None):
"""
This is the foundational function for all of redpipe.
Everything goes through here.
create pipelines, nest pipelines, get pipelines for a specific name.
It all happens here.
Here's a simple example:
.. code:: python... | python | {
"resource": ""
} |
q38533 | autoexec | train | def autoexec(pipe=None, name=None, exit_handler=None):
"""
create a pipeline with a context that will automatically execute the
pipeline upon leaving the context if no exception was raised.
:param pipe:
:param name:
:return:
"""
return pipeline(pipe=pipe, name=name, autoexec=True,
... | python | {
"resource": ""
} |
q38534 | dump_etree_helper | train | def dump_etree_helper(container_name, data, rules, nsmap, attrib):
"""Convert DataCite JSON format to DataCite XML.
JSON should be validated before it is given to to_xml.
"""
output = etree.Element(container_name, nsmap=nsmap, attrib=attrib)
for rule in rules:
if rule not in data:
... | python | {
"resource": ""
} |
q38535 | etree_to_string | train | def etree_to_string(root, pretty_print=True, xml_declaration=True,
encoding='utf-8'):
"""Dump XML etree as a string."""
return etree.tostring(
root,
pretty_print=pretty_print,
xml_declaration=xml_declaration,
encoding=encoding,
).decode('utf-8') | python | {
"resource": ""
} |
q38536 | Rules.rule | train | def rule(self, key):
"""Decorate as a rule for a key in top level JSON."""
def register(f):
self.rules[key] = f
return f
return register | python | {
"resource": ""
} |
q38537 | DatabaseTable.from_dataframe | train | def from_dataframe(cls, name, df, indices, primary_key=None):
"""Infer table metadata from a DataFrame"""
# ordered list (column_name, column_type) pairs
column_types = []
# which columns have nullable values
nullable = set()
# tag cached database by dataframe's number ... | python | {
"resource": ""
} |
q38538 | ParkingApi.detail_parking | train | def detail_parking(self, **kwargs):
"""Obtain detailed info of a given parking.
Args:
lang (str): Language code (*es* or *en*).
day (int): Day of the month in format DD.
The number is automatically padded if it only has one digit.
month (int): Month ... | python | {
"resource": ""
} |
q38539 | ParkingApi.detail_poi | train | def detail_poi(self, **kwargs):
"""Obtain detailed info of a given POI.
Args:
family (str): Family code of the POI (3 chars).
lang (str): Language code (*es* or *en*).
id (int): Optional, ID of the POI to query. Passing value -1 will
result in informa... | python | {
"resource": ""
} |
q38540 | ParkingApi.icon_description | train | def icon_description(self, **kwargs):
"""Obtain a list of elements that have an associated icon.
Args:
lang (str): Language code (*es* or *en*).
Returns:
Status boolean and parsed response (list[IconDescription]), or
message string in case of error.
... | python | {
"resource": ""
} |
q38541 | ParkingApi.info_parking_poi | train | def info_parking_poi(self, **kwargs):
"""Obtain generic information on POIs and parkings.
This returns a list of elements in a given radius from the coordinates.
Args:
radius (int): Radius of the search (in meters).
latitude (double): Latitude in decimal degrees.
... | python | {
"resource": ""
} |
q38542 | ParkingApi.list_street_poi_parking | train | def list_street_poi_parking(self, **kwargs):
"""Obtain a list of addresses and POIs.
This endpoint uses an address to perform the search
Args:
lang (str): Language code (*es* or *en*).
address (str): Address in which to perform the search.
Returns:
... | python | {
"resource": ""
} |
q38543 | ParkingApi.list_types_poi | train | def list_types_poi(self, **kwargs):
"""Obtain a list of families, types and categories of POI.
Args:
lang (str): Language code (*es* or *en*).
Returns:
Status boolean and parsed response (list[ParkingPoiType]), or message
string in case of error.
"""... | python | {
"resource": ""
} |
q38544 | YahooDAM.readQuotes | train | def readQuotes(self, start, end):
''' read quotes from Yahoo Financial'''
if self.symbol is None:
LOG.debug('Symbol is None')
return []
return self.__yf.getQuotes(self.symbol, start, end) | python | {
"resource": ""
} |
q38545 | deepcopy | train | def deepcopy(value):
"""
The default copy.deepcopy seems to copy all objects and some are not
`copy-able`.
We only need to make sure the provided data is a copy per key, object does
not need to be copied.
"""
if not isinstance(value, (dict, list, tuple)):
return value
if isins... | python | {
"resource": ""
} |
q38546 | LS370._factory_default | train | def _factory_default(self, confirm=False):
"""Resets the device to factory defaults.
:param confirm: This function should not normally be used, to prevent
accidental resets, a confirm value of `True` must be used.
"""
if confirm is True:
self._write(('DFLT', Int... | python | {
"resource": ""
} |
q38547 | PersistentSessionWrapper.createSessionForKey | train | def createSessionForKey(self, key, user):
"""
Create a persistent session in the database.
@type key: L{bytes}
@param key: The persistent session identifier.
@type user: L{bytes}
@param user: The username the session will belong to.
"""
PersistentSession... | python | {
"resource": ""
} |
q38548 | PersistentSessionWrapper.authenticatedUserForKey | train | def authenticatedUserForKey(self, key):
"""
Find a persistent session for a user.
@type key: L{bytes}
@param key: The persistent session identifier.
@rtype: L{bytes} or C{None}
@return: The avatar ID the session belongs to, or C{None} if no such
session exis... | python | {
"resource": ""
} |
q38549 | PersistentSessionWrapper.removeSessionWithKey | train | def removeSessionWithKey(self, key):
"""
Remove a persistent session, if it exists.
@type key: L{bytes}
@param key: The persistent session identifier.
"""
self.store.query(
PersistentSession,
PersistentSession.sessionKey == key).deleteFromStore() | python | {
"resource": ""
} |
q38550 | PersistentSessionWrapper._cleanSessions | train | def _cleanSessions(self):
"""
Clean expired sesisons.
"""
tooOld = extime.Time() - timedelta(seconds=PERSISTENT_SESSION_LIFETIME)
self.store.query(
PersistentSession,
PersistentSession.lastUsed < tooOld).deleteFromStore()
self._lastClean = self._cl... | python | {
"resource": ""
} |
q38551 | PersistentSessionWrapper._maybeCleanSessions | train | def _maybeCleanSessions(self):
"""
Clean expired sessions if it's been long enough since the last clean.
"""
sinceLast = self._clock.seconds() - self._lastClean
if sinceLast > self.sessionCleanFrequency:
self._cleanSessions() | python | {
"resource": ""
} |
q38552 | PersistentSessionWrapper.cookieDomainForRequest | train | def cookieDomainForRequest(self, request):
"""
Pick a domain to use when setting cookies.
@type request: L{nevow.inevow.IRequest}
@param request: Request to determine cookie domain for
@rtype: C{str} or C{None}
@return: Domain name to use when setting cookies, or C{None... | python | {
"resource": ""
} |
q38553 | PersistentSessionWrapper.savorSessionCookie | train | def savorSessionCookie(self, request):
"""
Make the session cookie last as long as the persistent session.
@type request: L{nevow.inevow.IRequest}
@param request: The HTTP request object for the guard login URL.
"""
cookieValue = request.getSession().uid
request.... | python | {
"resource": ""
} |
q38554 | PersistentSessionWrapper.login | train | def login(self, request, session, creds, segments):
"""
Called to check the credentials of a user.
Here we extend guard's implementation to preauthenticate users if they
have a valid persistent session.
@type request: L{nevow.inevow.IRequest}
@param request: The HTTP re... | python | {
"resource": ""
} |
q38555 | PersistentSessionWrapper.explicitLogout | train | def explicitLogout(self, session):
"""
Handle a user-requested logout.
Here we override guard's behaviour for the logout action to delete the
persistent session. In this case the user has explicitly requested a
logout, so the persistent session must be deleted to require the us... | python | {
"resource": ""
} |
q38556 | PersistentSessionWrapper.getCredentials | train | def getCredentials(self, request):
"""
Derive credentials from an HTTP request.
Override SessionWrapper.getCredentials to add the Host: header to the
credentials. This will make web-based virtual hosting work.
@type request: L{nevow.inevow.IRequest}
@param request: The... | python | {
"resource": ""
} |
q38557 | startMenu | train | def startMenu(translator, navigation, tag):
"""
Drop-down menu-style navigation view.
For each primary navigation element available, a copy of the I{tab}
pattern will be loaded from the tag. It will have its I{href} slot
filled with the URL for that navigation item. It will have its I{name}
s... | python | {
"resource": ""
} |
q38558 | applicationNavigation | train | def applicationNavigation(ctx, translator, navigation):
"""
Horizontal, primary-only navigation view.
For the navigation element currently being viewed, copies of the
I{selected-app-tab} and I{selected-tab-contents} patterns will be
loaded from the tag. For all other navigation elements, copies of... | python | {
"resource": ""
} |
q38559 | _generate | train | def _generate():
"""
Generate a new SSH key pair.
"""
privateKey = rsa.generate_private_key(
public_exponent=65537,
key_size=4096,
backend=default_backend())
return Key(privateKey).toString('openssh') | python | {
"resource": ""
} |
q38560 | ShellServer._draw | train | def _draw(self):
"""
Call the drawing API for the main menu widget with the current known
terminal size and the terminal.
"""
self._window.draw(self._width, self._height, self.terminal) | python | {
"resource": ""
} |
q38561 | ShellServer.reactivate | train | def reactivate(self):
"""
Called when a sub-protocol is finished. This disconnects the
sub-protocol and redraws the main menu UI.
"""
self._protocol.connectionLost(None)
self._protocol = None
self.terminal.reset()
self._window.filthy()
self._windo... | python | {
"resource": ""
} |
q38562 | ShellServer.keystrokeReceived | train | def keystrokeReceived(self, keyID, modifier):
"""
Forward input events to the application-supplied protocol if one is
currently active, otherwise forward them to the main menu UI.
"""
if self._protocol is not None:
self._protocol.keystrokeReceived(keyID, modifier)
... | python | {
"resource": ""
} |
q38563 | FloatingIP.fetch | train | def fetch(self):
"""
Fetch & return a new `FloatingIP` object representing the floating IP's
current state
:rtype: FloatingIP
:raises DOAPIError: if the API endpoint replies with an error (e.g., if
the floating IP no longer exists)
"""
api = self.doap... | python | {
"resource": ""
} |
q38564 | FloatingIP.assign | train | def assign(self, droplet_id):
"""
Assign the floating IP to a droplet
:param droplet_id: the droplet to assign the floating IP to as either
an ID or a `Droplet` object
:type droplet_id: integer or `Droplet`
:return: an `Action` representing the in-progress operation ... | python | {
"resource": ""
} |
q38565 | SSHKey._id | train | def _id(self):
r"""
The `SSHKey`'s ``id`` field, or if that is not defined, its
``fingerprint`` field. If neither field is defined, accessing this
attribute raises a `TypeError`.
"""
if self.get("id") is not None:
return self.id
elif self.get("fingerp... | python | {
"resource": ""
} |
q38566 | SSHKey.fetch | train | def fetch(self):
"""
Fetch & return a new `SSHKey` object representing the SSH key's current
state
:rtype: SSHKey
:raises DOAPIError: if the API endpoint replies with an error (e.g., if
the SSH key no longer exists)
"""
api = self.doapi_manager
... | python | {
"resource": ""
} |
q38567 | MongrelRequest.parse | train | def parse(msg):
"""
Helper method for parsing a Mongrel2 request string and returning a new
`MongrelRequest` instance.
"""
sender, conn_id, path, rest = msg.split(' ', 3)
headers, rest = tnetstring.pop(rest)
body, _ = tnetstring.pop(rest)
if type(headers)... | python | {
"resource": ""
} |
q38568 | MongrelRequest.should_close | train | def should_close(self):
"""
Check whether the HTTP connection of this request should be closed
after the request is finished.
We check for the `Connection` HTTP header and for the HTTP Version
(only `HTTP/1.1` supports keep-alive.
"""
if self.headers.get('connect... | python | {
"resource": ""
} |
q38569 | PPMS.system_status | train | def system_status(self):
"""The system status codes."""
flag, timestamp, status = self._query(('GETDAT? 1', (Integer, Float, Integer)))
return {
# convert unix timestamp to datetime object
'timestamp': datetime.datetime.fromtimestamp(timestamp),
# bit 0-3 repr... | python | {
"resource": ""
} |
q38570 | PPMS.beep | train | def beep(self, duration, frequency):
"""Generates a beep.
:param duration: The duration in seconds, in the range 0.1 to 5.
:param frequency: The frequency in Hz, in the range 500 to 5000.
"""
cmd = 'BEEP', [Float(min=0.1, max=5.0), Integer(min=500, max=5000)]
self._writ... | python | {
"resource": ""
} |
q38571 | PPMS.move | train | def move(self, position, slowdown=0):
"""Move to the specified sample position.
:param position: The target position.
:param slowdown: The slowdown code, an integer in the range 0 to 14,
used to scale the stepper motor speed. 0, the default, is the
fastest rate and 14 th... | python | {
"resource": ""
} |
q38572 | PPMS.move_to_limit | train | def move_to_limit(self, position):
"""Move to limit switch and define it as position.
:param position: The new position of the limit switch.
"""
cmd = 'MOVE', [Float, Integer]
self._write(cmd, position, 1) | python | {
"resource": ""
} |
q38573 | PPMS.redefine_position | train | def redefine_position(self, position):
"""Redefines the current position to the new position.
:param position: The new position.
"""
cmd = 'MOVE', [Float, Integer]
self._write(cmd, position, 2) | python | {
"resource": ""
} |
q38574 | PPMS.set_field | train | def set_field(self, field, rate, approach='linear', mode='persistent',
wait_for_stability=True, delay=1):
"""Sets the magnetic field.
:param field: The target field in Oersted.
.. note:: The conversion is 1 Oe = 0.1 mT.
:param rate: The field rate in Oersted per ... | python | {
"resource": ""
} |
q38575 | dumpgrants | train | def dumpgrants(destination, as_json=None, setspec=None):
"""Harvest grants from OpenAIRE and store them locally."""
if os.path.isfile(destination):
click.confirm("Database '{0}' already exists."
"Do you want to write to it?".format(destination),
abort=True) #... | python | {
"resource": ""
} |
q38576 | SetFrontPage.postOptions | train | def postOptions(self):
"""
Find an installed offering and set the site front page to its
application's front page.
"""
o = self.store.findFirst(
offering.InstalledOffering,
(offering.InstalledOffering.offeringName ==
self["name"]))
if ... | python | {
"resource": ""
} |
q38577 | _legacySpecialCases | train | def _legacySpecialCases(form, patterns, parameter):
"""
Create a view object for the given parameter.
This function implements the remaining view construction logic which has
not yet been converted to the C{viewFactory}-style expressed in
L{_LiveFormMixin.form}.
@type form: L{_LiveFormMixin}
... | python | {
"resource": ""
} |
q38578 | Parameter.clone | train | def clone(self, default):
"""
Make a copy of this parameter, supplying a different default.
@type default: C{unicode} or C{NoneType}
@param default: A value which will be initially presented in the view
as the value for this parameter, or C{None} if no such value is to be
... | python | {
"resource": ""
} |
q38579 | ListChangeParameter._prepareSubForm | train | def _prepareSubForm(self, liveForm):
"""
Utility for turning liveforms into subforms, and compacting them as
necessary.
@param liveForm: a liveform.
@type liveForm: L{LiveForm}
@return: a sub form.
@rtype: L{LiveForm}
"""
liveForm = liveForm.asSu... | python | {
"resource": ""
} |
q38580 | ListChangeParameter._newIdentifier | train | def _newIdentifier(self):
"""
Make a new identifier for an as-yet uncreated model object.
@rtype: C{int}
"""
id = self._allocateID()
self._idsToObjects[id] = self._NO_OBJECT_MARKER
self._lastValues[id] = None
return id | python | {
"resource": ""
} |
q38581 | ListChangeParameter._coerceSingleRepetition | train | def _coerceSingleRepetition(self, dataSet):
"""
Make a new liveform with our parameters, and get it to coerce our data
for us.
"""
# make a liveform because there is some logic in _coerced
form = LiveForm(lambda **k: None, self.parameters, self.name)
return form.f... | python | {
"resource": ""
} |
q38582 | ListChangeParameter.coercer | train | def coercer(self, dataSets):
"""
Coerce all of the repetitions and sort them into creations, edits and
deletions.
@rtype: L{ListChanges}
@return: An object describing all of the creations, modifications, and
deletions represented by C{dataSets}.
"""
#... | python | {
"resource": ""
} |
q38583 | ChoiceParameter.clone | train | def clone(self, choices):
"""
Make a copy of this parameter, supply different choices.
@param choices: A sequence of L{Option} instances.
@type choices: C{list}
@rtype: L{ChoiceParameter}
"""
return self.__class__(
self.name,
choices,
... | python | {
"resource": ""
} |
q38584 | _LiveFormMixin.compact | train | def compact(self):
"""
Switch to the compact variant of the live form template.
By default, this will simply create a loader for the
C{self.compactFragmentName} template and compact all of this form's
parameters.
"""
self.docFactory = webtheme.getLoader(self.comp... | python | {
"resource": ""
} |
q38585 | _LiveFormMixin.submitbutton | train | def submitbutton(self, request, tag):
"""
Render an INPUT element of type SUBMIT which will post this form to the
server.
"""
return tags.input(type='submit',
name='__submit__',
value=self._getDescription()) | python | {
"resource": ""
} |
q38586 | _LiveFormMixin.form | train | def form(self, request, tag):
"""
Render the inputs for a form.
@param tag: A tag with:
- I{form} and I{description} slots
- I{liveform} and I{subform} patterns, to fill the I{form} slot
- An I{inputs} slot, to fill with parameter views
- L{IP... | python | {
"resource": ""
} |
q38587 | _LiveFormMixin.invoke | train | def invoke(self, formPostEmulator):
"""
Invoke my callable with input from the browser.
@param formPostEmulator: a dict of lists of strings in a format like a
cgi-module form post.
"""
result = self.fromInputs(formPostEmulator)
result.addCallback(lambda param... | python | {
"resource": ""
} |
q38588 | _LiveFormMixin.fromInputs | train | def fromInputs(self, received):
"""
Convert some random strings received from a browser into structured
data, using a list of parameters.
@param received: a dict of lists of strings, i.e. the canonical Python
form of web form post.
@rtype: L{Deferred}
@retur... | python | {
"resource": ""
} |
q38589 | ListChangeParameterView.repeater | train | def repeater(self, req, tag):
"""
Render some UI for repeating our form.
"""
repeater = inevow.IQ(self.docFactory).onePattern('repeater')
return repeater.fillSlots(
'object-description', self.parameter.modelObjectDescription) | python | {
"resource": ""
} |
q38590 | FormParameterView.input | train | def input(self, request, tag):
"""
Add the wrapped form, as a subform, as a child of the given tag.
"""
subform = self.parameter.form.asSubForm(self.parameter.name)
subform.setFragmentParent(self)
return tag[subform] | python | {
"resource": ""
} |
q38591 | GeoApi.get_arrive_stop | train | def get_arrive_stop(self, **kwargs):
"""Obtain bus arrival info in target stop.
Args:
stop_number (int): Stop number to query.
lang (str): Language code (*es* or *en*).
Returns:
Status boolean and parsed response (list[Arrival]), or message string
... | python | {
"resource": ""
} |
q38592 | GeoApi.get_groups | train | def get_groups(self, **kwargs):
"""Obtain line types and details.
Args:
lang (str): Language code (*es* or *en*).
Returns:
Status boolean and parsed response (list[GeoGroupItem]), or message
string in case of error.
"""
# Endpoint parameters
... | python | {
"resource": ""
} |
q38593 | GeoApi.get_info_line | train | def get_info_line(self, **kwargs):
"""Obtain basic information on a bus line on a given date.
Args:
day (int): Day of the month in format DD.
The number is automatically padded if it only has one digit.
month (int): Month number in format MM.
The ... | python | {
"resource": ""
} |
q38594 | GeoApi.get_poi | train | def get_poi(self, **kwargs):
"""Obtain a list of POI in the given radius.
Args:
latitude (double): Latitude in decimal degrees.
longitude (double): Longitude in decimal degrees.
types (list[int] | int): POI IDs (or empty list to get all).
radius (int): Ra... | python | {
"resource": ""
} |
q38595 | GeoApi.get_poi_types | train | def get_poi_types(self, **kwargs):
"""Obtain POI types.
Args:
lang (str): Language code (*es* or *en*).
Returns:
Status boolean and parsed response (list[PoiType]), or message string
in case of error.
"""
# Endpoint parameters
params ... | python | {
"resource": ""
} |
q38596 | GeoApi.get_route_lines_route | train | def get_route_lines_route(self, **kwargs):
"""Obtain itinerary for one or more lines in the given date.
Args:
day (int): Day of the month in format DD.
The number is automatically padded if it only has one digit.
month (int): Month number in format MM.
... | python | {
"resource": ""
} |
q38597 | GeoApi.get_stops_line | train | def get_stops_line(self, **kwargs):
"""Obtain information on the stops of the given lines.
Arguments:
lines (list[int] | int): Lines to query, may be empty to get
all the lines.
direction (str): Optional, either *forward* or *backward*.
lang (str): La... | python | {
"resource": ""
} |
q38598 | GeoApi.get_street | train | def get_street(self, **kwargs):
"""Obtain a list of nodes related to a location within a given radius.
Not sure of its use, but...
Args:
street_name (str): Name of the street to search.
street_number (int): Street number to search.
radius (int): Radius (in m... | python | {
"resource": ""
} |
q38599 | GeoApi.get_street_from_xy | train | def get_street_from_xy(self, **kwargs):
"""Obtain a list of streets around the specified point.
Args:
latitude (double): Latitude in decimal degrees.
longitude (double): Longitude in decimal degrees.
radius (int): Radius (in meters) of the search.
lang (s... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.