INSTRUCTION stringlengths 1 46.3k | RESPONSE stringlengths 75 80.2k |
|---|---|
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:
The x position of the end point.
:param int y2:
The y position of the end point.
... | 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:
... |
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:
The x position of the end point.
:param int y2:
The y position of the end point.... | 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:
... |
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 `"black"`.
:param int outline:
`0` or `False` is no outline. `True` or value > 1 set... | 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... |
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 x2:
The x position of the middle point.
:param int y2:
The y position of the middle p... | 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... |
Inserts an image into the drawing, position by its top-left corner.
:param int x:
The x position to insert the image.
:param int y:
The y position to insert the image.
:param str image:
The file path or a PhotoImage or PIL.Image object.
:pa... | def image(self, x, y, image, width=None, height=None):
"""
Inserts an image into the drawing, position by its top-left corner.
:param int x:
The x position to insert the image.
:param int y:
The y position to insert the image.
:param str image:
... |
Inserts text into the drawing, position by its top-left corner.
:param int x:
The x position of the text.
:param int y:
The x position of the text.
:param str color:
The color of the text. Defaults to `"black"`.
:param str font:
... | def text(self, x, y, text, color="black", font=None, size=None, max_width=None):
"""
Inserts text into the drawing, position by its top-left corner.
:param int x:
The x position of the text.
:param int y:
The x position of the text.
:param str c... |
Deletes an "object" (line, triangle, image, etc) from the drawing.
:param int id:
The id of the object. | def delete(self, id):
"""
Deletes an "object" (line, triangle, image, etc) from the drawing.
:param int id:
The id of the object.
"""
if id in self._images.keys():
del self._images[id]
self.tk.delete(id) |
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`. | 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... |
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 its default. | 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... |
Destroy the tk widget. | 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() |
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:
Grid co-ordinates for the widget, required if the master layout
is 'grid', defaults to `None`.
:param ... | 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:
... |
Displays all the widgets associated with this Container.
Should be called when the widgets need to be "re-packed/gridded". | 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... |
Disable all the widgets in this container | 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() |
Enable all the widgets in this container | 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() |
Make this window full screen and bind the Escape key (or given key) to exit full screen mode | def set_full_screen(self, keybind="<Escape>"):
"""Make this window full screen and bind the Escape key (or given key) to exit full screen mode"""
self.tk.attributes("-fullscreen", True)
self._full_screen = True
self.events.set_event("<FullScreen.Escape>", keybind, self.exit_full_screen) |
Change from full screen to windowed mode and remove key binding | 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>") |
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. | 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:
... |
This is the main body of the "lifting" for the instruction.
This can/should be overriden to provide the general flow of how instructions in your arch work.
For example, in MSP430, this is:
- Figure out what your operands are by parsing the addressing, and load them into temporary registers
... | def lift(self, irsb_c, past_instructions, future_instructions): # pylint: disable=unused-argument
"""
This is the main body of the "lifting" for the instruction.
This can/should be overriden to provide the general flow of how instructions in your arch work.
For example, in MSP430, this i... |
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 | 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... |
Creates a constant as a VexValue
:param val: The value, as an integer
:param ty: The type of the resulting VexValue
:return: a VexValue | 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(... |
Load a value from a machine register into a VEX temporary register.
All values must be loaded out of registers before they can be used with operations, etc
and stored back into them when the instruction is over. See Put().
:param reg: Register number as an integer, or register string name
... | def get(self, reg, ty):
"""
Load a value from a machine register into a VEX temporary register.
All values must be loaded out of registers before they can be used with operations, etc
and stored back into them when the instruction is over. See Put().
:param reg: Register number... |
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)
:param reg: The integer register number to store i... | 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... |
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, don't use this method!)
:param valiftrue: the VexValue to put in reg if c... | 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, ... |
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 | 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) |
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 unconditional jump
:param to_addr: The address to jump to.
:param jumpkind: The JumpKin... | 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... |
Creates a CCall operation.
A CCall is a procedure that calculates a value at *runtime*, not at lift-time.
You can use these for flags, unresolvable jump targets, etc.
We caution you to avoid using them when at all possible though.
For an example of how to write and use a CCall, see gymr... | def ccall(self, ret_type, func_obj, args):
"""
Creates a CCall operation.
A CCall is a procedure that calculates a value at *runtime*, not at lift-time.
You can use these for flags, unresolvable jump targets, etc.
We caution you to avoid using them when at all possible though.
... |
Recursively lifts blocks using the registered lifters and postprocessors. Tries each lifter in the order in
which they are registered on the data to lift.
If a lifter raises a LiftingException on the data, it is skipped.
If it succeeds and returns a block with a jumpkind of Ijk_NoDecode, all of the lifters... | def lift(data, addr, arch, max_bytes=None, max_inst=None, bytes_offset=0, opt_level=1, traceflags=0,
strict_block_end=True, inner=False, skip_stmts=False, collect_data_refs=False):
"""
Recursively lifts blocks using the registered lifters and postprocessors. Tries each lifter in the order in
which ... |
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 lifter: :class:`Lifter` or :class:`Postprocess... | 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... |
A list of all of the expressions that this expression ends up evaluating. | 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... |
A list of all of the constants that this expression ends up using. | 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... |
Replace child expressions in-place.
:param IRExpr expr: The expression to look for.
:param IRExpr replacement: The expression to replace with.
:return: None | def replace_expression(self, expr, replacement):
"""
Replace child expressions in-place.
:param IRExpr expr: The expression to look for.
:param IRExpr replacement: The expression to replace with.
:return: None
"""
for k in self.__slot... |
Appends an irsb to the current irsb. The irsb that is appended is invalidated. The appended irsb's jumpkind and
default exit are used.
:param extendwith: The IRSB to append to this IRSB
:vartype extendwith: :class:`IRSB` | def extend(self, extendwith):
"""
Appends an irsb to the current irsb. The irsb that is appended is invalidated. The appended irsb's jumpkind and
default exit are used.
:param extendwith: The IRSB to append to this IRSB
:vartype extendwith: :class:`IRSB`
"""
... |
Return an iterator of all expressions contained in the IRSB. | 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 |
The number of instructions in this block | 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... |
Addresses of instructions in this block. | 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 + ... |
The size of this block, in bytes | 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 |
A list of all operations done by the IRSB, as libVEX enum names | 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 |
The constants (excluding updates of the program counter) in the IRSB as :class:`pyvex.const.IRConst`. | def constants(self):
"""
The constants (excluding updates of the program counter) in the IRSB as :class:`pyvex.const.IRConst`.
"""
return sum(
(s.constants for s in self.statements if not (type(s) is stmt.Put and s.offset == self.offsIP)), []) |
A set of the static jump targets of the basic block. | 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... |
A dict of the static jump targets of the basic block to their jumpkind. | 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
... |
Return the pretty-printed IRSB.
:rtype: str | 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... |
Checks if the default of this IRSB a direct jump or not. | 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
... |
Return the type of temporary variable `tmp` as an enum string | 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] |
Returns the size, in BITS, of a VEX type specifier
e.g., Ity_I16 -> 16
:param ty:
:return: | def get_type_size(ty):
"""
Returns the size, in BITS, of a VEX type specifier
e.g., Ity_I16 -> 16
:param ty:
:return:
"""
m = type_str_re.match(ty)
if m is None:
raise ValueError('Type %s does not have size' % ty)
return int(m.group('size')) |
Get the width of a "type specifier"
like I16U
or F16
or just 16
(Yes, this really just takes the int out. If we must special-case, do it here.
:param tyspec:
:return: | def get_type_spec_size(ty):
"""
Get the width of a "type specifier"
like I16U
or F16
or just 16
(Yes, this really just takes the int out. If we must special-case, do it here.
:param tyspec:
:return:
"""
m = type_tag_str_re.match(ty)
if m is None:
raise ValueError('Ty... |
Wrapper around the `lift` method on Lifters. Should not be overridden in child classes.
:param data: The bytes to lift as either a python string of bytes or a cffi buffer object.
:param bytes_offset: The offset into `data` to start lifting at.
:param max_bytes: T... | 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... |
Return a function which generates an op format (just a string of the vex instruction)
Functions by formatting the fmt_string with the types of the arguments | def make_format_op_generator(fmt_string):
"""
Return a function which generates an op format (just a string of the vex instruction)
Functions by formatting the fmt_string with the types of the arguments
"""
def gen(arg_types):
converted_arg_types = list(map(get_op_format_from_const_ty, arg_... |
Add an exit out of the middle of an IRSB.
(e.g., a conditional jump)
:param guard: An expression, the exit is taken if true
:param dst: the destination of the exit (a Const)
:param jk: the JumpKind of this exit (probably Ijk_Boring)
:param ip: The address of this exit's source | def add_exit(self, guard, dst, jk, ip):
"""
Add an exit out of the middle of an IRSB.
(e.g., a conditional jump)
:param guard: An expression, the exit is taken if true
:param dst: the destination of the exit (a Const)
:param jk: the JumpKind of this exit (probably Ijk_Bor... |
Creates a constant as a VexValue
:param irsb_c: The IRSBCustomizer to use
:param val: The value, as an integer
:param ty: The type of the resulting VexValue
:return: a VexValue | def Constant(cls, irsb_c, val, ty):
"""
Creates a constant as a VexValue
:param irsb_c: The IRSBCustomizer to use
:param val: The value, as an integer
:param ty: The type of the resulting VexValue
:return: a VexValue
"""
assert not (isinstance(val, VexValu... |
Replace child expressions in-place.
:param IRExpr expression: The expression to look for.
:param IRExpr replacement: The expression to replace with.
:return: None | def replace_expression(self, expression, replacement):
"""
Replace child expressions in-place.
:param IRExpr expression: The expression to look for.
:param IRExpr replacement: The expression to replace with.
:return: None
"""
for k in... |
Exponential backoff time | 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 |
Return a random available proxy (either good or unchecked) | def get_random(self):
""" Return a random available proxy (either good or unchecked) """
available = list(self.unchecked | self.good)
if not available:
return None
return random.choice(available) |
Return complete proxy name associated with a hostport of a given
``proxy_address``. If ``proxy_address`` is unkonwn or empty,
return None. | 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... |
Mark a proxy as dead | 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:... |
Mark a proxy as good | 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... |
Move dead proxies to unchecked if a backoff timeout passes | 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_... |
Mark all dead proxies as unchecked | def reset(self):
""" Mark all dead proxies as unchecked """
for proxy in list(self.dead):
self.dead.remove(proxy)
self.unchecked.add(proxy) |
get real-time quotes (index, last trade price, last trade time, etc) for stocks, using google api: http://finance.google.com/finance/info?client=ig&q=symbols
Unlike python package 'yahoo-finance' (15 min delay), There is no delay for NYSE and NASDAQ stocks in 'googlefinance' package.
example:
quotes = get... | def getQuotes(symbols):
'''
get real-time quotes (index, last trade price, last trade time, etc) for stocks, using google api: http://finance.google.com/finance/info?client=ig&q=symbols
Unlike python package 'yahoo-finance' (15 min delay), There is no delay for NYSE and NASDAQ stocks in 'googlefinance' pac... |
Add a folder, library (.py) or resource file (.robot, .tsv, .txt) to the database | def add(self, name, monitor=True):
"""Add a folder, library (.py) or resource file (.robot, .tsv, .txt) to the database
"""
if os.path.isdir(name):
if (not os.path.basename(name).startswith(".")):
self.add_folder(name)
elif os.path.isfile(name):
... |
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 | 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... |
Load a collection of keywords
One of path or libdoc needs to be passed in... | 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... |
Add a resource file or library file to the database | 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
... |
Add a library to the database
This method is for adding a library by name (eg: "BuiltIn")
rather than by a file. | 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... |
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 non-standard suffixes.
N.B. folders with nam... | 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... |
Insert data into the collection table | def add_collection(self, path, c_name, c_type, c_doc, c_version="unknown",
c_scope="", c_namedargs="yes", c_doc_format="ROBOT"):
"""Insert data into the collection table"""
if path is not None:
# We want to store the normalized form of the path in the
# dat... |
Add any installed libraries that we can find
We do this by looking in the `libraries` folder where
robot is installed. If you have libraries installed
in a non-standard place, this won't pick them up. | 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... |
Get a specific collection | 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,
... |
Returns a list of collection name/summary tuples | def get_collections(self, pattern="*", libtype="*"):
"""Returns a list of collection name/summary tuples"""
sql = """SELECT collection.collection_id, collection.name, collection.doc,
collection.type, collection.path
FROM collection_table as collection
... |
Get a specific keyword from a library | 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 ?
"""
... |
Returns all keywords that match a glob-style pattern
The result is a list of dictionaries, sorted by collection
name.
The pattern matching is insensitive to case. The function
returns a list of (library_name, keyword_name,
keyword_synopsis tuples) sorted by keyword name | def get_keyword_hierarchy(self, pattern="*"):
"""Returns all keywords that match a glob-style pattern
The result is a list of dictionaries, sorted by collection
name.
The pattern matching is insensitive to case. The function
returns a list of (library_name, keyword_name,
... |
Perform a pattern-based search on keyword names and documentation
The pattern matching is insensitive to case. The function
returns a list of tuples of the form library_id, library_name,
keyword_name, keyword_synopsis, sorted by library id,
library name, and then keyword name
I... | def search(self, pattern="*", mode="both"):
"""Perform a pattern-based search on keyword names and documentation
The pattern matching is insensitive to case. The function
returns a list of tuples of the form library_id, library_name,
keyword_name, keyword_synopsis, sorted by library id,... |
Returns all keywords that match a glob-style pattern
The pattern matching is insensitive to case. The function
returns a list of (library_name, keyword_name,
keyword_synopsis tuples) sorted by keyword name | def get_keywords(self, pattern="*"):
"""Returns all keywords that match a glob-style pattern
The pattern matching is insensitive to case. The function
returns a list of (library_name, keyword_name,
keyword_synopsis tuples) sorted by keyword name
"""
sql = """SELECT col... |
Return true if an xml file looks like a libdoc file | 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... |
Return true if the file has a keyword table but not a testcase table | 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
... |
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"... | 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... |
Execute an SQL query
This exists because I think it's tedious to get a cursor and
then use a cursor. | 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 |
Insert data into the keyword table
'args' should be a list, but since we can't store a list in an
sqlite database we'll make it json we can can convert it back
to a list later. | def _add_keyword(self, collection_id, name, doc, args):
"""Insert data into the keyword table
'args' should be a list, but since we can't store a list in an
sqlite database we'll make it json we can can convert it back
to a list later.
"""
argstring = json.dumps(args)
... |
Show a list of libraries, along with the nav panel on the left | 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",
... |
Show a list of available libraries, and resource files | 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=... |
Show all keywords that match a pattern | 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... |
Get list of collections from kwdb, then add urls necessary for hyperlinks | 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"] ... |
Get navpanel data from kwdb, and add urls necessary for hyperlinks | 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"]:
... |
Convert documentation to HTML | def doc_to_html(doc, doc_format="ROBOT"):
"""Convert documentation to HTML"""
from robot.libdocpkg.htmlwriter import DocToHtml
return DocToHtml(doc_format)(doc) |
Start the app | 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)
... |
Shutdown the server if the flag has been set | 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.") |
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 | 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... |
Returns the mapped coordinates from a Geometry after applying the provided
function to each dimension in tuples list (ie, linear scaling).
:param func: Function to apply to individual coordinate values
independently
:type func: function
:param obj: A geometry or feature to extract the coordinates f... | def map_coords(func, obj):
"""
Returns the mapped coordinates from a Geometry after applying the provided
function to each dimension in tuples list (ie, linear scaling).
:param func: Function to apply to individual coordinate values
independently
:type func: function
:param obj: A geometry ... |
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, LineString, MultiPoint, MultiLineString, Polygon... | 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... |
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 result of applying the function to each geometr... | 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... |
Generates random geojson features depending on the parameters
passed through.
The bounding box defaults to the world - [-180.0, -90.0, 180.0, 90.0].
The number of vertices defaults to 3.
:param featureType: A geometry type
:type featureType: Point, LineString, Polygon
:param numberVertices: The... | def generate_random(featureType, numberVertices=3,
boundingBox=[-180.0, -90.0, 180.0, 90.0]):
"""
Generates random geojson features depending on the parameters
passed through.
The bounding box defaults to the world - [-180.0, -90.0, 180.0, 90.0].
The number of vertices defaults t... |
Create an instance of SimpleWebFeature from a dict, o. If o does not
match a Python feature object, simply return o. This function serves as a
json decoder hook. See coding.load().
:param o: A dict to create the SimpleWebFeature from.
:type o: dict
:return: A SimpleWebFeature from the dict provided... | def create_simple_web_feature(o):
"""
Create an instance of SimpleWebFeature from a dict, o. If o does not
match a Python feature object, simply return o. This function serves as a
json decoder hook. See coding.load().
:param o: A dict to create the SimpleWebFeature from.
:type o: dict
:ret... |
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
:param ob: GeoJSON object into which to encode the dict provided in
... | 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... |
Validation helper function. | 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] |
Escape all special characters. | def _glob_escape(pathname):
"""
Escape all special characters.
"""
drive, pathname = os.path.splitdrive(pathname)
pathname = _magic_check.sub(r'[\1]', pathname)
return drive + pathname |
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 fails, "Run Only Once" fails.
Others executing "... | 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... |
Set a globally available key and value that can be accessed
from all the pabot processes. | 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... |
Get the value for a key. If there is no value for the key then empty
string is returned. | 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',
... |
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. | 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.
... |
Release a lock with name.
This will enable others to acquire the lock. | 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... |
Release all locks called by instance. | 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) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.