code
stringlengths 51
2.34k
| sequence
stringlengths 186
3.94k
| docstring
stringlengths 11
171
|
|---|---|---|
def remove_constraint(self, name):
index = self._get_constraint_index(name)
self._A = np.delete(self.A, index, 0)
self.upper_bounds = np.delete(self.upper_bounds, index)
del self._constraints[name]
self._update_constraint_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 expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list 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 constraint from the problem
|
def finalize_structure(self):
self.group_list.append(self.current_group)
group_set = get_unique_groups(self.group_list)
for item in self.group_list:
self.group_type_list.append(group_set.index(item))
self.group_list = [x.convert_to_dict() for x in group_set]
|
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier for_statement identifier attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier list_comprehension call attribute identifier identifier argument_list for_in_clause identifier identifier
|
Any functions needed to cleanup the structure.
|
def _strip_leading_dirname(self, path):
return os.path.sep.join(path.split(os.path.sep)[1:])
|
module function_definition identifier parameters identifier identifier block return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list subscript call attribute identifier identifier argument_list attribute attribute identifier identifier identifier slice integer
|
Strip leading directory name from the given path
|
def get(self):
data = b''
with self.lock:
data, self.buf = self.buf, b''
return data
|
module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_end with_statement with_clause with_item attribute identifier identifier block expression_statement assignment pattern_list identifier attribute identifier identifier expression_list attribute identifier identifier string string_start string_end return_statement identifier
|
Get the content of the buffer
|
def copy(self) :
"creates a copy of this Message."
result = dbus.dbus_message_copy(self._dbobj)
if result == None :
raise CallFailed("dbus_message_copy")
return \
type(self)(result)
|
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier if_statement comparison_operator identifier none block raise_statement call identifier argument_list string string_start string_content string_end return_statement line_continuation call call identifier argument_list identifier argument_list identifier
|
creates a copy of this Message.
|
def stage_http_request(self, conn_id, version, url, target, method, headers,
payload):
if self.enabled and self.http_detail_level is not None and \
self.httplogger.isEnabledFor(logging.DEBUG):
if 'Authorization' in headers:
authtype, cred = headers['Authorization'].split(' ')
headers['Authorization'] = _format(
"{0} {1}", authtype, 'X' * len(cred))
header_str = ' '.join('{0}:{1!r}'.format(k, v)
for k, v in headers.items())
if self.http_detail_level == 'summary':
upayload = ""
elif isinstance(payload, six.binary_type):
upayload = payload.decode('utf-8')
else:
upayload = payload
if self.http_maxlen and (len(payload) > self.http_maxlen):
upayload = upayload[:self.http_maxlen] + '...'
self.httplogger.debug('Request:%s %s %s %s %s %s\n %s',
conn_id, method, target, version, url,
header_str, upayload)
|
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier identifier block if_statement boolean_operator boolean_operator attribute identifier identifier comparison_operator attribute identifier identifier none line_continuation call attribute attribute identifier identifier identifier argument_list attribute identifier identifier block if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment pattern_list identifier identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list string string_start string_content string_end identifier binary_operator string string_start string_content string_end call identifier argument_list identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier generator_expression call attribute string string_start string_content string_end identifier argument_list identifier identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier string string_start string_end elif_clause call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end else_clause block expression_statement assignment identifier identifier if_statement boolean_operator attribute identifier identifier parenthesized_expression comparison_operator call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier binary_operator subscript identifier slice attribute identifier identifier string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content escape_sequence string_end identifier identifier identifier identifier identifier identifier identifier
|
Log request HTTP information including url, headers, etc.
|
def members(self):
with self._mutex:
if not self._members:
self._members = {}
for o in self.organisations:
self._members[o.org_id] = o.obj.get_members()
return self._members
|
module function_definition identifier parameters identifier block with_statement with_clause with_item attribute identifier identifier block if_statement not_operator attribute identifier identifier block expression_statement assignment attribute identifier identifier dictionary for_statement identifier attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier attribute identifier identifier call attribute attribute identifier identifier identifier argument_list return_statement attribute identifier identifier
|
Member components if this component is composite.
|
def __load_profile(self, profile, uuid, verbose):
def is_empty_profile(prf):
return not (prf.name or prf.email or
prf.gender or prf.gender_acc or
prf.is_bot or prf.country_code)
uid = api.unique_identities(self.db, uuid)[0]
if profile:
self.__create_profile(profile, uuid, verbose)
elif is_empty_profile(uid.profile):
self.__create_profile_from_identities(uid.identities, uuid, verbose)
else:
self.log("-- empty profile given for %s. Not updated" % uuid, verbose)
|
module function_definition identifier parameters identifier identifier identifier identifier block function_definition identifier parameters identifier block return_statement not_operator parenthesized_expression boolean_operator boolean_operator boolean_operator boolean_operator boolean_operator attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement assignment identifier subscript call attribute identifier identifier argument_list attribute identifier identifier identifier integer if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier identifier identifier elif_clause call identifier argument_list attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier identifier
|
Create a new profile when the unique identity does not have any.
|
def handle_symbol_info(self, call_id, payload):
with catch(KeyError, lambda e: self.editor.message("unknown_symbol")):
decl_pos = payload["declPos"]
f = decl_pos.get("file")
call_options = self.call_options[call_id]
self.log.debug('handle_symbol_info: call_options %s', call_options)
display = call_options.get("display")
if display and f:
self.editor.raw_message(f)
open_definition = call_options.get("open_definition")
if open_definition and f:
self.editor.clean_errors()
self.editor.doautocmd('BufLeave')
if call_options.get("split"):
vert = call_options.get("vert")
self.editor.split_window(f, vertical=vert)
else:
self.editor.edit(f)
self.editor.doautocmd('BufReadPre', 'BufRead', 'BufEnter')
self.set_position(decl_pos)
del self.call_options[call_id]
|
module function_definition identifier parameters identifier identifier identifier block with_statement with_clause with_item call identifier argument_list identifier lambda lambda_parameters identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier subscript attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement boolean_operator identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement boolean_operator identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier delete_statement subscript attribute identifier identifier identifier
|
Handler for response `SymbolInfo`.
|
def _get_line(self) -> str:
line = self.in_lines[self.index]
self.index += 1
return line
|
module function_definition identifier parameters identifier type identifier block expression_statement assignment identifier subscript attribute identifier identifier attribute identifier identifier expression_statement augmented_assignment attribute identifier identifier integer return_statement identifier
|
Returns the current line from the file while incrementing the index.
|
def train(ds, ii):
print("Loading model")
m = model.CannonModel(2)
print("Training...")
m.fit(ds)
np.savez("./ex%s_coeffs.npz" %ii, m.coeffs)
np.savez("./ex%s_scatters.npz" %ii, m.scatters)
np.savez("./ex%s_chisqs.npz" %ii, m.chisqs)
np.savez("./ex%s_pivots.npz" %ii, m.pivots)
fig = m.diagnostics_leading_coeffs(ds)
plt.savefig("ex%s_leading_coeffs.png" %ii)
return m
|
module function_definition identifier parameters identifier identifier block expression_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list integer expression_statement call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier return_statement identifier
|
Run the training step, given a dataset object.
|
def check_req(req):
if not isinstance(req, Requirement):
return None
info = get_package_info(req.name)
newest_version = _get_newest_version(info)
if _is_pinned(req) and _is_version_range(req):
return None
current_spec = next(iter(req.specifier)) if req.specifier else None
current_version = current_spec.version if current_spec else None
if current_version != newest_version:
return req.name, current_version, newest_version
|
module function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list identifier identifier block return_statement none expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier if_statement boolean_operator call identifier argument_list identifier call identifier argument_list identifier block return_statement none expression_statement assignment identifier conditional_expression call identifier argument_list call identifier argument_list attribute identifier identifier attribute identifier identifier none expression_statement assignment identifier conditional_expression attribute identifier identifier identifier none if_statement comparison_operator identifier identifier block return_statement expression_list attribute identifier identifier identifier identifier
|
Checks if a given req is the latest version available.
|
def workspaces(self, index=None):
c = self.centralWidget()
if index is None:
return (c.widget(n) for n in range(c.count()))
else:
return c.widget(index)
|
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier none block return_statement generator_expression call attribute identifier identifier argument_list identifier for_in_clause identifier call identifier argument_list call attribute identifier identifier argument_list else_clause block return_statement call attribute identifier identifier argument_list identifier
|
return generator for all all workspace instances
|
def _rational(self, val):
I32 = 4294967296
if isinstance(val, int):
numer, denom = val, 1
elif isinstance(val, fractions.Fraction):
numer, denom = val.numerator, val.denominator
elif hasattr(val, 'numer'):
(numer, denom) = (int(val.numer()), int(val.denom()))
else:
param.main.param.warning("Casting type '%s' to Fraction.fraction"
% type(val).__name__)
frac = fractions.Fraction(str(val))
numer, denom = frac.numerator, frac.denominator
return numer % I32, denom % I32
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier integer if_statement call identifier argument_list identifier identifier block expression_statement assignment pattern_list identifier identifier expression_list identifier integer elif_clause call identifier argument_list identifier attribute identifier identifier block expression_statement assignment pattern_list identifier identifier expression_list attribute identifier identifier attribute identifier identifier elif_clause call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment tuple_pattern identifier identifier tuple call identifier argument_list call attribute identifier identifier argument_list call identifier argument_list call attribute identifier identifier argument_list else_clause block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list binary_operator string string_start string_content string_end attribute call identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list identifier expression_statement assignment pattern_list identifier identifier expression_list attribute identifier identifier attribute identifier identifier return_statement expression_list binary_operator identifier identifier binary_operator identifier identifier
|
Convert the given value to a rational, if necessary.
|
def _run_flake8(filename, stamp_file_name, show_lint_files):
_debug_linter_status("flake8", filename, show_lint_files)
return _stamped_deps(stamp_file_name,
_run_flake8_internal,
filename)
|
module function_definition identifier parameters identifier identifier identifier block expression_statement call identifier argument_list string string_start string_content string_end identifier identifier return_statement call identifier argument_list identifier identifier identifier
|
Run flake8, cached by stamp_file_name.
|
def cheat(num):
solution = click.style(Problem(num).solution, bold=True)
click.confirm("View answer to problem %i?" % num, abort=True)
click.echo("The answer to problem {} is {}.".format(num, solution))
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute call identifier argument_list identifier identifier keyword_argument identifier true expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier keyword_argument identifier true expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier
|
View the answer to a problem.
|
def _get_ids_from_hostname(self, hostname):
results = self.list_hardware(hostname=hostname, mask="id")
return [result['id'] for result in results]
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end return_statement list_comprehension subscript identifier string string_start string_content string_end for_in_clause identifier identifier
|
Returns list of matching hardware IDs for a given hostname.
|
def store(self, stream, linesep=os.linesep):
for k, v in self.items():
write_key_val(stream, k, v, linesep)
stream.write(linesep.encode('utf-8'))
|
module function_definition identifier parameters identifier identifier default_parameter identifier attribute identifier identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement call identifier argument_list identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end
|
Serialize this section and write it to a binary stream
|
def list_names():
names = get_all_names()
nameslen = len(names)
print('\nListing {} names:\n'.format(nameslen))
namewidth = 20
swatch = ' ' * 9
third = nameslen // 3
lastthird = third * 2
cols = (
names[0: third],
names[third: lastthird],
names[lastthird:],
)
blankitem = ' ' * (namewidth + len(swatch) + 2)
for i in range(third):
nameset = []
for colset in cols:
try:
nameset.append(colset[i])
except IndexError:
nameset.append(None)
continue
line = C('').join(
C(': ').join(
C(name.rjust(namewidth)),
C(swatch, back=name),
) if name else blankitem
for name in nameset
)
print(line)
return 0
|
module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call identifier argument_list identifier expression_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 integer expression_statement assignment identifier binary_operator string string_start string_content string_end integer expression_statement assignment identifier binary_operator identifier integer expression_statement assignment identifier binary_operator identifier integer expression_statement assignment identifier tuple subscript identifier slice integer identifier subscript identifier slice identifier identifier subscript identifier slice identifier expression_statement assignment identifier binary_operator string string_start string_content string_end parenthesized_expression binary_operator binary_operator identifier call identifier argument_list identifier integer for_statement identifier call identifier argument_list identifier block expression_statement assignment identifier list for_statement identifier identifier block try_statement block expression_statement call attribute identifier identifier argument_list subscript identifier identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list none continue_statement expression_statement assignment identifier call attribute call identifier argument_list string string_start string_end identifier generator_expression conditional_expression call attribute call identifier argument_list string string_start string_content string_end identifier argument_list call identifier argument_list call attribute identifier identifier argument_list identifier call identifier argument_list identifier keyword_argument identifier identifier identifier identifier for_in_clause identifier identifier expression_statement call identifier argument_list identifier return_statement integer
|
List all known color names.
|
def method_wrapper(m):
if m.is_simple:
def simple_method(self):
return apply_transform(
self.__service__, m.output_transform,
grpc_call(self.__service__, m, unwrap(self)))
return simple_method
elif m.input_transform is not None:
def transform_method(self, *args, **kwargs):
request = m.input_transform(self, *args, **kwargs)
return apply_transform(
self.__service__, m.output_transform,
grpc_call(self.__service__, m, request))
return transform_method
elif m.static:
def static_method(cls, *args, **kwargs):
request = make_static_request(m, *args, **kwargs)
return apply_transform(
cls.__stub__(__server__), m.output_transform,
grpc_call(cls.__stub__(__server__), m, request))
return static_method
else:
def request_method(self, *args, **kwargs):
request = make_request(self, m, *args, **kwargs)
return apply_transform(
self.__service__, m.output_transform,
grpc_call(self.__service__, m, request))
return request_method
|
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block function_definition identifier parameters identifier block return_statement call identifier argument_list attribute identifier identifier attribute identifier identifier call identifier argument_list attribute identifier identifier identifier call identifier argument_list identifier return_statement identifier elif_clause comparison_operator attribute identifier identifier none block function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier list_splat identifier dictionary_splat identifier return_statement call identifier argument_list attribute identifier identifier attribute identifier identifier call identifier argument_list attribute identifier identifier identifier identifier return_statement identifier elif_clause attribute identifier identifier block function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list identifier list_splat identifier dictionary_splat identifier return_statement call identifier argument_list call attribute identifier identifier argument_list identifier attribute identifier identifier call identifier argument_list call attribute identifier identifier argument_list identifier identifier identifier return_statement identifier else_clause block function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list identifier identifier list_splat identifier dictionary_splat identifier return_statement call identifier argument_list attribute identifier identifier attribute identifier identifier call identifier argument_list attribute identifier identifier identifier identifier return_statement identifier
|
Generates a method from a `GrpcMethod` definition.
|
def unescape(url):
scheme = urlparse(url).scheme
if not scheme:
return url.lstrip('|')
elif scheme == 'salt':
path, saltenv = parse(url)
if salt.utils.platform.is_windows() and '|' in url:
return create(path.lstrip('_'), saltenv)
else:
return create(path.lstrip('|'), saltenv)
else:
return url
|
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute call identifier argument_list identifier identifier if_statement not_operator identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier if_statement boolean_operator call attribute attribute attribute identifier identifier identifier identifier argument_list comparison_operator string string_start string_content string_end identifier block return_statement call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end identifier else_clause block return_statement call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end identifier else_clause block return_statement identifier
|
remove escape character `|` from `url`
|
def py_to_couch_validate(key, val):
if key not in RESULT_ARG_TYPES:
raise CloudantArgumentError(116, key)
if (not isinstance(val, RESULT_ARG_TYPES[key]) or
(type(val) is bool and int in RESULT_ARG_TYPES[key])):
raise CloudantArgumentError(117, key, RESULT_ARG_TYPES[key])
if key == 'keys':
for key_list_val in val:
if (not isinstance(key_list_val, RESULT_ARG_TYPES['key']) or
type(key_list_val) is bool):
raise CloudantArgumentError(134, RESULT_ARG_TYPES['key'])
if key == 'stale':
if val not in ('ok', 'update_after'):
raise CloudantArgumentError(135, val)
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier identifier block raise_statement call identifier argument_list integer identifier if_statement parenthesized_expression boolean_operator not_operator call identifier argument_list identifier subscript identifier identifier parenthesized_expression boolean_operator comparison_operator call identifier argument_list identifier identifier comparison_operator identifier subscript identifier identifier block raise_statement call identifier argument_list integer identifier subscript identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block for_statement identifier identifier block if_statement parenthesized_expression boolean_operator not_operator call identifier argument_list identifier subscript identifier string string_start string_content string_end comparison_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list integer subscript identifier string string_start string_content string_end if_statement comparison_operator identifier string string_start string_content string_end block if_statement comparison_operator identifier tuple string string_start string_content string_end string string_start string_content string_end block raise_statement call identifier argument_list integer identifier
|
Validates the individual parameter key and value.
|
def configuration(self):
with self._mutex:
if not self._configuration:
self._configuration = utils.nvlist_to_dict(self._obj.get_configuration())
return self._configuration
|
module function_definition identifier parameters identifier block with_statement with_clause with_item attribute identifier identifier block if_statement not_operator attribute identifier identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list return_statement attribute identifier identifier
|
The configuration dictionary of the manager.
|
def typos(self):
return (self._deletes() | self._transposes() |
self._replaces() | self._inserts())
|
module function_definition identifier parameters identifier block return_statement parenthesized_expression binary_operator binary_operator binary_operator call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list
|
letter combinations one typo away from word
|
def cache_delsite(site_id):
'Removes all cache data from a site.'
mkey = getkey(T_META, site_id)
tmp = cache.get(mkey)
if not tmp:
return
for tkey in tmp:
cache.delete(tkey)
cache.delete(mkey)
|
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator identifier block return_statement for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier
|
Removes all cache data from a site.
|
def _filter_releases(self):
global display_filter_log
filter_plugins = filter_release_plugins()
if not filter_plugins:
if display_filter_log:
logger.info("No release filters are enabled. Skipping filtering")
display_filter_log = False
else:
for plugin in filter_plugins:
plugin.filter(self.info, self.releases)
|
module function_definition identifier parameters identifier block global_statement identifier expression_statement assignment identifier call identifier argument_list if_statement not_operator identifier block if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier false else_clause block for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier
|
Run the release filtering plugins
|
def user_avatar_update(self, userid, payload):
response, status_code = self.__pod__.User.post_v1_admin_user_uid_avatar_update(
sessionToken=self.__session,
uid=userid,
payload=payload
).result()
self.logger.debug('%s: %s' % (status_code, response))
return status_code, response
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment pattern_list identifier identifier call attribute call attribute attribute attribute identifier identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier identifier argument_list 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
|
updated avatar by userid
|
def delete_instance_if_removed(self, port):
instance_type = self.get_instance_type(port)
if not instance_type:
return
if not db_lib.instance_provisioned(port['device_id']):
i_res = MechResource(port['device_id'], instance_type,
a_const.DELETE)
self.provision_queue.put(i_res)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator identifier block return_statement if_statement not_operator call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list subscript identifier string string_start string_content string_end identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
|
Enqueue instance delete if it's no longer in the db
|
def message_failure(self):
if not isinstance(self.main_manifest, Manifest):
return None
return self.main_manifest.get('config', 'message_failure', default=None)
|
module function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list attribute identifier identifier identifier block return_statement none return_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier none
|
return a failure message, if one exists
|
def _plot_methods(self):
ret = {}
for attr in filter(lambda s: not s.startswith("_"), dir(self)):
obj = getattr(self, attr)
if isinstance(obj, PlotterInterface):
ret[attr] = obj._summary
return ret
|
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary for_statement identifier call identifier argument_list lambda lambda_parameters identifier not_operator call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list identifier identifier if_statement call identifier argument_list identifier identifier block expression_statement assignment subscript identifier identifier attribute identifier identifier return_statement identifier
|
A dictionary with mappings from plot method to their summary
|
def effective_len(self):
if self._effective_len is None:
self._effective_len = len([nuc for nuc in self.sequenceData
if nuc != "N" and nuc != "n"])
return self._effective_len
|
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier call identifier argument_list list_comprehension identifier for_in_clause identifier attribute identifier identifier if_clause boolean_operator comparison_operator identifier string string_start string_content string_end comparison_operator identifier string string_start string_content string_end return_statement attribute identifier identifier
|
Get the length of the sequence if N's are disregarded.
|
def query_edges_by_pubmed_identifiers(self, pubmed_identifiers: List[str]) -> List[Edge]:
fi = and_(Citation.type == CITATION_TYPE_PUBMED, Citation.reference.in_(pubmed_identifiers))
return self.session.query(Edge).join(Evidence).join(Citation).filter(fi).all()
|
module function_definition identifier parameters identifier typed_parameter identifier type generic_type identifier type_parameter type identifier type generic_type identifier type_parameter type identifier block expression_statement assignment identifier call identifier argument_list comparison_operator attribute identifier identifier identifier call attribute attribute identifier identifier identifier argument_list identifier return_statement call attribute call attribute call attribute call attribute call attribute attribute identifier identifier identifier argument_list identifier identifier argument_list identifier identifier argument_list identifier identifier argument_list identifier identifier argument_list
|
Get all edges annotated to the documents identified by the given PubMed identifiers.
|
def _message_from_token(self, token: Text, payload: Any) \
-> Optional[BaseMessage]:
try:
tk = jwt.decode(token, settings.WEBVIEW_SECRET_KEY)
except jwt.InvalidTokenError:
return
try:
user_id = tk['fb_psid']
assert isinstance(user_id, Text)
page_id = tk['fb_pid']
assert isinstance(page_id, Text)
except (KeyError, AssertionError):
return
if self.settings()['page_id'] == page_id:
return self._make_fake_message(user_id, page_id, payload)
|
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type identifier line_continuation type generic_type identifier type_parameter type identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier except_clause attribute identifier identifier block return_statement try_statement block expression_statement assignment identifier subscript identifier string string_start string_content string_end assert_statement call identifier argument_list identifier identifier expression_statement assignment identifier subscript identifier string string_start string_content string_end assert_statement call identifier argument_list identifier identifier except_clause tuple identifier identifier block return_statement if_statement comparison_operator subscript call attribute identifier identifier argument_list string string_start string_content string_end identifier block return_statement call attribute identifier identifier argument_list identifier identifier identifier
|
Analyzes a signed token and generates the matching message
|
def options(f):
f = click.option('--config', envvar='VODKA_HOME', default=click.get_app_dir('vodka'), help="location of config file")(f)
return f
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end argument_list identifier return_statement identifier
|
Shared options, used by all bartender commands
|
def _read_incoming(self):
fileno = self.proc.stdout.fileno()
while 1:
buf = b''
try:
buf = os.read(fileno, 1024)
except OSError as e:
self._log(e, 'read')
if not buf:
self._read_queue.put(None)
return
self._read_queue.put(buf)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list while_statement integer block expression_statement assignment identifier string string_start string_end try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier integer except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier string string_start string_content string_end if_statement not_operator identifier block expression_statement call attribute attribute identifier identifier identifier argument_list none return_statement expression_statement call attribute attribute identifier identifier identifier argument_list identifier
|
Run in a thread to move output from a pipe to a queue.
|
def print_long(filename, stat, print_func):
size = stat_size(stat)
mtime = stat_mtime(stat)
file_mtime = time.localtime(mtime)
curr_time = time.time()
if mtime > (curr_time + SIX_MONTHS) or mtime < (curr_time - SIX_MONTHS):
print_func('%6d %s %2d %04d %s' % (size, MONTH[file_mtime[1]],
file_mtime[2], file_mtime[0],
decorated_filename(filename, stat)))
else:
print_func('%6d %s %2d %02d:%02d %s' % (size, MONTH[file_mtime[1]],
file_mtime[2], file_mtime[3], file_mtime[4],
decorated_filename(filename, stat)))
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement boolean_operator comparison_operator identifier parenthesized_expression binary_operator identifier identifier comparison_operator identifier parenthesized_expression binary_operator identifier identifier block expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier subscript identifier subscript identifier integer subscript identifier integer subscript identifier integer call identifier argument_list identifier identifier else_clause block expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier subscript identifier subscript identifier integer subscript identifier integer subscript identifier integer subscript identifier integer call identifier argument_list identifier identifier
|
Prints detailed information about the file passed in.
|
def declfuncs(self):
for f in self.body:
if (hasattr(f, '_ctype')
and isinstance(f._ctype, FuncType)
and not hasattr(f, 'body')):
yield f
|
module function_definition identifier parameters identifier block for_statement identifier attribute identifier identifier block if_statement parenthesized_expression boolean_operator boolean_operator call identifier argument_list identifier string string_start string_content string_end call identifier argument_list attribute identifier identifier identifier not_operator call identifier argument_list identifier string string_start string_content string_end block expression_statement yield identifier
|
generator on all declaration of functions
|
def params_dict(self):
location_code = 'US'
language_code = 'en'
if len(self.location):
location_code = locationMap[process.extractOne(self.location, self.locations)[0]]
if len(self.language):
language_code = langMap[process.extractOne(self.language, self.languages)[0]]
params = {
'hl': language_code,
'gl': location_code,
'ceid': '{}:{}'.format(location_code, language_code)
}
return params
|
module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end if_statement call identifier argument_list attribute identifier identifier block expression_statement assignment identifier subscript identifier subscript call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier integer if_statement call identifier argument_list attribute identifier identifier block expression_statement assignment identifier subscript identifier subscript call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier integer 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 call attribute string string_start string_content string_end identifier argument_list identifier identifier return_statement identifier
|
function to get params dict for HTTP request
|
def stencil_sets(self):
if not self._stencil_sets:
self._stencil_sets = self.manifest['stencil_sets']
return self._stencil_sets
|
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block expression_statement assignment attribute identifier identifier subscript attribute identifier identifier string string_start string_content string_end return_statement attribute identifier identifier
|
List of stencil sets.
|
def get(cls, parent, url_id):
return cls.query.filter_by(parent=parent, url_id=url_id).one_or_none()
|
module function_definition identifier parameters identifier identifier identifier block return_statement call attribute call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier identifier argument_list
|
Get an instance matching the parent and url_id
|
def on_mode_button(self, my_button, state):
if state:
self.controller.set_mode(my_button.get_label())
|
module function_definition identifier parameters identifier identifier identifier block if_statement identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list
|
Notify the controller of a new mode setting.
|
def _await_if_required(
target: typing.Callable[..., typing.Union["typing.Awaitable[typing.Any]", typing.Any]]
) -> typing.Callable[..., typing.Any]:
@functools.wraps(target)
def wrapper(*args, **kwargs):
result = target(*args, **kwargs)
if asyncio.iscoroutine(result):
loop = asyncio.new_event_loop()
result = loop.run_until_complete(result)
loop.close()
return result
return wrapper
|
module function_definition identifier parameters typed_parameter identifier type subscript attribute identifier identifier ellipsis subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier type subscript attribute identifier identifier ellipsis attribute identifier identifier block decorated_definition decorator call attribute identifier identifier argument_list identifier function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list list_splat identifier dictionary_splat identifier if_statement call attribute identifier identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list return_statement identifier return_statement identifier
|
Await result if coroutine was returned.
|
def createDocument(self, nsuri, qname, doctype=None):
impl = xml.dom.minidom.getDOMImplementation()
return impl.createDocument(nsuri, qname, doctype)
|
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list return_statement call attribute identifier identifier argument_list identifier identifier identifier
|
Create a new writable DOM document object.
|
def _init_code(self, code: int) -> None:
if -1 < code < 256:
self.code = '{:02}'.format(code)
self.hexval = term2hex(code)
self.rgb = hex2rgb(self.hexval)
else:
raise ValueError(' '.join((
'Code must be in the range 0-255, inclusive.',
'Got: {} ({})'
)).format(code, getattr(code, '__name__', type(code).__name__)))
|
module function_definition identifier parameters identifier typed_parameter identifier type identifier type none block if_statement comparison_operator unary_operator integer identifier integer block expression_statement assignment attribute identifier identifier call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment attribute identifier identifier call identifier argument_list identifier expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier else_clause block raise_statement call identifier argument_list call attribute call attribute string string_start string_content string_end identifier argument_list tuple string string_start string_content string_end string string_start string_content string_end identifier argument_list identifier call identifier argument_list identifier string string_start string_content string_end attribute call identifier argument_list identifier identifier
|
Initialize from an int terminal code.
|
def __plain_bfs(adj, source):
seen = set()
nextlevel = {source}
while nextlevel:
thislevel = nextlevel
nextlevel = set()
for v in thislevel:
if v not in seen:
yield v
seen.add(v)
nextlevel.update(adj[v])
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier set identifier while_statement identifier block expression_statement assignment identifier identifier expression_statement assignment identifier call identifier argument_list for_statement identifier identifier block if_statement comparison_operator identifier identifier block expression_statement yield identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list subscript identifier identifier
|
modified NX fast BFS node generator
|
def processConfig(self, worker_config):
self.config['headless'] |= worker_config.get("headless", False)
if self.config['headless']:
if not self.discovery_thread:
self.discovery_thread = discovery.Advertise(
port=",".join(str(a) for a in self.getPorts()),
)
|
module function_definition identifier parameters identifier identifier block expression_statement augmented_assignment subscript attribute identifier identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end false if_statement subscript attribute identifier identifier string string_start string_content string_end block if_statement not_operator attribute identifier identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list keyword_argument identifier call attribute string string_start string_content string_end identifier generator_expression call identifier argument_list identifier for_in_clause identifier call attribute identifier identifier argument_list
|
Update the pool configuration with a worker configuration.
|
def create_response(self, message, sign):
def _response(code=200, data=None):
resp_msg = message.to_response(code=code, data=data, sign=sign)
with self._session.session_lock:
mid = self._conn.publish(topic="/controller",
qos=0, payload=resp_msg.to_dict())
session = self._session.create(resp_msg, mid=mid, age=10)
logging.debug("sending response as mid: %s" % mid)
return self._wait_published(session, no_response=True)
return _response
|
module function_definition identifier parameters identifier identifier identifier block function_definition identifier parameters default_parameter identifier integer default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier with_statement with_clause with_item attribute attribute identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier integer keyword_argument identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier integer expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier true return_statement identifier
|
return function for response
|
def real_out_dtype(self):
if self.__real_out_dtype is None:
raise AttributeError(
'no real variant of output dtype {} defined'
''.format(dtype_repr(self.scalar_out_dtype)))
else:
return self.__real_out_dtype
|
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block raise_statement call identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_end identifier argument_list call identifier argument_list attribute identifier identifier else_clause block return_statement attribute identifier identifier
|
The real dtype corresponding to this space's `out_dtype`.
|
def blend(c1, c2):
return [c1[i] * (0xFF - c2[3]) + c2[i] * c2[3] >> 8 for i in range(3)]
|
module function_definition identifier parameters identifier identifier block return_statement list_comprehension binary_operator binary_operator binary_operator subscript identifier identifier parenthesized_expression binary_operator integer subscript identifier integer binary_operator subscript identifier identifier subscript identifier integer integer for_in_clause identifier call identifier argument_list integer
|
Alpha blends two colors, using the alpha given by c2
|
def OnInsertChartDialog(self, event):
key = self.grid.actions.cursor
cell_code = self.grid.code_array(key)
if cell_code is None:
cell_code = u""
chart_dialog = ChartDialog(self.grid.main_window, key, cell_code)
if chart_dialog.ShowModal() == wx.ID_OK:
code = chart_dialog.get_code()
key = self.grid.actions.cursor
self.grid.actions.set_code(key, code)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute attribute attribute identifier identifier identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement assignment identifier string string_start string_end expression_statement assignment identifier call identifier argument_list attribute attribute identifier identifier identifier identifier identifier if_statement comparison_operator call attribute identifier identifier argument_list attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier attribute attribute attribute identifier identifier identifier identifier expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier identifier
|
Chart dialog event handler
|
def _matchremove_simple_endings(self, word):
was_stemmed = False
simple_endings = ['ibus',
'ius',
'ae',
'am',
'as',
'em',
'es',
'ia',
'is',
'nt',
'os',
'ud',
'um',
'us',
'a',
'e',
'i',
'o',
'u']
for ending in simple_endings:
if word.endswith(ending):
word = re.sub(r'{0}$'.format(ending), '', word)
was_stemmed = True
break
return word, was_stemmed
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier false expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end for_statement identifier identifier block if_statement call attribute identifier identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier string string_start string_end identifier expression_statement assignment identifier true break_statement return_statement expression_list identifier identifier
|
Remove the noun, adjective, adverb word endings
|
def build_nested_field(self, field_name, relation_info, nested_depth):
class NestedSerializer(HyperlinkedModelSerializer):
class Meta:
model = relation_info.related_model
depth = nested_depth - 1
field_class = NestedSerializer
field_kwargs = get_nested_relation_kwargs(relation_info)
return field_class, field_kwargs
|
module function_definition identifier parameters identifier identifier identifier identifier block class_definition identifier argument_list identifier block class_definition identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier binary_operator identifier integer expression_statement assignment identifier identifier expression_statement assignment identifier call identifier argument_list identifier return_statement expression_list identifier identifier
|
Create nested fields for forward and reverse relationships.
|
def password(password_command):
gui = lambda: has_Gtk() and get_password_gui
tty = lambda: sys.stdin.isatty() and get_password_tty
if password_command == 'builtin:gui':
return gui() or tty()
elif password_command == 'builtin:tty':
return tty() or gui()
elif password_command:
return DeviceCommand(password_command).password
else:
return None
|
module function_definition identifier parameters identifier block expression_statement assignment identifier lambda boolean_operator call identifier argument_list identifier expression_statement assignment identifier lambda boolean_operator call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator identifier string string_start string_content string_end block return_statement boolean_operator call identifier argument_list call identifier argument_list elif_clause comparison_operator identifier string string_start string_content string_end block return_statement boolean_operator call identifier argument_list call identifier argument_list elif_clause identifier block return_statement attribute call identifier argument_list identifier identifier else_clause block return_statement none
|
Create a password prompt function.
|
def create_zip_from_file(zip_file, fname):
with zipfile.ZipFile(zip_file, 'w') as myzip:
myzip.write(fname)
|
module function_definition identifier parameters 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 as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier
|
add a file to the archive
|
def p_recent(self, kind, cur_p='', with_catalog=True, with_date=True):
if cur_p == '':
current_page_number = 1
else:
current_page_number = int(cur_p)
current_page_number = 1 if current_page_number < 1 else current_page_number
pager_num = int(MPost.total_number(kind) / CMS_CFG['list_num'])
kwd = {
'pager': '',
'title': 'Recent posts.',
'with_catalog': with_catalog,
'with_date': with_date,
'kind': kind,
'current_page': current_page_number,
'post_count': MPost.get_counts(),
'router': config.router_post[kind],
}
self.render('admin/post_ajax/post_list.html',
kwd=kwd,
view=MPost.query_recent(num=20, kind=kind),
infos=MPost.query_pager_by_slug(
kind=kind,
current_page_num=current_page_number
),
format_date=tools.format_date,
userinfo=self.userinfo,
cfg=CMS_CFG, )
|
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_end default_parameter identifier true default_parameter identifier true block if_statement comparison_operator identifier string string_start string_end block expression_statement assignment identifier integer else_clause block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier conditional_expression integer comparison_operator identifier integer identifier expression_statement assignment identifier call identifier argument_list binary_operator call attribute identifier identifier argument_list identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end 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 pair string string_start string_content string_end call attribute identifier identifier argument_list pair string string_start string_content string_end subscript attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier call attribute identifier identifier argument_list keyword_argument identifier integer keyword_argument identifier identifier keyword_argument identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier
|
List posts that recent edited, partially.
|
def MapSizer(field_descriptor, is_message_map):
message_type = field_descriptor.message_type
message_sizer = MessageSizer(field_descriptor.number, False, False)
def FieldSize(map_value):
total = 0
for key in map_value:
value = map_value[key]
entry_msg = message_type._concrete_class(key=key, value=value)
total += message_sizer(entry_msg)
if is_message_map:
value.ByteSize()
return total
return FieldSize
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier false false function_definition identifier parameters identifier block expression_statement assignment identifier integer for_statement identifier identifier block expression_statement assignment identifier subscript identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier expression_statement augmented_assignment identifier call identifier argument_list identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list return_statement identifier return_statement identifier
|
Returns a sizer for a map field.
|
def write_lockfile(self, content):
s = self._lockfile_encoder.encode(content)
open_kwargs = {"newline": self._lockfile_newlines, "encoding": "utf-8"}
with vistir.contextmanagers.atomic_open_for_write(
self.lockfile_location, **open_kwargs
) as f:
f.write(s)
if not s.endswith(u"\n"):
f.write(u"\n")
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end string string_start string_content string_end with_statement with_clause with_item as_pattern call attribute attribute identifier identifier identifier argument_list attribute identifier identifier dictionary_splat identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier if_statement not_operator call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end block expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end
|
Write out the lockfile.
|
def delete(build_folder):
if _meta_.del_build in ["on", "ON"] and os.path.exists(build_folder):
shutil.rmtree(build_folder)
|
module function_definition identifier parameters identifier block if_statement boolean_operator comparison_operator attribute identifier identifier list string string_start string_content string_end string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier
|
Delete build directory and all its contents.
|
def scope(self, key, *tags, default=None):
scope = self._scopes[key]
tags = self._ensure_exclamation(tags)
default = default if not default or default.startswith("!") else "!" + default
if scope:
scope[0] = scope[0] + tags
scope[1] = default if default else scope[1]
else:
scope.append(tags)
scope.append(default)
|
module function_definition identifier parameters identifier identifier list_splat_pattern identifier default_parameter identifier none block expression_statement assignment identifier subscript attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier conditional_expression identifier boolean_operator not_operator identifier call attribute identifier identifier argument_list string string_start string_content string_end binary_operator string string_start string_content string_end identifier if_statement identifier block expression_statement assignment subscript identifier integer binary_operator subscript identifier integer identifier expression_statement assignment subscript identifier integer conditional_expression identifier identifier subscript identifier integer else_clause block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier
|
Only apply tags and default for top-level key, effectively scoping the tags.
|
def add_auth(f):
def add_auth_decorator(*args, **kwargs):
token = get_user_token()
if 'headers' not in kwargs:
kwargs['headers'] = {}
kwargs['headers']['Authorization'] = "Bearer %s" % token
return f(*args, **kwargs)
return add_auth_decorator
|
module function_definition identifier parameters identifier block function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end dictionary expression_statement assignment subscript subscript identifier string string_start string_content string_end string string_start string_content string_end binary_operator string string_start string_content string_end identifier return_statement call identifier argument_list list_splat identifier dictionary_splat identifier return_statement identifier
|
A decorator that adds the authentication header to requests arguments
|
def precision(self):
if self._precision is None:
cov = np.atleast_3d(self.covariance)
self._precision = np.zeros(cov.shape)
for p in range(cov.shape[-1]):
self._precision[:, :, p] = pdinv(cov[:, :, p])[0]
return self._precision
|
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 attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier for_statement identifier call identifier argument_list subscript attribute identifier identifier unary_operator integer block expression_statement assignment subscript attribute identifier identifier slice slice identifier subscript call identifier argument_list subscript identifier slice slice identifier integer return_statement attribute identifier identifier
|
Inverse of posterior covariance
|
def unicode_key(key):
if not isinstance(key, (text_type, binary_type)):
from mo_logs import Log
Log.error("{{key|quote}} is not a valid key", key=key)
return quote(text_type(key))
|
module function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list identifier tuple identifier identifier block import_from_statement dotted_name identifier dotted_name identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier return_statement call identifier argument_list call identifier argument_list identifier
|
CONVERT PROPERTY VALUE TO QUOTED NAME OF SAME
|
def _compute_metadata_from_readers(self):
mda = {'sensor': self._get_sensor_names()}
if self.readers:
mda['start_time'] = min(x.start_time
for x in self.readers.values())
mda['end_time'] = max(x.end_time
for x in self.readers.values())
return mda
|
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end call attribute identifier identifier argument_list if_statement attribute identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end call identifier generator_expression attribute identifier identifier for_in_clause identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end call identifier generator_expression attribute identifier identifier for_in_clause identifier call attribute attribute identifier identifier identifier argument_list return_statement identifier
|
Determine pieces of metadata from the readers loaded.
|
def random_orthonormal(normal):
u = normal_fns[np.argmin(np.fabs(normal))](normal)
u /= np.linalg.norm(u)
v = np.cross(normal, u)
v /= np.linalg.norm(v)
alpha = np.random.uniform(0.0, np.pi*2)
return np.cos(alpha)*u + np.sin(alpha)*v
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call subscript identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier argument_list identifier expression_statement augmented_assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement augmented_assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list float binary_operator attribute identifier identifier integer return_statement binary_operator binary_operator call attribute identifier identifier argument_list identifier identifier binary_operator call attribute identifier identifier argument_list identifier identifier
|
Return a random normalized vector orthogonal to the given vector
|
def _run_hooks(self):
for hook in self.hooks:
getattr(self, hook)(self._state)
|
module function_definition identifier parameters identifier block for_statement identifier attribute identifier identifier block expression_statement call call identifier argument_list identifier identifier argument_list attribute identifier identifier
|
Calls any registered hooks providing the current state.
|
def image_id_from_registry(image_name):
registry, repository, tag = parse(image_name)
try:
token = auth_token(registry, repository).get("token")
if registry == "index.docker.io":
registry = "registry-1.docker.io"
res = requests.head("https://{}/v2/{}/manifests/{}".format(registry, repository, tag), headers={
"Authorization": "Bearer {}".format(token),
"Accept": "application/vnd.docker.distribution.manifest.v2+json"
}, timeout=5)
res.raise_for_status()
except requests.RequestException:
log.error("Received {} when attempting to get digest for {}".format(
res, image_name))
return None
return "@".join([registry+"/"+repository, res.headers["Docker-Content-Digest"]])
|
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier identifier call identifier argument_list identifier try_statement block expression_statement assignment identifier call attribute call identifier argument_list identifier identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier identifier keyword_argument identifier dictionary pair string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list identifier pair string string_start string_content string_end string string_start string_content string_end keyword_argument identifier integer expression_statement call attribute identifier identifier argument_list except_clause attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier return_statement none return_statement call attribute string string_start string_content string_end identifier argument_list list binary_operator binary_operator identifier string string_start string_content string_end identifier subscript attribute identifier identifier string string_start string_content string_end
|
Get the docker id from a public or private registry
|
def validate_edge_direction(edge_direction):
if not isinstance(edge_direction, six.string_types):
raise TypeError(u'Expected string edge_direction, got: {} {}'.format(
type(edge_direction), edge_direction))
if edge_direction not in ALLOWED_EDGE_DIRECTIONS:
raise ValueError(u'Unrecognized edge direction: {}'.format(edge_direction))
|
module function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list identifier attribute identifier identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier identifier if_statement comparison_operator identifier identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier
|
Ensure the provided edge direction is either "in" or "out".
|
def translate_diff(origtext,deltas):
'take diff run on separated words and convert the deltas to character offsets'
lens=[0]+cumsum(map(len,splitpreserve(origtext)))
return [Delta(lens[a],lens[b],''.join(replace)) for a,b,replace in deltas]
|
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier binary_operator list integer call identifier argument_list call identifier argument_list identifier call identifier argument_list identifier return_statement list_comprehension call identifier argument_list subscript identifier identifier subscript identifier identifier call attribute string string_start string_end identifier argument_list identifier for_in_clause pattern_list identifier identifier identifier identifier
|
take diff run on separated words and convert the deltas to character offsets
|
def __ProcessHttpResponse(self, method_config, http_response, request):
if http_response.status_code not in (http_client.OK,
http_client.CREATED,
http_client.NO_CONTENT):
raise exceptions.HttpError.FromResponse(
http_response, method_config=method_config, request=request)
if http_response.status_code == http_client.NO_CONTENT:
http_response = http_wrapper.Response(
info=http_response.info, content='{}',
request_url=http_response.request_url)
content = http_response.content
if self._client.response_encoding and isinstance(content, bytes):
content = content.decode(self._client.response_encoding)
if self.__client.response_type_model == 'json':
return content
response_type = _LoadClass(method_config.response_type_name,
self.__client.MESSAGES_MODULE)
return self.__client.DeserializeMessage(response_type, content)
|
module function_definition identifier parameters identifier identifier identifier identifier block if_statement comparison_operator attribute identifier identifier tuple attribute identifier identifier attribute identifier identifier attribute identifier identifier block raise_statement call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier if_statement boolean_operator attribute attribute identifier identifier identifier call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier if_statement comparison_operator attribute attribute identifier identifier identifier string string_start string_content string_end block return_statement identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier attribute attribute identifier identifier identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier identifier
|
Process the given http response.
|
def updateBoostStrength(self):
if self.training:
self.boostStrength = self.boostStrength * self.boostStrengthFactor
|
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement assignment attribute identifier identifier binary_operator attribute identifier identifier attribute identifier identifier
|
Update boost strength using given strength factor during training
|
def _importSequence(chromosome, fastaFile, targetDir) :
"Serializes fastas into .dat files"
f = gzip.open(fastaFile)
header = f.readline()
strRes = f.read().upper().replace('\n', '').replace('\r', '')
f.close()
fn = '%s/chromosome%s.dat' % (targetDir, chromosome.number)
f = open(fn, 'w')
f.write(strRes)
f.close()
chromosome.dataFile = fn
chromosome.header = header
return len(strRes)
|
module function_definition identifier parameters identifier identifier identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute call attribute call attribute call attribute identifier identifier argument_list identifier argument_list identifier argument_list string string_start string_content escape_sequence string_end string string_start string_end identifier argument_list string string_start string_content escape_sequence string_end string string_start string_end expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier return_statement call identifier argument_list identifier
|
Serializes fastas into .dat files
|
def clear():
fig = _context['figure']
if fig is not None:
fig.marks = []
fig.axes = []
setattr(fig, 'axis_registry', {})
_context['scales'] = {}
key = _context['current_key']
if key is not None:
_context['scale_registry'][key] = {}
|
module function_definition identifier parameters block expression_statement assignment identifier subscript identifier string string_start string_content string_end if_statement comparison_operator identifier none block expression_statement assignment attribute identifier identifier list expression_statement assignment attribute identifier identifier list expression_statement call identifier argument_list identifier string string_start string_content string_end dictionary expression_statement assignment subscript identifier string string_start string_content string_end dictionary expression_statement assignment identifier subscript identifier string string_start string_content string_end if_statement comparison_operator identifier none block expression_statement assignment subscript subscript identifier string string_start string_content string_end identifier dictionary
|
Clears the current context figure of all marks axes and grid lines.
|
def hook(name=None, *args, **kwargs):
def decorator(f):
if not hasattr(f, "hooks"):
f.hooks = []
f.hooks.append((name or f.__name__, args, kwargs))
return f
return decorator
|
module function_definition identifier parameters default_parameter identifier none list_splat_pattern identifier dictionary_splat_pattern identifier block function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier list expression_statement call attribute attribute identifier identifier identifier argument_list tuple boolean_operator identifier attribute identifier identifier identifier identifier return_statement identifier return_statement identifier
|
Decorator to register the function as a hook
|
def drawBezier(page, p1, p2, p3, p4, color=None, fill=None,
dashes=None, width=1, morph=None,
closePath=False, roundCap=False, overlay=True):
img = page.newShape()
Q = img.drawBezier(Point(p1), Point(p2), Point(p3), Point(p4))
img.finish(color=color, fill=fill, dashes=dashes, width=width,
roundCap=roundCap, morph=morph, closePath=closePath)
img.commit(overlay)
return Q
|
module function_definition identifier parameters identifier identifier identifier identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier integer default_parameter identifier none default_parameter identifier false default_parameter identifier false default_parameter identifier true block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list identifier call identifier argument_list identifier call identifier argument_list identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
|
Draw a general cubic Bezier curve from p1 to p4 using control points p2 and p3.
|
def send_slack_message(channel, text):
http = httplib2.Http()
return http.request(SLACK_MESSAGE_URL, 'POST', body=json.dumps({
'channel': channel,
'text': text,
}))
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list return_statement call attribute identifier identifier argument_list identifier string string_start string_content string_end keyword_argument identifier 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
|
Send a message to Slack
|
def run_sbml_validation(document, notifications):
validator = libsbml.SBMLValidator()
validator.validate(document)
for i in range(document.getNumErrors()):
notifications['errors'].append(format_failure(document.getError(i)))
for i in range(validator.getNumFailures()):
failure = validator.getFailure(i)
if failure.isWarning():
notifications['warnings'].append(format_failure(failure))
else:
notifications['errors'].append(format_failure(failure))
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier for_statement identifier call identifier argument_list call attribute identifier identifier argument_list block expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list call identifier argument_list call attribute identifier identifier argument_list identifier for_statement identifier call identifier argument_list call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement call attribute identifier identifier argument_list block expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list call identifier argument_list identifier else_clause block expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list call identifier argument_list identifier
|
Report errors and warnings found in an SBML document.
|
def write_changelog(debug=False):
changelog = _iter_log_oneline(debug)
if changelog:
changelog = _iter_changelog(changelog)
if not changelog:
return
if debug:
print('Writing ChangeLog')
new_changelog = os.path.join(os.path.curdir, 'ChangeLog')
if (os.path.exists(new_changelog)
and not os.access(new_changelog, os.W_OK)):
return
with io.open(new_changelog, 'w', encoding='utf-8') as changelog_file:
for release, content in changelog:
changelog_file.write(content)
|
module function_definition identifier parameters default_parameter identifier false block expression_statement assignment identifier call identifier argument_list identifier if_statement identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement not_operator identifier block return_statement if_statement identifier block expression_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier string string_start string_content string_end if_statement parenthesized_expression boolean_operator call attribute attribute identifier identifier identifier argument_list identifier not_operator call attribute identifier identifier argument_list identifier attribute identifier identifier block return_statement 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 string string_start string_content string_end as_pattern_target identifier block for_statement pattern_list identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier
|
Write a changelog based on the git changelog.
|
def start(self):
current_pedalboard = self.controller(CurrentController).pedalboard
if current_pedalboard is None:
self.log('Not exists any current pedalboard.')
self.log('Use CurrentController to set the current pedalboard')
else:
self.log('Load current pedalboard - "{}"', current_pedalboard.name)
self.mod_host.pedalboard = current_pedalboard
for component in self.components:
component.init()
self.log('Load component - {}', component.__class__.__name__)
self.log('Components loaded')
atexit.register(self.stop)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute call attribute identifier identifier argument_list identifier identifier if_statement comparison_operator identifier 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 string string_start string_content string_end else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement assignment attribute attribute identifier identifier identifier identifier for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list attribute identifier identifier
|
Start the application, initializing your components.
|
def version(self):
branches = self.branches()
if self.info['branch'] == branches.sandbox:
try:
return self.software_version()
except Exception as exc:
raise utils.CommandError(
'Could not obtain repo version, do you have a makefile '
'with version entry?\n%s' % exc
)
else:
branch = self.info['branch'].lower()
branch = re.sub('[^a-z0-9_-]+', '-', branch)
return f"{branch}-{self.info['head']['id'][:8]}"
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier block try_statement block return_statement call attribute identifier identifier argument_list except_clause as_pattern identifier as_pattern_target identifier block raise_statement call attribute identifier identifier argument_list binary_operator concatenated_string string string_start string_content string_end string string_start string_content escape_sequence string_end identifier else_clause block expression_statement assignment identifier call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier return_statement string string_start interpolation identifier string_content interpolation subscript subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end slice integer string_end
|
Software version of the current repository
|
def write_values(self):
return dict(((k, v.value) for k, v in self._inputs.items() if not v.is_secret and not v.is_empty(False)))
|
module function_definition identifier parameters identifier block return_statement call identifier argument_list generator_expression tuple identifier attribute identifier identifier for_in_clause pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list if_clause boolean_operator not_operator attribute identifier identifier not_operator call attribute identifier identifier argument_list false
|
Return the dictionary with which to write values
|
def split(self, dt):
outlist=[]
for seg in self:
start = seg.start()
stop = seg.end()
id = seg.id()
while start < stop:
tmpstop = start + dt
if tmpstop > stop:
tmpstop = stop
elif tmpstop + dt > stop:
tmpstop = int( (start + stop)/2 )
x = ScienceSegment(tuple([id,start,tmpstop,tmpstop-start]))
outlist.append(x)
start = tmpstop
self.__sci_segs = outlist
return len(self)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list while_statement comparison_operator identifier identifier block expression_statement assignment identifier binary_operator identifier identifier if_statement comparison_operator identifier identifier block expression_statement assignment identifier identifier elif_clause comparison_operator binary_operator identifier identifier identifier block expression_statement assignment identifier call identifier argument_list binary_operator parenthesized_expression binary_operator identifier identifier integer expression_statement assignment identifier call identifier argument_list call identifier argument_list list identifier identifier identifier binary_operator identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier identifier expression_statement assignment attribute identifier identifier identifier return_statement call identifier argument_list identifier
|
Split the segments in the list is subsegments at least as long as dt
|
def _get_free_display_port(self):
display = 100
if not os.path.exists("/tmp/.X11-unix/"):
return display
while True:
if not os.path.exists("/tmp/.X11-unix/X{}".format(display)):
return display
display += 1
|
module function_definition identifier parameters identifier block expression_statement assignment identifier integer if_statement not_operator call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block return_statement identifier while_statement true block if_statement not_operator call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier block return_statement identifier expression_statement augmented_assignment identifier integer
|
Search a free display port
|
def verify_id(ctx, param, app):
if app is None:
raise TypeError("Select an experiment using the --app parameter.")
elif app[0:5] == "dlgr-":
raise ValueError(
"The --app parameter requires the full "
"UUID beginning with {}-...".format(app[5:13])
)
return app
|
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator identifier none block raise_statement call identifier argument_list string string_start string_content string_end elif_clause comparison_operator subscript identifier slice integer integer string string_start string_content string_end 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 subscript identifier slice integer integer return_statement identifier
|
Verify the experiment id.
|
def _parse_marc_code(field):
field = str(field)
if len(field) < 4:
raise Exception('Wrong field code: %s' % field)
else:
field += '__'
tag = field[0:3]
ind1 = field[3].replace('_', '')
ind2 = field[4].replace('_', '')
return tag, ind1, ind2
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator call identifier argument_list identifier integer block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier else_clause block expression_statement augmented_assignment identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier slice integer integer expression_statement assignment identifier call attribute subscript identifier integer identifier argument_list string string_start string_content string_end string string_start string_end expression_statement assignment identifier call attribute subscript identifier integer identifier argument_list string string_start string_content string_end string string_start string_end return_statement expression_list identifier identifier identifier
|
Parse marc field and return default indicators if not filled in.
|
def delete(self):
'Delete this folder and return a deleted JFSFolder'
params = {'dlDir':'true'}
r = self.jfs.post(self.path, params)
self.sync()
return r
|
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list return_statement identifier
|
Delete this folder and return a deleted JFSFolder
|
def generate(basename, xml_list):
for idx in range(len(xml_list)):
xml = xml_list[idx]
xml.xml_idx = idx
generate_one(basename, xml)
copy_fixed_headers(basename, xml_list[0])
|
module function_definition identifier parameters identifier identifier block for_statement identifier call identifier argument_list call identifier argument_list identifier block expression_statement assignment identifier subscript identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement call identifier argument_list identifier identifier expression_statement call identifier argument_list identifier subscript identifier integer
|
generate complete MAVLink C implemenation
|
def parse_multiple_rpcs(cls, record_data):
rpcs = []
while len(record_data) > 0:
total_length, record_type = struct.unpack_from("<LB3x", record_data)
if record_type != SendErrorCheckingRPCRecord.RecordType:
raise ArgumentError("Record set contains a record that is not an error checking RPC",
record_type=record_type)
record_contents = record_data[8: total_length]
parsed_rpc = cls._parse_rpc_info(record_contents)
rpcs.append(parsed_rpc)
record_data = record_data[total_length:]
return rpcs
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list while_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement comparison_operator identifier attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end keyword_argument identifier identifier expression_statement assignment identifier subscript identifier slice integer identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier subscript identifier slice identifier return_statement identifier
|
Parse record_data into multiple error checking rpcs.
|
def VcardMergeListFields(field1, field2):
field_dict = {}
for f in field1 + field2:
field_dict[str(f)] = f
return list(field_dict.values())
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary for_statement identifier binary_operator identifier identifier block expression_statement assignment subscript identifier call identifier argument_list identifier identifier return_statement call identifier argument_list call attribute identifier identifier argument_list
|
Handle merging list fields that may include some overlap.
|
def save(self):
with open(self.config_file, "w") as f:
f.write(dump(self.config, default_flow_style=False))
|
module function_definition identifier parameters identifier block with_statement with_clause with_item as_pattern call identifier argument_list attribute identifier identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list attribute identifier identifier keyword_argument identifier false
|
Save current state of config dictionary.
|
def upload_kitten(client):
config = {
'album': album,
'name': 'Catastrophe!',
'title': 'Catastrophe!',
'description': 'Cute kitten being cute on {0}'.format(datetime.now())
}
print("Uploading image... ")
image = client.upload_from_path(image_path, config=config, anon=False)
print("Done")
print()
return image
|
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list expression_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier false expression_statement call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list return_statement identifier
|
Upload a picture of a kitten. We don't ship one, so get creative!
|
def _safe_attr(attr, camel_killer=False, replacement_char='x'):
allowed = string.ascii_letters + string.digits + '_'
attr = _safe_key(attr)
if camel_killer:
attr = _camel_killer(attr)
attr = attr.replace(' ', '_')
out = ''
for character in attr:
out += character if character in allowed else "_"
out = out.strip("_")
try:
int(out[0])
except (ValueError, IndexError):
pass
else:
out = '{0}{1}'.format(replacement_char, out)
if out in kwlist:
out = '{0}{1}'.format(replacement_char, out)
return re.sub('_+', '_', out)
|
module function_definition identifier parameters identifier default_parameter identifier false default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier binary_operator binary_operator attribute identifier identifier attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier if_statement identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier string string_start string_end for_statement identifier identifier block expression_statement augmented_assignment identifier conditional_expression identifier comparison_operator identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end try_statement block expression_statement call identifier argument_list subscript identifier integer except_clause tuple identifier identifier block pass_statement else_clause block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier identifier if_statement comparison_operator identifier identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier identifier return_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier
|
Convert a key into something that is accessible as an attribute
|
def add_ref(self, reftype, data):
ref = (reftype, data)
try:
index = self.refs.index(ref)
except ValueError:
self.refs.append(ref)
index = len(self.refs) - 1
return str(index)
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier tuple identifier identifier try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier except_clause identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier binary_operator call identifier argument_list attribute identifier identifier integer return_statement call identifier argument_list identifier
|
Add a reference and returns the identifier.
|
def keygrip_ed25519(vk):
return _compute_keygrip([
['p', util.num2bytes(0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFED, size=32)],
['a', b'\x01'],
['b', util.num2bytes(0x2DFC9311D490018C7338BF8688861767FF8FF5B2BEBE27548A14B235ECA6874A, size=32)],
['g', util.num2bytes(0x04216936D3CD6E53FEC0A4E231FDD6DC5C692CC7609525A7B2C9562D608F25D51A6666666666666666666666666666666666666666666666666666666666666658, size=65)],
['n', util.num2bytes(0x1000000000000000000000000000000014DEF9DEA2F79CD65812631A5CF5D3ED, size=32)],
['q', vk.to_bytes()],
])
|
module function_definition identifier parameters identifier block return_statement call identifier argument_list list list string string_start string_content string_end call attribute identifier identifier argument_list integer keyword_argument identifier integer list string string_start string_content string_end string string_start string_content escape_sequence string_end list string string_start string_content string_end call attribute identifier identifier argument_list integer keyword_argument identifier integer list string string_start string_content string_end call attribute identifier identifier argument_list integer keyword_argument identifier integer list string string_start string_content string_end call attribute identifier identifier argument_list integer keyword_argument identifier integer list string string_start string_content string_end call attribute identifier identifier argument_list
|
Compute keygrip for Ed25519 public keys.
|
def _loop_thread_main(self):
asyncio.set_event_loop(self.loop)
self._loop_check.inside_loop = True
try:
self._logger.debug("Starting loop in background thread")
self.loop.run_forever()
self._logger.debug("Finished loop in background thread")
except:
self._logger.exception("Exception raised from event loop thread")
finally:
self.loop.close()
|
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute attribute identifier identifier identifier true try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end except_clause block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end finally_clause block expression_statement call attribute attribute identifier identifier identifier argument_list
|
Main background thread running the event loop.
|
def cluster_add_slots(self, slot, *slots):
slots = (slot,) + slots
if not all(isinstance(s, int) for s in slots):
raise TypeError("All parameters must be of type int")
fut = self.execute(b'CLUSTER', b'ADDSLOTS', *slots)
return wait_ok(fut)
|
module function_definition identifier parameters identifier identifier list_splat_pattern identifier block expression_statement assignment identifier binary_operator tuple identifier identifier if_statement not_operator call identifier generator_expression call identifier argument_list identifier identifier for_in_clause identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end list_splat identifier return_statement call identifier argument_list identifier
|
Assign new hash slots to receiving node.
|
def format_cell(val, round_floats = False, decimal_places = 2, format_links = False,
hlx = '', hxl = '', xhl = ''):
if round_floats:
val = smart_round(val, decimal_places = decimal_places)
if format_links:
val = format_hyperlink(val, hlx, hxl, xhl)
return val
|
module function_definition identifier parameters identifier default_parameter identifier false default_parameter identifier integer default_parameter identifier false 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 if_statement identifier block expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier if_statement identifier block expression_statement assignment identifier call identifier argument_list identifier identifier identifier identifier return_statement identifier
|
Applys smart_round and format_hyperlink to values in a cell if desired.
|
def deferred_emails():
status = SERVER_STATUS['OK']
count = Message.objects.deferred().count()
if DEFERRED_WARNING_THRESHOLD <= count < DEFERRED_DANGER_THRESHOLD:
status = SERVER_STATUS['WARNING']
if count >= DEFERRED_DANGER_THRESHOLD:
status = SERVER_STATUS['DANGER']
return {
'label': 'Deferred Email',
'status': status,
'info': 'There are currently {0} deferred messages.'.format(count)
}
|
module function_definition identifier parameters block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list if_statement comparison_operator identifier identifier identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end if_statement comparison_operator identifier identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end return_statement dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end identifier pair string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list identifier
|
Checks for deferred email, that otherwise fill up the queue.
|
def get(self, item):
if item in self:
item = getattr(self, item)
return item()
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier return_statement call identifier argument_list
|
Helper method to avoid calling getattr
|
def commit(self, offset=None, limit=None, dryrun=False):
self.stream.command = "rsync -avRK --files-from={path} {source} {destination}"
self.stream.append_tasks_to_streamlets(offset=offset, limit=limit)
self.stream.commit_streamlets()
self.stream.run_streamlets()
self.stream.reset_streamlet()
|
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier false block expression_statement assignment attribute attribute identifier identifier identifier string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier 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
|
Start the rsync download
|
def list_autoscaling_group(region, filter_by_kwargs):
conn = boto.ec2.autoscale.connect_to_region(region)
groups = conn.get_all_groups()
return lookup(groups, filter_by=filter_by_kwargs)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list return_statement call identifier argument_list identifier keyword_argument identifier identifier
|
List all Auto Scaling Groups.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.