code
stringlengths 51
2.34k
| sequence
stringlengths 186
3.94k
| docstring
stringlengths 11
171
|
|---|---|---|
def add_log_entry(self, process_name, timeperiod, msg):
tree = self.get_tree(process_name)
node = tree.get_node(process_name, timeperiod)
node.add_log_entry([datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S'), msg])
|
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list list call attribute call attribute identifier identifier argument_list identifier argument_list string string_start string_content string_end identifier
|
adds a non-persistent log entry to the tree node
|
def find_node_api_version(self, node_pyxb):
max_major = 0
for s in node_pyxb.services.service:
max_major = max(max_major, int(s.version[1:]))
return max_major
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier integer for_statement identifier attribute attribute identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier call identifier argument_list subscript attribute identifier identifier slice integer return_statement identifier
|
Find the highest API major version supported by node.
|
def remove(self, item):
'Remove first occurence of item. Raise ValueError if not found'
i = self.index(item)
del self._keys[i]
del self._items[i]
|
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier delete_statement subscript attribute identifier identifier identifier delete_statement subscript attribute identifier identifier identifier
|
Remove first occurence of item. Raise ValueError if not found
|
def _save_image(image, filename, return_img=None):
if not image.size:
raise Exception('Empty image. Have you run plot() first?')
if isinstance(filename, str):
if isinstance(vtki.FIGURE_PATH, str) and not os.path.isabs(filename):
filename = os.path.join(vtki.FIGURE_PATH, filename)
if not return_img:
return imageio.imwrite(filename, image)
imageio.imwrite(filename, image)
return image
|
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement not_operator attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement call identifier argument_list identifier identifier block if_statement boolean_operator call identifier argument_list attribute identifier identifier identifier not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier if_statement not_operator identifier block return_statement call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier return_statement identifier
|
Internal helper for saving a NumPy image array
|
def assert_is_not(expected, actual, message=None, extra=None):
assert expected is not actual, _assert_fail_message(
message, expected, actual, "is", extra
)
|
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none block assert_statement comparison_operator identifier identifier call identifier argument_list identifier identifier identifier string string_start string_content string_end identifier
|
Raises an AssertionError if expected is actual.
|
def _initialize_session():
sys_random = random.SystemRandom()
_thread_local_storage.secret_key = b''.join(
int2byte(sys_random.randint(0, 255))
for _ in range(SECRET_KEY_BITS // 8))
|
module function_definition identifier parameters block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute string string_start string_end identifier generator_expression call identifier argument_list call attribute identifier identifier argument_list integer integer for_in_clause identifier call identifier argument_list binary_operator identifier integer
|
Generate a new session key and store it to thread local storage.
|
def white(cls):
"Make the text foreground color white."
wAttributes = cls._get_text_attributes()
wAttributes &= ~win32.FOREGROUND_MASK
wAttributes |= win32.FOREGROUND_GREY
cls._set_text_attributes(wAttributes)
|
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement augmented_assignment identifier unary_operator attribute identifier identifier expression_statement augmented_assignment identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier
|
Make the text foreground color white.
|
def create_from_dictionary(self, datas):
configuration = ObjectConfiguration()
if "uri" in datas:
configuration.uri = str(datas["uri"])
if "title" in datas:
configuration.title = str(datas["title"])
if "description" in datas:
configuration.description = str(datas["description"])
return configuration
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment attribute identifier identifier call identifier argument_list subscript identifier string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment attribute identifier identifier call identifier argument_list subscript identifier string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment attribute identifier identifier call identifier argument_list subscript identifier string string_start string_content string_end return_statement identifier
|
Return a populated object Configuration from dictionnary datas
|
def _GetArgsDescription(self, args_type):
args = {}
if args_type:
for type_descriptor in args_type.type_infos:
if not type_descriptor.hidden:
args[type_descriptor.name] = {
"description": type_descriptor.description,
"default": type_descriptor.default,
"type": "",
}
if type_descriptor.type:
args[type_descriptor.name]["type"] = type_descriptor.type.__name__
return args
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary if_statement identifier block for_statement identifier attribute identifier identifier block if_statement not_operator attribute identifier identifier block expression_statement assignment subscript identifier attribute identifier identifier dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end string string_start string_end if_statement attribute identifier identifier block expression_statement assignment subscript subscript identifier attribute identifier identifier string string_start string_content string_end attribute attribute identifier identifier identifier return_statement identifier
|
Get a simplified description of the args_type for a flow.
|
def genes(self):
return [ExpGene.from_series(g)
for i, g in self.reset_index().iterrows()]
|
module function_definition identifier parameters identifier block return_statement list_comprehension call attribute identifier identifier argument_list identifier for_in_clause pattern_list identifier identifier call attribute call attribute identifier identifier argument_list identifier argument_list
|
Return a list of all genes.
|
def meta_enter_message(python_input):
def get_text_fragments():
return [('class:accept-message', ' [Meta+Enter] Execute ')]
def extra_condition():
" Only show when... "
b = python_input.default_buffer
return (
python_input.show_meta_enter_message and
(not b.document.is_cursor_at_the_end or
python_input.accept_input_on_enter is None) and
'\n' in b.text)
visible = ~is_done & has_focus(DEFAULT_BUFFER) & Condition(extra_condition)
return ConditionalContainer(
content=Window(FormattedTextControl(get_text_fragments)),
filter=visible)
|
module function_definition identifier parameters identifier block function_definition identifier parameters block return_statement list tuple string string_start string_content string_end string string_start string_content string_end function_definition identifier parameters block expression_statement string string_start string_content string_end expression_statement assignment identifier attribute identifier identifier return_statement parenthesized_expression boolean_operator boolean_operator attribute identifier identifier parenthesized_expression boolean_operator not_operator attribute attribute identifier identifier identifier comparison_operator attribute identifier identifier none comparison_operator string string_start string_content escape_sequence string_end attribute identifier identifier expression_statement assignment identifier binary_operator binary_operator unary_operator identifier call identifier argument_list identifier call identifier argument_list identifier return_statement call identifier argument_list keyword_argument identifier call identifier argument_list call identifier argument_list identifier keyword_argument identifier identifier
|
Create the `Layout` for the 'Meta+Enter` message.
|
def _get_tool_dict(self, tool_name):
tool = getattr(self, tool_name)
standard_attrs, custom_attrs = self._get_button_attrs(tool)
return dict(
name=tool_name,
label=getattr(tool, 'label', tool_name),
standard_attrs=standard_attrs,
custom_attrs=custom_attrs,
)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier return_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier call identifier argument_list identifier string string_start string_content string_end identifier keyword_argument identifier identifier keyword_argument identifier identifier
|
Represents the tool as a dict with extra meta.
|
def db_type(cls, dtype):
if isinstance(dtype, ExtensionDtype):
return cls.type_map.get(dtype.kind)
elif hasattr(dtype, 'char'):
return cls.type_map.get(dtype.char)
|
module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier identifier block return_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier elif_clause call identifier argument_list identifier string string_start string_content string_end block return_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier
|
Given a numpy dtype, Returns a generic database type
|
def cycle_windows(tree, direction):
wanted = {
"orientation": ("vertical" if direction in ("up", "down")
else "horizontal"),
"direction": (1 if direction in ("down", "right")
else -1),
}
split = find_parent_split(tree.focused.parent, wanted["orientation"])
if split:
child_ids = [child.id for child in split.children]
focus_idx = child_ids.index(split.focused_child.id)
next_idx = (focus_idx + wanted['direction']) % len(child_ids)
next_node = split.children[next_idx]
return find_focusable(next_node)
return None
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end parenthesized_expression conditional_expression string string_start string_content string_end comparison_operator identifier tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end parenthesized_expression conditional_expression integer comparison_operator identifier tuple string string_start string_content string_end string string_start string_content string_end unary_operator integer expression_statement assignment identifier call identifier argument_list attribute attribute identifier identifier identifier subscript identifier string string_start string_content string_end if_statement identifier block expression_statement assignment identifier list_comprehension attribute identifier identifier for_in_clause identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier expression_statement assignment identifier binary_operator parenthesized_expression binary_operator identifier subscript identifier string string_start string_content string_end call identifier argument_list identifier expression_statement assignment identifier subscript attribute identifier identifier identifier return_statement call identifier argument_list identifier return_statement none
|
Cycle through windows of the current workspace
|
def function(self, fun, *args, **kwargs):
func = self.sminion.functions[fun]
args, kwargs = salt.minion.load_args_and_kwargs(
func,
salt.utils.args.parse_input(args, kwargs=kwargs),)
return func(*args, **kwargs)
|
module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier subscript attribute attribute identifier identifier identifier identifier expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier keyword_argument identifier identifier return_statement call identifier argument_list list_splat identifier dictionary_splat identifier
|
Call a single salt function
|
def draw_widget(self, item):
if item:
self.filter_remove(remember=True)
selected_id = self.treedata[item]['id']
item = self.get_toplevel_parent(item)
widget_id = self.treedata[item]['id']
wclass = self.treedata[item]['class']
xmlnode = self.tree_node_to_xml('', item)
self.previewer.draw(item, widget_id, xmlnode, wclass)
self.previewer.show_selected(item, selected_id)
self.filter_restore()
|
module function_definition identifier parameters identifier identifier block if_statement identifier block expression_statement call attribute identifier identifier argument_list keyword_argument identifier true expression_statement assignment identifier subscript subscript attribute identifier identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier subscript subscript attribute identifier identifier identifier string string_start string_content string_end expression_statement assignment identifier subscript subscript attribute identifier identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_end identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list
|
Create a preview of the selected treeview item
|
def deleteMask(self,signature):
if signature in self.masklist:
self.masklist[signature] = None
else:
log.warning("No matching mask")
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier none else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end
|
Delete just the mask that matches the signature given.
|
def pid(self):
pf = self.path('cmd.pid')
if not os.path.exists(pf):
return None
with open(pf, 'r') as f:
return int(f.read())
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block return_statement none with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block return_statement call identifier argument_list call attribute identifier identifier argument_list
|
The integer PID of the subprocess or None.
|
def filterGraph(graph, node_fnc):
nodes = filter(lambda l: node_fnc(l), graph.nodes())
edges = {}
gedges = graph.edges()
for u in gedges:
if u not in nodes:
continue
for v in gedges[u]:
if v not in nodes:
continue
try:
edges[u].append(v)
except KeyError:
edges[u] = [v]
return Graph(nodes, edges)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list lambda lambda_parameters identifier call identifier argument_list identifier call attribute identifier identifier argument_list expression_statement assignment identifier dictionary expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier identifier block if_statement comparison_operator identifier identifier block continue_statement for_statement identifier subscript identifier identifier block if_statement comparison_operator identifier identifier block continue_statement try_statement block expression_statement call attribute subscript identifier identifier identifier argument_list identifier except_clause identifier block expression_statement assignment subscript identifier identifier list identifier return_statement call identifier argument_list identifier identifier
|
Remove all nodes for with node_fnc does not hold
|
def add_filter(self, component, filter_group="pyxley-filter"):
if getattr(component, "name") != "Filter":
raise Exception("Component is not an instance of Filter")
if filter_group not in self.filters:
self.filters[filter_group] = []
self.filters[filter_group].append(component)
|
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end block if_statement comparison_operator call identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end block raise_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier list expression_statement call attribute subscript attribute identifier identifier identifier identifier argument_list identifier
|
Add a filter to the layout.
|
def _get_training_data(vrn_files):
out = {"SNP": [], "INDEL": []}
for name, train_info in [("train_hapmap", "known=false,training=true,truth=true,prior=15.0"),
("train_omni", "known=false,training=true,truth=true,prior=12.0"),
("train_1000g", "known=false,training=true,truth=false,prior=10.0"),
("dbsnp", "known=true,training=false,truth=false,prior=2.0")]:
if name not in vrn_files:
return {}
else:
out["SNP"].append((name.replace("train_", ""), train_info, vrn_files[name]))
if "train_indels" in vrn_files:
out["INDEL"].append(("mills", "known=true,training=true,truth=true,prior=12.0",
vrn_files["train_indels"]))
else:
return {}
return out
|
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end list pair string string_start string_content string_end list for_statement pattern_list identifier identifier list tuple string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end block if_statement comparison_operator identifier identifier block return_statement dictionary else_clause block expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list tuple call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end identifier subscript identifier identifier if_statement comparison_operator string string_start string_content string_end identifier block expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list tuple string string_start string_content string_end string string_start string_content string_end subscript identifier string string_start string_content string_end else_clause block return_statement dictionary return_statement identifier
|
Retrieve training data, returning an empty set of information if not available.
|
def dates(self):
dates = []
d = self.date_a
while d < self.date_b:
dates.append(d)
d += datetime.timedelta(1)
return dates
|
module function_definition identifier parameters identifier block expression_statement assignment identifier list expression_statement assignment identifier attribute identifier identifier while_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement augmented_assignment identifier call attribute identifier identifier argument_list integer return_statement identifier
|
Returns a list of dates in this date interval.
|
def should_cache(self, request, response):
if not getattr(request, '_cache_update_cache', False):
return False
if not response.status_code in getattr(settings, 'BETTERCACHE_CACHEABLE_STATUS', CACHEABLE_STATUS):
return False
if getattr(settings, 'BETTERCACHE_ANONYMOUS_ONLY', False) and self.session_accessed and request.user.is_authenticated:
return False
if self.has_uncacheable_headers(response):
return False
return True
|
module function_definition identifier parameters identifier identifier identifier block if_statement not_operator call identifier argument_list identifier string string_start string_content string_end false block return_statement false if_statement not_operator comparison_operator attribute identifier identifier call identifier argument_list identifier string string_start string_content string_end identifier block return_statement false if_statement boolean_operator boolean_operator call identifier argument_list identifier string string_start string_content string_end false attribute identifier identifier attribute attribute identifier identifier identifier block return_statement false if_statement call attribute identifier identifier argument_list identifier block return_statement false return_statement true
|
Given the request and response should it be cached
|
def chunks(f, chunk_size=None):
if not chunk_size:
chunk_size = 64 * 2 ** 10
if hasattr(f, "seek"):
f.seek(0)
while True:
data = f.read(chunk_size)
if not data:
break
yield data
|
module function_definition identifier parameters identifier default_parameter identifier none block if_statement not_operator identifier block expression_statement assignment identifier binary_operator integer binary_operator integer integer if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list integer while_statement true block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator identifier block break_statement expression_statement yield identifier
|
Read the file and yield chucks of ``chunk_size`` bytes.
|
def wrap_inner(node, tag):
children = list(node.childNodes)
wrap_node = node.ownerDocument.createElement(tag)
for c in children:
wrap_node.appendChild(c)
node.appendChild(wrap_node)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier
|
Wrap the given tag around the contents of a node.
|
def _add_handler(logger, handler=None, loglevel=None):
handler.setLevel(loglevel or DEFAULT_LOGLEVEL)
if handler.level <= logging.DEBUG:
_fmt = '%(asctime)s| %(levelname)-4.3s|%(threadName)10.9s/' \
'%(lineno)04d@%(module)-10.9s| %(message)s'
handler.setFormatter(logging.Formatter(_fmt))
else:
handler.setFormatter(logging.Formatter(
'%(asctime)s| %(levelname)-8s| %(message)s'
))
logger.addHandler(handler)
|
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block expression_statement call attribute identifier identifier argument_list boolean_operator identifier identifier if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier concatenated_string string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier
|
Add a handler to an existing logging.Logger object
|
def channel(layer, n_channel, batch=None):
if batch is None:
return lambda T: tf.reduce_mean(T(layer)[..., n_channel])
else:
return lambda T: tf.reduce_mean(T(layer)[batch, ..., n_channel])
|
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement comparison_operator identifier none block return_statement lambda lambda_parameters identifier call attribute identifier identifier argument_list subscript call identifier argument_list identifier ellipsis identifier else_clause block return_statement lambda lambda_parameters identifier call attribute identifier identifier argument_list subscript call identifier argument_list identifier identifier ellipsis identifier
|
Visualize a single channel
|
def authenticate(self) -> bool:
with IHCController._mutex:
if not self.client.authenticate(self._username, self._password):
return False
if self._ihcevents:
self.client.enable_runtime_notifications(
self._ihcevents.keys())
return True
|
module function_definition identifier parameters identifier type identifier block with_statement with_clause with_item attribute identifier identifier block if_statement not_operator call attribute attribute identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier block return_statement false if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list return_statement true
|
Authenticate and enable the registered notifications
|
def _update_data(self, name, value, timestamp, interval, config, conn):
i_time = config['i_calc'].to_bucket(timestamp)
if not config['coarse']:
r_time = config['r_calc'].to_bucket(timestamp)
else:
r_time = None
stmt = self._table.update().where(
and_(
self._table.c.name==name,
self._table.c.interval==interval,
self._table.c.i_time==i_time,
self._table.c.r_time==r_time)
).values({self._table.c.value: value})
rval = conn.execute( stmt )
return rval.rowcount
|
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list identifier if_statement not_operator subscript identifier string string_start string_content string_end block expression_statement assignment identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list identifier else_clause block expression_statement assignment identifier none expression_statement assignment identifier call attribute call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list call identifier argument_list comparison_operator attribute attribute attribute identifier identifier identifier identifier identifier comparison_operator attribute attribute attribute identifier identifier identifier identifier identifier comparison_operator attribute attribute attribute identifier identifier identifier identifier identifier comparison_operator attribute attribute attribute identifier identifier identifier identifier identifier identifier argument_list dictionary pair attribute attribute attribute identifier identifier identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement attribute identifier identifier
|
Support function for insert. Should be called within a transaction
|
def data(self,data):
assert type(data) is np.ndarray
assert data.shape[1] == self.nCols
for i in range(self.nCols):
self.colData[i]=data[:,i].tolist()
|
module function_definition identifier parameters identifier identifier block assert_statement comparison_operator call identifier argument_list identifier attribute identifier identifier assert_statement comparison_operator subscript attribute identifier identifier integer attribute identifier identifier for_statement identifier call identifier argument_list attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier call attribute subscript identifier slice identifier identifier argument_list
|
Given a 2D numpy array, fill colData with it.
|
def parse(data):
reader = io.BytesIO(data)
headers = []
while reader.tell() < len(data):
h = Header()
h.tag = int.from_bytes(reader.read(2), byteorder='big', signed=False)
h.taglen = int.from_bytes(reader.read(2), byteorder='big', signed=False)
h.tagdata = reader.read(h.taglen)
headers.append(h)
return headers
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier list while_statement comparison_operator call attribute identifier identifier argument_list call identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list integer keyword_argument identifier string string_start string_content string_end keyword_argument identifier false expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list integer keyword_argument identifier string string_start string_content string_end keyword_argument identifier false expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
|
returns a list of header tags
|
def buy_limit_order(self, amount, price, base="btc", quote="usd", limit_price=None):
data = {'amount': amount, 'price': price}
if limit_price is not None:
data['limit_price'] = limit_price
url = self._construct_url("buy/", base, quote)
return self._post(url, data=data, return_json=True, version=2)
|
module function_definition identifier parameters identifier identifier identifier default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_content string_end default_parameter identifier none block expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier if_statement comparison_operator identifier none block expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier true keyword_argument identifier integer
|
Order to buy amount of bitcoins for specified price.
|
async def install_mediaroom_protocol(responses_callback, box_ip=None):
from . import version
_LOGGER.debug(version)
loop = asyncio.get_event_loop()
mediaroom_protocol = MediaroomProtocol(responses_callback, box_ip)
sock = create_socket()
await loop.create_datagram_endpoint(lambda: mediaroom_protocol, sock=sock)
return mediaroom_protocol
|
module function_definition identifier parameters identifier default_parameter identifier none block import_from_statement relative_import import_prefix dotted_name identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list expression_statement await call attribute identifier identifier argument_list lambda identifier keyword_argument identifier identifier return_statement identifier
|
Install an asyncio protocol to process NOTIFY messages.
|
def send_by_packet(self, data):
total_sent = 0
while total_sent < PACKET_SIZE:
sent = self.sock.send(data[total_sent:])
if sent == 0:
raise RuntimeError("socket connection broken")
total_sent += sent
return total_sent
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier integer while_statement comparison_operator identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list subscript identifier slice identifier if_statement comparison_operator identifier integer block raise_statement call identifier argument_list string string_start string_content string_end expression_statement augmented_assignment identifier identifier return_statement identifier
|
Send data by packet on socket
|
def c_getprocs(self):
getprocs = []
for name, dummy_args in self.funcs:
if name == 'GetProcAddress':
if callable(self.opts.hash_func):
continue
getter = 'get_proc_by_string'
elif self.opts.no_structs:
getter = 'GetProcAddress'
else:
getter = 'windll->kernel32.GetProcAddress'
if callable(self.opts.hash_func):
getter = 'get_proc_by_hash'
if self.opts.no_structs:
var = name
else:
var = 'windll->{}.{}'.format(self.name, name)
getproc = '{} = ({} *){}({}, {}{});\n'.format(
var,
self._c_type_name(name),
getter,
self._c_base_var(),
self.opts.prefix, name
)
getprocs.append(getproc + self._c_null_check(var))
return getprocs
|
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement pattern_list identifier identifier attribute identifier identifier block if_statement comparison_operator identifier string string_start string_content string_end block if_statement call identifier argument_list attribute attribute identifier identifier identifier block continue_statement expression_statement assignment identifier string string_start string_content string_end elif_clause attribute attribute identifier identifier identifier block expression_statement assignment identifier string string_start string_content string_end else_clause block expression_statement assignment identifier string string_start string_content string_end if_statement call identifier argument_list attribute attribute identifier identifier identifier block expression_statement assignment identifier string string_start string_content string_end if_statement attribute attribute identifier identifier identifier block expression_statement assignment identifier identifier else_clause block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier identifier expression_statement assignment identifier call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier call attribute identifier identifier argument_list identifier identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator identifier call attribute identifier identifier argument_list identifier return_statement identifier
|
Get the getprocs of the module.
|
def indices_to_labels(self, indices: Sequence[int]) -> List[str]:
return [(self.INDEX_TO_LABEL[index]) for index in indices]
|
module function_definition identifier parameters identifier typed_parameter identifier type generic_type identifier type_parameter type identifier type generic_type identifier type_parameter type identifier block return_statement list_comprehension parenthesized_expression subscript attribute identifier identifier identifier for_in_clause identifier identifier
|
Converts a sequence of indices into their corresponding labels.
|
def accepts(self, package):
return (
self._name == package.name
and self._constraint.allows(package.version)
and (not package.is_prerelease() or self.allows_prereleases())
)
|
module function_definition identifier parameters identifier identifier block return_statement parenthesized_expression boolean_operator boolean_operator comparison_operator attribute identifier identifier attribute identifier identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier parenthesized_expression boolean_operator not_operator call attribute identifier identifier argument_list call attribute identifier identifier argument_list
|
Determines if the given package matches this dependency.
|
async def main():
async with aiohttp.ClientSession() as session:
data = Luftdaten(SENSOR_ID, loop, session)
await data.get_data()
if not await data.validate_sensor():
print("Station is not available:", data.sensor_id)
return
if data.values and data.meta:
print("Sensor values:", data.values)
print("Location:", data.meta['latitude'], data.meta['longitude'])
|
module function_definition identifier parameters block with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list as_pattern_target identifier block expression_statement assignment identifier call identifier argument_list identifier identifier identifier expression_statement await call attribute identifier identifier argument_list if_statement not_operator await call attribute identifier identifier argument_list block expression_statement call identifier argument_list string string_start string_content string_end attribute identifier identifier return_statement if_statement boolean_operator attribute identifier identifier attribute identifier identifier block expression_statement call identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call identifier argument_list string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end
|
Sample code to retrieve the data.
|
def capfirst(x):
x = to_string(x).strip()
if x:
return x[0].upper() + x[1:].lower()
else:
return x
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute call identifier argument_list identifier identifier argument_list if_statement identifier block return_statement binary_operator call attribute subscript identifier integer identifier argument_list call attribute subscript identifier slice integer identifier argument_list else_clause block return_statement identifier
|
Capitalise the first letter of ``x``.
|
def from_cli(cls, opt):
injection_file = opt.injection_file
chirp_time_window = \
opt.injection_filter_rejector_chirp_time_window
match_threshold = opt.injection_filter_rejector_match_threshold
coarsematch_deltaf = opt.injection_filter_rejector_coarsematch_deltaf
coarsematch_fmax = opt.injection_filter_rejector_coarsematch_fmax
seg_buffer = opt.injection_filter_rejector_seg_buffer
if opt.injection_filter_rejector_f_lower is not None:
f_lower = opt.injection_filter_rejector_f_lower
else:
f_lower = opt.low_frequency_cutoff
return cls(injection_file, chirp_time_window, match_threshold,
f_lower, coarsematch_deltaf=coarsematch_deltaf,
coarsematch_fmax=coarsematch_fmax,
seg_buffer=seg_buffer)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier line_continuation attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier attribute identifier identifier else_clause block expression_statement assignment identifier attribute identifier identifier return_statement call identifier argument_list identifier identifier identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
|
Create an InjFilterRejector instance from command-line options.
|
def read_registry(self):
lm = _winreg.ConnectRegistry(None, _winreg.HKEY_LOCAL_MACHINE)
want_scan = False
try:
try:
tcp_params = _winreg.OpenKey(lm,
r'SYSTEM\CurrentControlSet'
r'\Services\Tcpip\Parameters')
want_scan = True
except EnvironmentError:
tcp_params = _winreg.OpenKey(lm,
r'SYSTEM\CurrentControlSet'
r'\Services\VxD\MSTCP')
try:
self._config_win32_fromkey(tcp_params)
finally:
tcp_params.Close()
if want_scan:
interfaces = _winreg.OpenKey(lm,
r'SYSTEM\CurrentControlSet'
r'\Services\Tcpip\Parameters'
r'\Interfaces')
try:
i = 0
while True:
try:
guid = _winreg.EnumKey(interfaces, i)
i += 1
key = _winreg.OpenKey(interfaces, guid)
if not self._win32_is_nic_enabled(lm, guid, key):
continue
try:
self._config_win32_fromkey(key)
finally:
key.Close()
except EnvironmentError:
break
finally:
interfaces.Close()
finally:
lm.Close()
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list none attribute identifier identifier expression_statement assignment identifier false try_statement block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier concatenated_string string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier true except_clause identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier concatenated_string string string_start string_content string_end string string_start string_content string_end try_statement block expression_statement call attribute identifier identifier argument_list identifier finally_clause block expression_statement call attribute identifier identifier argument_list if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end try_statement block expression_statement assignment identifier integer while_statement true block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement augmented_assignment identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement not_operator call attribute identifier identifier argument_list identifier identifier identifier block continue_statement try_statement block expression_statement call attribute identifier identifier argument_list identifier finally_clause block expression_statement call attribute identifier identifier argument_list except_clause identifier block break_statement finally_clause block expression_statement call attribute identifier identifier argument_list finally_clause block expression_statement call attribute identifier identifier argument_list
|
Extract resolver configuration from the Windows registry.
|
async def _inform_watchdog(self):
async with self._wd_lock:
if self._watchdog_task is None:
return
self._watchdog_task.cancel()
try:
await self._watchdog_task
except asyncio.CancelledError:
self._watchdog_task = self.loop.create_task(self._watchdog(
self._watchdog_timeout))
|
module function_definition identifier parameters identifier block with_statement with_clause with_item attribute identifier identifier block if_statement comparison_operator attribute identifier identifier none block return_statement expression_statement call attribute attribute identifier identifier identifier argument_list try_statement block expression_statement await attribute identifier identifier except_clause attribute identifier identifier block expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier
|
Inform the watchdog of activity.
|
def _json_request(self, method, path, data):
response = self._request(method, path, data=data)
_raise_for_status(response)
if len(response.data) > 0:
return _json_from_response(response)
return response.data
|
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier keyword_argument identifier identifier expression_statement call identifier argument_list identifier if_statement comparison_operator call identifier argument_list attribute identifier identifier integer block return_statement call identifier argument_list identifier return_statement attribute identifier identifier
|
Issue request against the crate HTTP API.
|
def Search(self,key):
results = []
for template in self.templates:
if template.id.lower().find(key.lower()) != -1: results.append(template)
elif template.name.lower().find(key.lower()) != -1: results.append(template)
return(results)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list for_statement identifier attribute identifier identifier block if_statement comparison_operator call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list call attribute identifier identifier argument_list unary_operator integer block expression_statement call attribute identifier identifier argument_list identifier elif_clause comparison_operator call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list call attribute identifier identifier argument_list unary_operator integer block expression_statement call attribute identifier identifier argument_list identifier return_statement parenthesized_expression identifier
|
Search template list by providing partial name, ID, or other key.
|
def create_label(self, name, justify=Gtk.Justification.CENTER, wrap_mode=True, tooltip=None):
label = Gtk.Label()
name = name.replace('|', '\n')
label.set_markup(name)
label.set_justify(justify)
label.set_line_wrap(wrap_mode)
if tooltip is not None:
label.set_has_tooltip(True)
label.connect("query-tooltip", self.parent.tooltip_queries, tooltip)
return label
|
module function_definition identifier parameters identifier identifier default_parameter identifier attribute attribute identifier identifier identifier default_parameter identifier true default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content escape_sequence string_end expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list true expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute attribute identifier identifier identifier identifier return_statement identifier
|
The function is used for creating lable with HTML text
|
def files(self, data):
current_files = self.files
if current_files:
raise RuntimeError('Can not update existing files.')
for key in data:
current_files[key] = data[key]
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier if_statement identifier block raise_statement call identifier argument_list string string_start string_content string_end for_statement identifier identifier block expression_statement assignment subscript identifier identifier subscript identifier identifier
|
Set files from data.
|
def create(cls):
if cls not in cls._instances:
cls._instances[cls] = cls()
return cls._instances[cls]
|
module function_definition identifier parameters identifier block if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier call identifier argument_list return_statement subscript attribute identifier identifier identifier
|
Return always the same instance of the backend class
|
def identical(self, other):
try:
return (utils.dict_equiv(self.attrs, other.attrs) and
self.equals(other))
except (TypeError, AttributeError):
return False
|
module function_definition identifier parameters identifier identifier block try_statement block return_statement parenthesized_expression boolean_operator call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier call attribute identifier identifier argument_list identifier except_clause tuple identifier identifier block return_statement false
|
Like equals, but also checks attributes.
|
def split32(data):
all_pieces = []
for position in range(0, len(data), 32):
piece = data[position:position + 32]
all_pieces.append(piece)
return all_pieces
|
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier call identifier argument_list integer call identifier argument_list identifier integer block expression_statement assignment identifier subscript identifier slice identifier binary_operator identifier integer expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
|
Split data into pieces of 32 bytes.
|
def fetch(self):
length = np.random.randint(1, self._curr_length + 1)
nesting = np.random.randint(1, self._curr_nesting + 1)
return length, nesting
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list integer binary_operator attribute identifier identifier integer expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list integer binary_operator attribute identifier identifier integer return_statement expression_list identifier identifier
|
Samples up to current difficulty.
|
def content(self):
if isinstance(self.__report_file, io.StringIO):
return self.__report_file.getvalue()
else:
return ''
|
module function_definition identifier parameters identifier block if_statement call identifier argument_list attribute identifier identifier attribute identifier identifier block return_statement call attribute attribute identifier identifier identifier argument_list else_clause block return_statement string string_start string_end
|
Return report content as a string if mode == STRINGIO else an empty string
|
def parseJSON(self, f):
try:
parsed_json = json.load(f['f'])
except Exception as e:
print(e)
log.warn("Could not parse DamageProfiler JSON: '{}'".format(f['fn']))
return None
s_name = self.clean_s_name(parsed_json['metadata']['sample_name'],'')
self.add_data_source(f, s_name)
self.threepGtoAfreq_data[s_name] = parsed_json['dmg_3p']
self.fivepCtoTfreq_data[s_name] = parsed_json['dmg_5p']
self.lgdist_fw_data[s_name] = parsed_json['lendist_fw']
self.lgdist_rv_data[s_name] = parsed_json['lendist_rv']
self.summary_metrics_data[s_name] = parsed_json['summary_stats']
|
module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end except_clause as_pattern identifier as_pattern_target identifier block expression_statement call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list subscript identifier string string_start string_content string_end return_statement none expression_statement assignment identifier call attribute identifier identifier argument_list subscript subscript identifier string string_start string_content string_end string string_start string_content string_end string string_start string_end expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement assignment subscript attribute identifier identifier identifier subscript identifier string string_start string_content string_end expression_statement assignment subscript attribute identifier identifier identifier subscript identifier string string_start string_content string_end expression_statement assignment subscript attribute identifier identifier identifier subscript identifier string string_start string_content string_end expression_statement assignment subscript attribute identifier identifier identifier subscript identifier string string_start string_content string_end expression_statement assignment subscript attribute identifier identifier identifier subscript identifier string string_start string_content string_end
|
Parse the JSON output from DamageProfiler and save the summary statistics
|
def active_pt_window(self):
" The active prompt_toolkit layout Window. "
if self.active_tab:
w = self.active_tab.active_window
if w:
return w.pt_window
|
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end if_statement attribute identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier if_statement identifier block return_statement attribute identifier identifier
|
The active prompt_toolkit layout Window.
|
def _get_translation_for_locale(self, locale):
translations = None
for dirname in self.paths:
catalog = Translations.load(dirname, [locale], domain=self.domain)
if translations is None:
if isinstance(catalog, Translations):
translations = catalog
continue
try:
translations.merge(catalog)
except AttributeError:
if isinstance(catalog, NullTranslations):
current_app.logger.debug(
'Compiled translations seems to be missing'
' in {0}.'.format(dirname))
continue
raise
return translations or NullTranslations()
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier none for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier list identifier keyword_argument identifier attribute identifier identifier if_statement comparison_operator identifier none block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier identifier continue_statement try_statement block expression_statement call attribute identifier identifier argument_list identifier except_clause identifier block if_statement call identifier argument_list identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list identifier continue_statement raise_statement return_statement boolean_operator identifier call identifier argument_list
|
Get translation for a specific locale.
|
def _RemoveCompletedPathspec(self, index):
pathspec = self.state.indexed_pathspecs[index]
request_data = self.state.request_data_list[index]
self.state.indexed_pathspecs[index] = None
self.state.request_data_list[index] = None
self.state.pending_hashes.pop(index, None)
self.state.pending_files.pop(index, None)
self._TryToStartNextPathspec()
return pathspec, request_data
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript attribute attribute identifier identifier identifier identifier expression_statement assignment identifier subscript attribute attribute identifier identifier identifier identifier expression_statement assignment subscript attribute attribute identifier identifier identifier identifier none expression_statement assignment subscript attribute attribute identifier identifier identifier identifier none expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier none expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier none expression_statement call attribute identifier identifier argument_list return_statement expression_list identifier identifier
|
Removes a pathspec from the list of pathspecs.
|
def remove_all_nexusnve_bindings():
LOG.debug("remove_all_nexusport_bindings() called")
session = bc.get_writer_session()
session.query(nexus_models_v2.NexusNVEBinding).delete()
session.flush()
|
module function_definition identifier parameters block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute call attribute identifier identifier argument_list attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list
|
Removes all nexusnve bindings.
|
def compute_merkletree_with(
merkletree: MerkleTreeState,
lockhash: LockHash,
) -> Optional[MerkleTreeState]:
result = None
leaves = merkletree.layers[LEAVES]
if lockhash not in leaves:
leaves = list(leaves)
leaves.append(Keccak256(lockhash))
result = MerkleTreeState(compute_layers(leaves))
return result
|
module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type identifier type generic_type identifier type_parameter type identifier block expression_statement assignment identifier none expression_statement assignment identifier subscript attribute identifier identifier identifier if_statement comparison_operator identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier return_statement identifier
|
Register the given lockhash with the existing merkle tree.
|
def configure_root(self, config, incremental=False):
root = logging.getLogger()
self.common_logger_config(root, config, incremental)
|
module function_definition identifier parameters identifier identifier default_parameter identifier false block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier identifier identifier
|
Configure a root logger from a dictionary.
|
def uncamel(name):
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name)
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower()
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier return_statement call attribute call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier identifier argument_list
|
Transform CamelCase naming convention into C-ish convention.
|
def _rotate_vector(x, y, x2, y2, x1, y1):
angle = atan2(y2 - y1, x2 - x1)
cos_rad = cos(angle)
sin_rad = sin(angle)
return cos_rad * x + sin_rad * y, -sin_rad * x + cos_rad * y
|
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list binary_operator identifier identifier binary_operator identifier identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier return_statement expression_list binary_operator binary_operator identifier identifier binary_operator identifier identifier binary_operator binary_operator unary_operator identifier identifier binary_operator identifier identifier
|
rotate x,y vector over x2-x1, y2-y1 angle
|
def _send_request(self):
self._generate_hash()
params = self._get_params()
try:
resp = self._endpoint(**params)
logger.debug(resp)
except WebFault, e:
logger.exception('An error occurred while making the SOAP request.')
return None
self.response = XmlDictConfig(ElementTree.XML(smart_str(resp)))
self.response = normalize_dictionary_values(self.response)
if self.response['status']['errorCode'] != 'OK':
logger.error(resp)
return self.response
|
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list dictionary_splat identifier expression_statement call attribute identifier identifier argument_list identifier except_clause identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement none expression_statement assignment attribute identifier identifier call identifier argument_list call attribute identifier identifier argument_list call identifier argument_list identifier expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier if_statement comparison_operator subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier return_statement attribute identifier identifier
|
Make the SOAP request and convert the result to a dictionary.
|
def appendDatastore(self, store):
if not isinstance(store, Datastore):
raise TypeError("stores must be of type %s" % Datastore)
self._stores.append(store)
|
module function_definition identifier parameters identifier identifier block if_statement not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
|
Appends datastore `store` to this collection.
|
def _datastore_api(self):
if self._datastore_api_internal is None:
if self._use_grpc:
self._datastore_api_internal = make_datastore_api(self)
else:
self._datastore_api_internal = HTTPDatastoreAPI(self)
return self._datastore_api_internal
|
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block if_statement attribute identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list identifier else_clause block expression_statement assignment attribute identifier identifier call identifier argument_list identifier return_statement attribute identifier identifier
|
Getter for a wrapped API object.
|
def _split_token_to_subtokens(token, subtoken_dict, max_subtoken_length):
ret = []
start = 0
token_len = len(token)
while start < token_len:
for end in xrange(min(token_len, start + max_subtoken_length), start, -1):
subtoken = token[start:end]
if subtoken in subtoken_dict:
ret.append(subtoken)
start = end
break
else:
raise ValueError("Was unable to split token \"%s\" into subtokens." %
token)
return ret
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier list expression_statement assignment identifier integer expression_statement assignment identifier call identifier argument_list identifier while_statement comparison_operator identifier identifier block for_statement identifier call identifier argument_list call identifier argument_list identifier binary_operator identifier identifier identifier unary_operator integer block expression_statement assignment identifier subscript identifier slice identifier identifier if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier identifier break_statement else_clause block raise_statement call identifier argument_list binary_operator string string_start string_content escape_sequence escape_sequence string_end identifier return_statement identifier
|
Splits a token into subtokens defined in the subtoken dict.
|
def generate_np(self, x_val, **kwargs):
_, feedable, _feedable_types, hash_key = self.construct_variables(kwargs)
if hash_key not in self.graphs:
with tf.variable_scope(None, 'attack_%d' % len(self.graphs)):
with tf.device('/gpu:0'):
x = tf.placeholder(tf.float32, shape=x_val.shape, name='x')
inputs, outputs = self.generate(x, **kwargs)
from runner import RunnerMultiGPU
runner = RunnerMultiGPU(inputs, outputs, sess=self.sess)
self.graphs[hash_key] = runner
runner = self.graphs[hash_key]
feed_dict = {'x': x_val}
for name in feedable:
feed_dict[name] = feedable[name]
fvals = runner.run(feed_dict)
while not runner.is_finished():
fvals = runner.run()
return fvals['adv_x']
|
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block expression_statement assignment pattern_list identifier identifier identifier identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier attribute identifier identifier block with_statement with_clause with_item call attribute identifier identifier argument_list none binary_operator string string_start string_content string_end call identifier argument_list attribute identifier identifier block with_statement with_clause with_item call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier string string_start string_content string_end expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier dictionary_splat identifier import_from_statement dotted_name identifier dotted_name identifier expression_statement assignment identifier call identifier argument_list identifier identifier keyword_argument identifier attribute identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier expression_statement assignment identifier subscript attribute identifier identifier identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier for_statement identifier identifier block expression_statement assignment subscript identifier identifier subscript identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier while_statement not_operator call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list return_statement subscript identifier string string_start string_content string_end
|
Facilitates testing this attack.
|
def harmonic_mean(data):
if not data:
raise StatisticsError('harmonic_mean requires at least one data point')
divisor = sum(map(lambda x: 1.0 / x if x else 0.0, data))
return len(data) / divisor if divisor else 0.0
|
module function_definition identifier parameters identifier block if_statement not_operator identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list call identifier argument_list lambda lambda_parameters identifier conditional_expression binary_operator float identifier identifier float identifier return_statement conditional_expression binary_operator call identifier argument_list identifier identifier identifier float
|
Return the harmonic mean of data
|
def add_badge(self, kind):
badge = self.get_badge(kind)
if badge:
return badge
if kind not in getattr(self, '__badges__', {}):
msg = 'Unknown badge type for {model}: {kind}'
raise db.ValidationError(msg.format(model=self.__class__.__name__,
kind=kind))
badge = Badge(kind=kind)
if current_user.is_authenticated:
badge.created_by = current_user.id
self.update(__raw__={
'$push': {
'badges': {
'$each': [badge.to_mongo()],
'$position': 0
}
}
})
self.reload()
post_save.send(self.__class__, document=self)
on_badge_added.send(self, kind=kind)
return self.get_badge(kind)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement identifier block return_statement identifier if_statement comparison_operator identifier call identifier argument_list identifier string string_start string_content string_end dictionary block expression_statement assignment identifier string string_start string_content string_end raise_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier if_statement attribute identifier identifier block expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier dictionary pair string string_start string_content string_end dictionary pair string string_start string_content string_end dictionary pair string string_start string_content string_end list call attribute identifier identifier argument_list pair string string_start string_content string_end integer expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier return_statement call attribute identifier identifier argument_list identifier
|
Perform an atomic prepend for a new badge
|
def checkIsConsistent(self):
if is_an_array(self.mask) and self.mask.shape != self.data.shape:
raise ConsistencyError("Shape mismatch mask={}, data={}"
.format(self.mask.shape != self.data.shape))
|
module function_definition identifier parameters identifier block if_statement boolean_operator call identifier argument_list attribute identifier identifier comparison_operator attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list comparison_operator attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier
|
Raises a ConsistencyError if the mask has an incorrect shape.
|
def format_installed_dap(name, full=False):
dap_data = get_installed_daps_detailed().get(name)
if not dap_data:
raise DapiLocalError('DAP "{dap}" is not installed, can not query for info.'.format(dap=name))
locations = [os.path.join(data['location'], '') for data in dap_data]
for location in locations:
dap = dapi.Dap(None, fake=True, mimic_filename=name)
meta_path = os.path.join(location, 'meta', name + '.yaml')
with open(meta_path, 'r') as fh:
dap.meta = dap._load_meta(fh)
dap.files = _get_assistants_snippets(location, name)
dap._find_bad_meta()
format_local_dap(dap, full=full, custom_location=os.path.dirname(location))
|
module function_definition identifier parameters identifier default_parameter identifier false block expression_statement assignment identifier call attribute call identifier argument_list identifier argument_list identifier if_statement not_operator identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier expression_statement assignment identifier list_comprehension call attribute attribute identifier identifier identifier argument_list subscript identifier string string_start string_content string_end string string_start string_end for_in_clause identifier identifier for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list none keyword_argument identifier true keyword_argument identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end binary_operator identifier string string_start string_content string_end with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier call identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier call attribute attribute identifier identifier identifier argument_list identifier
|
Formats information about an installed DAP in a human readable form to list of lines
|
def _u_distance_correlation_sqr_naive(x, y, exponent=1):
return _distance_sqr_stats_naive_generic(
x, y,
matrix_centered=_u_distance_matrix,
product=u_product,
exponent=exponent).correlation_xy
|
module function_definition identifier parameters identifier identifier default_parameter identifier integer block return_statement attribute call identifier argument_list identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier identifier
|
Bias-corrected distance correlation estimator between two matrices.
|
def getLate(self):
for analysis in self.getAnalyses():
if analysis.review_state == "retracted":
continue
analysis_obj = api.get_object(analysis)
if analysis_obj.isLateAnalysis():
return True
return False
|
module function_definition identifier parameters identifier block for_statement identifier call attribute identifier identifier argument_list block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block continue_statement expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement call attribute identifier identifier argument_list block return_statement true return_statement false
|
Return True if there is at least one late analysis in this Request
|
def shutdown(self):
self.signal_children(signal.SIGABRT)
waiting = 0
while self.living_children:
time.sleep(0.5)
waiting += 1
if waiting == self.MAX_SHUTDOWN_WAIT:
self.signal_children(signal.SIGKILL)
break
|
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier integer while_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list float expression_statement augmented_assignment identifier integer if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier break_statement
|
Send SIGABRT to child processes to instruct them to stop
|
def clean(self, value):
if value is None:
value = self.default
try:
value = self.to_python(value)
self.validate(value)
except ValidationError as error:
raise ValidationError("invalid value for {}: {}".format(
self.name,
error.args[0]
))
return value
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier none block expression_statement assignment identifier attribute identifier identifier try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier subscript attribute identifier identifier integer return_statement identifier
|
Run validators and return the clean value.
|
def resolve_object_number(self, ref):
if not isinstance(ref, ObjectNumber):
on = ObjectNumber.parse(ref)
else:
on = ref
ds_on = on.as_dataset
return ds_on
|
module function_definition identifier parameters identifier identifier block if_statement not_operator call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment identifier identifier expression_statement assignment identifier attribute identifier identifier return_statement identifier
|
Resolve a variety of object numebrs to a dataset number
|
def safestr(value):
if not value or isinstance(value, (int, float, bool, long)):
return value
elif isinstance(value, (date, datetime)):
return value.isoformat()
else:
return unicode(value)
|
module function_definition identifier parameters identifier block if_statement boolean_operator not_operator identifier call identifier argument_list identifier tuple identifier identifier identifier identifier block return_statement identifier elif_clause call identifier argument_list identifier tuple identifier identifier block return_statement call attribute identifier identifier argument_list else_clause block return_statement call identifier argument_list identifier
|
Ensure type to string serialization
|
def exec_cmd(self, cmd):
cmd = self._cmd_str(cmd)
logmsg = 'Executing command: {0}'.format(cmd)
if self.passwd:
logmsg = logmsg.replace(self.passwd, ('*' * 6))
if 'decode("base64")' in logmsg or 'base64.b64decode(' in logmsg:
log.debug('Executed SHIM command. Command logged to TRACE')
log.trace(logmsg)
else:
log.debug(logmsg)
ret = self._run_cmd(cmd)
return ret
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier if_statement attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier parenthesized_expression binary_operator string string_start string_content string_end integer if_statement boolean_operator comparison_operator string string_start string_content string_end identifier comparison_operator string string_start string_content string_end identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement identifier
|
Execute a remote command
|
def register(cls, package_type):
if not issubclass(package_type, cls):
raise TypeError('package_type must be a subclass of Package.')
cls._REGISTRY.add(package_type)
|
module function_definition identifier parameters identifier identifier block if_statement not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list identifier
|
Register a concrete implementation of a Package to be recognized by pex.
|
def described_as(self, description, *args):
if len(args):
description = description.format(*args)
self.description = description
return self
|
module function_definition identifier parameters identifier identifier list_splat_pattern identifier block if_statement call identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list list_splat identifier expression_statement assignment attribute identifier identifier identifier return_statement identifier
|
Specify a custom message for the matcher
|
def list(args):
jm = setup(args)
jm.list(job_ids=get_ids(args.job_ids), print_array_jobs=args.print_array_jobs, print_dependencies=args.print_dependencies, status=args.status, long=args.long, print_times=args.print_times, ids_only=args.ids_only, names=args.names)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier call identifier argument_list attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier
|
Lists the jobs in the given database.
|
def load(self):
try:
with open(self.file_root + '.pkl', "rb") as f:
return pickle.load(f)
except IOError:
raise CacheMissing(self.file_root)
|
module function_definition identifier parameters identifier block try_statement block with_statement with_clause with_item as_pattern call identifier argument_list binary_operator attribute identifier identifier string string_start string_content string_end string string_start string_content string_end as_pattern_target identifier block return_statement call attribute identifier identifier argument_list identifier except_clause identifier block raise_statement call identifier argument_list attribute identifier identifier
|
Load cache from file using pickle.
|
def _exprparser(
expr, scope, lang=None, conf=None, configurable=None,
safe=DEFAULT_SAFE, besteffort=DEFAULT_BESTEFFORT, tostr=False
):
if scope is None:
scope = {}
scope.update({
'configurable': configurable,
'conf': conf
})
expr = REGEX_EXPR_R.sub(
_refrepl(
configurable=configurable, conf=conf, safe=safe, scope=scope,
besteffort=besteffort
), expr
)
result = resolve(
expr=expr, name=lang, safe=safe, scope=scope, tostr=tostr,
besteffort=besteffort
)
return result
|
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier identifier default_parameter identifier identifier default_parameter identifier false block if_statement comparison_operator identifier none block expression_statement assignment identifier dictionary expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier return_statement identifier
|
In charge of parsing an expression and return a python object.
|
def add_command_arguments(parser):
parser.add_argument(
'--noinput',
'--no-input',
action='store_const',
const=False,
dest='interactive',
help='Tells Django to NOT prompt the user for input of any kind.',
)
parser.add_argument(
'--failfast', action='store_const', const=True, dest='failfast',
help=('Tells Django to stop running the '
'test suite after first failed test.'),
)
parser.add_argument(
'-r', '--reverse', action='store_const', const=True, dest='reverse',
help='Reverses test cases order.',
)
parser.add_argument(
'--use-existing-database',
action='store_true',
default=False,
help="Don't create a test database. USE AT YOUR OWN RISK!",
)
parser.add_argument(
'-k', '--keepdb',
action='store_const',
const=True,
help="Preserves the test DB between runs.",
)
parser.add_argument(
'-S', '--simple',
action='store_true',
default=False,
help="Use simple test runner that supports Django's"
" testing client only (no web browser automation)"
)
|
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier false keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier true keyword_argument identifier string string_start string_content string_end keyword_argument identifier parenthesized_expression concatenated_string string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier true keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier false keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier true keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier false keyword_argument identifier concatenated_string string string_start string_content string_end string string_start string_content string_end
|
Additional command line arguments for the behave management command
|
def _getel(key, value):
if key in ['HorizontalRule', 'Null']:
return elt(key, 0)()
elif key in ['Plain', 'Para', 'BlockQuote', 'BulletList',
'DefinitionList', 'HorizontalRule', 'Null']:
return elt(key, 1)(value)
return elt(key, len(value))(*value)
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier list string string_start string_content string_end string string_start string_content string_end block return_statement call call identifier argument_list identifier integer argument_list elif_clause comparison_operator identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block return_statement call call identifier argument_list identifier integer argument_list identifier return_statement call call identifier argument_list identifier call identifier argument_list identifier argument_list list_splat identifier
|
Returns an element given a key and value.
|
def geoid(self):
if self.valuetype_class.is_geoid():
return self
for c in self.table.columns:
if c.parent == self.name and c.valuetype_class.is_geoid():
return c
|
module function_definition identifier parameters identifier block if_statement call attribute attribute identifier identifier identifier argument_list block return_statement identifier for_statement identifier attribute attribute identifier identifier identifier block if_statement boolean_operator comparison_operator attribute identifier identifier attribute identifier identifier call attribute attribute identifier identifier identifier argument_list block return_statement identifier
|
Return first child of the column, or self that is marked as a geographic identifier
|
def replace(self, html):
self.html = html
text = html.text()
positions = []
def perform_replacement(match):
offset = sum(positions)
start, stop = match.start() + offset, match.end() + offset
s = self.html[start:stop]
if self._is_replacement_allowed(s):
repl = match.expand(self.replacement)
self.html[start:stop] = repl
else:
repl = match.group()
positions.append(match.end())
return repl
while True:
if positions:
text = text[positions[-1]:]
text, n = self.pattern.subn(perform_replacement, text, count=1)
if not n:
break
|
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier list function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment pattern_list identifier identifier expression_list binary_operator call attribute identifier identifier argument_list identifier binary_operator call attribute identifier identifier argument_list identifier expression_statement assignment identifier subscript attribute identifier identifier slice identifier identifier if_statement call attribute identifier identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment subscript attribute identifier identifier slice identifier identifier identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list return_statement identifier while_statement true block if_statement identifier block expression_statement assignment identifier subscript identifier slice subscript identifier unary_operator integer expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier identifier keyword_argument identifier integer if_statement not_operator identifier block break_statement
|
Perform replacements on given HTML fragment.
|
def err_exit(msg, rc=1):
print(msg, file=sys.stderr)
sys.exit(rc)
|
module function_definition identifier parameters identifier default_parameter identifier integer block expression_statement call identifier argument_list identifier keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier
|
Print msg to stderr and exit with rc.
|
async def async_open(self) -> None:
await self._loop.create_connection(
lambda: self,
self._host,
self._port)
|
module function_definition identifier parameters identifier type none block expression_statement await call attribute attribute identifier identifier identifier argument_list lambda identifier attribute identifier identifier attribute identifier identifier
|
Opens connection to the LifeSOS ethernet interface.
|
def loads(self, data, raw=False):
data = self.decrypt(data)
if not data.startswith(self.PICKLE_PAD):
return {}
load = self.serial.loads(data[len(self.PICKLE_PAD):], raw=raw)
return load
|
module function_definition identifier parameters identifier identifier default_parameter identifier false block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator call attribute identifier identifier argument_list attribute identifier identifier block return_statement dictionary expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list subscript identifier slice call identifier argument_list attribute identifier identifier keyword_argument identifier identifier return_statement identifier
|
Decrypt and un-serialize a python object
|
def not_found(self, *args, **kwargs):
kwargs['api'] = self.api
return not_found(*args, **kwargs)
|
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier return_statement call identifier argument_list list_splat identifier dictionary_splat identifier
|
Defines the handler that should handle not found requests against this API
|
def meaningful_value(self, val, undefined):
if isinstance(val, fields.files.FieldFile):
return val.name and not (
isinstance(undefined, fields.files.FieldFile) and val == undefined)
return val is not None and val != undefined
|
module function_definition identifier parameters identifier identifier identifier block if_statement call identifier argument_list identifier attribute attribute identifier identifier identifier block return_statement boolean_operator attribute identifier identifier not_operator parenthesized_expression boolean_operator call identifier argument_list identifier attribute attribute identifier identifier identifier comparison_operator identifier identifier return_statement boolean_operator comparison_operator identifier none comparison_operator identifier identifier
|
Check if val is considered non-empty.
|
def _normalize_words(words, acronyms):
for i, _ in enumerate(words):
if words[i].upper() in acronyms:
words[i] = words[i].upper()
else:
if not words[i].isupper():
words[i] = words[i].capitalize()
return words
|
module function_definition identifier parameters identifier identifier block for_statement pattern_list identifier identifier call identifier argument_list identifier block if_statement comparison_operator call attribute subscript identifier identifier identifier argument_list identifier block expression_statement assignment subscript identifier identifier call attribute subscript identifier identifier identifier argument_list else_clause block if_statement not_operator call attribute subscript identifier identifier identifier argument_list block expression_statement assignment subscript identifier identifier call attribute subscript identifier identifier identifier argument_list return_statement identifier
|
Normalize case of each word to PascalCase.
|
def sortmerna_detailed_barplot (self):
keys = OrderedDict()
metrics = set()
for sample in self.sortmerna:
for key in self.sortmerna[sample]:
if not key in ["total", "rRNA", "non_rRNA"] and not "_pct" in key:
metrics.add(key)
for key in metrics:
keys[key] = { 'name': key.replace("_count","") }
pconfig = {
'id': 'sortmerna-detailed-plot',
'title': 'SortMeRNA: Hit Counts',
'ylab': 'Reads'
}
self.add_section( plot = bargraph.plot(self.sortmerna, keys, pconfig) )
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call identifier argument_list for_statement identifier attribute identifier identifier block for_statement identifier subscript attribute identifier identifier identifier block if_statement boolean_operator not_operator comparison_operator identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end not_operator comparison_operator string string_start string_content string_end identifier block expression_statement call attribute identifier identifier argument_list identifier for_statement identifier identifier block expression_statement assignment subscript identifier identifier dictionary pair string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list attribute identifier identifier identifier identifier
|
Make the HighCharts HTML to plot the sortmerna rates
|
def handle_units(changeset):
units, records = {}, {}
for service_name, service in sorted(changeset.bundle['services'].items()):
for i in range(service.get('num_units', 0)):
record_id = 'addUnit-{}'.format(changeset.next_action())
unit_name = '{}/{}'.format(service_name, i)
records[record_id] = {
'id': record_id,
'method': 'addUnit',
'args': [
'${}'.format(changeset.services_added[service_name]),
None,
],
'requires': [changeset.services_added[service_name]],
}
units[unit_name] = {
'record': record_id,
'service': service_name,
'unit': i,
}
_handle_units_placement(changeset, units, records)
|
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier expression_list dictionary dictionary for_statement pattern_list identifier identifier call identifier argument_list call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list block for_statement identifier call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end integer block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier identifier expression_statement assignment subscript identifier identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end list call attribute string string_start string_content string_end identifier argument_list subscript attribute identifier identifier identifier none pair string string_start string_content string_end list subscript attribute identifier identifier identifier expression_statement assignment subscript identifier identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier expression_statement call identifier argument_list identifier identifier identifier
|
Populate the change set with addUnit changes.
|
def _set_whitespaces_flags(self, show):
doc = self.document()
options = doc.defaultTextOption()
if show:
options.setFlags(options.flags() |
QtGui.QTextOption.ShowTabsAndSpaces)
else:
options.setFlags(
options.flags() & ~QtGui.QTextOption.ShowTabsAndSpaces)
doc.setDefaultTextOption(options)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list if_statement identifier block expression_statement call attribute identifier identifier argument_list binary_operator call attribute identifier identifier argument_list attribute attribute identifier identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list binary_operator call attribute identifier identifier argument_list unary_operator attribute attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier
|
Sets show white spaces flag
|
def value(self):
user = self.trigger.agentml.request_log.most_recent().user
groups = self.trigger.agentml.request_log.most_recent().groups
if len(self._element):
message = ''.join(map(str, self.trigger.agentml.parse_tags(self._element, self.trigger)))
else:
message = self._element.text
default = attribute(self._element, 'default', '')
response = self.trigger.agentml.get_reply(user.id, message, groups)
return response or default
|
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute call attribute attribute attribute attribute identifier identifier identifier identifier identifier argument_list identifier expression_statement assignment identifier attribute call attribute attribute attribute attribute identifier identifier identifier identifier identifier argument_list identifier if_statement call identifier argument_list attribute identifier identifier block expression_statement assignment identifier call attribute string string_start string_end identifier argument_list call identifier argument_list identifier call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier else_clause block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier string string_start string_content string_end string string_start string_end expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier identifier identifier return_statement boolean_operator identifier identifier
|
Return the value of the redirect response
|
def _ifconfig_getnode():
for args in ('', '-a', '-av'):
mac = _find_mac('ifconfig', args, ['hwaddr', 'ether'], lambda i: i+1)
if mac:
return mac
import socket
ip_addr = socket.gethostbyname(socket.gethostname())
mac = _find_mac('arp', '-an', [ip_addr], lambda i: -1)
if mac:
return mac
mac = _find_mac('lanscan', '-ai', ['lan0'], lambda i: 0)
if mac:
return mac
return None
|
module function_definition identifier parameters block for_statement identifier tuple string string_start string_end string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end identifier list string string_start string_content string_end string string_start string_content string_end lambda lambda_parameters identifier binary_operator identifier integer if_statement identifier block return_statement identifier import_statement dotted_name identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list string string_start string_content string_end string string_start string_content string_end list identifier lambda lambda_parameters identifier unary_operator integer if_statement identifier block return_statement identifier expression_statement assignment identifier call identifier argument_list string string_start string_content string_end string string_start string_content string_end list string string_start string_content string_end lambda lambda_parameters identifier integer if_statement identifier block return_statement identifier return_statement none
|
Get the hardware address on Unix by running ifconfig.
|
def header_check(self, content):
encode = None
m = RE_HTML_ENCODE.search(content)
if m:
enc = m.group(1).decode('ascii')
try:
codecs.getencoder(enc)
encode = enc
except LookupError:
pass
else:
encode = self._has_xml_encode(content)
return encode
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier none expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list integer identifier argument_list string string_start string_content string_end try_statement block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier identifier except_clause identifier block pass_statement else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement identifier
|
Special HTML encoding check.
|
def all_tags(self):
tags = set()
for post in self:
tags.update(post.tags)
return list(tags)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier return_statement call identifier argument_list identifier
|
Returns a list of all the unique tags, as strings, that posts in the collection have.
|
def xlabel_halo(ax):
import matplotlib.patheffects as effects
for tick in ax.get_xticklabels() + [ax.xaxis.label]:
tick.set_path_effects([effects.withStroke(linewidth=4, foreground='w')])
|
module function_definition identifier parameters identifier block import_statement aliased_import dotted_name identifier identifier identifier for_statement identifier binary_operator call attribute identifier identifier argument_list list attribute attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list list call attribute identifier identifier argument_list keyword_argument identifier integer keyword_argument identifier string string_start string_content string_end
|
Add a white "halo" around the xlabels.
|
def make_uninstall(parser):
parser.add_argument(
'host',
metavar='HOST',
nargs='+',
help='hosts to uninstall Ceph from',
)
parser.set_defaults(
func=uninstall,
)
|
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier
|
Remove Ceph packages from remote hosts.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.