_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q232400 | Combo.clear | train | def clear(self):
"""
Clears all the options in a Combo
"""
self._options = []
self._combo_menu.tk.delete(0, END)
self._selected.set("") | python | {
"resource": ""
} |
q232401 | Combo._set_option | train | def _set_option(self, value):
"""
Sets a single option in the Combo, returning True if it was able too.
"""
if len(self._options) > 0:
if value in self._options:
self._selected.set(value)
return True
else:
return Fal... | python | {
"resource": ""
} |
q232402 | Combo._set_option_by_index | train | def _set_option_by_index(self, index):
"""
Sets a single option in the Combo by its index, returning True if it was able too.
"""
if index < len(self._options):
self._selected.set(self._options[index])
return True
else:
return False | python | {
"resource": ""
} |
q232403 | ScheduleMixin.after | train | def after(self, time, function, args = []):
"""Call `function` after `time` milliseconds."""
callback_id = self.tk.after(time, self._call_wrapper, time, function, *args)
self._callback[function] = [callback_id, False] | python | {
"resource": ""
} |
q232404 | ScheduleMixin.repeat | train | def repeat(self, time, function, args = []):
"""Repeat `function` every `time` milliseconds."""
callback_id = self.tk.after(time, self._call_wrapper, time, function, *args)
self._callback[function] = [callback_id, True] | python | {
"resource": ""
} |
q232405 | ScheduleMixin.cancel | train | def cancel(self, function):
"""Cancel the scheduled `function` calls."""
if function in self._callback.keys():
callback_id = self._callback[function][0]
self.tk.after_cancel(callback_id)
self._callback.pop(function)
else:
utils.error_format("Could ... | python | {
"resource": ""
} |
q232406 | ScheduleMixin._call_wrapper | train | def _call_wrapper(self, time, function, *args):
"""Fired by tk.after, gets the callback and either executes the function and cancels or repeats"""
# execute the function
function(*args)
if function in self._callback.keys():
repeat = self._callback[function][1]
if ... | python | {
"resource": ""
} |
q232407 | EventCallback.rebind | train | def rebind(self, tks):
"""
Rebinds the tk event, only used if a widget has been destroyed
and recreated.
"""
self._tks = tks
for tk in self._tks:
tk.unbind_all(self._tk_event)
func_id = tk.bind(self._tk_event, self._event_callback)
self... | python | {
"resource": ""
} |
q232408 | EventManager.rebind_events | train | def rebind_events(self, *tks):
"""
Rebinds all the tk events, only used if a tk widget has been destroyed
and recreated.
"""
for ref in self._refs:
self._refs[ref].rebind(tks) | python | {
"resource": ""
} |
q232409 | Box.set_border | train | def set_border(self, thickness, color="black"):
"""
Sets the border thickness and color.
:param int thickness:
The thickenss of the border.
:param str color:
The color of the border.
"""
self._set_tk_config("highlightthickness", thickness)
... | python | {
"resource": ""
} |
q232410 | Window.hide | train | def hide(self):
"""Hide the window."""
self.tk.withdraw()
self._visible = False
if self._modal:
self.tk.grab_release() | python | {
"resource": ""
} |
q232411 | Window.show | train | def show(self, wait = False):
"""Show the window."""
self.tk.deiconify()
self._visible = True
self._modal = wait
if self._modal:
self.tk.grab_set() | python | {
"resource": ""
} |
q232412 | App.destroy | train | def destroy(self):
"""
Destroy and close the App.
:return:
None.
:note:
Once destroyed an App can no longer be used.
"""
# if this is the main_app - set the _main_app class variable to `None`.
if self == App._main_app:
App._m... | python | {
"resource": ""
} |
q232413 | Drawing.line | train | def line(self, x1, y1, x2, y2, color="black", width=1):
"""
Draws a line between 2 points
:param int x1:
The x position of the starting point.
:param int y1:
The y position of the starting point.
:param int x2:
The x position of the end poin... | python | {
"resource": ""
} |
q232414 | Drawing.oval | train | def oval(self, x1, y1, x2, y2, color="black", outline=False, outline_color="black"):
"""
Draws an oval between 2 points
:param int x1:
The x position of the starting point.
:param int y1:
The y position of the starting point.
:param int x2:
... | python | {
"resource": ""
} |
q232415 | Drawing.rectangle | train | def rectangle(self, x1, y1, x2, y2, color="black", outline=False, outline_color="black"):
"""
Draws a rectangle between 2 points
:param int x1:
The x position of the starting point.
:param int y1:
The y position of the starting point.
:param int x2:
... | python | {
"resource": ""
} |
q232416 | Drawing.polygon | train | def polygon(self, *coords, color="black", outline=False, outline_color="black"):
"""
Draws a polygon from an list of co-ordinates
:param int *coords:
Pairs of x and y positions which make up the polygon.
:param str color:
The color of the shape. Defaults to `"bl... | python | {
"resource": ""
} |
q232417 | Drawing.triangle | train | def triangle(self, x1, y1, x2, y2, x3, y3, color="black", outline=False, outline_color="black"):
"""
Draws a triangle between 3 points
:param int x1:
The x position of the starting point.
:param int y1:
The y position of the starting point.
:param int x... | python | {
"resource": ""
} |
q232418 | Base._get_tk_config | train | def _get_tk_config(self, key, default=False):
"""
Gets the config from the widget's tk object.
:param string key:
The tk config key.
:param bool default:
Returns the default value for this key. Defaults to `False`.
"""
if default:
ret... | python | {
"resource": ""
} |
q232419 | Base._set_tk_config | train | def _set_tk_config(self, keys, value):
"""
Gets the config from the widget's tk object
:param string/List keys:
The tk config key or a list of tk keys.
:param variable value:
The value to set. If the value is `None`, the config value will be
reset to... | python | {
"resource": ""
} |
q232420 | Component.destroy | train | def destroy(self):
"""
Destroy the tk widget.
"""
# if this widget has a master remove the it from the master
if self.master is not None:
self.master._remove_child(self)
self.tk.destroy() | python | {
"resource": ""
} |
q232421 | Container.add_tk_widget | train | def add_tk_widget(self, tk_widget, grid=None, align=None, visible=True, enabled=None, width=None, height=None):
"""
Adds a tk widget into a guizero container.
:param tkinter.Widget tk_widget:
The Container (App, Box, etc) the tk widget will belong too.
:param List grid:
... | python | {
"resource": ""
} |
q232422 | Container.display_widgets | train | def display_widgets(self):
"""
Displays all the widgets associated with this Container.
Should be called when the widgets need to be "re-packed/gridded".
"""
# All widgets are removed and then recreated to ensure the order they
# were created is the order they are displa... | python | {
"resource": ""
} |
q232423 | Container.disable | train | def disable(self):
"""
Disable all the widgets in this container
"""
self._enabled = False
for child in self.children:
if isinstance(child, (Container, Widget)):
child.disable() | python | {
"resource": ""
} |
q232424 | Container.enable | train | def enable(self):
"""
Enable all the widgets in this container
"""
self._enabled = True
for child in self.children:
if isinstance(child, (Container, Widget)):
child.enable() | python | {
"resource": ""
} |
q232425 | BaseWindow.exit_full_screen | train | def exit_full_screen(self):
"""Change from full screen to windowed mode and remove key binding"""
self.tk.attributes("-fullscreen", False)
self._full_screen = False
self.events.remove_event("<FullScreen.Escape>") | python | {
"resource": ""
} |
q232426 | ContainerWidget._set_propagation | train | def _set_propagation(self, width, height):
"""
Set the propagation value of the tk widget dependent on the width and height
:param int width:
The width of the widget.
:param int height:
The height of the widget.
"""
if width is None:
... | python | {
"resource": ""
} |
q232427 | Instruction.load | train | def load(self, addr, ty):
"""
Load a value from memory into a VEX temporary register.
:param addr: The VexValue containing the addr to load from.
:param ty: The Type of the resulting data
:return: a VexValue
"""
rdt = self.irsb_c.load(addr.rdt, ty)
return... | python | {
"resource": ""
} |
q232428 | Instruction.constant | train | def constant(self, val, ty):
"""
Creates a constant as a VexValue
:param val: The value, as an integer
:param ty: The type of the resulting VexValue
:return: a VexValue
"""
if isinstance(val, VexValue) and not isinstance(val, IRExpr):
raise Exception(... | python | {
"resource": ""
} |
q232429 | Instruction.put | train | def put(self, val, reg):
"""
Puts a value from a VEX temporary register into a machine register.
This is how the results of operations done to registers get committed to the machine's state.
:param val: The VexValue to store (Want to store a constant? See Constant() first)
:para... | python | {
"resource": ""
} |
q232430 | Instruction.put_conditional | train | def put_conditional(self, cond, valiftrue, valiffalse, reg):
"""
Like put, except it checks a condition
to decide what to put in the destination register.
:param cond: The VexValue representing the logical expression for the condition
(if your expression only has constants, ... | python | {
"resource": ""
} |
q232431 | Instruction.store | train | def store(self, val, addr):
"""
Store a VexValue in memory at the specified loaction.
:param val: The VexValue of the value to store
:param addr: The VexValue of the address to store into
:return: None
"""
self.irsb_c.store(addr.rdt, val.rdt) | python | {
"resource": ""
} |
q232432 | Instruction.jump | train | def jump(self, condition, to_addr, jumpkind=JumpKind.Boring, ip_offset=None):
"""
Jump to a specified destination, under the specified condition.
Used for branches, jumps, calls, returns, etc.
:param condition: The VexValue representing the expression for the guard, or None for an uncon... | python | {
"resource": ""
} |
q232433 | register | train | def register(lifter, arch_name):
"""
Registers a Lifter or Postprocessor to be used by pyvex. Lifters are are given priority based on the order
in which they are registered. Postprocessors will be run in registration order.
:param lifter: The Lifter or Postprocessor to register
:vartype lifte... | python | {
"resource": ""
} |
q232434 | IRExpr.child_expressions | train | def child_expressions(self):
"""
A list of all of the expressions that this expression ends up evaluating.
"""
expressions = [ ]
for k in self.__slots__:
v = getattr(self, k)
if isinstance(v, IRExpr):
expressions.append(v)
e... | python | {
"resource": ""
} |
q232435 | IRExpr.constants | train | def constants(self):
"""
A list of all of the constants that this expression ends up using.
"""
constants = [ ]
for k in self.__slots__:
v = getattr(self, k)
if isinstance(v, IRExpr):
constants.extend(v.constants)
elif isinstanc... | python | {
"resource": ""
} |
q232436 | IRSB.expressions | train | def expressions(self):
"""
Return an iterator of all expressions contained in the IRSB.
"""
for s in self.statements:
for expr_ in s.expressions:
yield expr_
yield self.next | python | {
"resource": ""
} |
q232437 | IRSB.instructions | train | def instructions(self):
"""
The number of instructions in this block
"""
if self._instructions is None:
if self.statements is None:
self._instructions = 0
else:
self._instructions = len([s for s in self.statements if type(s) is stmt... | python | {
"resource": ""
} |
q232438 | IRSB.instruction_addresses | train | def instruction_addresses(self):
"""
Addresses of instructions in this block.
"""
if self._instruction_addresses is None:
if self.statements is None:
self._instruction_addresses = [ ]
else:
self._instruction_addresses = [ (s.addr + ... | python | {
"resource": ""
} |
q232439 | IRSB.size | train | def size(self):
"""
The size of this block, in bytes
"""
if self._size is None:
self._size = sum(s.len for s in self.statements if type(s) is stmt.IMark)
return self._size | python | {
"resource": ""
} |
q232440 | IRSB.operations | train | def operations(self):
"""
A list of all operations done by the IRSB, as libVEX enum names
"""
ops = []
for e in self.expressions:
if hasattr(e, 'op'):
ops.append(e.op)
return ops | python | {
"resource": ""
} |
q232441 | IRSB.constant_jump_targets | train | def constant_jump_targets(self):
"""
A set of the static jump targets of the basic block.
"""
exits = set()
if self.exit_statements:
for _, _, stmt_ in self.exit_statements:
exits.add(stmt_.dst.value)
default_target = self.default_exit_target... | python | {
"resource": ""
} |
q232442 | IRSB.constant_jump_targets_and_jumpkinds | train | def constant_jump_targets_and_jumpkinds(self):
"""
A dict of the static jump targets of the basic block to their jumpkind.
"""
exits = dict()
if self.exit_statements:
for _, _, stmt_ in self.exit_statements:
exits[stmt_.dst.value] = stmt_.jumpkind
... | python | {
"resource": ""
} |
q232443 | IRSB._pp_str | train | def _pp_str(self):
"""
Return the pretty-printed IRSB.
:rtype: str
"""
sa = []
sa.append("IRSB {")
if self.statements is not None:
sa.append(" %s" % self.tyenv)
sa.append("")
if self.statements is not None:
for i, s in en... | python | {
"resource": ""
} |
q232444 | IRSB._is_defaultexit_direct_jump | train | def _is_defaultexit_direct_jump(self):
"""
Checks if the default of this IRSB a direct jump or not.
"""
if not (self.jumpkind == 'Ijk_InvalICache' or self.jumpkind == 'Ijk_Boring' or self.jumpkind == 'Ijk_Call'):
return False
target = self.default_exit_target
... | python | {
"resource": ""
} |
q232445 | IRTypeEnv.lookup | train | def lookup(self, tmp):
"""
Return the type of temporary variable `tmp` as an enum string
"""
if tmp < 0 or tmp > self.types_used:
l.debug("Invalid temporary number %d", tmp)
raise IndexError(tmp)
return self.types[tmp] | python | {
"resource": ""
} |
q232446 | Lifter._lift | train | def _lift(self,
data,
bytes_offset=None,
max_bytes=None,
max_inst=None,
opt_level=1,
traceflags=None,
allow_arch_optimizations=None,
strict_block_end=None,
skip_stmts=False,
collec... | python | {
"resource": ""
} |
q232447 | exp_backoff | train | def exp_backoff(attempt, cap=3600, base=300):
""" Exponential backoff time """
# this is a numerically stable version of
# min(cap, base * 2 ** attempt)
max_attempts = math.log(cap / base, 2)
if attempt <= max_attempts:
return base * 2 ** attempt
return cap | python | {
"resource": ""
} |
q232448 | Proxies.get_proxy | train | def get_proxy(self, proxy_address):
"""
Return complete proxy name associated with a hostport of a given
``proxy_address``. If ``proxy_address`` is unkonwn or empty,
return None.
"""
if not proxy_address:
return None
hostport = extract_proxy_hostport(p... | python | {
"resource": ""
} |
q232449 | Proxies.mark_dead | train | def mark_dead(self, proxy, _time=None):
""" Mark a proxy as dead """
if proxy not in self.proxies:
logger.warn("Proxy <%s> was not found in proxies list" % proxy)
return
if proxy in self.good:
logger.debug("GOOD proxy became DEAD: <%s>" % proxy)
else:... | python | {
"resource": ""
} |
q232450 | Proxies.mark_good | train | def mark_good(self, proxy):
""" Mark a proxy as good """
if proxy not in self.proxies:
logger.warn("Proxy <%s> was not found in proxies list" % proxy)
return
if proxy not in self.good:
logger.debug("Proxy <%s> is GOOD" % proxy)
self.unchecked.discard... | python | {
"resource": ""
} |
q232451 | Proxies.reanimate | train | def reanimate(self, _time=None):
""" Move dead proxies to unchecked if a backoff timeout passes """
n_reanimated = 0
now = _time or time.time()
for proxy in list(self.dead):
state = self.proxies[proxy]
assert state.next_check is not None
if state.next_... | python | {
"resource": ""
} |
q232452 | Proxies.reset | train | def reset(self):
""" Mark all dead proxies as unchecked """
for proxy in list(self.dead):
self.dead.remove(proxy)
self.unchecked.add(proxy) | python | {
"resource": ""
} |
q232453 | KeywordTable.on_change | train | def on_change(self, path, event_type):
"""Respond to changes in the file system
This method will be given the path to a file that
has changed on disk. We need to reload the keywords
from that file
"""
# I can do all this work in a sql statement, but
# for debuggi... | python | {
"resource": ""
} |
q232454 | KeywordTable._load_keywords | train | def _load_keywords(self, collection_id, path=None, libdoc=None):
"""Load a collection of keywords
One of path or libdoc needs to be passed in...
"""
if libdoc is None and path is None:
raise(Exception("You must provide either a path or libdoc argument"))
if libdo... | python | {
"resource": ""
} |
q232455 | KeywordTable.add_file | train | def add_file(self, path):
"""Add a resource file or library file to the database"""
libdoc = LibraryDocumentation(path)
if len(libdoc.keywords) > 0:
if libdoc.doc.startswith("Documentation for resource file"):
# bah! The file doesn't have an file-level documentation
... | python | {
"resource": ""
} |
q232456 | KeywordTable.add_library | train | def add_library(self, name):
"""Add a library to the database
This method is for adding a library by name (eg: "BuiltIn")
rather than by a file.
"""
libdoc = LibraryDocumentation(name)
if len(libdoc.keywords) > 0:
# FIXME: figure out the path to the library f... | python | {
"resource": ""
} |
q232457 | KeywordTable.add_folder | train | def add_folder(self, dirname, watch=True):
"""Recursively add all files in a folder to the database
By "all files" I mean, "all files that are resource files
or library files". It will silently ignore files that don't
look like they belong in the database. Pity the fool who
uses... | python | {
"resource": ""
} |
q232458 | KeywordTable.add_installed_libraries | train | def add_installed_libraries(self, extra_libs = ["Selenium2Library",
"SudsLibrary",
"RequestsLibrary"]):
"""Add any installed libraries that we can find
We do this by looking in the `libraries` folder... | python | {
"resource": ""
} |
q232459 | KeywordTable.get_collection | train | def get_collection(self, collection_id):
"""Get a specific collection"""
sql = """SELECT collection.collection_id, collection.type,
collection.name, collection.path,
collection.doc,
collection.version, collection.scope,
... | python | {
"resource": ""
} |
q232460 | KeywordTable.get_keyword | train | def get_keyword(self, collection_id, name):
"""Get a specific keyword from a library"""
sql = """SELECT keyword.name, keyword.args, keyword.doc
FROM keyword_table as keyword
WHERE keyword.collection_id == ?
AND keyword.name like ?
"""
... | python | {
"resource": ""
} |
q232461 | KeywordTable._looks_like_libdoc_file | train | def _looks_like_libdoc_file(self, name):
"""Return true if an xml file looks like a libdoc file"""
# inefficient since we end up reading the file twice,
# but it's fast enough for our purposes, and prevents
# us from doing a full parse of files that are obviously
# not libdoc fil... | python | {
"resource": ""
} |
q232462 | KeywordTable._looks_like_resource_file | train | def _looks_like_resource_file(self, name):
"""Return true if the file has a keyword table but not a testcase table"""
# inefficient since we end up reading the file twice,
# but it's fast enough for our purposes, and prevents
# us from doing a full parse of files that are obviously
... | python | {
"resource": ""
} |
q232463 | KeywordTable._should_ignore | train | def _should_ignore(self, name):
"""Return True if a given library name should be ignored
This is necessary because not all files we find in the library
folder are libraries. I wish there was a public robot API
for "give me a list of installed libraries"...
"""
_name = na... | python | {
"resource": ""
} |
q232464 | KeywordTable._execute | train | def _execute(self, *args):
"""Execute an SQL query
This exists because I think it's tedious to get a cursor and
then use a cursor.
"""
cursor = self.db.cursor()
cursor.execute(*args)
return cursor | python | {
"resource": ""
} |
q232465 | KeywordTable._glob_to_sql | train | def _glob_to_sql(self, string):
"""Convert glob-like wildcards to SQL wildcards
* becomes %
? becomes _
% becomes \%
\\ remains \\
\* remains \*
\? remains \?
This also adds a leading and trailing %, unless the pattern begins with
^ or ends with ... | python | {
"resource": ""
} |
q232466 | doc | train | def doc():
"""Show a list of libraries, along with the nav panel on the left"""
kwdb = current_app.kwdb
libraries = get_collections(kwdb, libtype="library")
resource_files = get_collections(kwdb, libtype="resource")
hierarchy = get_navpanel_data(kwdb)
return flask.render_template("home.html",
... | python | {
"resource": ""
} |
q232467 | index | train | def index():
"""Show a list of available libraries, and resource files"""
kwdb = current_app.kwdb
libraries = get_collections(kwdb, libtype="library")
resource_files = get_collections(kwdb, libtype="resource")
return flask.render_template("libraryNames.html",
data=... | python | {
"resource": ""
} |
q232468 | search | train | def search():
"""Show all keywords that match a pattern"""
pattern = flask.request.args.get('pattern', "*").strip().lower()
# if the pattern contains "in:<collection>" (eg: in:builtin),
# filter results to only that (or those) collections
# This was kind-of hacked together, but seems to work well e... | python | {
"resource": ""
} |
q232469 | get_collections | train | def get_collections(kwdb, libtype="*"):
"""Get list of collections from kwdb, then add urls necessary for hyperlinks"""
collections = kwdb.get_collections(libtype=libtype)
for result in collections:
url = flask.url_for(".doc_for_library", collection_id=result["collection_id"])
result["url"] ... | python | {
"resource": ""
} |
q232470 | get_navpanel_data | train | def get_navpanel_data(kwdb):
"""Get navpanel data from kwdb, and add urls necessary for hyperlinks"""
data = kwdb.get_keyword_hierarchy()
for library in data:
library["url"] = flask.url_for(".doc_for_library", collection_id=library["collection_id"])
for keyword in library["keywords"]:
... | python | {
"resource": ""
} |
q232471 | doc_to_html | train | def doc_to_html(doc, doc_format="ROBOT"):
"""Convert documentation to HTML"""
from robot.libdocpkg.htmlwriter import DocToHtml
return DocToHtml(doc_format)(doc) | python | {
"resource": ""
} |
q232472 | RobotHub.start | train | def start(self):
"""Start the app"""
if self.args.debug:
self.app.run(port=self.args.port, debug=self.args.debug, host=self.args.interface)
else:
root = "http://%s:%s" % (self.args.interface, self.args.port)
print("tornado web server running on " + root)
... | python | {
"resource": ""
} |
q232473 | RobotHub.check_shutdown_flag | train | def check_shutdown_flag(self):
"""Shutdown the server if the flag has been set"""
if self.shutdown_requested:
tornado.ioloop.IOLoop.instance().stop()
print("web server stopped.") | python | {
"resource": ""
} |
q232474 | coords | train | def coords(obj):
"""
Yields the coordinates from a Feature or Geometry.
:param obj: A geometry or feature to extract the coordinates from.
:type obj: Feature, Geometry
:return: A generator with coordinate tuples from the geometry or feature.
:rtype: generator
"""
# Handle recursive case... | python | {
"resource": ""
} |
q232475 | map_tuples | train | def map_tuples(func, obj):
"""
Returns the mapped coordinates from a Geometry after applying the provided
function to each coordinate.
:param func: Function to apply to tuples
:type func: function
:param obj: A geometry or feature to extract the coordinates from.
:type obj: Point, LineStrin... | python | {
"resource": ""
} |
q232476 | map_geometries | train | def map_geometries(func, obj):
"""
Returns the result of passing every geometry in the given geojson object
through func.
:param func: Function to apply to tuples
:type func: function
:param obj: A geometry or feature to extract the coordinates from.
:type obj: GeoJSON
:return: The resu... | python | {
"resource": ""
} |
q232477 | GeoJSON.to_instance | train | def to_instance(cls, ob, default=None, strict=False):
"""Encode a GeoJSON dict into an GeoJSON object.
Assumes the caller knows that the dict should satisfy a GeoJSON type.
:param cls: Dict containing the elements to be encoded into a GeoJSON
object.
:type cls: dict
:par... | python | {
"resource": ""
} |
q232478 | GeoJSON.check_list_errors | train | def check_list_errors(self, checkFunc, lst):
"""Validation helper function."""
# check for errors on each subitem, filter only subitems with errors
results = (checkFunc(i) for i in lst)
return [err for err in results if err] | python | {
"resource": ""
} |
q232479 | PabotLib.run_only_once | train | def run_only_once(self, keyword):
"""
Runs a keyword only once in one of the parallel processes.
As the keyword will be called
only in one process and the return value could basically be anything.
The "Run Only Once" can't return the actual return value.
If the keyword fa... | python | {
"resource": ""
} |
q232480 | PabotLib.set_parallel_value_for_key | train | def set_parallel_value_for_key(self, key, value):
"""
Set a globally available key and value that can be accessed
from all the pabot processes.
"""
if self._remotelib:
self._remotelib.run_keyword('set_parallel_value_for_key',
[k... | python | {
"resource": ""
} |
q232481 | PabotLib.get_parallel_value_for_key | train | def get_parallel_value_for_key(self, key):
"""
Get the value for a key. If there is no value for the key then empty
string is returned.
"""
if self._remotelib:
return self._remotelib.run_keyword('get_parallel_value_for_key',
... | python | {
"resource": ""
} |
q232482 | PabotLib.acquire_lock | train | def acquire_lock(self, name):
"""
Wait for a lock with name.
This will prevent other processes from acquiring the lock with
the name while it is held. Thus they will wait in the position
where they are acquiring the lock until the process that has it
releases it.
... | python | {
"resource": ""
} |
q232483 | PabotLib.release_lock | train | def release_lock(self, name):
"""
Release a lock with name.
This will enable others to acquire the lock.
"""
if self._remotelib:
self._remotelib.run_keyword('release_lock',
[name, self._my_id], {})
else:
_Pab... | python | {
"resource": ""
} |
q232484 | PabotLib.release_locks | train | def release_locks(self):
"""
Release all locks called by instance.
"""
if self._remotelib:
self._remotelib.run_keyword('release_locks',
[self._my_id], {})
else:
_PabotLib.release_locks(self, self._my_id) | python | {
"resource": ""
} |
q232485 | PabotLib.acquire_value_set | train | def acquire_value_set(self, *tags):
"""
Reserve a set of values for this execution.
No other process can reserve the same set of values while the set is
reserved. Acquired value set needs to be released after use to allow
other processes to access it.
Add tags to limit th... | python | {
"resource": ""
} |
q232486 | PabotLib.get_value_from_set | train | def get_value_from_set(self, key):
"""
Get a value from previously reserved value set.
"""
#TODO: This should be done locally.
# We do not really need to call centralised server if the set is already
# reserved as the data there is immutable during execution
key ... | python | {
"resource": ""
} |
q232487 | PabotLib.release_value_set | train | def release_value_set(self):
"""
Release a reserved value set so that other executions can use it also.
"""
if self._remotelib:
self._remotelib.run_keyword('release_value_set', [self._my_id], {})
else:
_PabotLib.release_value_set(self, self._my_id) | python | {
"resource": ""
} |
q232488 | install_all_patches | train | def install_all_patches():
"""
A convenience method that installs all available hooks.
If a specific module is not available on the path, it is ignored.
"""
from . import mysqldb
from . import psycopg2
from . import strict_redis
from . import sqlalchemy
from . import tornado_http
... | python | {
"resource": ""
} |
q232489 | install_patches | train | def install_patches(patchers='all'):
"""
Usually called from middleware to install client hooks
specified in the client_hooks section of the configuration.
:param patchers: a list of patchers to run. Acceptable values include:
* None - installs all client patches
* 'all' - installs all clie... | python | {
"resource": ""
} |
q232490 | install_client_interceptors | train | def install_client_interceptors(client_interceptors=()):
"""
Install client interceptors for the patchers.
:param client_interceptors: a list of client interceptors to install.
Should be a list of classes
"""
if not _valid_args(client_interceptors):
raise ValueError('client_intercep... | python | {
"resource": ""
} |
q232491 | _load_symbol | train | def _load_symbol(name):
"""Load a symbol by name.
:param str name: The name to load, specified by `module.attr`.
:returns: The attribute value. If the specified module does not contain
the requested attribute then `None` is returned.
"""
module_name, key = name.rsplit('.', 1)
try:... | python | {
"resource": ""
} |
q232492 | span_in_stack_context | train | def span_in_stack_context(span):
"""
Create Tornado's StackContext that stores the given span in the
thread-local request context. This function is intended for use
in Tornado applications based on IOLoop, although will work fine
in single-threaded apps like Flask, albeit with more overhead.
##... | python | {
"resource": ""
} |
q232493 | traced_function | train | def traced_function(func=None, name=None, on_start=None,
require_active_trace=False):
"""
A decorator that enables tracing of the wrapped function or
Tornado co-routine provided there is a parent span already established.
.. code-block:: python
@traced_function
def ... | python | {
"resource": ""
} |
q232494 | start_child_span | train | def start_child_span(operation_name, tracer=None, parent=None, tags=None):
"""
Start a new span as a child of parent_span. If parent_span is None,
start a new root span.
:param operation_name: operation name
:param tracer: Tracer or None (defaults to opentracing.tracer)
:param parent: parent Sp... | python | {
"resource": ""
} |
q232495 | before_request | train | def before_request(request, tracer=None):
"""
Attempts to extract a tracing span from incoming request.
If no tracing context is passed in the headers, or the data
cannot be parsed, a new root span is started.
:param request: HTTP request with `.headers` property exposed
that satisfies a re... | python | {
"resource": ""
} |
q232496 | WSGIRequestWrapper._parse_wsgi_headers | train | def _parse_wsgi_headers(wsgi_environ):
"""
HTTP headers are presented in WSGI environment with 'HTTP_' prefix.
This method finds those headers, removes the prefix, converts
underscores to dashes, and converts to lower case.
:param wsgi_environ:
:return: returns a diction... | python | {
"resource": ""
} |
q232497 | ClientInterceptors.append | train | def append(cls, interceptor):
"""
Add interceptor to the end of the internal list.
Note: Raises ``ValueError`` if interceptor
does not extend ``OpenTracingInterceptor``
"""
cls._check(interceptor)
cls._interceptors.append(interceptor) | python | {
"resource": ""
} |
q232498 | ClientInterceptors.insert | train | def insert(cls, index, interceptor):
"""
Add interceptor to the given index in the internal list.
Note: Raises ``ValueError`` if interceptor
does not extend ``OpenTracingInterceptor``
"""
cls._check(interceptor)
cls._interceptors.insert(index, interceptor) | python | {
"resource": ""
} |
q232499 | singleton | train | def singleton(func):
"""
This decorator allows you to make sure that a function is called once and
only once. Note that recursive functions will still work.
WARNING: Not thread-safe!!!
"""
@functools.wraps(func)
def wrapper(*args, **kwargs):
if wrapper.__call_state__ == CALLED:
... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.