_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q45500 | CapakeyRestGateway.get_sectie_by_id_and_afdeling | train | def get_sectie_by_id_and_afdeling(self, id, afdeling):
'''
Get a `sectie`.
:param id: An id of a sectie. eg. "A"
:param afdeling: The :class:`Afdeling` for in which the `sectie` can \
be found. Can also be the id of and `afdeling`.
:rtype: A :class:`Sectie`.
... | python | {
"resource": ""
} |
q45501 | CapakeyRestGateway.list_percelen_by_sectie | train | def list_percelen_by_sectie(self, sectie):
'''
List all percelen in a `sectie`.
:param sectie: The :class:`Sectie` for which the percelen are wanted.
:param integer sort: Field to sort on.
:rtype: A :class:`list` of :class:`Perceel`.
'''
sid = sectie.id
a... | python | {
"resource": ""
} |
q45502 | Perceel._split_capakey | train | def _split_capakey(self):
'''
Split a capakey into more readable elements.
Splits a capakey into it's grondnummer, bisnummer, exponent and macht.
'''
import re
match = re.match(
r"^[0-9]{5}[A-Z]{1}([0-9]{4})\/([0-9]{2})([A-Z\_]{1})([0-9]{3})$",
se... | python | {
"resource": ""
} |
q45503 | requires_libsodium | train | def requires_libsodium(func):
"""
Mark a function as requiring libsodium.
If no libsodium support is detected, a `RuntimeError` is thrown.
"""
@wraps(func)
def wrapper(*args, **kwargs):
libsodium_check()
return func(*args, **kwargs)
return wrapper | python | {
"resource": ""
} |
q45504 | NamespaceAdmin.has_delete_permission | train | def has_delete_permission(self, request, obj=None):
"""
Default namespaces cannot be deleted.
"""
if obj is not None and obj.fixed:
return False
return super(NamespaceAdmin, self).has_delete_permission(request, obj) | python | {
"resource": ""
} |
q45505 | EntryAdminWYMEditorMixin.get_urls | train | def get_urls(self):
"""
Overload the admin's urls for WYMEditor.
"""
entry_admin_urls = super(EntryAdminWYMEditorMixin, self).get_urls()
urls = [
url(r'^wymeditor/$',
self.admin_site.admin_view(self.wymeditor),
name='zinnia_entry_wymedi... | python | {
"resource": ""
} |
q45506 | MockOpen._get_child_mock | train | def _get_child_mock(self, **kws):
"""Create a new FileLikeMock instance.
The new mock will inherit the parent's side_effect and read_data
attributes.
"""
kws.update({
'_new_parent': self,
'side_effect': self._mock_side_effect,
'read_data': sel... | python | {
"resource": ""
} |
q45507 | ZAPAuthenticator.on_request | train | async def on_request(
self,
domain,
address,
identity,
mechanism,
credentials,
):
"""
Handle a ZAP request.
"""
logger.debug(
"Request in domain %s for %s (%r): %r (%r)",
domain,
address,
... | python | {
"resource": ""
} |
q45508 | APIResource.factory | train | def factory(data):
"""
Try to reconstruct the APIResource from its data.
:param data: The APIResource data
:type data: dict
:return: The guessed APIResource
:raise
exceptions.UnkownAPIResource when it's impossible to reconstruct the APIResource from its dat... | python | {
"resource": ""
} |
q45509 | APIResource._initialize | train | def _initialize(self, **resource_attributes):
"""
Initialize a resource.
Default behavior is just to set all the attributes. You may want to override this.
:param resource_attributes: The resource attributes
"""
self._set_attributes(**resource_attributes)
for att... | python | {
"resource": ""
} |
q45510 | Payment._mapper | train | def _mapper(self):
"""
Maps payment attributes to their specific types.
:see :func:`~APIResource._mapper`
"""
return {
'card': Payment.Card,
'customer': Payment.Customer,
'hosted_payment': Payment.HostedPayment,
'notification': Pay... | python | {
"resource": ""
} |
q45511 | Customer.list_cards | train | def list_cards(self, *args, **kwargs):
"""
List the cards of the customer.
:param page: the page number
:type page: int|None
:param per_page: number of customers per page. It's a good practice to increase this number if you know that you
will need a lot of payments.
... | python | {
"resource": ""
} |
q45512 | APIResourceCollection._initialize | train | def _initialize(self, **resource_attributes):
"""
Initialize the collection.
:param resource_attributes: API resource parameters
"""
super(APIResourceCollection, self)._initialize(**resource_attributes)
dict_list = self.data
self.data = []
for resource i... | python | {
"resource": ""
} |
q45513 | retry | train | def retry(retries=10, wait=5, catch=None):
"""
Decorator to retry on exceptions raised
"""
catch = catch or (Exception,)
def real_retry(function):
def wrapper(*args, **kwargs):
for _ in range(retries):
try:
ret = function(*args, **kwargs)
... | python | {
"resource": ""
} |
q45514 | BaseConnection.discard_incoming_messages | train | def discard_incoming_messages(self):
"""
Discard all incoming messages for the time of the context manager.
"""
# Flush any received message so far.
self.inbox.clear()
# This allows nesting of discard_incoming_messages() calls.
previous = self._discard_incoming_m... | python | {
"resource": ""
} |
q45515 | MediaType.provides | train | def provides(self, imt):
"""
Returns True iff the self is at least as specific as other.
Examples:
application/xhtml+xml provides application/xml, application/*, */*
text/html provides text/*, but not application/xhtml+xml or application/html
"""
return self.type... | python | {
"resource": ""
} |
q45516 | MediaType.resolve | train | def resolve(cls, accept, available_renderers):
"""
Resolves a list of accepted MediaTypes and available renderers to the preferred renderer.
Call as MediaType.resolve([MediaType], [renderer]).
"""
assert isinstance(available_renderers, tuple)
accept = sorted(accept)
... | python | {
"resource": ""
} |
q45517 | StaticCompilerFileStorage.get_available_name | train | def get_available_name(self, name):
"""
Deletes the given file if it exists.
"""
if self.exists(name):
self.delete(name)
return name | python | {
"resource": ""
} |
q45518 | Multiplexer.add_socket | train | def add_socket(self, socket):
"""
Add a socket to the multiplexer.
:param socket: The socket. If it was added already, it won't be added a
second time.
"""
if socket not in self._sockets:
self._sockets.add(socket)
socket.on_closed.connect(self... | python | {
"resource": ""
} |
q45519 | Multiplexer.remove_socket | train | def remove_socket(self, socket):
"""
Remove a socket from the multiplexer.
:param socket: The socket. If it was removed already or if it wasn't
added, the call does nothing.
"""
if socket in self._sockets:
socket.on_closed.disconnect(self.remove_socket)
... | python | {
"resource": ""
} |
q45520 | Multiplexer.recv_multipart | train | async def recv_multipart(self):
"""
Read from all the associated sockets.
:returns: A list of tuples (socket, frames) for each socket that
returned a result.
"""
if not self._sockets:
return []
results = []
async def recv_and_store(socke... | python | {
"resource": ""
} |
q45521 | modified_data_decorator | train | def modified_data_decorator(function):
"""
Decorator to initialise the modified_data if necessary. To be used in list functions
to modify the list
"""
@wraps(function)
def func(self, *args, **kwargs):
"""Decorator function"""
if not self.get_read_only() or not self.is_locked():
... | python | {
"resource": ""
} |
q45522 | ListModel.initialise_modified_data | train | def initialise_modified_data(self):
"""
Initialise the modified_data if necessary
"""
if self.__modified_data__ is None:
if self.__original_data__:
self.__modified_data__ = list(self.__original_data__)
else:
self.__modified_data__ =... | python | {
"resource": ""
} |
q45523 | ListModel.append | train | def append(self, item):
"""
Appending elements to our list
"""
validated_value = self.get_validated_object(item)
if validated_value is not None:
self.__modified_data__.append(validated_value) | python | {
"resource": ""
} |
q45524 | ListModel.insert | train | def insert(self, index, p_object):
"""
Insert an element to a list
"""
validated_value = self.get_validated_object(p_object)
if validated_value is not None:
self.__modified_data__.insert(index, validated_value) | python | {
"resource": ""
} |
q45525 | ListModel.index | train | def index(self, value):
"""
Gets the index in the list for a value
"""
if self.__modified_data__ is not None:
return self.__modified_data__.index(value)
return self.__original_data__.index(value) | python | {
"resource": ""
} |
q45526 | ListModel.count | train | def count(self, value):
"""
Gives the number of occurrencies of a value in the list
"""
if self.__modified_data__ is not None:
return self.__modified_data__.count(value)
return self.__original_data__.count(value) | python | {
"resource": ""
} |
q45527 | ListModel.flat_data | train | def flat_data(self):
"""
Function to pass our modified values to the original ones
"""
def flat_field(value):
"""
Flat item
"""
try:
value.flat_data()
return value
except AttributeError:
... | python | {
"resource": ""
} |
q45528 | ListModel.export_data | train | def export_data(self):
"""
Retrieves the data in a jsoned form
"""
def export_field(value):
"""
Export item
"""
try:
return value.export_data()
except AttributeError:
return value
if sel... | python | {
"resource": ""
} |
q45529 | ListModel.export_modified_data | train | def export_modified_data(self):
"""
Retrieves the modified data in a jsoned form
"""
def export_modfield(value, is_modified_seq=True):
"""
Export modified item
"""
try:
return value.export_modified_data()
except... | python | {
"resource": ""
} |
q45530 | ListModel.export_modifications | train | def export_modifications(self):
"""
Returns list modifications.
"""
if self.__modified_data__ is not None:
return self.export_data()
result = {}
for key, value in enumerate(self.__original_data__):
try:
if not value.is_modified():... | python | {
"resource": ""
} |
q45531 | ListModel.export_original_data | train | def export_original_data(self):
"""
Retrieves the original_data
"""
def export_field(value):
"""
Export item
"""
try:
return value.export_original_data()
except AttributeError:
return value
... | python | {
"resource": ""
} |
q45532 | ListModel.export_deleted_fields | train | def export_deleted_fields(self):
"""
Returns a list with any deleted fields form original data.
In tree models, deleted fields on children will be appended.
"""
result = []
if self.__modified_data__ is not None:
return result
for index, item in enumer... | python | {
"resource": ""
} |
q45533 | ListModel.is_modified | train | def is_modified(self):
"""
Returns whether list is modified or not
"""
if self.__modified_data__ is not None:
return True
for value in self.__original_data__:
try:
if value.is_modified():
return True
except A... | python | {
"resource": ""
} |
q45534 | ListModel._get_indexes_by_path | train | def _get_indexes_by_path(self, field):
"""
Returns a list of indexes by field path.
:param field: Field structure as following:
*.subfield_2 would apply the function to the every subfield_2 of the elements
1.subfield_2 would apply the function to the subfield_2 of the elemen... | python | {
"resource": ""
} |
q45535 | example | train | def example(index):
"""Index page."""
pid = PersistentIdentifier.query.filter_by(id=index).one()
record = RecordMetadata.query.filter_by(id=pid.object_uuid).first()
return render_template("app/detail.html", record=record.json, pid=pid,
title="Demosite Invenio Org") | python | {
"resource": ""
} |
q45536 | rebin | train | def rebin(a, factor, func=None):
u"""Aggregate data from the input array ``a`` into rectangular tiles.
The output array results from tiling ``a`` and applying `func` to
each tile. ``factor`` specifies the size of the tiles. More
precisely, the returned array ``out`` is such that::
out[i0, i1, ... | python | {
"resource": ""
} |
q45537 | can_use_enum | train | def can_use_enum(func):
"""
Decorator to use Enum value on type checks.
"""
@wraps(func)
def inner(self, value):
if isinstance(value, Enum):
return self.check_value(value.value) or func(self, value.value)
return func(self, value)
return inner | python | {
"resource": ""
} |
q45538 | convert_enum | train | def convert_enum(func):
"""
Decorator to use Enum value on type casts.
"""
@wraps(func)
def inner(self, value):
try:
if self.check_value(value.value):
return value.value
return func(self, value.value)
except AttributeError:
pass
... | python | {
"resource": ""
} |
q45539 | BaseField.use_value | train | def use_value(self, value):
"""Converts value to field type or use original"""
if self.check_value(value):
return value
return self.convert_value(value) | python | {
"resource": ""
} |
q45540 | StringIdField.set_value | train | def set_value(self, obj, value):
"""Sets value to model if not empty"""
if value:
obj.set_field_value(self.name, value)
else:
self.delete_value(obj) | python | {
"resource": ""
} |
q45541 | ArgumentParser.action | train | def action(self):
"""
Invoke functions according to the supplied flags
"""
user = self.args['--user'] if self.args['--user'] else None
reset = True if self.args['--reset'] else False
if self.args['generate']:
generate_network(user, reset)
elif self.a... | python | {
"resource": ""
} |
q45542 | renderer | train | def renderer(format, mimetypes=(), priority=0, name=None, test=None):
"""
Decorates a view method to say that it renders a particular format and mimetypes.
Use as:
@renderer(format="foo")
def render_foo(self, request, context, template_name): ...
or
@renderer(format="foo", mimet... | python | {
"resource": ""
} |
q45543 | AsyncList.wait_change | train | async def wait_change(self):
"""
Wait for the list to change.
"""
future = asyncio.Future(loop=self.loop)
self._change_futures.add(future)
future.add_done_callback(self._change_futures.discard)
await future | python | {
"resource": ""
} |
q45544 | FairListProxy.shift | train | def shift(self, count=1):
"""
Shift the view a specified number of times.
:param count: The count of times to shift the view.
"""
if self:
self._index = (self._index + count) % len(self)
else:
self._index = 0 | python | {
"resource": ""
} |
q45545 | render | train | def render(value):
"""
This function finishes the url pattern creation by adding starting
character ^ end possibly by adding end character at the end
:param value: naive URL value
:return: raw string
"""
# Empty urls
if not value: # use case: wild card imports
return r'^$'
... | python | {
"resource": ""
} |
q45546 | get_conjunctive_graph | train | def get_conjunctive_graph(store_id=None):
"""
Returns an open conjunctive graph.
"""
if not store_id:
store_id = DEFAULT_STORE
store = DjangoStore(DEFAULT_STORE)
graph = ConjunctiveGraph(store=store, identifier=store_id)
if graph.open(None) != VALID_STORE:
raise ValueError("... | python | {
"resource": ""
} |
q45547 | get_named_graph | train | def get_named_graph(identifier, store_id=DEFAULT_STORE, create=True):
"""
Returns an open named graph.
"""
if not isinstance(identifier, URIRef):
identifier = URIRef(identifier)
store = DjangoStore(store_id)
graph = Graph(store, identifier=identifier)
if graph.open(None, create=crea... | python | {
"resource": ""
} |
q45548 | User.languages | train | def languages(self):
"""
A list of strings describing the user's languages.
"""
languages = []
for language in self.cache['languages']:
language = Structure(
id = language['id'],
name = language['name']
)
langu... | python | {
"resource": ""
} |
q45549 | User.interested_in | train | def interested_in(self):
"""
A list of strings describing the genders the user is interested in.
"""
genders = []
for gender in self.cache['interested_in']:
genders.append(gender)
return genders | python | {
"resource": ""
} |
q45550 | User.education | train | def education(self):
"""
A list of structures describing the user's education history.
Each structure has attributes ``school``, ``year``, ``concentration`` and ``type``.
``school``, ``year`` reference ``Page`` instances, while ``concentration`` is a list of ``Page``
instances.... | python | {
"resource": ""
} |
q45551 | User.permissions | train | def permissions(self):
"""
A list of strings describing permissions.
See Facebook's exhaustive `Permissions Reference <http://developers.facebook.com/docs/authentication/permissions/>`_
for a list of available permissions.
"""
response = self.graph.get('%s/permissions' %... | python | {
"resource": ""
} |
q45552 | User.accounts | train | def accounts(self):
"""
A list of structures describing apps and pages owned by this user.
"""
response = self.graph.get('%s/accounts' % self.id)
accounts = []
for item in response['data']:
account = Structure(
page = Page(
... | python | {
"resource": ""
} |
q45553 | Benchmark.update_xml_element | train | def update_xml_element(self):
"""
Updates the XML element contents to matches the instance contents.
:returns: Updated XML element.
:rtype: lxml.etree._Element
"""
if not hasattr(self, 'xml_element'):
self.xml_element = etree.Element(self.name, nsmap=NSMAP)
... | python | {
"resource": ""
} |
q45554 | post_message | train | def post_message(plugin, polled_time, identity, message):
"""Post single message
:type plugin: errbot.BotPlugin
:type polled_time: datetime.datetime
:type identity: str
:type message: str
"""
user = plugin.build_identifier(identity)
return plugin.send(user, message) | python | {
"resource": ""
} |
q45555 | open_pipe_connection | train | async def open_pipe_connection(
path=None,
*,
loop=None,
limit=DEFAULT_LIMIT,
**kwargs
):
"""
Connect to a server using a Windows named pipe.
"""
path = path.replace('/', '\\')
loop = loop or asyncio.get_event_loop()
reader = asyncio.StreamReader(limit=limit, loop=loop)
... | python | {
"resource": ""
} |
q45556 | BaseData.set_read_only | train | def set_read_only(self, value):
"""
Sets whether model could be modified or not
"""
if self.__read_only__ != value:
self.__read_only__ = value
self._update_read_only() | python | {
"resource": ""
} |
q45557 | BaseData.is_locked | train | def is_locked(self):
"""
Returns whether model is locked
"""
if not self.__locked__:
return False
elif self.get_parent():
return self.get_parent().is_locked()
return True | python | {
"resource": ""
} |
q45558 | generate_gml | train | def generate_gml(username, nodes, edges, cache=False):
"""
Generate a GML format file representing the given graph attributes
"""
# file segment that represents all the nodes in graph
node_content = ""
for i in range(len(nodes)):
node_id = "\t\tid %d\n" % (i + 1)
node_label = "\... | python | {
"resource": ""
} |
q45559 | config_extensions | train | def config_extensions(app):
" Init application with extensions. "
cache.init_app(app)
db.init_app(app)
main.init_app(app)
collect.init_app(app)
config_babel(app) | python | {
"resource": ""
} |
q45560 | config_babel | train | def config_babel(app):
" Init application with babel. "
babel.init_app(app)
def get_locale():
return request.accept_languages.best_match(app.config['BABEL_LANGUAGES'])
babel.localeselector(get_locale) | python | {
"resource": ""
} |
q45561 | CrontabMixin.activate_crontab | train | def activate_crontab(self):
"""Activate polling function and register first crontab
"""
self._crontab = []
if hasattr(self, 'CRONTAB'):
for crontab_spec in self.CRONTAB:
args = cronjob.parse_crontab(crontab_spec)
job = cronjob.CronJob()
... | python | {
"resource": ""
} |
q45562 | CrontabMixin.poll_crontab | train | def poll_crontab(self):
"""Check crontab and run target jobs
"""
polled_time = self._get_current_time()
if polled_time.second >= 30:
self.log.debug('Skip cronjobs in {}'.format(polled_time))
return
for job in self._crontab:
if not job.is_runnab... | python | {
"resource": ""
} |
q45563 | RouteMap.include | train | def include(self, location, namespace=None, app_name=None):
"""
Return an object suitable for url_patterns.
:param location: root URL for all URLs from this router
:param namespace: passed to url()
:param app_name: passed to url()
"""
sorted_entries = sorted(self... | python | {
"resource": ""
} |
q45564 | Installer.clone_source | train | def clone_source(self):
" Clone source and prepare templates "
print_header('Clone src: %s' % self.src, '-')
# Get source
source_dir = self._get_source()
# Append settings from source
self.read(op.join(source_dir, settings.CFGNAME))
self.templates += (self.arg... | python | {
"resource": ""
} |
q45565 | Installer._get_source | train | def _get_source(self):
" Get source from CVS or filepath. "
source_dir = op.join(self.deploy_dir, 'source')
for tp, cmd in settings.SRC_CLONE:
if self.src.startswith(tp + '+'):
program = which(tp)
assert program, '%s not found.' % tp
cm... | python | {
"resource": ""
} |
q45566 | quote | train | def quote(text, ws=plain):
"""Quote special characters in shell command arguments.
E.g ``--foo bar>=10.1`` becomes "--foo bar\>\=10\.1``.
"""
return "".join(chr in ws and chr or '\\' + chr
for chr in text) | python | {
"resource": ""
} |
q45567 | AbstractResponseMixin.render_to_response | train | def render_to_response(self, context):
"Return HttpResponse."
return http.HttpResponse(
self.render_template(context),
content_type=self.mimetype) | python | {
"resource": ""
} |
q45568 | prepare_plot_data | train | def prepare_plot_data(data_file):
"""
Return a list of Plotly elements representing the network graph
"""
G = ig.Graph.Read_GML(data_file)
layout = G.layout('graphopt')
labels = list(G.vs['label'])
N = len(labels)
E = [e.tuple for e in G.es]
community = G.community_multilevel().m... | python | {
"resource": ""
} |
q45569 | publish_network | train | def publish_network(user=None, reset=False):
"""
Generate graph network for a user and plot it using Plotly
"""
username = generate_network(user, reset)
network_file = username_to_file(username)
plot_data = prepare_plot_data(network_file)
data = Data(plot_data)
# hide axis line, grid,... | python | {
"resource": ""
} |
q45570 | array_split | train | def array_split(
ary,
indices_or_sections=None,
axis=None,
tile_shape=None,
max_tile_bytes=None,
max_tile_shape=None,
sub_tile_shape=None,
halo=None
):
"To be replaced."
return [
ary[slyce]
for slyce in
shape_split(
array_shape=ary.shape,
... | python | {
"resource": ""
} |
q45571 | ShapeSplitter.check_consistent_parameter_grouping | train | def check_consistent_parameter_grouping(self):
"""
Ensures this object does not have conflicting groups of parameters.
:raises ValueError: For conflicting or absent parameters.
"""
parameter_groups = {}
if self.indices_per_axis is not None:
parameter_groups["... | python | {
"resource": ""
} |
q45572 | Context.socket | train | def socket(self, socket_type, identity=None, mechanism=None):
"""
Create and register a new socket.
:param socket_type: The type of the socket.
:param loop: An optional event loop to associate the socket with.
This is the preferred method to create new sockets.
"""
... | python | {
"resource": ""
} |
q45573 | Context.set_zap_authenticator | train | def set_zap_authenticator(self, zap_authenticator):
"""
Setup a ZAP authenticator.
:param zap_authenticator: A ZAP authenticator instance to use. The
context takes ownership of the specified instance. It will close it
automatically when it stops. If `None` is specified, ... | python | {
"resource": ""
} |
q45574 | GitRepo.get_vcs_directory | train | def get_vcs_directory(context, directory):
"""Get the pathname of the directory containing the version control metadata files."""
nested = os.path.join(directory, '.git')
return nested if context.is_directory(nested) else directory | python | {
"resource": ""
} |
q45575 | GitRepo.expand_branch_name | train | def expand_branch_name(self, name):
"""
Expand branch names to their unambiguous form.
:param name: The name of a local or remote branch (a string).
:returns: The unambiguous form of the branch name (a string).
This internal method is used by methods like :func:`find_revision_i... | python | {
"resource": ""
} |
q45576 | GitRepo.find_author | train | def find_author(self):
"""Get the author information from the version control system."""
return Author(name=self.context.capture('git', 'config', 'user.name', check=False, silent=True),
email=self.context.capture('git', 'config', 'user.email', check=False, silent=True)) | python | {
"resource": ""
} |
q45577 | GitRepo.get_create_command | train | def get_create_command(self):
"""Get the command to create the local repository."""
command = ['git', 'clone' if self.remote else 'init']
if self.bare:
command.append('--bare')
if self.remote:
command.append(self.remote)
command.append(self.local)
... | python | {
"resource": ""
} |
q45578 | GitRepo.get_export_command | train | def get_export_command(self, directory, revision):
"""Get the command to export the complete tree from the local repository."""
shell_command = 'git archive %s | tar --extract --directory=%s'
return [shell_command % (quote(revision), quote(directory))] | python | {
"resource": ""
} |
q45579 | Instance.new | train | def new(cls, settings, *args, **kwargs):
"""
Create a new Cloud instance based on the Settings
"""
logger.debug('Initializing new "%s" Instance object' % settings['CLOUD'])
cloud = settings['CLOUD']
if cloud == 'bare':
self = BareInstance(settings=settings, *a... | python | {
"resource": ""
} |
q45580 | initialise_loggers | train | def initialise_loggers(names, log_level=_builtin_logging.WARNING, handler_class=SplitStreamHandler):
"""
Initialises specified loggers to generate output at the
specified logging level. If the specified named loggers do not exist,
they are created.
:type names: :obj:`list` of :obj:`str`
:param ... | python | {
"resource": ""
} |
q45581 | ClientController.close | train | def close(self):
"""Shut down the socket connection, client and controller"""
self._sock = None
self._controller = None
if hasattr(self, "_port") and self._port:
portpicker.return_port(self._port)
self._port = None | python | {
"resource": ""
} |
q45582 | ClientController.connect | train | def connect(self, url=c.LOCALHOST, port=None, timeout=c.INITIAL_TIMEOUT,
debug=False):
"""socket connect to an already running starcraft2 process"""
if port != None: # force a selection to a new port
if self._port!=None: # if previously allocated port, return it
... | python | {
"resource": ""
} |
q45583 | ClientController.debug | train | def debug(self, *debugReqs):
"""send a debug command to control the game state's setup"""
return self._client.send(debug=sc2api_pb2.RequestDebug(debug=debugReqs)) | python | {
"resource": ""
} |
q45584 | GoogleCloudProvider.submit | train | def submit(self, command="", blocksize=1, job_name="parsl.auto"):
''' The submit method takes the command string to be executed upon
instantiation of a resource most often to start a pilot.
Args :
- command (str) : The bash command string to be executed.
- blocksize (i... | python | {
"resource": ""
} |
q45585 | unpack | train | def unpack(rv):
"""Unpack the response from a view.
:param rv: the view response
:type rv: either a :class:`werkzeug.wrappers.Response` or a
tuple of (data, status_code, headers)
"""
if isinstance(rv, ResponseBase):
return rv
status = headers = None
if isinstance(rv, tuple... | python | {
"resource": ""
} |
q45586 | Api.init_app | train | def init_app(self, app):
"""Initialize actions with the app or blueprint.
:param app: the Flask application or blueprint object
:type app: :class:`~flask.Flask` or :class:`~flask.Blueprint`
Examples::
api = Api()
api.add_resource(...)
api.init_app(b... | python | {
"resource": ""
} |
q45587 | Api._deferred_blueprint_init | train | def _deferred_blueprint_init(self, setup_state):
"""Bind resources to the app as recorded in blueprint.
Synchronize prefix between blueprint/api and registration options, then
perform initialization with setup_state.app :class:`flask.Flask` object.
When a :class:`flask.ext.resteasy.Api`... | python | {
"resource": ""
} |
q45588 | Api._register_view | train | def _register_view(self, app, resource, *urls, **kwargs):
"""Bind resources to the app.
:param app: an actual :class:`flask.Flask` app
:param resource:
:param urls:
:param endpoint: endpoint name (defaults to :meth:`Resource.__name__.lower`
Can be used to reference ... | python | {
"resource": ""
} |
q45589 | Api._add_url_rule_patch | train | def _add_url_rule_patch(blueprint_setup, rule, endpoint=None, view_func=None, **options):
"""Patch BlueprintSetupState.add_url_rule for delayed creation.
Method used for setup state instance corresponding to this Api
instance. Exists primarily to enable _make_url's function.
:param bl... | python | {
"resource": ""
} |
q45590 | Api._make_url | train | def _make_url(self, url_part, blueprint_prefix):
"""Create URL from blueprint_prefix, api prefix and resource url.
This method is used to defer the construction of the final url in
the case that the Api is created with a Blueprint.
:param url_part: The part of the url the endpoint is r... | python | {
"resource": ""
} |
q45591 | Api.url_for | train | def url_for(self, resource, **kwargs):
"""Create a url for the given resource.
:param resource: The resource
:type resource: :class:`Resource`
:param kwargs: Same arguments you would give :class:`flask.url_for`
"""
if self.blueprint:
return flask.url_for('.' ... | python | {
"resource": ""
} |
q45592 | Deployer.deploy | train | def deploy(self, job_name, command='', blocksize=1):
instances = []
"""Deploy the template to a resource group."""
self.client.resource_groups.create_or_update(
self.resource_group,
{
'location': self.location,
}
)
template_pa... | python | {
"resource": ""
} |
q45593 | Deployer.destroy | train | def destroy(self, job_ids):
"""Destroy the given resource group"""
for job_id in job_ids:
self.client.resource_groups.delete(self.resource_group) | python | {
"resource": ""
} |
q45594 | Deployer.get_vm | train | def get_vm(self, resource_group_name, vm_name):
'''
you need to retry this just in case the credentials token expires,
that's where the decorator comes in
this will return all the data about the virtual machine
'''
return self.client.virtual_machines.get(
reso... | python | {
"resource": ""
} |
q45595 | Russound._retrieve_cached_zone_variable | train | def _retrieve_cached_zone_variable(self, zone_id, name):
"""
Retrieves the cache state of the named variable for a particular
zone. If the variable has not been cached then the UncachedVariable
exception is raised.
"""
try:
s = self._zone_state[zone_id][name.l... | python | {
"resource": ""
} |
q45596 | Russound._store_cached_zone_variable | train | def _store_cached_zone_variable(self, zone_id, name, value):
"""
Stores the current known value of a zone variable into the cache.
Calls any zone callbacks.
"""
zone_state = self._zone_state.setdefault(zone_id, {})
name = name.lower()
zone_state[name] = value
... | python | {
"resource": ""
} |
q45597 | Russound._retrieve_cached_source_variable | train | def _retrieve_cached_source_variable(self, source_id, name):
"""
Retrieves the cache state of the named variable for a particular
source. If the variable has not been cached then the UncachedVariable
exception is raised.
"""
try:
s = self._source_state[source_... | python | {
"resource": ""
} |
q45598 | Russound._store_cached_source_variable | train | def _store_cached_source_variable(self, source_id, name, value):
"""
Stores the current known value of a source variable into the cache.
Calls any source callbacks.
"""
source_state = self._source_state.setdefault(source_id, {})
name = name.lower()
source_state[na... | python | {
"resource": ""
} |
q45599 | Russound.connect | train | def connect(self):
"""
Connect to the controller and start processing responses.
"""
logger.info("Connecting to %s:%s", self._host, self._port)
reader, writer = yield from asyncio.open_connection(
self._host, self._port, loop=self._loop)
self._ioloop_futur... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.