code
stringlengths 51
2.34k
| sequence
stringlengths 186
3.94k
| docstring
stringlengths 11
171
|
|---|---|---|
def acknowledge_gnome_notification():
x0, y0 = mouse_pos()
mouse_move(10000, 10000)
x, y = mouse_pos()
mouse_rmove(-x/2, 0)
mouse_click(LEFT)
time.sleep(.2)
mouse_move(x0, y0)
|
module function_definition identifier parameters block expression_statement assignment pattern_list identifier identifier call identifier argument_list expression_statement call identifier argument_list integer integer expression_statement assignment pattern_list identifier identifier call identifier argument_list expression_statement call identifier argument_list binary_operator unary_operator identifier integer integer expression_statement call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list float expression_statement call identifier argument_list identifier identifier
|
Moves mouse pointer to the bottom center of the screen and clicks on it.
|
def _expandGLQ(self, zeros, lmax, lmax_calc):
if self.normalization == '4pi':
norm = 1
elif self.normalization == 'schmidt':
norm = 2
elif self.normalization == 'unnorm':
norm = 3
elif self.normalization == 'ortho':
norm = 4
else:
raise ValueError(
"Normalization must be '4pi', 'ortho', 'schmidt', or " +
"'unnorm'. Input value was {:s}"
.format(repr(self.normalization)))
if zeros is None:
zeros, weights = _shtools.SHGLQ(self.lmax)
data = _shtools.MakeGridGLQC(self.coeffs, zeros, norm=norm,
csphase=self.csphase, lmax=lmax,
lmax_calc=lmax_calc)
gridout = SHGrid.from_array(data, grid='GLQ', copy=False)
return gridout
|
module function_definition identifier parameters identifier identifier identifier identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier integer elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier integer elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier integer elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier integer else_clause block raise_statement call identifier argument_list binary_operator string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list call identifier argument_list attribute identifier identifier if_statement comparison_operator identifier none block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier false return_statement identifier
|
Evaluate the coefficients on a Gauss-Legendre quadrature grid.
|
def _traverse_command(self, name, *args, **kwargs):
args = list(args)
args.insert(0, self.name)
return super(InstanceHashField, self)._traverse_command(name, *args, **kwargs)
|
module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list integer attribute identifier identifier return_statement call attribute call identifier argument_list identifier identifier identifier argument_list identifier list_splat identifier dictionary_splat identifier
|
Add key AND the hash field to the args, and call the Redis command.
|
def add(self, snapshot, component='main'):
try:
self.components[component].append(snapshot)
except KeyError:
self.components[component] = [snapshot]
|
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end block try_statement block expression_statement call attribute subscript attribute identifier identifier identifier identifier argument_list identifier except_clause identifier block expression_statement assignment subscript attribute identifier identifier identifier list identifier
|
Add snapshot of component to publish
|
def reset(self):
for key in list(self.keys()): self.iterators[key] = _itertools.cycle(self[key])
return self
|
module function_definition identifier parameters identifier block for_statement identifier call identifier argument_list call attribute identifier identifier argument_list block expression_statement assignment subscript attribute identifier identifier identifier call attribute identifier identifier argument_list subscript identifier identifier return_statement identifier
|
Resets the style cycle.
|
def parse(self, instrs):
instrs_reil = []
try:
for instr in instrs:
instr_lower = instr.lower()
if instr_lower not in self._cache:
self._cache[instr_lower] = instruction.parseString(
instr_lower)[0]
instrs_reil += [copy.deepcopy(self._cache[instr_lower])]
except:
error_msg = "Failed to parse instruction: %s"
logger.error(error_msg, instr, exc_info=True)
return instrs_reil
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list try_statement block for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier subscript call attribute identifier identifier argument_list identifier integer expression_statement augmented_assignment identifier list call attribute identifier identifier argument_list subscript attribute identifier identifier identifier except_clause block expression_statement assignment identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier identifier keyword_argument identifier true return_statement identifier
|
Parse an IR instruction.
|
def _extract_yaml_block(self, indent, fh):
raw_yaml = []
indent_match = re.compile(r"^{}".format(indent))
try:
fh.next()
while indent_match.match(fh.peek()):
raw_yaml.append(fh.next().replace(indent, "", 1))
if self.yaml_block_end.match(fh.peek()):
fh.next()
break
except StopIteration:
pass
return "\n".join(raw_yaml)
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier list expression_statement assignment identifier call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier try_statement block expression_statement call attribute identifier identifier argument_list while_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list call attribute call attribute identifier identifier argument_list identifier argument_list identifier string string_start string_end integer if_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list break_statement except_clause identifier block pass_statement return_statement call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier
|
Extract a raw yaml block from a file handler
|
def _BuildAuthenticatorResponse(self, app_id, client_data, plugin_response):
encoded_client_data = self._Base64Encode(client_data)
signature_data = str(plugin_response['signatureData'])
key_handle = str(plugin_response['keyHandle'])
response = {
'clientData': encoded_client_data,
'signatureData': signature_data,
'applicationId': app_id,
'keyHandle': key_handle,
}
return response
|
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 identifier argument_list subscript identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list subscript identifier string string_start string_content string_end expression_statement assignment 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 pair string string_start string_content string_end identifier return_statement identifier
|
Builds the response to return to the caller.
|
def _SignedVarintEncoder():
local_chr = chr
def EncodeSignedVarint(write, value):
if value < 0:
value += (1 << 64)
bits = value & 0x7f
value >>= 7
while value:
write(0x80|bits)
bits = value & 0x7f
value >>= 7
return write(bits)
return EncodeSignedVarint
|
module function_definition identifier parameters block expression_statement assignment identifier identifier function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier integer block expression_statement augmented_assignment identifier parenthesized_expression binary_operator integer integer expression_statement assignment identifier binary_operator identifier integer expression_statement augmented_assignment identifier integer while_statement identifier block expression_statement call identifier argument_list binary_operator integer identifier expression_statement assignment identifier binary_operator identifier integer expression_statement augmented_assignment identifier integer return_statement call identifier argument_list identifier return_statement identifier
|
Return an encoder for a basic signed varint value.
|
def all_minutes(self):
opens_in_ns = self._opens.values.astype(
'datetime64[ns]',
).view('int64')
closes_in_ns = self._closes.values.astype(
'datetime64[ns]',
).view('int64')
return DatetimeIndex(
compute_all_minutes(opens_in_ns, closes_in_ns),
tz=UTC,
)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end identifier argument_list string string_start string_content string_end return_statement call identifier argument_list call identifier argument_list identifier identifier keyword_argument identifier identifier
|
Returns a DatetimeIndex representing all the minutes in this calendar.
|
def search_line(line, search, searchtype):
if searchtype == 're' or searchtype == 'word':
return re.search(search, line)
elif searchtype == 'pos':
return searcher.search_out(line, search)
elif searchtype == 'hyper':
return searcher.hypernym_search(line, search)
|
module function_definition identifier parameters identifier identifier identifier block if_statement boolean_operator comparison_operator identifier string string_start string_content string_end comparison_operator identifier string string_start string_content string_end block return_statement call attribute identifier identifier argument_list identifier identifier elif_clause comparison_operator identifier string string_start string_content string_end block return_statement call attribute identifier identifier argument_list identifier identifier elif_clause comparison_operator identifier string string_start string_content string_end block return_statement call attribute identifier identifier argument_list identifier identifier
|
Return True if search term is found in given line, False otherwise.
|
def _pickle_load(path):
_, ext = os.path.splitext(path)
topology = None
if sys.version_info.major == 2:
if ext == '.pickle2':
with open(path, 'rb') as f:
topology = pickle.load(f)
elif ext in ('.pickle3', '.pickle'):
with open(path, 'rb') as f:
topology = pickle.load(f, protocol=3)
elif sys.version_info.major == 3:
if ext == '.pickle2':
with open(path, 'rb') as f:
topology = pickle.load(f)
elif ext in ('.pickle3', '.pickle'):
with open(path, 'rb') as f:
topology = pickle.load(f)
if topology is None:
raise ValueError('File {} is not compatible with this version'.format(path))
return topology
|
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier none if_statement comparison_operator attribute attribute identifier identifier identifier integer block if_statement comparison_operator identifier string string_start string_content string_end block 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 identifier call attribute identifier identifier argument_list identifier elif_clause comparison_operator identifier tuple string string_start string_content string_end string string_start string_content string_end block 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 identifier call attribute identifier identifier argument_list identifier keyword_argument identifier integer elif_clause comparison_operator attribute attribute identifier identifier identifier integer block if_statement comparison_operator identifier string string_start string_content string_end block 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 identifier call attribute identifier identifier argument_list identifier elif_clause comparison_operator identifier tuple string string_start string_content string_end string string_start string_content string_end block 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 identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier return_statement identifier
|
Loads pickled topology. Careful with Python versions though!
|
def make_call_with_cb(self, fun, *args):
cid, event = self.handler.register_callback()
argscp = list(args)
argscp.append(cid)
self.make_call(fun, *argscp)
return event
|
module function_definition identifier parameters identifier identifier list_splat_pattern identifier block expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier list_splat identifier return_statement identifier
|
Makes an API call with a callback to wait for
|
def _connect(self):
try:
while True:
_LOGGER.info('Trying to connect to %s', self.server_address)
try:
yield from asyncio.wait_for(
self.loop.create_connection(
lambda: self.protocol, *self.server_address),
self.reconnect_timeout, loop=self.loop)
self.tcp_check_timer = time.time()
self.tcp_disconnect_timer = time.time()
self._check_connection()
return
except asyncio.TimeoutError:
_LOGGER.error(
'Connecting to socket timed out for %s',
self.server_address)
_LOGGER.info(
'Waiting %s secs before trying to connect again',
self.reconnect_timeout)
yield from asyncio.sleep(
self.reconnect_timeout, loop=self.loop)
except OSError:
_LOGGER.error(
'Failed to connect to socket at %s',
self.server_address)
_LOGGER.info(
'Waiting %s secs before trying to connect again',
self.reconnect_timeout)
yield from asyncio.sleep(
self.reconnect_timeout, loop=self.loop)
except asyncio.CancelledError:
_LOGGER.debug(
'Connect attempt to %s cancelled', self.server_address)
|
module function_definition identifier parameters identifier block try_statement block while_statement true block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier try_statement block expression_statement yield call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list lambda attribute identifier identifier list_splat attribute identifier identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list return_statement except_clause attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement yield call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier attribute identifier identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement yield call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier attribute identifier identifier except_clause attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier
|
Connect to the socket.
|
def savePkeyPem(self, pkey, path):
with s_common.genfile(path) as fd:
fd.write(crypto.dump_privatekey(crypto.FILETYPE_PEM, pkey))
|
module function_definition identifier parameters identifier identifier identifier block with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier identifier
|
Save a private key in PEM format to a file outside the certdir.
|
def _firmware_update(firmwarefile='', host='',
directory=''):
dest = os.path.join(directory, firmwarefile[7:])
__salt__['cp.get_file'](firmwarefile, dest)
username = __pillar__['proxy']['admin_user']
password = __pillar__['proxy']['admin_password']
__salt__['dracr.update_firmware'](dest,
host=host,
admin_username=username,
admin_password=password)
|
module function_definition identifier parameters default_parameter identifier string string_start string_end default_parameter identifier string string_start string_end default_parameter identifier string string_start string_end block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier subscript identifier slice integer expression_statement call subscript identifier string string_start string_content string_end argument_list identifier identifier expression_statement assignment identifier subscript subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier subscript subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement call subscript identifier string string_start string_content string_end argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
|
Update firmware for a single host
|
def rgetattr(obj, attr, *args):
def _getattr(obj, attr):
return getattr(obj, attr, *args)
return functools.reduce(_getattr, [obj] + attr.split("."))
|
module function_definition identifier parameters identifier identifier list_splat_pattern identifier block function_definition identifier parameters identifier identifier block return_statement call identifier argument_list identifier identifier list_splat identifier return_statement call attribute identifier identifier argument_list identifier binary_operator list identifier call attribute identifier identifier argument_list string string_start string_content string_end
|
Get attr that handles dots in attr name.
|
def custom_object_prefix_strict(instance):
if (instance['type'] not in enums.TYPES and
instance['type'] not in enums.RESERVED_OBJECTS and
not CUSTOM_TYPE_PREFIX_RE.match(instance['type'])):
yield JSONError("Custom object type '%s' should start with 'x-' "
"followed by a source unique identifier (like a "
"domain name with dots replaced by hyphens), a hyphen "
"and then the name." % instance['type'],
instance['id'], 'custom-prefix')
|
module function_definition identifier parameters identifier block if_statement parenthesized_expression boolean_operator boolean_operator comparison_operator subscript identifier string string_start string_content string_end attribute identifier identifier comparison_operator subscript identifier string string_start string_content string_end attribute identifier identifier not_operator call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end block expression_statement yield call identifier argument_list binary_operator concatenated_string 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 subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end string string_start string_content string_end
|
Ensure custom objects follow strict naming style conventions.
|
def open(cls, sock, chunk_type, isatty, chunk_eof_type=None, buf_size=None, select_timeout=None):
with cls.open_multi(sock,
(chunk_type,),
(isatty,),
chunk_eof_type,
buf_size,
select_timeout) as ctx:
yield ctx
|
module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none block with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list identifier tuple identifier tuple identifier identifier identifier identifier as_pattern_target identifier block expression_statement yield identifier
|
Yields the write side of a pipe that will copy appropriately chunked values to a socket.
|
def fraction_correct_fuzzy_linear_create_vector(z, z_cutoff, z_fuzzy_range):
assert(z_fuzzy_range * 2 < z_cutoff)
if (z == None or numpy.isnan(z)):
return None
elif (z >= z_cutoff + z_fuzzy_range):
return [0, 0, 1]
elif (z <= -z_cutoff - z_fuzzy_range):
return [1, 0, 0]
elif (-z_cutoff + z_fuzzy_range <= z <= z_cutoff - z_fuzzy_range):
return [0, 1, 0]
elif (-z_cutoff - z_fuzzy_range < z < -z_cutoff + z_fuzzy_range):
neutrality = (z + z_cutoff + z_fuzzy_range) / (z_fuzzy_range * 2)
zvec = [1 - neutrality, neutrality, 0]
elif (z_cutoff - z_fuzzy_range < z < z_cutoff + z_fuzzy_range):
positivity = (z - z_cutoff + z_fuzzy_range) / (z_fuzzy_range * 2)
zvec = [0, 1 - positivity, positivity]
else:
raise Exception('Logical error.')
length = math.sqrt(numpy.dot(zvec, zvec))
return numpy.divide(zvec, length)
|
module function_definition identifier parameters identifier identifier identifier block assert_statement parenthesized_expression comparison_operator binary_operator identifier integer identifier if_statement parenthesized_expression boolean_operator comparison_operator identifier none call attribute identifier identifier argument_list identifier block return_statement none elif_clause parenthesized_expression comparison_operator identifier binary_operator identifier identifier block return_statement list integer integer integer elif_clause parenthesized_expression comparison_operator identifier binary_operator unary_operator identifier identifier block return_statement list integer integer integer elif_clause parenthesized_expression comparison_operator binary_operator unary_operator identifier identifier identifier binary_operator identifier identifier block return_statement list integer integer integer elif_clause parenthesized_expression comparison_operator binary_operator unary_operator identifier identifier identifier binary_operator unary_operator identifier identifier block expression_statement assignment identifier binary_operator parenthesized_expression binary_operator binary_operator identifier identifier identifier parenthesized_expression binary_operator identifier integer expression_statement assignment identifier list binary_operator integer identifier identifier integer elif_clause parenthesized_expression comparison_operator binary_operator identifier identifier identifier binary_operator identifier identifier block expression_statement assignment identifier binary_operator parenthesized_expression binary_operator binary_operator identifier identifier identifier parenthesized_expression binary_operator identifier integer expression_statement assignment identifier list integer binary_operator integer identifier identifier else_clause block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier return_statement call attribute identifier identifier argument_list identifier identifier
|
A helper function for fraction_correct_fuzzy_linear.
|
def _stop_remote_console(self):
if self._telnet_server:
self._telnet_server.close()
yield from self._telnet_server.wait_closed()
self._remote_pipe.close()
self._telnet_server = None
|
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement yield call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier none
|
Stops remote console support for this VM.
|
def preview(self, when=timezone.now(), **kwargs):
return self.operate_on(when=when, apply=False, **kwargs)
|
module function_definition identifier parameters identifier default_parameter identifier call attribute identifier identifier argument_list dictionary_splat_pattern identifier block return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier false dictionary_splat identifier
|
Preview transactions, but don't actually save changes to list.
|
def create_bandwidth_limit_rule(self, policy, body=None):
return self.post(self.qos_bandwidth_limit_rules_path % policy,
body=body)
|
module function_definition identifier parameters identifier identifier default_parameter identifier none block return_statement call attribute identifier identifier argument_list binary_operator attribute identifier identifier identifier keyword_argument identifier identifier
|
Creates a new bandwidth limit rule.
|
def _match_lhs(cp, rules):
rule_matches = []
for rule in rules:
reactant_pattern = rule.rule_expression.reactant_pattern
for rule_cp in reactant_pattern.complex_patterns:
if _cp_embeds_into(rule_cp, cp):
rule_matches.append(rule)
break
return rule_matches
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier for_statement identifier attribute identifier identifier block if_statement call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list identifier break_statement return_statement identifier
|
Get rules with a left-hand side matching the given ComplexPattern.
|
def getblock(self, hash: str) -> dict:
return cast(dict, self.api_fetch('getblock?hash=' + hash))
|
module function_definition identifier parameters identifier typed_parameter identifier type identifier type identifier block return_statement call identifier argument_list identifier call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier
|
Returns information about the block with the given hash.
|
def copytree(src, dst, symlinks=False, ignore=None):
if not osp.exists(dst):
os.makedirs(dst)
for item in os.listdir(src):
s = osp.join(src, item)
d = osp.join(dst, item)
if osp.isdir(s):
shutil.copytree(s, d, symlinks, ignore)
else:
shutil.copy2(s, d)
|
module function_definition identifier parameters identifier identifier default_parameter identifier false default_parameter identifier none block if_statement not_operator call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier for_statement identifier call attribute identifier identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier identifier identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier identifier
|
Copy from source directory to destination
|
def separate_reach_logs(log_str):
log_lines = log_str.splitlines()
reach_logs = []
reach_lines = []
adding_reach_lines = False
for l in log_lines[:]:
if not adding_reach_lines and 'Beginning reach' in l:
adding_reach_lines = True
elif adding_reach_lines and 'Reach finished' in l:
adding_reach_lines = False
reach_logs.append(('SUCCEEDED', '\n'.join(reach_lines)))
reach_lines = []
elif adding_reach_lines:
reach_lines.append(l.split('readers - ')[1])
log_lines.remove(l)
if adding_reach_lines:
reach_logs.append(('FAILURE', '\n'.join(reach_lines)))
return '\n'.join(log_lines), reach_logs
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier list expression_statement assignment identifier list expression_statement assignment identifier false for_statement identifier subscript identifier slice block if_statement boolean_operator not_operator identifier comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier true elif_clause boolean_operator identifier comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier false expression_statement call attribute identifier identifier argument_list tuple string string_start string_content string_end call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier expression_statement assignment identifier list elif_clause identifier block expression_statement call attribute identifier identifier argument_list subscript call attribute identifier identifier argument_list string string_start string_content string_end integer expression_statement call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list tuple string string_start string_content string_end call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier return_statement expression_list call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier identifier
|
Get the list of reach logs from the overall logs.
|
def for_json(self):
value = super(DatetimeField, self).for_json()
if isinstance(value, pendulum.Interval):
return value.in_seconds() * 1000
if isinstance(value, datetime):
return self.format_datetime(value)
if isinstance(value, pendulum.Time):
return str(value)
if isinstance(value, pendulum.Date):
return value.to_date_string()
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute call identifier argument_list identifier identifier identifier argument_list if_statement call identifier argument_list identifier attribute identifier identifier block return_statement binary_operator call attribute identifier identifier argument_list integer if_statement call identifier argument_list identifier identifier block return_statement call attribute identifier identifier argument_list identifier if_statement call identifier argument_list identifier attribute identifier identifier block return_statement call identifier argument_list identifier if_statement call identifier argument_list identifier attribute identifier identifier block return_statement call attribute identifier identifier argument_list
|
Return date ISO8601 string formats for datetime, date, and time values, milliseconds for intervals
|
def getVersion():
print('epochs version:', str(CDFepoch.version) + '.' +
str(CDFepoch.release) + '.'+str(CDFepoch.increment))
|
module function_definition identifier parameters block expression_statement call identifier argument_list string string_start string_content string_end binary_operator binary_operator binary_operator binary_operator call identifier argument_list attribute identifier identifier string string_start string_content string_end call identifier argument_list attribute identifier identifier string string_start string_content string_end call identifier argument_list attribute identifier identifier
|
Shows the code version.
|
def refresh_context(self):
User = self.model('res.user')
self.context = User.get_preferences(True)
return self.context
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list true return_statement attribute identifier identifier
|
Get the default context of the user and save it
|
def parse_eep(self, rorg_func=None, rorg_type=None, direction=None, command=None):
if rorg_func is not None and rorg_type is not None:
self.select_eep(rorg_func, rorg_type, direction, command)
provides, values = self.eep.get_values(self._profile, self._bit_data, self._bit_status)
self.parsed.update(values)
return list(provides)
|
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none block if_statement boolean_operator comparison_operator identifier none comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list identifier identifier identifier identifier expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement call identifier argument_list identifier
|
Parse EEP based on FUNC and TYPE
|
def cross_entropy_error(self, input_data, targets, average=True,
cache=None, prediction=False,
sum_errors=True):
loss = []
if cache is None:
cache = self.n_tasks * [None]
for targets_task, cache_task, task in \
izip(targets, cache, self.tasks):
loss.append(task.cross_entropy_error(
input_data, targets_task, average=average,
cache=cache_task,
prediction=prediction))
if sum_errors:
return sum(loss)
else:
return loss
|
module function_definition identifier parameters identifier identifier identifier default_parameter identifier true default_parameter identifier none default_parameter identifier false default_parameter identifier true block expression_statement assignment identifier list if_statement comparison_operator identifier none block expression_statement assignment identifier binary_operator attribute identifier identifier list none for_statement pattern_list identifier identifier identifier line_continuation call identifier argument_list identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier if_statement identifier block return_statement call identifier argument_list identifier else_clause block return_statement identifier
|
Computes the cross-entropy error for all tasks.
|
def first(self):
page = self.get_page(num_elements=1)
data = self.extract_data(page)
if data:
return data[0]
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement identifier block return_statement subscript identifier integer
|
Extract the first AppNexus object present in the response
|
def config_babel(app):
" Init application with babel. "
babel.init_app(app)
def get_locale():
return request.accept_languages.best_match(app.config['BABEL_LANGUAGES'])
babel.localeselector(get_locale)
|
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier function_definition identifier parameters block return_statement call attribute attribute identifier identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier
|
Init application with babel.
|
def _get_session(server):
if server in _sessions:
return _sessions[server]
config = _get_spacewalk_configuration(server)
if not config:
raise Exception('No config for \'{0}\' found on master'.format(server))
session = _get_client_and_key(config['api_url'], config['username'], config['password'])
atexit.register(_disconnect_session, session)
client = session['client']
key = session['key']
_sessions[server] = (client, key)
return client, key
|
module function_definition identifier parameters identifier block if_statement comparison_operator identifier identifier block return_statement subscript identifier identifier expression_statement assignment identifier call identifier argument_list identifier if_statement not_operator identifier block raise_statement call identifier argument_list call attribute string string_start string_content escape_sequence escape_sequence string_end identifier argument_list identifier expression_statement assignment identifier call identifier argument_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment subscript identifier identifier tuple identifier identifier return_statement expression_list identifier identifier
|
Get session and key
|
def to_array(self, channels=2):
return np.linspace(self.volume, self.volume,
self.duration * channels).reshape(self.duration, channels)
|
module function_definition identifier parameters identifier default_parameter identifier integer block return_statement call attribute call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier binary_operator attribute identifier identifier identifier identifier argument_list attribute identifier identifier identifier
|
Generate the array of multipliers for the dynamic
|
def execd_submodule_paths(command, execd_dir=None):
for module_path in execd_module_paths(execd_dir):
path = os.path.join(module_path, command)
if os.access(path, os.X_OK) and os.path.isfile(path):
yield path
|
module function_definition identifier parameters identifier default_parameter identifier none block for_statement identifier call identifier argument_list identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier if_statement boolean_operator call attribute identifier identifier argument_list identifier attribute identifier identifier call attribute attribute identifier identifier identifier argument_list identifier block expression_statement yield identifier
|
Generate a list of full paths to the specified command within exec_dir.
|
def mgmt_nw_id(cls):
if cls._mgmt_nw_uuid is None:
tenant_id = cls.l3_tenant_id()
if not tenant_id:
return
net = bc.get_plugin().get_networks(
bc.context.get_admin_context(),
{'tenant_id': [tenant_id],
'name': [cfg.CONF.general.management_network]},
['id', 'subnets'])
if len(net) == 1:
num_subnets = len(net[0]['subnets'])
if num_subnets == 0:
LOG.error('The management network has no subnet. '
'Please assign one.')
return
elif num_subnets > 1:
LOG.info('The management network has %d subnets. The '
'first one will be used.', num_subnets)
cls._mgmt_nw_uuid = net[0].get('id')
cls._mgmt_subnet_uuid = net[0]['subnets'][0]
elif len(net) > 1:
LOG.error('The management network for does not have '
'unique name. Please ensure that it is.')
else:
LOG.error('There is no virtual management network. Please '
'create one.')
return cls._mgmt_nw_uuid
|
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement not_operator identifier block return_statement expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list call attribute attribute identifier identifier identifier argument_list dictionary pair string string_start string_content string_end list identifier pair string string_start string_content string_end list attribute attribute attribute identifier identifier identifier identifier list string string_start string_content string_end string string_start string_content string_end if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier call identifier argument_list subscript subscript identifier integer string string_start string_content string_end if_statement comparison_operator identifier integer block expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end return_statement elif_clause comparison_operator identifier integer block expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end identifier expression_statement assignment attribute identifier identifier call attribute subscript identifier integer identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier subscript subscript subscript identifier integer string string_start string_content string_end integer elif_clause comparison_operator call identifier argument_list identifier integer block expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end else_clause block expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end return_statement attribute identifier identifier
|
Returns id of the management network.
|
def print_trace(self):
traceback.print_exc()
for tb in self.tracebacks:
print tb,
print ''
|
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list for_statement identifier attribute identifier identifier block print_statement identifier print_statement string string_start string_end
|
Prints stack trace for current exceptions chain.
|
def room_members(self, stream_id):
req_hook = 'pod/v2/room/' + str(stream_id) + '/membership/list'
req_args = None
status_code, response = self.__rest__.GET_query(req_hook, req_args)
self.logger.debug('%s: %s' % (status_code, response))
return status_code, response
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier binary_operator binary_operator string string_start string_content string_end call identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier none expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier return_statement expression_list identifier identifier
|
get list of room members
|
def _mp_run_check(tasks, results, options):
try:
for index, change in iter(tasks.get, None):
change.check()
squashed = squash(change, options=options)
change.clear()
results.put((index, squashed))
except KeyboardInterrupt:
return
|
module function_definition identifier parameters identifier identifier identifier block try_statement block for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier none block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list tuple identifier identifier except_clause identifier block return_statement
|
a helper function for multiprocessing with DistReport.
|
def spin_py(self):
return conversions.primary_spin(self.mass1, self.mass2, self.spin1y,
self.spin2y)
|
module function_definition identifier parameters identifier block return_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier
|
Returns the y-component of the spin of the primary mass.
|
def rbetabin(alpha, beta, n, size=None):
phi = np.random.beta(alpha, beta, size)
return np.random.binomial(n, phi)
|
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier identifier
|
Random beta-binomial variates.
|
def moveToPoint(self, xxx_todo_changeme):
(x,y) = xxx_todo_changeme
self.set_x(float(self.get_x()) + float(x))
self.set_y(float(self.get_y()) + float(y))
|
module function_definition identifier parameters identifier identifier block expression_statement assignment tuple_pattern identifier identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator call identifier argument_list call attribute identifier identifier argument_list call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list binary_operator call identifier argument_list call attribute identifier identifier argument_list call identifier argument_list identifier
|
Moves the rect to the point x,y
|
def printInspectors():
from argos.application import ArgosApplication
argosApp = ArgosApplication()
argosApp.loadOrInitRegistries()
for regItem in argosApp.inspectorRegistry.items:
print(regItem.fullName)
|
module function_definition identifier parameters block import_from_statement dotted_name identifier identifier dotted_name identifier expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list for_statement identifier attribute attribute identifier identifier identifier block expression_statement call identifier argument_list attribute identifier identifier
|
Prints a list of inspectors
|
def _get_paths(self, fullname):
real_path = os.path.join(*fullname[len(self.package_prefix):].split('.'))
for base_path in sys.path:
if base_path == '':
base_path = os.getcwd()
path = os.path.join(base_path, real_path)
yield path + '.ipynb'
yield path + '.py'
yield os.path.join(path, '__init__.ipynb')
yield os.path.join(path, '__init__.py')
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list list_splat call attribute subscript identifier slice call identifier argument_list attribute identifier identifier identifier argument_list string string_start string_content string_end for_statement identifier attribute identifier identifier block if_statement comparison_operator identifier string string_start string_end block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement yield binary_operator identifier string string_start string_content string_end expression_statement yield binary_operator identifier string string_start string_content string_end expression_statement yield call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end expression_statement yield call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end
|
Generate ordered list of paths we should look for fullname module in
|
def can_fetch(self, useragent, url):
if self.disallow_all:
return False
if self.allow_all:
return True
parsed_url = urllib.parse.urlparse(urllib.parse.unquote(url))
url = urllib.parse.urlunparse(('','',parsed_url.path,
parsed_url.params,parsed_url.query, parsed_url.fragment))
url = urllib.parse.quote(url)
if not url:
url = "/"
for entry in self.entries:
if entry.applies_to(useragent):
return entry.allowance(url)
if self.default_entry:
return self.default_entry.allowance(url)
return True
|
module function_definition identifier parameters identifier identifier identifier block if_statement attribute identifier identifier block return_statement false if_statement attribute identifier identifier block return_statement true expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list tuple string string_start string_end string string_start string_end attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement not_operator identifier block expression_statement assignment identifier string string_start string_content string_end for_statement identifier attribute identifier identifier block if_statement call attribute identifier identifier argument_list identifier block return_statement call attribute identifier identifier argument_list identifier if_statement attribute identifier identifier block return_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement true
|
using the parsed robots.txt decide if useragent can fetch url
|
def source_roots(self, document_path):
files = _utils.find_parents(self._root_path, document_path, ['setup.py']) or []
return [os.path.dirname(setup_py) for setup_py in files]
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier boolean_operator call attribute identifier identifier argument_list attribute identifier identifier identifier list string string_start string_content string_end list return_statement list_comprehension call attribute attribute identifier identifier identifier argument_list identifier for_in_clause identifier identifier
|
Return the source roots for the given document.
|
def _get_number_of_slices(self, slice_type):
if slice_type == SliceType.AXIAL:
return self.dimensions[self.axial_orientation.normal_component]
elif slice_type == SliceType.SAGITTAL:
return self.dimensions[self.sagittal_orientation.normal_component]
elif slice_type == SliceType.CORONAL:
return self.dimensions[self.coronal_orientation.normal_component]
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block return_statement subscript attribute identifier identifier attribute attribute identifier identifier identifier elif_clause comparison_operator identifier attribute identifier identifier block return_statement subscript attribute identifier identifier attribute attribute identifier identifier identifier elif_clause comparison_operator identifier attribute identifier identifier block return_statement subscript attribute identifier identifier attribute attribute identifier identifier identifier
|
Get the number of slices in a certain direction
|
def stop_workers(self, _join_arbiter=True):
self._must_stop.set()
self._workers.stop()
self._result_notifier.join()
self._broker.stop()
if _join_arbiter:
self._arbiter.join()
self._reset()
|
module function_definition identifier parameters identifier default_parameter identifier true block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list if_statement identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list
|
Stop the workers and wait for them to terminate.
|
def _handle_sigint(self, signum: int, frame: Any) -> None:
logger.warning("Catched SIGINT")
self.shutdown()
|
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type identifier type none block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list
|
Shutdown after processing current task.
|
def make_request(self, method, path, headers=None, data='', host=None,
auth_path=None, sender=None, override_num_retries=None):
http_request = self.build_base_http_request(method, path, auth_path,
{}, headers, data, host)
return self._mexe(http_request, sender, override_num_retries)
|
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none default_parameter identifier string string_start string_end default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier dictionary identifier identifier identifier return_statement call attribute identifier identifier argument_list identifier identifier identifier
|
Makes a request to the server, with stock multiple-retry logic.
|
def bind(self, callback):
handlers = self._handlers
if self._self is None:
raise RuntimeError('%s already fired, cannot add callbacks' % self)
if handlers is None:
handlers = []
self._handlers = handlers
handlers.append(callback)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier none block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier if_statement comparison_operator identifier none block expression_statement assignment identifier list expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier
|
Bind a ``callback`` to this event.
|
def external_metadata(self, datasource_type=None, datasource_id=None):
if datasource_type == 'druid':
datasource = ConnectorRegistry.get_datasource(
datasource_type, datasource_id, db.session)
elif datasource_type == 'table':
database = (
db.session
.query(Database)
.filter_by(id=request.args.get('db_id'))
.one()
)
Table = ConnectorRegistry.sources['table']
datasource = Table(
database=database,
table_name=request.args.get('table_name'),
schema=request.args.get('schema') or None,
)
external_metadata = datasource.external_metadata()
return self.json_response(external_metadata)
|
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier attribute identifier identifier elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier parenthesized_expression call attribute call attribute call attribute attribute identifier identifier identifier argument_list identifier identifier argument_list keyword_argument identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier argument_list expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier boolean_operator call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end none expression_statement assignment identifier call attribute identifier identifier argument_list return_statement call attribute identifier identifier argument_list identifier
|
Gets column info from the source system
|
def trial(log_dir=None,
upload_dir=None,
sync_period=None,
trial_prefix="",
param_map=None,
init_logging=True):
global _trial
if _trial:
raise ValueError("A trial already exists in the current context")
local_trial = Trial(
log_dir=log_dir,
upload_dir=upload_dir,
sync_period=sync_period,
trial_prefix=trial_prefix,
param_map=param_map,
init_logging=True)
try:
_trial = local_trial
_trial.start()
yield local_trial
finally:
_trial = None
local_trial.close()
|
module function_definition identifier parameters default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier string string_start string_end default_parameter identifier none default_parameter identifier true block global_statement identifier if_statement identifier block raise_statement call identifier argument_list string string_start string_content string_end 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 true try_statement block expression_statement assignment identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement yield identifier finally_clause block expression_statement assignment identifier none expression_statement call attribute identifier identifier argument_list
|
Generates a trial within a with context.
|
def length(self):
return np.sqrt(np.sum(self**2, axis=1)).view(np.ndarray)
|
module function_definition identifier parameters identifier block return_statement call attribute call attribute identifier identifier argument_list call attribute identifier identifier argument_list binary_operator identifier integer keyword_argument identifier integer identifier argument_list attribute identifier identifier
|
Array of vector lengths
|
def delete_flag(self):
self.__status = Flag.NotFlagged
self.__start = None
self.__due_date = None
self.__completed = None
self._track_changes()
|
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier none expression_statement call attribute identifier identifier argument_list
|
Sets this message as un flagged
|
def _serialize(
self,
element,
value,
state
):
xml_value = _hooks_apply_before_serialize(self._hooks, state, value)
if xml_value is None:
if self._default is None:
serialized_value = Text('')
else:
serialized_value = Text(self._default)
else:
serialized_value = Text(xml_value)
if self._attribute:
element.set(self._attribute, serialized_value)
else:
element.text = serialized_value
|
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier identifier identifier if_statement comparison_operator identifier none block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier call identifier argument_list string string_start string_end else_clause block expression_statement assignment identifier call identifier argument_list attribute identifier identifier else_clause block expression_statement assignment identifier call identifier argument_list identifier if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier else_clause block expression_statement assignment attribute identifier identifier identifier
|
Serialize the value to the element.
|
def path(path_name=None, override=None, *, root=None, name=None, ext=None,
inject=None, relpath=None, reduce=False):
path_name, identity, root = _initialize(path_name, override, root, inject)
new_name = _process_name(path_name, identity, name, ext)
new_directory = _process_directory(path_name, identity, root, inject)
full_path = os.path.normpath(os.path.join(new_directory, new_name))
if APPEND_SEP_TO_DIRS and not new_name and full_path[-1] != os.sep:
full_path += os.sep
final_path = _format_path(full_path, root, relpath, reduce)
return final_path
|
module function_definition identifier parameters default_parameter identifier none default_parameter identifier none keyword_separator default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier false block expression_statement assignment pattern_list identifier identifier identifier call identifier argument_list identifier identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier if_statement boolean_operator boolean_operator identifier not_operator identifier comparison_operator subscript identifier unary_operator integer attribute identifier identifier block expression_statement augmented_assignment identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier identifier return_statement identifier
|
Path manipulation black magic
|
def create(self, product_id, period, csr, software_id, organization_handle,
approver_email=None, signature_hash_algorithm=None, domain_validation_methods=None,
hostnames=None, technical_handle=None):
response = self.request(E.createSslCertRequest(
E.productId(product_id),
E.period(period),
E.csr(csr),
E.softwareId(software_id),
E.organizationHandle(organization_handle),
OE('approverEmail', approver_email),
OE('signatureHashAlgorithm', signature_hash_algorithm),
OE('domainValidationMethods', domain_validation_methods, transform=_domain_validation_methods),
OE('hostNames', hostnames, transform=_simple_array),
OE('technicalHandle', technical_handle),
))
return int(response.data.id)
|
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier call identifier argument_list string string_start string_content string_end identifier call identifier argument_list string string_start string_content string_end identifier call identifier argument_list string string_start string_content string_end identifier keyword_argument identifier identifier call identifier argument_list string string_start string_content string_end identifier keyword_argument identifier identifier call identifier argument_list string string_start string_content string_end identifier return_statement call identifier argument_list attribute attribute identifier identifier identifier
|
Order a new SSL certificate.
|
def dim_upper_extent_dict(self):
return { d.name: d.upper_extent for d in self._dims.itervalues()}
|
module function_definition identifier parameters identifier block return_statement dictionary_comprehension pair attribute identifier identifier attribute identifier identifier for_in_clause identifier call attribute attribute identifier identifier identifier argument_list
|
Returns a mapping of dimension name to upper_extent
|
def _get_registry_names(self, registry):
return ', '.join(
f.__name__ if not isinstance(f, tuple) else f[0].__name__
for f in getattr(self, registry, []))
|
module function_definition identifier parameters identifier identifier block return_statement call attribute string string_start string_content string_end identifier generator_expression conditional_expression attribute identifier identifier not_operator call identifier argument_list identifier identifier attribute subscript identifier integer identifier for_in_clause identifier call identifier argument_list identifier identifier list
|
Returns functions names for a registry
|
def cast_like(x, y):
x = tf.convert_to_tensor(x)
y = tf.convert_to_tensor(y)
if x.dtype.base_dtype == y.dtype.base_dtype:
return x
cast_x = tf.cast(x, y.dtype)
if cast_x.device != x.device:
x_name = "(eager Tensor)"
try:
x_name = x.name
except AttributeError:
pass
tf.logging.warning("Cast for %s may induce copy from '%s' to '%s'", x_name,
x.device, cast_x.device)
return cast_x
|
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 identifier identifier argument_list identifier if_statement comparison_operator attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier block return_statement identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier string string_start string_content string_end try_statement block expression_statement assignment identifier attribute identifier identifier except_clause identifier block pass_statement expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier attribute identifier identifier attribute identifier identifier return_statement identifier
|
Cast x to y's dtype, if necessary.
|
def _make_stream_transport(self):
msg_queue = queue.Queue()
with self._stream_transport_map_lock:
self._last_id_used = (self._last_id_used % STREAM_ID_LIMIT) + 1
for local_id in itertools.islice(
itertools.chain(
range(self._last_id_used, STREAM_ID_LIMIT),
range(1, self._last_id_used)), 64):
if local_id not in list(self._stream_transport_map.keys()):
self._last_id_used = local_id
break
else:
raise usb_exceptions.AdbStreamUnavailableError('Ran out of local ids!')
stream_transport = AdbStreamTransport(self, local_id, msg_queue)
self._stream_transport_map[local_id] = stream_transport
return stream_transport
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list with_statement with_clause with_item attribute identifier identifier block expression_statement assignment attribute identifier identifier binary_operator parenthesized_expression binary_operator attribute identifier identifier identifier integer for_statement identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list call identifier argument_list attribute identifier identifier identifier call identifier argument_list integer attribute identifier identifier integer block if_statement comparison_operator identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list block expression_statement assignment attribute identifier identifier identifier break_statement else_clause block raise_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier return_statement identifier
|
Create an AdbStreamTransport with a newly allocated local_id.
|
def package_path(self, team, user, package):
return os.path.join(self.user_path(team, user), package)
|
module function_definition identifier parameters identifier identifier identifier identifier block return_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier identifier
|
Returns the path to a package repository.
|
def _preflight_check(desired, fromrepo, **kwargs):
if 'pkg.check_db' not in __salt__:
return {}
ret = {'suggest': {}, 'no_suggest': []}
pkginfo = __salt__['pkg.check_db'](
*list(desired.keys()), fromrepo=fromrepo, **kwargs
)
for pkgname in pkginfo:
if pkginfo[pkgname]['found'] is False:
if pkginfo[pkgname]['suggestions']:
ret['suggest'][pkgname] = pkginfo[pkgname]['suggestions']
else:
ret['no_suggest'].append(pkgname)
return ret
|
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block if_statement comparison_operator string string_start string_content string_end identifier block return_statement dictionary expression_statement assignment identifier dictionary pair string string_start string_content string_end dictionary pair string string_start string_content string_end list expression_statement assignment identifier call subscript identifier string string_start string_content string_end argument_list list_splat call identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier identifier dictionary_splat identifier for_statement identifier identifier block if_statement comparison_operator subscript subscript identifier identifier string string_start string_content string_end false block if_statement subscript subscript identifier identifier string string_start string_content string_end block expression_statement assignment subscript subscript identifier string string_start string_content string_end identifier subscript subscript identifier identifier string string_start string_content string_end else_clause block expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list identifier return_statement identifier
|
Perform platform-specific checks on desired packages
|
def seven_zip(archive, items, self_extracting=False):
if not isinstance(items, (list, tuple)):
items = [items]
if self_extracting:
return er(_get_sz(), "a", "-ssw", "-sfx", archive, *items)
else:
return er(_get_sz(), "a", "-ssw", archive, *items)
|
module function_definition identifier parameters identifier identifier default_parameter identifier false block if_statement not_operator call identifier argument_list identifier tuple identifier identifier block expression_statement assignment identifier list identifier if_statement identifier block return_statement call identifier argument_list call identifier argument_list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier list_splat identifier else_clause block return_statement call identifier argument_list call identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier list_splat identifier
|
Create a 7z archive.
|
def init(self, access_key=None, secret_key=None):
if not access_key and not secret_key:
self._router.post_init(org_id=self.organizationId, data='{"initCloudAccount": true}')
else:
self._router.post_init(org_id=self.organizationId, data='{}')
ca_data = dict(accessKey=access_key, secretKey=secret_key)
self._router.post_init_custom_cloud_account(org_id=self.organizationId, data=json.dumps(ca_data))
|
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block if_statement boolean_operator not_operator identifier not_operator identifier block expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier string string_start string_content string_end else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier call attribute identifier identifier argument_list identifier
|
Mimics wizard's environment preparation
|
def translate(self, mo):
attrs = {}
groupdict = mo.groupdict()
for name, value in compat_iteritems(groupdict):
if value is None:
value = None
elif self._int_re.match(value):
value = int(value)
elif self._float_re.match(value):
value = float(value)
attrs[name] = (value)
return Struct(attrs)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary expression_statement assignment identifier call attribute identifier identifier argument_list for_statement pattern_list identifier identifier call identifier argument_list identifier block if_statement comparison_operator identifier none block expression_statement assignment identifier none elif_clause call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list identifier elif_clause call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment subscript identifier identifier parenthesized_expression identifier return_statement call identifier argument_list identifier
|
Extract a structure from a match object, while translating the types in the process.
|
def name(self):
with self._bt_interface.connect(self._mac) as connection:
name = connection.read_handle(_HANDLE_READ_NAME)
if not name:
raise BluetoothBackendException("Could not read NAME using handle %s"
" from Mi Temp sensor %s" % (hex(_HANDLE_READ_NAME), self._mac))
return ''.join(chr(n) for n in name)
|
module function_definition identifier parameters identifier block with_statement with_clause with_item as_pattern call attribute attribute identifier identifier identifier argument_list attribute identifier identifier as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator identifier block raise_statement call identifier argument_list binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end tuple call identifier argument_list identifier attribute identifier identifier return_statement call attribute string string_start string_end identifier generator_expression call identifier argument_list identifier for_in_clause identifier identifier
|
Return the name of the sensor.
|
def build_histogram(data, colorscale=None, nbins=10):
if colorscale is None:
colorscale = colorscale_default
colorscale = _colors_to_rgb(colorscale)
h_min, h_max = 0, 1
hist, bin_edges = np.histogram(data, range=(h_min, h_max), bins=nbins)
bin_mids = np.mean(np.array(list(zip(bin_edges, bin_edges[1:]))), axis=1)
histogram = []
max_bucket_value = max(hist)
sum_bucket_value = sum(hist)
for bar, mid in zip(hist, bin_mids):
height = np.floor(((bar / max_bucket_value) * 100) + 0.5)
perc = round((bar / sum_bucket_value) * 100.0, 1)
color = _map_val2color(mid, 0.0, 1.0, colorscale)
histogram.append({"height": height, "perc": perc, "color": color})
return histogram
|
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier integer block if_statement comparison_operator identifier none block expression_statement assignment identifier identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment pattern_list identifier identifier expression_list integer integer expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier keyword_argument identifier tuple identifier identifier keyword_argument identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list call identifier argument_list call identifier argument_list identifier subscript identifier slice integer keyword_argument identifier integer expression_statement assignment identifier list expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier for_statement pattern_list identifier identifier call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator parenthesized_expression binary_operator parenthesized_expression binary_operator identifier identifier integer float expression_statement assignment identifier call identifier argument_list binary_operator parenthesized_expression binary_operator identifier identifier float integer expression_statement assignment identifier call identifier argument_list identifier float float identifier 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 pair string string_start string_content string_end identifier return_statement identifier
|
Build histogram of data based on values of color_function
|
def save_initial_state(self):
paths = self.paths
self.initial_widget = self.get_widget()
self.initial_cursors = {}
for i, editor in enumerate(self.widgets):
if editor is self.initial_widget:
self.initial_path = paths[i]
try:
self.initial_cursors[paths[i]] = editor.textCursor()
except AttributeError:
pass
|
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier dictionary for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier subscript identifier identifier try_statement block expression_statement assignment subscript attribute identifier identifier subscript identifier identifier call attribute identifier identifier argument_list except_clause identifier block pass_statement
|
Save initial cursors and initial active widget.
|
def othertype(self, othertype):
if othertype is not None:
self._el.set('TYPE', 'OTHER')
self._el.set('OTHERTYPE', othertype)
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier
|
Set the ``OTHERTYPE`` attribute value.
|
def _package_conf_file_to_dir(file_name):
if file_name in SUPPORTED_CONFS:
path = BASE_PATH.format(file_name)
if os.path.exists(path):
if os.path.isdir(path):
return False
else:
os.rename(path, path + '.tmpbak')
os.mkdir(path, 0o755)
os.rename(path + '.tmpbak', os.path.join(path, 'tmp'))
return True
else:
os.mkdir(path, 0o755)
return True
|
module function_definition identifier parameters identifier block if_statement comparison_operator identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement call attribute attribute identifier identifier identifier argument_list identifier block if_statement call attribute attribute identifier identifier identifier argument_list identifier block return_statement false else_clause block expression_statement call attribute identifier identifier argument_list identifier binary_operator identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier integer expression_statement call attribute identifier identifier argument_list binary_operator identifier string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end return_statement true else_clause block expression_statement call attribute identifier identifier argument_list identifier integer return_statement true
|
Convert a config file to a config directory.
|
def picard_sort(picard, align_bam, sort_order="coordinate",
out_file=None, compression_level=None, pipe=False):
base, ext = os.path.splitext(align_bam)
if out_file is None:
out_file = "%s-sort%s" % (base, ext)
if not file_exists(out_file):
with tx_tmpdir(picard._config) as tmp_dir:
with file_transaction(picard._config, out_file) as tx_out_file:
opts = [("INPUT", align_bam),
("OUTPUT", out_file if pipe else tx_out_file),
("TMP_DIR", tmp_dir),
("SORT_ORDER", sort_order)]
if compression_level:
opts.append(("COMPRESSION_LEVEL", compression_level))
picard.run("SortSam", opts, pipe=pipe)
return out_file
|
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end default_parameter identifier none default_parameter identifier none default_parameter identifier false block expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier identifier if_statement not_operator call identifier argument_list identifier block with_statement with_clause with_item as_pattern call identifier argument_list attribute identifier identifier as_pattern_target identifier block with_statement with_clause with_item as_pattern call identifier argument_list attribute identifier identifier identifier as_pattern_target identifier block expression_statement assignment identifier list tuple string string_start string_content string_end identifier tuple string string_start string_content string_end conditional_expression identifier identifier identifier tuple string string_start string_content string_end identifier tuple string string_start string_content string_end identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list tuple string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier keyword_argument identifier identifier return_statement identifier
|
Sort a BAM file by coordinates.
|
def header2dict(self, names, struct_format, data):
unpacked_data = struct.unpack(struct_format, data)
return dict(zip(names, unpacked_data))
|
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier return_statement call identifier argument_list call identifier argument_list identifier identifier
|
Unpack the raw received IP and ICMP header information to a dict.
|
def remove_variable(self, name):
index = self._get_var_index(name)
self._A = np.delete(self.A, index, 1)
del self.bounds[name]
del self._variables[name]
self._update_variable_indices()
self._reset_solution()
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier identifier integer delete_statement subscript attribute identifier identifier identifier delete_statement subscript attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list
|
Remove a variable from the problem.
|
def _create_handler_directory(self, handler_name, api_version, server_type):
directory = "{}/api/v{}/{}/{}".format(self._directory, api_version, server_type, handler_name)
os.makedirs(directory, exist_ok=True)
with open("{}/api/v{}/{}/{}.rst".format(self._directory, api_version, server_type, handler_name), "w+") as f:
f.write(handler_name.replace("api.", "").replace("_", " ", ).capitalize())
f.write("\n-----------------------------\n\n")
f.write(".. toctree::\n :glob:\n :maxdepth: 2\n\n {}/*\n".format(handler_name))
|
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier true with_statement with_clause with_item as_pattern call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier identifier identifier identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list call attribute call attribute call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence escape_sequence escape_sequence string_end expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence string_end identifier argument_list identifier
|
Create a directory for the handler and add an index inside
|
def get(cls, key):
if isinstance(key, Enum) and not isinstance(key, cls):
raise TypeError("Cannot type cast between enums")
if isinstance(key, int):
if not int(key) in cls._values:
raise KeyError("There is no enum with key %d" % key)
return cls._values[key]
if isinstance(key, (str, unicode)):
if not key in cls._names:
raise KeyError("There is no enum with name %s" % key)
return cls._names[key]
raise TypeError("Invalid enum key type: %s"
% (key.__class__.__name__))
|
module function_definition identifier parameters identifier identifier block if_statement boolean_operator call identifier argument_list identifier identifier not_operator call identifier argument_list 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 not_operator comparison_operator call identifier argument_list identifier attribute identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier return_statement subscript attribute identifier identifier identifier if_statement call identifier argument_list identifier tuple identifier identifier block if_statement not_operator comparison_operator identifier attribute identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier return_statement subscript attribute identifier identifier identifier raise_statement call identifier argument_list binary_operator string string_start string_content string_end parenthesized_expression attribute attribute identifier identifier identifier
|
str, int or Enum => Enum
|
def ushort(filename):
import pyfits
f=pyfits.open(filename,mode='update')
f[0].scale('int16','',bzero=32768)
f.flush()
f.close()
|
module function_definition identifier parameters identifier block import_statement dotted_name identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end expression_statement call attribute subscript identifier integer identifier argument_list string string_start string_content string_end string string_start string_end keyword_argument identifier integer expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list
|
Ushort a the pixels
|
def room_temperature(self):
tmp = None
tmp2 = None
for user in self.users:
obj = self.users[user]
if obj.current_values['processing']:
if tmp is None:
tmp = obj.current_values['room_temp']
else:
tmp = (tmp + obj.current_values['room_temp']) / 2
else:
if tmp2 is None:
tmp2 = obj.current_values['room_temp']
else:
tmp2 = (tmp2 + obj.current_values['room_temp']) / 2
if tmp is not None:
return tmp
elif tmp2 is not None:
return tmp2
|
module function_definition identifier parameters identifier block expression_statement assignment identifier none expression_statement assignment identifier none for_statement identifier attribute identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier identifier if_statement subscript attribute identifier identifier string string_start string_content string_end block if_statement comparison_operator identifier none block expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end else_clause block expression_statement assignment identifier binary_operator parenthesized_expression binary_operator identifier subscript attribute identifier identifier string string_start string_content string_end integer else_clause block if_statement comparison_operator identifier none block expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end else_clause block expression_statement assignment identifier binary_operator parenthesized_expression binary_operator identifier subscript attribute identifier identifier string string_start string_content string_end integer if_statement comparison_operator identifier none block return_statement identifier elif_clause comparison_operator identifier none block return_statement identifier
|
Return room temperature for both sides of bed.
|
def BuildTemplate(self,
context=None,
output=None,
fleetspeak_service_config=None):
context = context or []
context.append("Arch:%s" % self.GetArch())
self.platform = platform.system()
context.append("Platform:%s" % self.platform)
context.append("Target:%s" % self.platform)
if "Target:Linux" in context:
context.append(self.GetPackageFormat())
template_path = None
if output:
template_path = os.path.join(
output,
grr_config.CONFIG.Get(
"PyInstaller.template_filename", context=context))
builder_obj = self.GetBuilder(context, fleetspeak_service_config)
builder_obj.MakeExecutableTemplate(output_file=template_path)
|
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier boolean_operator identifier list expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier if_statement comparison_operator string string_start string_content string_end identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement assignment identifier none if_statement identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier
|
Find template builder and call it.
|
def security(self):
return {k: v for i in self.pdf.resolvedObjects.items() for k, v in i[1].items()}
|
module function_definition identifier parameters identifier block return_statement dictionary_comprehension pair identifier identifier for_in_clause identifier call attribute attribute attribute identifier identifier identifier identifier argument_list for_in_clause pattern_list identifier identifier call attribute subscript identifier integer identifier argument_list
|
Print security object information for a pdf document
|
def create_tables(self, tables):
cursor = self.get_cursor()
for table in tables:
columns = mslookup_tables[table]
try:
cursor.execute('CREATE TABLE {0}({1})'.format(
table, ', '.join(columns)))
except sqlite3.OperationalError as error:
print(error)
print('Warning: Table {} already exists in database, will '
'add to existing tables instead of creating '
'new.'.format(table))
else:
self.conn.commit()
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier identifier block expression_statement assignment identifier subscript identifier identifier try_statement block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier call attribute string string_start string_content string_end identifier argument_list identifier except_clause as_pattern attribute identifier identifier as_pattern_target identifier block expression_statement call identifier argument_list identifier expression_statement call identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier argument_list identifier else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list
|
Creates database tables in sqlite lookup db
|
def _serialize_data(self, data):
if self.request and self.request.query_params.get('hydrate_data', False):
serializer = DataSerializer(data, many=True, read_only=True)
serializer.bind('data', self)
return serializer.data
else:
return [d.id for d in data]
|
module function_definition identifier parameters identifier identifier block if_statement boolean_operator attribute identifier identifier call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end false block expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier true keyword_argument identifier true expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement attribute identifier identifier else_clause block return_statement list_comprehension attribute identifier identifier for_in_clause identifier identifier
|
Return serialized data or list of ids, depending on `hydrate_data` query param.
|
def as_tree(self):
"Return the nodes as a list of lists."
if self._nodes is None:
return [self]
ret = [self]
for node in self._nodes:
ret.append(node.as_tree())
return ret
|
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end if_statement comparison_operator attribute identifier identifier none block return_statement list identifier expression_statement assignment identifier list identifier for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list return_statement identifier
|
Return the nodes as a list of lists.
|
def _deep_merge_dict(a, b):
for k, v in b.items():
if k in a and isinstance(a[k], dict) and isinstance(v, dict):
_deep_merge_dict(a[k], v)
else:
a[k] = v
|
module function_definition identifier parameters identifier identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement boolean_operator boolean_operator comparison_operator identifier identifier call identifier argument_list subscript identifier identifier identifier call identifier argument_list identifier identifier block expression_statement call identifier argument_list subscript identifier identifier identifier else_clause block expression_statement assignment subscript identifier identifier identifier
|
Additively merge right side dict into left side dict.
|
def load_writer(writer, ppp_config_dir=None, **writer_kwargs):
if ppp_config_dir is None:
ppp_config_dir = get_environ_config_dir()
config_fn = writer + ".yaml" if "." not in writer else writer
config_files = config_search_paths(
os.path.join("writers", config_fn), ppp_config_dir)
writer_kwargs.setdefault("config_files", config_files)
if not writer_kwargs['config_files']:
raise ValueError("Unknown writer '{}'".format(writer))
try:
return load_writer_configs(writer_kwargs['config_files'],
ppp_config_dir=ppp_config_dir,
**writer_kwargs)
except ValueError:
raise ValueError("Writer '{}' does not exist or could not be "
"loaded".format(writer))
|
module function_definition identifier parameters identifier default_parameter identifier none dictionary_splat_pattern identifier block if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier conditional_expression binary_operator identifier string string_start string_content string_end comparison_operator string string_start string_content string_end identifier identifier expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement not_operator subscript identifier string string_start string_content string_end block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier try_statement block return_statement call identifier argument_list subscript identifier string string_start string_content string_end keyword_argument identifier identifier dictionary_splat identifier except_clause identifier block raise_statement call 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
|
Find and load writer `writer` in the available configuration files.
|
def create_migration(self, app, fixture_path):
self.monkey_patch_migration_template(app, fixture_path)
out = StringIO()
management.call_command('makemigrations', app.label, empty=True, stdout=out)
self.restore_migration_template()
self.stdout.write(out.getvalue())
|
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier keyword_argument identifier true keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list
|
Create a data migration for app that uses fixture_path.
|
def copy(self, target, timeout=500):
if self.metadata and 'encoding' in self.metadata:
with io.open(target,'w', encoding=self.metadata['encoding']) as f:
for line in self:
f.write(line)
else:
with io.open(target,'wb') as f:
for line in self:
if sys.version < '3' and isinstance(line,unicode):
f.write(line.encode('utf-8'))
elif sys.version >= '3' and isinstance(line,str):
f.write(line.encode('utf-8'))
else:
f.write(line)
|
module function_definition identifier parameters identifier identifier default_parameter identifier integer block if_statement boolean_operator attribute identifier identifier comparison_operator string string_start string_content string_end attribute identifier identifier block with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list identifier string string_start string_content string_end keyword_argument identifier subscript attribute identifier identifier string string_start string_content string_end as_pattern_target identifier block for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier else_clause block with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block for_statement identifier identifier block if_statement boolean_operator comparison_operator attribute identifier identifier string string_start string_content string_end call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end elif_clause boolean_operator comparison_operator attribute identifier identifier string string_start string_content string_end call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end else_clause block expression_statement call attribute identifier identifier argument_list identifier
|
Copy or download this file to a new local file
|
def _entryChanged(self, entry):
self.purrer.save()
if entry.tw_item:
number = entry.tw_item._ientry
entry.tw_item = None
self.etw.takeTopLevelItem(number)
if number:
after = self.etw.topLevelItem(number - 1)
else:
after = None
self._addEntryItem(entry, number, after)
self._updateViewer()
|
module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list if_statement attribute identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment attribute identifier identifier none expression_statement call attribute attribute identifier identifier identifier argument_list identifier if_statement identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list binary_operator identifier integer else_clause block expression_statement assignment identifier none expression_statement call attribute identifier identifier argument_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list
|
This is called when a log entry is changed
|
def pretty_str(p, decimal_places=2, print_zero=True, label_columns=False):
if len(p.shape) == 1:
return vector_str(p, decimal_places, print_zero)
if len(p.shape) == 2:
return matrix_str(p, decimal_places, print_zero, label_columns)
raise Exception('Invalid array with shape {0}'.format(p.shape))
|
module function_definition identifier parameters identifier default_parameter identifier integer default_parameter identifier true default_parameter identifier false block if_statement comparison_operator call identifier argument_list attribute identifier identifier integer block return_statement call identifier argument_list identifier identifier identifier if_statement comparison_operator call identifier argument_list attribute identifier identifier integer block return_statement call identifier argument_list identifier identifier identifier identifier raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier
|
Pretty-print a matrix or vector.
|
def _parse_precinct_size(spcod):
spcod = np.frombuffer(spcod, dtype=np.uint8)
precinct_size = []
for item in spcod:
ep2 = (item & 0xF0) >> 4
ep1 = item & 0x0F
precinct_size.append((2 ** ep1, 2 ** ep2))
return tuple(precinct_size)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier binary_operator parenthesized_expression binary_operator identifier integer integer expression_statement assignment identifier binary_operator identifier integer expression_statement call attribute identifier identifier argument_list tuple binary_operator integer identifier binary_operator integer identifier return_statement call identifier argument_list identifier
|
Compute precinct size from SPcod or SPcoc.
|
def follow_hand(poppy, delta):
right_arm_position = poppy.l_arm_chain.end_effector + delta
poppy.r_arm_chain.goto(right_arm_position, 0.5, wait=True)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier binary_operator attribute attribute identifier identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier float keyword_argument identifier true
|
Tell the right hand to follow the left hand
|
def refresh(self):
if not self._client:
return
current_images = self._client.images()
self.clear()
self._update(current_images)
for image in current_images:
tags = image.get('RepoTags')
if tags:
self.update({tag: image['Id'] for tag in tags})
|
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block return_statement expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement call attribute identifier identifier argument_list dictionary_comprehension pair identifier subscript identifier string string_start string_content string_end for_in_clause identifier identifier
|
Fetches image and their ids from the client.
|
def _arguments_repr(self):
document_class_repr = (
'dict' if self.document_class is dict
else repr(self.document_class))
uuid_rep_repr = UUID_REPRESENTATION_NAMES.get(self.uuid_representation,
self.uuid_representation)
return ('document_class=%s, tz_aware=%r, uuid_representation=%s, '
'unicode_decode_error_handler=%r, tzinfo=%r, '
'type_registry=%r' %
(document_class_repr, self.tz_aware, uuid_rep_repr,
self.unicode_decode_error_handler, self.tzinfo,
self.type_registry))
|
module function_definition identifier parameters identifier block expression_statement assignment identifier parenthesized_expression conditional_expression string string_start string_content string_end comparison_operator attribute identifier identifier identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier return_statement parenthesized_expression binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end tuple identifier attribute identifier identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier
|
Representation of the arguments used to create this object.
|
def generate_key_data_from_nonce(server_nonce, new_nonce):
server_nonce = server_nonce.to_bytes(16, 'little', signed=True)
new_nonce = new_nonce.to_bytes(32, 'little', signed=True)
hash1 = sha1(new_nonce + server_nonce).digest()
hash2 = sha1(server_nonce + new_nonce).digest()
hash3 = sha1(new_nonce + new_nonce).digest()
key = hash1 + hash2[:12]
iv = hash2[12:20] + hash3 + new_nonce[:4]
return key, iv
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list integer string string_start string_content string_end keyword_argument identifier true expression_statement assignment identifier call attribute identifier identifier argument_list integer string string_start string_content string_end keyword_argument identifier true expression_statement assignment identifier call attribute call identifier argument_list binary_operator identifier identifier identifier argument_list expression_statement assignment identifier call attribute call identifier argument_list binary_operator identifier identifier identifier argument_list expression_statement assignment identifier call attribute call identifier argument_list binary_operator identifier identifier identifier argument_list expression_statement assignment identifier binary_operator identifier subscript identifier slice integer expression_statement assignment identifier binary_operator binary_operator subscript identifier slice integer integer identifier subscript identifier slice integer return_statement expression_list identifier identifier
|
Generates the key data corresponding to the given nonce
|
def parse(self):
expr = self.expression()
if not isinstance(self.current_token, EndToken):
raise InvalidTokenError("Unconsumed trailing tokens.")
return expr
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement not_operator call identifier argument_list attribute identifier identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end return_statement identifier
|
Parse the flow of tokens, and return their evaluation.
|
def fill(h1: Histogram1D, ax: Axes, **kwargs):
show_stats = kwargs.pop("show_stats", False)
density = kwargs.pop("density", False)
cumulative = kwargs.pop("cumulative", False)
kwargs["label"] = kwargs.get("label", h1.name)
data = get_data(h1, cumulative=cumulative, density=density)
_apply_xy_lims(ax, h1, data, kwargs)
_add_ticks(ax, h1, kwargs)
_add_labels(ax, h1, kwargs)
ax.fill_between(h1.bin_centers, 0, data, **kwargs)
if show_stats:
_add_stats_box(h1, ax, stats=show_stats)
return ax
|
module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end false expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end false expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end false expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call identifier argument_list identifier identifier identifier identifier expression_statement call identifier argument_list identifier identifier identifier expression_statement call identifier argument_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier integer identifier dictionary_splat identifier if_statement identifier block expression_statement call identifier argument_list identifier identifier keyword_argument identifier identifier return_statement identifier
|
Fill plot of 1D histogram.
|
def _validate_type(self):
if not isinstance(self._value, self._type):
title = '{} has an invalid type'.format(self._key_name())
description = '{} must be a {}'.format(self._key_name(), self._type.__name__)
self._add_error(title=title, description=description)
|
module function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list attribute identifier identifier attribute identifier identifier 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 call attribute identifier identifier argument_list attribute attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier
|
Validation to ensure value is the correct type
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.