code stringlengths 51 2.34k | sequence stringlengths 186 3.94k | docstring stringlengths 11 171 |
|---|---|---|
def update_misc(uid, **kwargs):
if 'rating' in kwargs:
MPost.__update_rating(uid, kwargs['rating'])
elif 'kind' in kwargs:
MPost.__update_kind(uid, kwargs['kind'])
elif 'keywords' in kwargs:
MPost.__update_keywords(uid, kwargs['keywords'])
elif 'count' in kwargs:
MPost.__update_view_count(uid) | module function_definition identifier parameters identifier dictionary_splat_pattern identifier block if_statement comparison_operator string string_start string_content string_end identifier block expression_statement call attribute identifier identifier argument_list identifier subscript identifier string string_start string_content string_end elif_clause comparison_operator string string_start string_content string_end identifier block expression_statement call attribute identifier identifier argument_list identifier subscript identifier string string_start string_content string_end elif_clause comparison_operator string string_start string_content string_end identifier block expression_statement call attribute identifier identifier argument_list identifier subscript identifier string string_start string_content string_end elif_clause comparison_operator string string_start string_content string_end identifier block expression_statement call attribute identifier identifier argument_list identifier | update rating, kind, or count |
def from_path(cls, path):
f = GitFile(path, 'rb')
try:
ret = cls.from_file(f)
ret.path = path
return ret
finally:
f.close() | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier return_statement identifier finally_clause block expression_statement call attribute identifier identifier argument_list | Read configuration from a file on disk. |
def bwrite(stream, obj):
handle = None
if not hasattr(stream, "write"):
stream = handle = open(stream, "wb")
try:
stream.write(bencode(obj))
finally:
if handle:
handle.close() | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier none if_statement not_operator call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier assignment identifier call identifier argument_list identifier string string_start string_content string_end try_statement block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier finally_clause block if_statement identifier block expression_statement call attribute identifier identifier argument_list | Encode a given object to a file or stream. |
def update(self, path):
self._reset()
self.path = path
self._refresh_synced()
if self.is_synced:
self._refresh_path()
self._refresh_signed()
self._refresh_nvr() | module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list | Update the attributes of this CartItem. |
def scope(cls, f):
if not hasattr(cls, "scopes"):
cls.scopes = copy(STANDARD_SCOPES)
cls.scopes.append(f)
def create_builder(self, *args, **kwargs):
bldr = ScopeBuilder(cls, cls.scopes)
return getattr(bldr, f.__name__)(*args, **kwargs)
setattr(cls, f.__name__, classmethod(create_builder))
return f | module function_definition identifier parameters identifier 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 call identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list identifier attribute identifier identifier return_statement call call identifier argument_list identifier attribute identifier identifier argument_list list_splat identifier dictionary_splat identifier expression_statement call identifier argument_list identifier attribute identifier identifier call identifier argument_list identifier return_statement identifier | Decorator which can dynamically attach a query scope to the model. |
def _parse_datetime_default_value(property_name, default_value_string):
parsed_value = time.strptime(default_value_string, ORIENTDB_DATETIME_FORMAT)
return datetime.datetime(
parsed_value.tm_year, parsed_value.tm_mon, parsed_value.tm_mday,
parsed_value.tm_hour, parsed_value.tm_min, parsed_value.tm_sec, 0, None) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier return_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier integer none | Parse and return the default value for a datetime property. |
async def flexible_api_handler(service, action_type, payload, props, **kwds):
if action_type == intialize_service_action():
model = json.loads(payload) if isinstance(payload, str) else payload
models = service._external_service_data['models']
connections = service._external_service_data['connections']
mutations = service._external_service_data['mutations']
if 'connection' in model:
if not [conn for conn in connections if conn['name'] == model['name']]:
connections.append(model)
elif 'fields' in model and not [mod for mod in models if mod['name'] == model['name']]:
models.append(model)
if 'mutations' in model:
for mutation in model['mutations']:
if not [mut for mut in mutations if mut['name'] == mutation['name']]:
mutations.append(mutation)
if models:
service.schema = generate_api_schema(
models=models,
connections=connections,
mutations=mutations,
) | module function_definition identifier parameters identifier identifier identifier identifier dictionary_splat_pattern identifier block if_statement comparison_operator identifier call identifier argument_list block expression_statement assignment identifier conditional_expression call attribute identifier identifier argument_list identifier call identifier argument_list identifier identifier identifier expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block if_statement not_operator list_comprehension identifier for_in_clause identifier identifier if_clause comparison_operator subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier elif_clause boolean_operator comparison_operator string string_start string_content string_end identifier not_operator list_comprehension identifier for_in_clause identifier identifier if_clause comparison_operator subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator string string_start string_content string_end identifier block for_statement identifier subscript identifier string string_start string_content string_end block if_statement not_operator list_comprehension identifier for_in_clause identifier identifier if_clause comparison_operator subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement assignment attribute identifier identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier | This query handler builds the dynamic picture of availible services. |
def split_css_classes(css_classes):
classes_list = text_value(css_classes).split(" ")
return [c for c in classes_list if c] | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute call identifier argument_list identifier identifier argument_list string string_start string_content string_end return_statement list_comprehension identifier for_in_clause identifier identifier if_clause identifier | Turn string into a list of CSS classes |
def _main():
usage = "usage: %prog [options] cmd [arg] ..."
optprs = OptionParser(usage=usage, version=version)
optprs.add_option("--debug", dest="debug", default=False,
action="store_true",
help="Enter the pdb debugger on main()")
optprs.add_option("--host", dest="host", metavar="HOST",
default="localhost", help="Connect to server at HOST")
optprs.add_option("--port", dest="port", type="int",
default=9000, metavar="PORT",
help="Connect to server at PORT")
optprs.add_option("--profile", dest="profile", action="store_true",
default=False,
help="Run the profiler on main()")
(options, args) = optprs.parse_args(sys.argv[1:])
if options.debug:
import pdb
pdb.run('main(options, args)')
elif options.profile:
import profile
print("%s profile:" % sys.argv[0])
profile.run('main(options, args)')
else:
main(options, args) | module function_definition identifier parameters block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier false keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier integer keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier false keyword_argument identifier string string_start string_content string_end expression_statement assignment tuple_pattern identifier identifier call attribute identifier identifier argument_list subscript attribute identifier identifier slice integer if_statement attribute identifier identifier block import_statement dotted_name identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end elif_clause attribute identifier identifier block import_statement dotted_name identifier expression_statement call identifier argument_list binary_operator string string_start string_content string_end subscript attribute identifier identifier integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end else_clause block expression_statement call identifier argument_list identifier identifier | Run from command line. |
def changed_action(mapper, connection, target):
action_history = get_history(target, 'action')
argument_history = get_history(target, 'argument')
owner_history = get_history(
target,
'user' if isinstance(target, ActionUsers) else
'role' if isinstance(target, ActionRoles) else 'role_name')
if action_history.has_changes() or argument_history.has_changes() \
or owner_history.has_changes():
current_access.delete_action_cache(
get_action_cache_key(target.action, target.argument))
current_access.delete_action_cache(
get_action_cache_key(
action_history.deleted[0] if action_history.deleted
else target.action,
argument_history.deleted[0] if argument_history.deleted
else target.argument)
) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier conditional_expression string string_start string_content string_end call identifier argument_list identifier identifier conditional_expression string string_start string_content string_end call identifier argument_list identifier identifier string string_start string_content string_end if_statement boolean_operator boolean_operator call attribute identifier identifier argument_list call attribute identifier identifier argument_list line_continuation call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list call identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list conditional_expression subscript attribute identifier identifier integer attribute identifier identifier attribute identifier identifier conditional_expression subscript attribute identifier identifier integer attribute identifier identifier attribute identifier identifier | Remove the action from cache when an item is updated. |
def simplify_scalar(self, func=sympy.simplify):
def element_simplify(v):
if isinstance(v, sympy.Basic):
return func(v)
elif isinstance(v, QuantumExpression):
return v.simplify_scalar(func=func)
else:
return v
return self.element_wise(element_simplify) | module function_definition identifier parameters identifier default_parameter identifier attribute identifier identifier block function_definition identifier parameters identifier block if_statement call identifier argument_list identifier attribute identifier identifier block return_statement call identifier argument_list identifier elif_clause call identifier argument_list identifier identifier block return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier else_clause block return_statement identifier return_statement call attribute identifier identifier argument_list identifier | Simplify all scalar expressions appearing in the Matrix. |
def ensure_state(default_getter, exc_class, default_msg=None):
def decorator(getter=default_getter, msg=default_msg):
def ensure_decorator(f):
@wraps(f)
def inner(self, *args, **kwargs):
if not getter(self):
raise exc_class(msg) if msg else exc_class()
return f(self, *args, **kwargs)
return inner
return ensure_decorator
return decorator | module function_definition identifier parameters identifier identifier default_parameter identifier none block function_definition identifier parameters default_parameter identifier identifier default_parameter identifier identifier block function_definition identifier parameters identifier block decorated_definition decorator call identifier argument_list identifier function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block if_statement not_operator call identifier argument_list identifier block raise_statement conditional_expression call identifier argument_list identifier identifier call identifier argument_list return_statement call identifier argument_list identifier list_splat identifier dictionary_splat identifier return_statement identifier return_statement identifier return_statement identifier | Create a decorator factory function. |
def _wait_for_tasks(tasks, service_instance):
log.trace('Waiting for vsan tasks: {0}',
', '.join([six.text_type(t) for t in tasks]))
try:
vsanapiutils.WaitForTasks(tasks, service_instance)
except vim.fault.NoPermission as exc:
log.exception(exc)
raise VMwareApiError('Not enough permissions. Required privilege: '
'{0}'.format(exc.privilegeId))
except vim.fault.VimFault as exc:
log.exception(exc)
raise VMwareApiError(exc.msg)
except vmodl.RuntimeFault as exc:
log.exception(exc)
raise VMwareRuntimeError(exc.msg)
log.trace('Tasks %s finished successfully',
', '.join([six.text_type(t) for t in tasks])) | module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier identifier try_statement block expression_statement call attribute identifier identifier argument_list identifier identifier except_clause as_pattern attribute attribute identifier identifier identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier 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 attribute identifier identifier except_clause as_pattern attribute attribute identifier identifier identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier raise_statement call identifier argument_list attribute identifier identifier except_clause as_pattern attribute identifier identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier raise_statement call identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier identifier | Wait for tasks created via the VSAN API |
def setLevel(self, level):
if isinstance(level, int):
self.logger.setLevel(level)
return
level = level.lower()
if level == "debug":
self.logger.setLevel(logging.DEBUG)
elif level == "info":
self.logger.setLevel(logging.INFO)
elif level == "warning" or level == "warning":
self.logger.setLevel(logging.WARN)
elif level == "error":
self.logger.setLevel(logging.ERROR)
else:
self.logger.setLevel(logging.INFO) | module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier string string_start string_content string_end block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier elif_clause boolean_operator comparison_operator identifier string string_start string_content string_end comparison_operator identifier string string_start string_content string_end block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier | Changement du niveau du Log |
def author_preview_view(self, context):
children_contents = []
fragment = Fragment()
for child_id in self.children:
child = self.runtime.get_block(child_id)
child_fragment = self._render_child_fragment(child, context, 'preview_view')
fragment.add_frag_resources(child_fragment)
children_contents.append(child_fragment.content)
render_context = {
'block': self,
'children_contents': children_contents
}
render_context.update(context)
fragment.add_content(self.loader.render_template(self.CHILD_PREVIEW_TEMPLATE, render_context))
return fragment | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list expression_statement assignment identifier call identifier argument_list for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier 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 attribute identifier identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier return_statement identifier | View for previewing contents in studio. |
def _generate_create_callable(name, display_name, arguments, regex, doc, supported, post_arguments, is_action):
def f(self, *args, **kwargs):
for key, value in args[-1].items():
if type(value) == file:
return self._put_or_post_multipart('POST', self._generate_url(regex, args[:-1]), args[-1])
return self._put_or_post_json('POST', self._generate_url(regex, args[:-1]), args[-1])
if is_action:
f.__name__ = str(name)
else:
f.__name__ = str('create_%s' % name)
f.__doc__ = doc
f._resource_uri = regex
f._get_args = arguments
f._put_or_post_args = post_arguments
f.resource_name = display_name
f.is_api_call = True
f.is_supported_api = supported
return f | module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier identifier block function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block for_statement pattern_list identifier identifier call attribute subscript identifier unary_operator integer identifier argument_list block if_statement comparison_operator call identifier argument_list identifier identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list identifier subscript identifier slice unary_operator integer subscript identifier unary_operator integer return_statement call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list identifier subscript identifier slice unary_operator integer subscript identifier unary_operator integer if_statement identifier block expression_statement assignment attribute identifier identifier call identifier argument_list identifier else_clause block expression_statement assignment attribute identifier identifier call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier true expression_statement assignment attribute identifier identifier identifier return_statement identifier | Returns a callable which conjures the URL for the resource and POSTs data |
def element_contains(self, element_id, value):
elements = ElementSelector(
world.browser,
str('id("{id}")[contains(., "{value}")]'.format(
id=element_id, value=value)),
filter_displayed=True,
)
if not elements:
raise AssertionError("Expected element not found.") | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier call identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier true if_statement not_operator identifier block raise_statement call identifier argument_list string string_start string_content string_end | Assert provided content is contained within an element found by ``id``. |
def _pfp__show(self, level=0, include_offset=False):
res = []
res.append("{}{} {{".format(
"{:04x} ".format(self._pfp__offset) if include_offset else "",
self._pfp__show_name
))
for child in self._pfp__children:
res.append("{}{}{:10s} = {}".format(
" "*(level+1),
"{:04x} ".format(child._pfp__offset) if include_offset else "",
child._pfp__name,
child._pfp__show(level+1, include_offset)
))
res.append("{}}}".format(" "*level))
return "\n".join(res) | module function_definition identifier parameters identifier default_parameter identifier integer default_parameter identifier false block expression_statement assignment identifier list expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list conditional_expression call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier identifier string string_start string_end attribute identifier identifier for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list binary_operator string string_start string_content string_end parenthesized_expression binary_operator identifier integer conditional_expression call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier identifier string string_start string_end attribute identifier identifier call attribute identifier identifier argument_list binary_operator identifier integer identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list binary_operator string string_start string_content string_end identifier return_statement call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier | Show the contents of the struct |
def _structure_tuple(self, obj, tup):
tup_params = tup.__args__
has_ellipsis = tup_params and tup_params[-1] is Ellipsis
if tup_params is None or (has_ellipsis and tup_params[0] is Any):
return tuple(obj)
if has_ellipsis:
tup_type = tup_params[0]
conv = self._structure_func.dispatch(tup_type)
return tuple(conv(e, tup_type) for e in obj)
else:
return tuple(
self._structure_func.dispatch(t)(e, t)
for t, e in zip(tup_params, obj)
) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier boolean_operator identifier comparison_operator subscript identifier unary_operator integer identifier if_statement boolean_operator comparison_operator identifier none parenthesized_expression boolean_operator identifier comparison_operator subscript identifier integer identifier block return_statement call identifier argument_list identifier if_statement identifier block expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier return_statement call identifier generator_expression call identifier argument_list identifier identifier for_in_clause identifier identifier else_clause block return_statement call identifier generator_expression call call attribute attribute identifier identifier identifier argument_list identifier argument_list identifier identifier for_in_clause pattern_list identifier identifier call identifier argument_list identifier identifier | Deal with converting to a tuple. |
def use_plenary_catalog_view(self):
self._catalog_view = PLENARY
for session in self._get_provider_sessions():
try:
session.use_plenary_catalog_view()
except AttributeError:
pass | module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier identifier for_statement identifier call attribute identifier identifier argument_list block try_statement block expression_statement call attribute identifier identifier argument_list except_clause identifier block pass_statement | Pass through to provider CatalogLookupSession.use_plenary_catalog_view |
def create_single(cls, value, idx='default'):
return LabelList(idx=idx, labels=[
Label(value=value)
]) | module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end block return_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier list call identifier argument_list keyword_argument identifier identifier | Create a label-list with a single label containing the given value. |
def _iterate_to_update_x_transforms(self):
self._inner_iters = 0
self._last_inner_error = float('inf')
while self._inner_error_is_decreasing():
print(' Starting inner iteration {0:03d}. Current err = {1:12.5E}'
''.format(self._inner_iters, self._last_inner_error))
self._update_x_transforms()
self._inner_iters += 1 | module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier call identifier argument_list string string_start string_content string_end while_statement call attribute identifier identifier argument_list block expression_statement call identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_end identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement augmented_assignment attribute identifier identifier integer | Perform the inner iteration. |
def drive(self, event, *args):
maps = self.base.get(event, self.step)
for handle, data in maps[:]:
params = args + data
try:
handle(self, *params)
except Stop:
break
except StopIteration:
pass
except Kill as Root:
raise
except Erase:
maps.remove((handle, data))
except Exception as e:
debug(event, params)
for handle in self.pool:
handle(self, event, args) | module function_definition identifier parameters identifier identifier list_splat_pattern identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier attribute identifier identifier for_statement pattern_list identifier identifier subscript identifier slice block expression_statement assignment identifier binary_operator identifier identifier try_statement block expression_statement call identifier argument_list identifier list_splat identifier except_clause identifier block break_statement except_clause identifier block pass_statement except_clause as_pattern identifier as_pattern_target identifier block raise_statement except_clause identifier block expression_statement call attribute identifier identifier argument_list tuple identifier identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call identifier argument_list identifier identifier for_statement identifier attribute identifier identifier block expression_statement call identifier argument_list identifier identifier identifier | Used to dispatch events. |
def _GenerateStopTimesTuples(self):
stoptimes = self.GetStopTimes()
for i, st in enumerate(stoptimes):
yield st.GetFieldValuesTuple(self.trip_id) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement yield call attribute identifier identifier argument_list attribute identifier identifier | Generator for rows of the stop_times file |
def _get_data_from_list_of_dicts(source, fields='*', first_row=0, count=-1, schema=None):
if schema is None:
schema = google.datalab.bigquery.Schema.from_data(source)
fields = get_field_list(fields, schema)
gen = source[first_row:first_row + count] if count >= 0 else source
rows = [{'c': [{'v': row[c]} if c in row else {} for c in fields]} for row in gen]
return {'cols': _get_cols(fields, schema), 'rows': rows}, len(source) | module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end default_parameter identifier integer default_parameter identifier unary_operator integer default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute attribute attribute attribute identifier identifier identifier identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier conditional_expression subscript identifier slice identifier binary_operator identifier identifier comparison_operator identifier integer identifier expression_statement assignment identifier list_comprehension dictionary pair string string_start string_content string_end list_comprehension conditional_expression dictionary pair string string_start string_content string_end subscript identifier identifier comparison_operator identifier identifier dictionary for_in_clause identifier identifier for_in_clause identifier identifier return_statement expression_list dictionary pair string string_start string_content string_end call identifier argument_list identifier identifier pair string string_start string_content string_end identifier call identifier argument_list identifier | Helper function for _get_data that handles lists of dicts. |
def check_important_variables(self):
if len(self.important_variables - set(self.args.keys())):
raise TypeError("Some important variables are not set") | module function_definition identifier parameters identifier block if_statement call identifier argument_list binary_operator attribute identifier identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list block raise_statement call identifier argument_list string string_start string_content string_end | Check all the variables needed are defined |
def hog(concurrency, requests, limit, timeout,
params, paramfile, headers, headerfile, method, url):
params = parse_from_list_and_file(params, paramfile)
headers = parse_from_list_and_file(headers, headerfile)
click.echo(HR)
click.echo("Hog is running with {} threads, ".format(concurrency) +
"{} requests ".format(requests) +
"and timeout in {} second(s).".format(timeout))
if limit != 0:
click.echo(">>> Limit: {} request(s) per second.".format(limit))
click.echo(HR)
result = Hog(callback).run(url, params, headers, method, timeout, concurrency, requests, limit)
sys.stdout.write("\n")
print_result(result) | module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list binary_operator binary_operator call attribute string string_start string_content string_end identifier argument_list identifier call attribute string string_start string_content string_end identifier argument_list identifier call attribute string string_start string_content string_end identifier argument_list identifier if_statement comparison_operator identifier integer block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute call identifier argument_list identifier identifier argument_list identifier identifier identifier identifier identifier identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content escape_sequence string_end expression_statement call identifier argument_list identifier | Sending multiple `HTTP` requests `ON` `GREEN` thread |
def bgseq(code):
if isinstance(code, str):
code = nametonum(code)
if code == -1:
return ""
s = termcap.get('setab', code) or termcap.get('setb', code)
return s | module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier unary_operator integer block return_statement string string_start string_end expression_statement assignment identifier boolean_operator call attribute identifier identifier argument_list string string_start string_content string_end identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement identifier | Returns the background color terminal escape sequence for the given color code number. |
def best_fit(li, value):
index = min(bisect_left(li, value), len(li) - 1)
if index in (0, len(li)):
return index
if li[index] - value < value - li[index-1]:
return index
else:
return index-1 | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier identifier binary_operator call identifier argument_list identifier integer if_statement comparison_operator identifier tuple integer call identifier argument_list identifier block return_statement identifier if_statement comparison_operator binary_operator subscript identifier identifier identifier binary_operator identifier subscript identifier binary_operator identifier integer block return_statement identifier else_clause block return_statement binary_operator identifier integer | For a sorted list li, returns the closest item to value |
def _get_next_buffered_row(self):
if self._iter_row == self._iter_nrows:
raise StopIteration
if self._row_buffer_index >= self._iter_row_buffer:
self._buffer_iter_rows(self._iter_row)
data = self._row_buffer[self._row_buffer_index]
self._iter_row += 1
self._row_buffer_index += 1
return data | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block raise_statement identifier if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier subscript attribute identifier identifier attribute identifier identifier expression_statement augmented_assignment attribute identifier identifier integer expression_statement augmented_assignment attribute identifier identifier integer return_statement identifier | Get the next row for iteration. |
def load_stream(filename):
rawfile = pkg_resources.resource_stream(__name__, filename)
if six.PY2:
return rawfile
return io.TextIOWrapper(rawfile, 'utf-8') | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement attribute identifier identifier block return_statement identifier return_statement call attribute identifier identifier argument_list identifier string string_start string_content string_end | Load a file stream from the package resources. |
def fn_device_dependency(name, device=""):
key = name + "_" + device
outs = []
def body():
with tf.control_dependencies(fn_device_dependency_dict()[key]):
yield outs
assert outs
deps = outs
if isinstance(outs[0], (list, tuple)):
assert len(outs) == 1
deps = outs[0]
fn_device_dependency_dict()[key] = deps
if device:
with tf.device(device):
return body()
else:
return body() | module function_definition identifier parameters identifier default_parameter identifier string string_start string_end block expression_statement assignment identifier binary_operator binary_operator identifier string string_start string_content string_end identifier expression_statement assignment identifier list function_definition identifier parameters block with_statement with_clause with_item call attribute identifier identifier argument_list subscript call identifier argument_list identifier block expression_statement yield identifier assert_statement identifier expression_statement assignment identifier identifier if_statement call identifier argument_list subscript identifier integer tuple identifier identifier block assert_statement comparison_operator call identifier argument_list identifier integer expression_statement assignment identifier subscript identifier integer expression_statement assignment subscript call identifier argument_list identifier identifier if_statement identifier block with_statement with_clause with_item call attribute identifier identifier argument_list identifier block return_statement call identifier argument_list else_clause block return_statement call identifier argument_list | Add control deps for name and device. |
def substrate_a(self, **kwargs):
if self.substrate is not None:
return self.substrate.a(**kwargs)
else:
return (self.unstrained.a(**kwargs) /
(1. - self.strain_in_plane(**kwargs))) | module function_definition identifier parameters identifier dictionary_splat_pattern identifier block if_statement comparison_operator attribute identifier identifier none block return_statement call attribute attribute identifier identifier identifier argument_list dictionary_splat identifier else_clause block return_statement parenthesized_expression binary_operator call attribute attribute identifier identifier identifier argument_list dictionary_splat identifier parenthesized_expression binary_operator float call attribute identifier identifier argument_list dictionary_splat identifier | Returns the substrate's lattice parameter. |
def _execute(self, worker):
self._assert_status_is(TaskStatus.RUNNING)
operation = worker.look_up(self.operation)
operation.invoke(self, [], worker=worker) | module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier list keyword_argument identifier identifier | This method is ASSIGNED during the evaluation to control how to resume it once it has been paused |
def prepare_infrastructure():
runner = ForemastRunner()
runner.write_configs()
runner.create_app()
archaius = runner.configs[runner.env]['app']['archaius_enabled']
eureka = runner.configs[runner.env]['app']['eureka_enabled']
deploy_type = runner.configs['pipeline']['type']
if deploy_type not in ['s3', 'datapipeline']:
runner.create_iam()
if archaius:
runner.create_archaius()
runner.create_secgroups()
if eureka:
LOG.info("Eureka Enabled, skipping ELB and DNS setup")
elif deploy_type == "lambda":
LOG.info("Lambda Enabled, skipping ELB and DNS setup")
runner.create_awslambda()
elif deploy_type == "s3":
runner.create_s3app()
elif deploy_type == 'datapipeline':
runner.create_datapipeline()
else:
LOG.info("No Eureka, running ELB and DNS setup")
runner.create_elb()
runner.create_dns()
runner.slack_notify()
runner.cleanup() | module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier subscript subscript subscript attribute identifier identifier attribute identifier identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier subscript subscript subscript attribute identifier identifier attribute identifier identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end if_statement comparison_operator identifier list string string_start string_content string_end string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list if_statement identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list if_statement identifier block expression_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 call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list | Entry point for preparing the infrastructure in a specific env. |
def read_geo(fid, key):
dsid = GEO_NAMES[key.name]
add_epoch = False
if "time" in key.name:
days = fid["/L1C/" + dsid["day"]].value
msecs = fid["/L1C/" + dsid["msec"]].value
data = _form_datetimes(days, msecs)
add_epoch = True
dtype = np.float64
else:
data = fid["/L1C/" + dsid].value
dtype = np.float32
data = xr.DataArray(da.from_array(data, chunks=CHUNK_SIZE),
name=key.name, dims=['y', 'x']).astype(dtype)
if add_epoch:
data.attrs['sensing_time_epoch'] = EPOCH
return data | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript identifier attribute identifier identifier expression_statement assignment identifier false if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement assignment identifier attribute subscript identifier binary_operator string string_start string_content string_end subscript identifier string string_start string_content string_end identifier expression_statement assignment identifier attribute subscript identifier binary_operator string string_start string_content string_end subscript identifier string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier true expression_statement assignment identifier attribute identifier identifier else_clause block expression_statement assignment identifier attribute subscript identifier binary_operator string string_start string_content string_end identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier list string string_start string_content string_end string string_start string_content string_end identifier argument_list identifier if_statement identifier block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end identifier return_statement identifier | Read geolocation and related datasets. |
def make(parser):
mgr_parser = parser.add_subparsers(dest='subcommand')
mgr_parser.required = True
mgr_create = mgr_parser.add_parser(
'create',
help='Deploy Ceph MGR on remote host(s)'
)
mgr_create.add_argument(
'mgr',
metavar='HOST[:NAME]',
nargs='+',
type=colon_separated,
help='host (and optionally the daemon name) to deploy on',
)
parser.set_defaults(
func=mgr,
) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier true expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier | Ceph MGR daemon management |
def loads(inputStr):
inCat = json.loads(inputStr)
assert CATALOGUE_TYPE in _values(inCat[CATALOGUE_METADATA], ISCONTENTTYPE_RELATION)
desc = _values(inCat[CATALOGUE_METADATA], DESCRIPTION_RELATION)[0]
outCat = Hypercat(desc)
for i in inCat[ITEMS]:
href = i[HREF]
contentType = _values(i[ITEM_METADATA], ISCONTENTTYPE_RELATION) [0]
desc = _values(i[ITEM_METADATA], DESCRIPTION_RELATION) [0]
if contentType == CATALOGUE_TYPE:
r = Hypercat(desc)
else:
r = Resource(desc, contentType)
outCat.addItem(r, href)
return outCat | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier assert_statement comparison_operator identifier call identifier argument_list subscript identifier identifier identifier expression_statement assignment identifier subscript call identifier argument_list subscript identifier identifier identifier integer expression_statement assignment identifier call identifier argument_list identifier for_statement identifier subscript identifier identifier block expression_statement assignment identifier subscript identifier identifier expression_statement assignment identifier subscript call identifier argument_list subscript identifier identifier identifier integer expression_statement assignment identifier subscript call identifier argument_list subscript identifier identifier identifier integer if_statement comparison_operator identifier identifier block expression_statement assignment identifier call identifier argument_list identifier else_clause block expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier return_statement identifier | Takes a string and converts it into an internal hypercat object, with some checking |
def generate(self, name: str, **kwargs):
path = self.urlmapper.generate(name, **kwargs)
return self.make_full_qualified_url(path) | module function_definition identifier parameters identifier typed_parameter identifier type identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier dictionary_splat identifier return_statement call attribute identifier identifier argument_list identifier | generate full qualified url for named url pattern with kwargs |
def chain(request):
bars = foobar_models.Bar.objects.all()
bazs = foobar_models.Baz.objects.all()
qsc = XmlQuerySetChain(bars, bazs)
return HttpResponse(tree.xml(qsc), mimetype='text/xml') | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier identifier return_statement call identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end | shows how the XmlQuerySetChain can be used instead of @toxml decorator |
def __select_autocomplete_identities(self, sources):
MIN_PRIORITY = 99999999
checked = {}
for source in sources:
uids = api.unique_identities(self.db, source=source)
for uid in uids:
if uid.uuid in checked:
continue
max_priority = MIN_PRIORITY
selected = []
for identity in sorted(uid.identities, key=lambda x: x.id):
try:
priority = sources.index(identity.source)
if priority < max_priority:
selected = [identity]
max_priority = priority
elif priority == max_priority:
selected.append(identity)
except ValueError:
continue
checked[uid.uuid] = selected
identities = collections.OrderedDict(sorted(checked.items(),
key=lambda t: t[0]))
return identities | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier integer expression_statement assignment identifier dictionary for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier identifier for_statement identifier identifier block if_statement comparison_operator attribute identifier identifier identifier block continue_statement expression_statement assignment identifier identifier expression_statement assignment identifier list for_statement identifier call identifier argument_list attribute identifier identifier keyword_argument identifier lambda lambda_parameters identifier attribute identifier identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier if_statement comparison_operator identifier identifier block expression_statement assignment identifier list identifier expression_statement assignment identifier identifier elif_clause comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier except_clause identifier block continue_statement expression_statement assignment subscript identifier attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier lambda lambda_parameters identifier subscript identifier integer return_statement identifier | Select the identities used for autocompleting |
def write_forward_run(self):
with open(os.path.join(self.m.model_ws,self.forward_run_file),'w') as f:
f.write("import os\nimport numpy as np\nimport pandas as pd\nimport flopy\n")
f.write("import pyemu\n")
for ex_imp in self.extra_forward_imports:
f.write('import {0}\n'.format(ex_imp))
for tmp_file in self.tmp_files:
f.write("try:\n")
f.write(" os.remove('{0}')\n".format(tmp_file))
f.write("except Exception as e:\n")
f.write(" print('error removing tmp file:{0}')\n".format(tmp_file))
for line in self.frun_pre_lines:
f.write(line+'\n')
for line in self.frun_model_lines:
f.write(line+'\n')
for line in self.frun_post_lines:
f.write(line+'\n') | module function_definition identifier parameters identifier block with_statement with_clause with_item as_pattern call identifier argument_list call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier attribute identifier identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence escape_sequence escape_sequence escape_sequence string_end expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator identifier string string_start string_content escape_sequence string_end for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator identifier string string_start string_content escape_sequence string_end for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator identifier string string_start string_content escape_sequence string_end | write the forward run script forward_run.py |
def add_dicts(d1, d2):
if d1 is None:
return d2
if d2 is None:
return d1
keys = set(d1)
keys.update(set(d2))
ret = {}
for key in keys:
v1 = d1.get(key)
v2 = d2.get(key)
if v1 is None:
ret[key] = v2
elif v2 is None:
ret[key] = v1
else:
ret[key] = v1 + v2
return ret | module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier none block return_statement identifier if_statement comparison_operator identifier none block return_statement identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier expression_statement assignment identifier dictionary for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement assignment subscript identifier identifier identifier elif_clause comparison_operator identifier none block expression_statement assignment subscript identifier identifier identifier else_clause block expression_statement assignment subscript identifier identifier binary_operator identifier identifier return_statement identifier | Merge two dicts of addable values |
def add_barplot(self):
cats = OrderedDict()
cats['n_nondups'] = {'name': 'Non-duplicates'}
cats['n_dups'] = {'name': 'Duplicates'}
pconfig = {
'id': 'samblaster_duplicates',
'title': 'Samblaster: Number of duplicate reads',
'ylab': 'Number of reads'
}
self.add_section( plot = bargraph.plot(self.samblaster_data, cats, pconfig) ) | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end dictionary pair string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end dictionary pair string string_start string_content string_end 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 pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list attribute identifier identifier identifier identifier | Generate the Samblaster bar plot. |
def _get_struct_shape(self):
obj = _make_object("Shape")
bc = BitConsumer(self._src)
obj.NumFillBits = n_fill_bits = bc.u_get(4)
obj.NumLineBits = n_line_bits = bc.u_get(4)
obj.ShapeRecords = self._get_shaperecords(
n_fill_bits, n_line_bits, 0)
return obj | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier assignment identifier call attribute identifier identifier argument_list integer expression_statement assignment attribute identifier identifier assignment identifier call attribute identifier identifier argument_list integer expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier identifier integer return_statement identifier | Get the values for the SHAPE record. |
def sample_lonlat(self, n):
radius = self.sample_radius(n)
a = radius; b = self.jacobian * radius
t = 2. * np.pi * np.random.rand(n)
cost,sint = np.cos(t),np.sin(t)
phi = np.pi/2. - np.deg2rad(self.theta)
cosphi,sinphi = np.cos(phi),np.sin(phi)
x = a*cost*cosphi - b*sint*sinphi
y = a*cost*sinphi + b*sint*cosphi
if self.projector is None:
logger.debug("Creating AITOFF projector for sampling")
projector = Projector(self.lon,self.lat,'ait')
else:
projector = self.projector
lon, lat = projector.imageToSphere(x, y)
return lon, lat | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier identifier expression_statement assignment identifier binary_operator attribute identifier identifier identifier expression_statement assignment identifier binary_operator binary_operator float attribute identifier identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment pattern_list identifier identifier expression_list call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator binary_operator attribute identifier identifier float call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment pattern_list identifier identifier expression_list call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator binary_operator binary_operator identifier identifier identifier binary_operator binary_operator identifier identifier identifier expression_statement assignment identifier binary_operator binary_operator binary_operator identifier identifier identifier binary_operator binary_operator identifier identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list attribute identifier identifier attribute identifier identifier string string_start string_content string_end else_clause block expression_statement assignment identifier attribute identifier identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier identifier return_statement expression_list identifier identifier | Sample 2D distribution of points in lon, lat |
def add_caption(self, image, caption, colour=None):
if colour is None:
colour = "white"
width, height = image.size
draw = ImageDraw.Draw(image)
draw.font = self.font
draw.font = self.font
draw.text((width // 10, height//20), caption,
fill=colour)
return image | module function_definition identifier parameters identifier identifier identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment pattern_list identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list tuple binary_operator identifier integer binary_operator identifier integer identifier keyword_argument identifier identifier return_statement identifier | Add a caption to the image |
def major(self):
url = self._subfeed("major")
if "major" in self.url or "minor" in self.url:
return self
if self._major is None:
self._major = self.__class__(url, pypump=self._pump)
return self._major | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement boolean_operator comparison_operator string string_start string_content string_end attribute identifier identifier comparison_operator string string_start string_content string_end attribute identifier identifier block return_statement identifier if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier return_statement attribute identifier identifier | Major inbox feed, contains major activities such as notes and images. |
def add_behave_arguments(parser):
conflicts = [
'--no-color',
'--version',
'-c',
'-k',
'-v',
'-S',
'--simple',
]
parser.add_argument(
'paths',
action='store',
nargs='*',
help="Feature directory, file or file location (FILE:LINE)."
)
for fixed, keywords in behave_options:
keywords = keywords.copy()
if not fixed:
continue
option_strings = []
for option in fixed:
if option in conflicts:
prefix = '--' if option.startswith('--') else '-'
option = option.replace(prefix, '--behave-', 1)
option_strings.append(option)
if 'config_help' in keywords:
keywords['help'] = keywords['config_help']
del keywords['config_help']
parser.add_argument(*option_strings, **keywords) | module function_definition identifier parameters identifier block 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 expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end for_statement pattern_list identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement not_operator identifier block continue_statement expression_statement assignment identifier list for_statement identifier identifier block if_statement comparison_operator identifier identifier block expression_statement assignment identifier conditional_expression string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end integer expression_statement call attribute identifier identifier argument_list identifier 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 subscript identifier string string_start string_content string_end delete_statement subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list list_splat identifier dictionary_splat identifier | Additional command line arguments extracted directly from behave |
def login(self):
self._username = input("Username:")
self._password = getpass.getpass("Password:")
if self.get_auth_token():
_LOGGER.debug("Login successful!")
return True
_LOGGER.warning("Unable to login with %s.", self._username)
return False | module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement true expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier return_statement false | Prompt user for username and password. |
def calibrate_refl(array, attributes, index):
offset = np.float32(attributes["reflectance_offsets"][index])
scale = np.float32(attributes["reflectance_scales"][index])
array = (array - offset) * scale * 100
return array | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list subscript subscript identifier string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list subscript subscript identifier string string_start string_content string_end identifier expression_statement assignment identifier binary_operator binary_operator parenthesized_expression binary_operator identifier identifier identifier integer return_statement identifier | Calibration for reflective channels. |
def gen_decode(iterable):
"A generator for de-unsynchronizing a byte iterable."
sync = False
for b in iterable:
if sync and b & 0xE0:
warn("Invalid unsynched data", Warning)
if not (sync and b == 0x00):
yield b
sync = (b == 0xFF) | module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier false for_statement identifier identifier block if_statement boolean_operator identifier binary_operator identifier integer block expression_statement call identifier argument_list string string_start string_content string_end identifier if_statement not_operator parenthesized_expression boolean_operator identifier comparison_operator identifier integer block expression_statement yield identifier expression_statement assignment identifier parenthesized_expression comparison_operator identifier integer | A generator for de-unsynchronizing a byte iterable. |
def setNumWorkers(self, num_workers):
cur_num = len(self.workers)
if cur_num > num_workers:
self.dismissWorkers(cur_num - num_workers)
else:
self.createWorkers(num_workers - cur_num) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list binary_operator identifier identifier | Set number of worker threads to num_workers |
def dtstr_to_datetime(dtstr, to_tz=None, fail_silently=True):
try:
dt = datetime.datetime.utcfromtimestamp(int(dtstr, 36) / 1e3)
if to_tz:
dt = timezone.make_aware(dt, timezone=pytz.UTC)
if to_tz != pytz.UTC:
dt = dt.astimezone(to_tz)
return dt
except ValueError, e:
if not fail_silently:
raise e
return None | module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier true block try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list binary_operator call identifier argument_list identifier integer float if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement identifier except_clause identifier identifier block if_statement not_operator identifier block raise_statement identifier return_statement none | Convert result from datetime_to_dtstr to datetime in timezone UTC0. |
def addVariantSearchOptions(parser):
addVariantSetIdArgument(parser)
addReferenceNameArgument(parser)
addCallSetIdsArgument(parser)
addStartArgument(parser)
addEndArgument(parser)
addPageSizeArgument(parser) | module function_definition identifier parameters identifier block expression_statement call identifier argument_list identifier expression_statement call identifier argument_list identifier expression_statement call identifier argument_list identifier expression_statement call identifier argument_list identifier expression_statement call identifier argument_list identifier expression_statement call identifier argument_list identifier | Adds common options to a variant searches command line parser. |
def public_copy(self):
return self.__class__(
chain_code=self.chain_code,
depth=self.depth,
parent_fingerprint=self.parent_fingerprint,
child_number=self.child_number,
public_pair=self.public_key.to_public_pair(),
network=self.network) | module function_definition identifier parameters identifier block return_statement call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier | Clone this wallet and strip it of its private information. |
def _replace_variables(data, variables):
formatter = string.Formatter()
return [formatter.vformat(item, [], variables) for item in data] | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list return_statement list_comprehension call attribute identifier identifier argument_list identifier list identifier for_in_clause identifier identifier | Replace the format variables in all items of data. |
def to_raw_address(addr, section):
return addr - section.header.VirtualAddress + section.header.PointerToRawData | module function_definition identifier parameters identifier identifier block return_statement binary_operator binary_operator identifier attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier | Converts the addr from a rva to a pointer to raw data in the file |
def calculate_category_probability(self):
total_tally = 0.0
probs = {}
for category, bayes_category in \
self.categories.get_categories().items():
count = bayes_category.get_tally()
total_tally += count
probs[category] = count
for category, count in probs.items():
if total_tally > 0:
probs[category] = float(count)/float(total_tally)
else:
probs[category] = 0.0
for category, probability in probs.items():
self.probabilities[category] = {
'prc': probability,
'prnc': sum(probs.values()) - probability
} | module function_definition identifier parameters identifier block expression_statement assignment identifier float expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier line_continuation call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement augmented_assignment identifier identifier expression_statement assignment subscript identifier identifier identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement comparison_operator identifier integer block expression_statement assignment subscript identifier identifier binary_operator call identifier argument_list identifier call identifier argument_list identifier else_clause block expression_statement assignment subscript identifier identifier float for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment subscript attribute identifier identifier identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end binary_operator call identifier argument_list call attribute identifier identifier argument_list identifier | Caches the individual probabilities for each category |
def Parse(self, stat, file_object, knowledge_base):
_, _ = stat, knowledge_base
packages = []
sw_data = utils.ReadFileBytesAsUnicode(file_object)
try:
for pkg in self._deb822.Packages.iter_paragraphs(sw_data.splitlines()):
if self.installed_re.match(pkg["Status"]):
packages.append(
rdf_client.SoftwarePackage(
name=pkg["Package"],
description=pkg["Description"],
version=pkg["Version"],
architecture=pkg["Architecture"],
publisher=pkg["Maintainer"],
install_state="INSTALLED"))
except SystemError:
yield rdf_anomaly.Anomaly(
type="PARSER_ANOMALY", symptom="Invalid dpkg status file")
finally:
if packages:
yield rdf_client.SoftwarePackages(packages=packages) | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment pattern_list identifier identifier expression_list identifier identifier expression_statement assignment identifier list expression_statement assignment identifier call attribute identifier identifier argument_list identifier try_statement block for_statement identifier call attribute attribute attribute identifier identifier identifier identifier argument_list call attribute identifier identifier argument_list block if_statement call attribute attribute identifier identifier identifier argument_list subscript identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end except_clause identifier block expression_statement yield call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end finally_clause block if_statement identifier block expression_statement yield call attribute identifier identifier argument_list keyword_argument identifier identifier | Parse the status file. |
def _check_inference(self, inference):
if inference=='GP2KronSum':
assert self.n_randEffs==2, 'VarianceDecomposition: for fast inference number of random effect terms must be == 2'
assert not sp.isnan(self.Y).any(), 'VarianceDecomposition: fast inference available only for complete phenotype designs' | module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier string string_start string_content string_end block assert_statement comparison_operator attribute identifier identifier integer string string_start string_content string_end assert_statement not_operator call attribute call attribute identifier identifier argument_list attribute identifier identifier identifier argument_list string string_start string_content string_end | Internal method for checking that the selected inference scheme is compatible with the specified model |
def unpack_ip_addr(addr):
if isinstance(addr, bytearray):
addr = bytes(addr)
return (socket.inet_ntoa(addr[0:4]), struct.unpack('!H', addr[4:6])[0]) | module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier return_statement tuple call attribute identifier identifier argument_list subscript identifier slice integer integer subscript call attribute identifier identifier argument_list string string_start string_content string_end subscript identifier slice integer integer integer | Given a six-octet BACnet address, return an IP address tuple. |
def diskwarp_multi_fn(src_fn_list, res='first', extent='intersection', t_srs='first', r='cubic', verbose=True, outdir=None, dst_ndv=None):
if not iolib.fn_list_check(src_fn_list):
sys.exit('Missing input file(s)')
src_ds_list = [gdal.Open(fn, gdal.GA_ReadOnly) for fn in src_fn_list]
return diskwarp_multi(src_ds_list, res, extent, t_srs, r, verbose=verbose, outdir=outdir, dst_ndv=dst_ndv) | module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_content string_end default_parameter identifier true default_parameter identifier none default_parameter identifier none block if_statement not_operator call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list identifier attribute identifier identifier for_in_clause identifier identifier return_statement call identifier argument_list identifier identifier identifier identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier | Helper function for diskwarp of multiple input filenames |
def process_python_symbol_data(oedata):
symbol_list = []
for key in oedata:
val = oedata[key]
if val and key != 'found_cell_separators':
if val.is_class_or_function():
symbol_list.append((key, val.def_name, val.fold_level,
val.get_token()))
return sorted(symbol_list) | module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier subscript identifier identifier if_statement boolean_operator identifier comparison_operator identifier string string_start string_content string_end block if_statement call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list tuple identifier attribute identifier identifier attribute identifier identifier call attribute identifier identifier argument_list return_statement call identifier argument_list identifier | Returns a list with line number, definition name, fold and token. |
def import_data(self, fname):
if self.count():
nsb = self.current_widget()
nsb.refresh_table()
nsb.import_data(filenames=fname)
if self.dockwidget and not self.ismaximized:
self.dockwidget.setVisible(True)
self.dockwidget.raise_() | module function_definition identifier parameters identifier identifier block if_statement call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier if_statement boolean_operator attribute identifier identifier not_operator attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list true expression_statement call attribute attribute identifier identifier identifier argument_list | Import data in current namespace |
def extern_get_type_for(self, context_handle, val):
c = self._ffi.from_handle(context_handle)
obj = self._ffi.from_handle(val[0])
type_id = c.to_id(type(obj))
return TypeId(type_id) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list subscript identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list identifier return_statement call identifier argument_list identifier | Return a representation of the object's type. |
def tiered_alignment(in_bam, tier_num, multi_mappers, extra_args,
genome_build, pair_stats,
work_dir, dirs, config):
nomap_fq1, nomap_fq2 = select_unaligned_read_pairs(in_bam, "tier{}".format(tier_num),
work_dir, config)
if nomap_fq1 is not None:
base_name = "{}-tier{}out".format(os.path.splitext(os.path.basename(in_bam))[0],
tier_num)
config = copy.deepcopy(config)
dirs = copy.deepcopy(dirs)
config["algorithm"]["bam_sort"] = "queryname"
config["algorithm"]["multiple_mappers"] = multi_mappers
config["algorithm"]["extra_align_args"] = ["-i", int(pair_stats["mean"]),
int(pair_stats["std"])] + extra_args
out_bam, ref_file = align_to_sort_bam(nomap_fq1, nomap_fq2,
lane.rg_names(base_name, base_name, config),
genome_build, "novoalign",
dirs, config,
dir_ext=os.path.join("hydra", os.path.split(nomap_fq1)[0]))
return out_bam
else:
return None | module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier identifier identifier block expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier call attribute string string_start string_content string_end identifier argument_list identifier identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list subscript call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier integer identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment subscript subscript identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript subscript identifier string string_start string_content string_end string string_start string_content string_end identifier expression_statement assignment subscript subscript identifier string string_start string_content string_end string string_start string_content string_end binary_operator list string string_start string_content string_end call identifier argument_list subscript identifier string string_start string_content string_end call identifier argument_list subscript identifier string string_start string_content string_end identifier expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier identifier call attribute identifier identifier argument_list identifier identifier identifier identifier string string_start string_content string_end identifier identifier keyword_argument identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end subscript call attribute attribute identifier identifier identifier argument_list identifier integer return_statement identifier else_clause block return_statement none | Perform the alignment of non-mapped reads from previous tier. |
def _save_group(self, group_id, result):
self.TaskSetModel._default_manager.store_result(group_id, result)
return result | module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier identifier return_statement identifier | Store the result of an executed group. |
def complete(self):
if Part.count(self) != self.last_part_number + 1:
raise MultipartMissingParts()
with db.session.begin_nested():
self.completed = True
self.file.readable = True
self.file.writable = False
return self | module function_definition identifier parameters identifier block if_statement comparison_operator call attribute identifier identifier argument_list identifier binary_operator attribute identifier identifier integer block raise_statement call identifier argument_list with_statement with_clause with_item call attribute attribute identifier identifier identifier argument_list block expression_statement assignment attribute identifier identifier true expression_statement assignment attribute attribute identifier identifier identifier true expression_statement assignment attribute attribute identifier identifier identifier false return_statement identifier | Mark a multipart object as complete. |
def jarSources(target, source, env, for_signature):
try:
env['JARCHDIR']
except KeyError:
jarchdir_set = False
else:
jarchdir_set = True
jarchdir = env.subst('$JARCHDIR', target=target, source=source)
if jarchdir:
jarchdir = env.fs.Dir(jarchdir)
result = []
for src in source:
contents = src.get_text_contents()
if contents[:16] != "Manifest-Version":
if jarchdir_set:
_chdir = jarchdir
else:
try:
_chdir = src.attributes.java_classdir
except AttributeError:
_chdir = None
if _chdir:
src = SCons.Subst.Literal(src.get_path(_chdir))
result.append('-C')
result.append(_chdir)
result.append(src)
return result | module function_definition identifier parameters identifier identifier identifier identifier block try_statement block expression_statement subscript identifier string string_start string_content string_end except_clause identifier block expression_statement assignment identifier false else_clause block expression_statement assignment identifier true expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier if_statement identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator subscript identifier slice integer string string_start string_content string_end block if_statement identifier block expression_statement assignment identifier identifier else_clause block try_statement block expression_statement assignment identifier attribute attribute identifier identifier identifier except_clause identifier block expression_statement assignment identifier none if_statement identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier expression_statement call attribute identifier 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 identifier return_statement identifier | Only include sources that are not a manifest file. |
def watch_source(self, source_id):
source_id = int(source_id)
r = yield from self._send_cmd(
"WATCH S[%d] ON" % (source_id, ))
self._watched_source.add(source_id)
return r | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier yield call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement identifier | Add a souce to the watchlist. |
def with_debug_id(debug_id):
ctx = SpanContext(
trace_id=None, span_id=None, parent_id=None, flags=None
)
ctx._debug_id = debug_id
return ctx | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list keyword_argument identifier none keyword_argument identifier none keyword_argument identifier none keyword_argument identifier none expression_statement assignment attribute identifier identifier identifier return_statement identifier | Deprecated, not used by Jaeger. |
def _build_provider_list():
registry = None
if appsettings.FLUENT_OEMBED_SOURCE == 'basic':
registry = bootstrap_basic()
elif appsettings.FLUENT_OEMBED_SOURCE == 'embedly':
params = {}
if appsettings.MICAWBER_EMBEDLY_KEY:
params['key'] = appsettings.MICAWBER_EMBEDLY_KEY
registry = bootstrap_embedly(**params)
elif appsettings.FLUENT_OEMBED_SOURCE == 'noembed':
registry = bootstrap_noembed(nowrap=1)
elif appsettings.FLUENT_OEMBED_SOURCE == 'list':
registry = ProviderRegistry()
for regex, provider in appsettings.FLUENT_OEMBED_PROVIDER_LIST:
registry.register(regex, Provider(provider))
else:
raise ImproperlyConfigured("Invalid value of FLUENT_OEMBED_SOURCE, only 'basic', 'list', 'noembed' or 'embedly' is supported.")
for regex, provider in appsettings.FLUENT_OEMBED_EXTRA_PROVIDERS:
registry.register(regex, Provider(provider))
return registry | module function_definition identifier parameters block expression_statement assignment identifier none if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier dictionary if_statement attribute identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call identifier argument_list dictionary_splat identifier elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list keyword_argument identifier integer elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list for_statement pattern_list identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier call identifier argument_list identifier else_clause block raise_statement call identifier argument_list string string_start string_content string_end for_statement pattern_list identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier call identifier argument_list identifier return_statement identifier | Construct the provider registry, using the app settings. |
def _check_release_done_processing(release):
if release.status != models.Release.PROCESSING:
logging.info('Release not in processing state yet: build_id=%r, '
'name=%r, number=%d', release.build_id, release.name,
release.number)
return False
query = models.Run.query.filter_by(release_id=release.id)
for run in query:
if run.status == models.Run.NEEDS_DIFF:
return False
if run.ref_config and not run.ref_image:
return False
if run.config and not run.image:
return False
logging.info('Release done processing, now reviewing: build_id=%r, '
'name=%r, number=%d', release.build_id, release.name,
release.number)
build_id = release.build_id
release_name = release.name
release_number = release.number
@utils.after_this_request
def send_notification_email(response):
emails.send_ready_for_review(build_id, release_name, release_number)
release.status = models.Release.REVIEWING
db.session.add(release)
return True | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier attribute attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end attribute identifier identifier attribute identifier identifier attribute identifier identifier return_statement false expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier for_statement identifier identifier block if_statement comparison_operator attribute identifier identifier attribute attribute identifier identifier identifier block return_statement false if_statement boolean_operator attribute identifier identifier not_operator attribute identifier identifier block return_statement false if_statement boolean_operator attribute identifier identifier not_operator attribute identifier identifier block return_statement false expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier decorated_definition decorator attribute identifier identifier function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list identifier identifier identifier expression_statement assignment attribute identifier identifier attribute attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement true | Moves a release candidate to reviewing if all runs are done. |
def sync_one(self, aws_syncr, amazon, bucket):
if bucket.permission.statements:
permission_document = bucket.permission.document
else:
permission_document = ""
bucket_info = amazon.s3.bucket_info(bucket.name)
if not bucket_info.creation_date:
amazon.s3.create_bucket(bucket.name, permission_document, bucket)
else:
amazon.s3.modify_bucket(bucket_info, bucket.name, permission_document, bucket) | module function_definition identifier parameters identifier identifier identifier identifier block if_statement attribute attribute identifier identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier else_clause block expression_statement assignment identifier string string_start string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier if_statement not_operator attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier identifier else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list identifier attribute identifier identifier identifier identifier | Make sure this bucket exists and has only attributes we want it to have |
def _get_inherited_field_types(class_to_field_type_overrides, schema_graph):
inherited_field_type_overrides = dict()
for superclass_name, field_type_overrides in class_to_field_type_overrides.items():
for subclass_name in schema_graph.get_subclass_set(superclass_name):
inherited_field_type_overrides.setdefault(subclass_name, dict())
inherited_field_type_overrides[subclass_name].update(field_type_overrides)
return inherited_field_type_overrides | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block for_statement identifier call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier call identifier argument_list expression_statement call attribute subscript identifier identifier identifier argument_list identifier return_statement identifier | Return a dictionary describing the field type overrides in subclasses. |
def add_bonus(worker_dict):
" Adds DB-logged worker bonus to worker list data "
try:
unique_id = '{}:{}'.format(worker_dict['workerId'], worker_dict['assignmentId'])
worker = Participant.query.filter(
Participant.uniqueid == unique_id).one()
worker_dict['bonus'] = worker.bonus
except sa.exc.InvalidRequestError:
worker_dict['bonus'] = 'N/A'
return worker_dict | module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end try_statement block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list comparison_operator attribute identifier identifier identifier identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier except_clause attribute attribute identifier identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end return_statement identifier | Adds DB-logged worker bonus to worker list data |
async def announce(self):
await self.event_broker.send(
action_type=intialize_service_action(),
payload=json.dumps(self.summarize())
) | module function_definition identifier parameters identifier block expression_statement await call attribute attribute identifier identifier identifier argument_list keyword_argument identifier call identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list | This method is used to announce the existence of the service |
def topic_over_time(self, k, mode='counts', slice_kwargs={}):
return self.corpus.feature_distribution('topics', k, mode=mode,
**slice_kwargs) | module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end default_parameter identifier dictionary block return_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier keyword_argument identifier identifier dictionary_splat identifier | Calculate the representation of topic ``k`` in the corpus over time. |
def send_zone_event(self, zone_id, event_name, *args):
cmd = "EVENT %s!%s %s" % (
zone_id.device_str(), event_name,
" ".join(str(x) for x in args))
return (yield from self._send_cmd(cmd)) | module function_definition identifier parameters identifier identifier identifier list_splat_pattern identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple call attribute identifier identifier argument_list identifier call attribute string string_start string_content string_end identifier generator_expression call identifier argument_list identifier for_in_clause identifier identifier return_statement parenthesized_expression yield call attribute identifier identifier argument_list identifier | Send an event to a zone. |
def print_token(self, token_node_index):
err_msg = "The given node is not a token node."
assert isinstance(self.nodes[token_node_index], TokenNode), err_msg
onset = self.nodes[token_node_index].onset
offset = self.nodes[token_node_index].offset
return self.text[onset:offset] | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier string string_start string_content string_end assert_statement call identifier argument_list subscript attribute identifier identifier identifier identifier identifier expression_statement assignment identifier attribute subscript attribute identifier identifier identifier identifier expression_statement assignment identifier attribute subscript attribute identifier identifier identifier identifier return_statement subscript attribute identifier identifier slice identifier identifier | returns the string representation of a token. |
def __deactivate_shared_objects(self, plugin, *args, **kwargs):
shared_objects = self.get()
for shared_object in shared_objects.keys():
self.unregister(shared_object) | module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier | Callback, which gets executed, if the signal "plugin_deactivate_post" was send by the plugin. |
def _remap_dirname(local, remote):
def do(x):
return x.replace(local, remote, 1)
return do | module function_definition identifier parameters identifier identifier block function_definition identifier parameters identifier block return_statement call attribute identifier identifier argument_list identifier identifier integer return_statement identifier | Remap directory names from local to remote. |
def rws_call(ctx, method, default_attr=None):
try:
response = ctx.obj['RWS'].send_request(method)
if ctx.obj['RAW']:
result = ctx.obj['RWS'].last_result.text
elif default_attr is not None:
result = ""
for item in response:
result = result + item.__dict__[default_attr] + "\n"
else:
result = ctx.obj['RWS'].last_result.text
if ctx.obj['OUTPUT']:
ctx.obj['OUTPUT'].write(result.encode('utf-8'))
else:
click.echo(result)
except RWSException as e:
click.echo(str(e)) | module function_definition identifier parameters identifier identifier default_parameter identifier none block try_statement block expression_statement assignment identifier call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list identifier if_statement subscript attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier attribute attribute subscript attribute identifier identifier string string_start string_content string_end identifier identifier elif_clause comparison_operator identifier none block expression_statement assignment identifier string string_start string_end for_statement identifier identifier block expression_statement assignment identifier binary_operator binary_operator identifier subscript attribute identifier identifier identifier string string_start string_content escape_sequence string_end else_clause block expression_statement assignment identifier attribute attribute subscript attribute identifier identifier string string_start string_content string_end identifier identifier if_statement subscript attribute identifier identifier string string_start string_content string_end block expression_statement call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end else_clause block expression_statement call attribute identifier identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier | Make request to RWS |
def compile_sass(self, sass_filename, sass_fileurl):
compile_kwargs = {
'filename': sass_filename,
'include_paths': SassProcessor.include_paths + APPS_INCLUDE_DIRS,
'custom_functions': get_custom_functions(),
}
if self.sass_precision:
compile_kwargs['precision'] = self.sass_precision
if self.sass_output_style:
compile_kwargs['output_style'] = self.sass_output_style
content = sass.compile(**compile_kwargs)
self.save_to_destination(content, sass_filename, sass_fileurl)
self.processed_files.append(sass_filename)
if self.verbosity > 1:
self.stdout.write("Compiled SASS/SCSS file: '{0}'\n".format(sass_filename)) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end binary_operator attribute identifier identifier identifier pair string string_start string_content string_end call identifier argument_list if_statement attribute identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier if_statement attribute identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list dictionary_splat identifier expression_statement call attribute identifier identifier argument_list identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator attribute identifier identifier integer block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier | Compile the given SASS file into CSS |
def python_sidebar_navigation(python_input):
def get_text_fragments():
tokens = []
tokens.extend([
('class:sidebar', ' '),
('class:sidebar.key', '[Arrows]'),
('class:sidebar', ' '),
('class:sidebar.description', 'Navigate'),
('class:sidebar', ' '),
('class:sidebar.key', '[Enter]'),
('class:sidebar', ' '),
('class:sidebar.description', 'Hide menu'),
])
return tokens
return Window(
FormattedTextControl(get_text_fragments),
style='class:sidebar',
width=Dimension.exact(43),
height=Dimension.exact(1)) | module function_definition identifier parameters identifier block function_definition identifier parameters block expression_statement assignment identifier list expression_statement call attribute identifier identifier argument_list list tuple string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end return_statement identifier return_statement call identifier argument_list call identifier argument_list identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier call attribute identifier identifier argument_list integer keyword_argument identifier call attribute identifier identifier argument_list integer | Create the `Layout` showing the navigation information for the sidebar. |
def getDMCframe(f, iFrm: int, finf: dict, verbose: bool=False):
currByte = iFrm * finf['bytesperframe']
if verbose:
print(f'seeking to byte {currByte}')
assert isinstance(iFrm, (int, int64)), 'int32 will fail on files > 2GB'
try:
f.seek(currByte, 0)
except IOError as e:
raise IOError(f'I couldnt seek to byte {currByte:d}. try using a 64-bit integer for iFrm \n'
'is {f.name} a DMCdata file? {e}')
try:
currFrame = fromfile(f, uint16,
finf['pixelsperimage']).reshape((finf['supery'], finf['superx']),
order='C')
except ValueError as e:
raise ValueError(f'read past end of file? {e}')
rawFrameInd = meta2rawInd(f, finf['nmetadata'])
if rawFrameInd is None:
rawFrameInd = iFrm + 1
return currFrame, rawFrameInd | module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_default_parameter identifier type identifier false block expression_statement assignment identifier binary_operator identifier subscript identifier string string_start string_content string_end if_statement identifier block expression_statement call identifier argument_list string string_start string_content interpolation identifier string_end assert_statement call identifier argument_list identifier tuple identifier identifier string string_start string_content string_end try_statement block expression_statement call attribute identifier identifier argument_list identifier integer except_clause as_pattern identifier as_pattern_target identifier block raise_statement call identifier argument_list concatenated_string string string_start string_content interpolation identifier format_specifier string_content escape_sequence string_end string string_start string_content string_end try_statement block expression_statement assignment identifier call attribute call identifier argument_list identifier identifier subscript identifier string string_start string_content string_end identifier argument_list tuple subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end except_clause as_pattern identifier as_pattern_target identifier block raise_statement call identifier argument_list string string_start string_content interpolation identifier string_end expression_statement assignment identifier call identifier argument_list identifier subscript identifier string string_start string_content string_end if_statement comparison_operator identifier none block expression_statement assignment identifier binary_operator identifier integer return_statement expression_list identifier identifier | f is open file handle |
def provStacks(self, offs, size):
for _, iden in self.provseq.slice(offs, size):
stack = self.getProvStack(iden)
if stack is None:
continue
yield (iden, stack) | module function_definition identifier parameters identifier identifier identifier block for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block continue_statement expression_statement yield tuple identifier identifier | Returns a stream of provenance stacks at the given offset |
def create_information(self):
info = self._info_type()(origin=self, contents=self._contents())
return info | module function_definition identifier parameters identifier block expression_statement assignment identifier call call attribute identifier identifier argument_list argument_list keyword_argument identifier identifier keyword_argument identifier call attribute identifier identifier argument_list return_statement identifier | Create new infos on demand. |
def _write_vvr(self, f, data):
f.seek(0, 2)
byte_loc = f.tell()
block_size = CDF.VVR_BASE_SIZE64 + len(data)
section_type = CDF.VVR_
vvr1 = bytearray(12)
vvr1[0:8] = struct.pack('>q', block_size)
vvr1[8:12] = struct.pack('>i', section_type)
f.write(vvr1)
f.write(data)
return byte_loc | module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list integer integer expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier binary_operator attribute identifier identifier call identifier argument_list identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list integer expression_statement assignment subscript identifier slice integer integer call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment subscript identifier slice integer integer call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | Writes a vvr to the end of file "f" with the byte stream "data". |
def delete(self, name):
if isinstance(name, (list, tuple)):
for xx in name:
self.delete(xx)
else:
if name in self._record_map:
del self._record_map[name]
self._record_list = [
r for r in self._record_list if r['name'] != name] | module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier tuple identifier identifier block for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier else_clause block if_statement comparison_operator identifier attribute identifier identifier block delete_statement subscript attribute identifier identifier identifier expression_statement assignment attribute identifier identifier list_comprehension identifier for_in_clause identifier attribute identifier identifier if_clause comparison_operator subscript identifier string string_start string_content string_end identifier | Delete the specified entry if it exists. |
def _import_plugins(self):
if self.detected:
return
self.scanLock.acquire()
if self.detected:
return
try:
import_apps_submodule("content_plugins")
self.detected = True
finally:
self.scanLock.release() | module function_definition identifier parameters identifier block if_statement attribute identifier identifier block return_statement expression_statement call attribute attribute identifier identifier identifier argument_list if_statement attribute identifier identifier block return_statement try_statement block expression_statement call identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier true finally_clause block expression_statement call attribute attribute identifier identifier identifier argument_list | Internal function, ensure all plugin packages are imported. |
def boston(display=False):
d = sklearn.datasets.load_boston()
df = pd.DataFrame(data=d.data, columns=d.feature_names)
return df, d.target | module function_definition identifier parameters default_parameter identifier false block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier return_statement expression_list identifier attribute identifier identifier | Return the boston housing data in a nice package. |
def pull(image, tag=None):
if tag:
image = ":".join([image, tag])
utils.xrun("docker pull", [image]) | module function_definition identifier parameters identifier default_parameter identifier none block if_statement identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list list identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end list identifier | pull a docker image |
def add_path(self, path):
if not os.path.exists(path):
raise RuntimeError('Path does not exists: %s.' % path)
self.paths.append(path) | module function_definition identifier parameters identifier identifier block if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier | Load translations from an existing path. |
def _clean(self, seed):
seed = deepcopy(seed)
self._inherit(*array(get(seed, 'inherit', [])))
if '&arguments' in seed:
self.arguments = merge(self.arguments, seed.pop('&arguments'))
elif 'arguments' in seed:
self.arguments = seed.pop('arguments')
self.seeds.append(seed) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list list_splat call identifier argument_list call identifier argument_list identifier string string_start string_content string_end list if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end elif_clause comparison_operator string string_start string_content string_end identifier block expression_statement assignment attribute identifier 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 | Takes a seed and applies it to the garden |
def find_on_path(importer, path_item, only=False):
path_item = _normalize_cached(path_item)
if _is_unpacked_egg(path_item):
yield Distribution.from_filename(
path_item, metadata=PathMetadata(
path_item, os.path.join(path_item, 'EGG-INFO')
)
)
return
entries = safe_listdir(path_item)
filtered = (
entry
for entry in entries
if dist_factory(path_item, entry, only)
)
path_item_entries = _by_version_descending(filtered)
for entry in path_item_entries:
fullpath = os.path.join(path_item, entry)
factory = dist_factory(path_item, entry, only)
for dist in factory(fullpath):
yield dist | module function_definition identifier parameters identifier identifier default_parameter identifier false block expression_statement assignment identifier call identifier argument_list identifier if_statement call identifier argument_list identifier block expression_statement yield call attribute identifier identifier argument_list identifier keyword_argument identifier call identifier argument_list identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end return_statement expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier generator_expression identifier for_in_clause identifier identifier if_clause call identifier argument_list identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier for_statement identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier for_statement identifier call identifier argument_list identifier block expression_statement yield identifier | Yield distributions accessible on a sys.path directory |
def versions_report(include_salt_cloud=False):
ver_info = versions_information(include_salt_cloud)
lib_pad = max(len(name) for name in ver_info['Dependency Versions'])
sys_pad = max(len(name) for name in ver_info['System Versions'])
padding = max(lib_pad, sys_pad) + 1
fmt = '{0:>{pad}}: {1}'
info = []
for ver_type in ('Salt Version', 'Dependency Versions', 'System Versions'):
info.append('{0}:'.format(ver_type))
for name in sorted(ver_info[ver_type], key=lambda x: x.lower()):
ver = fmt.format(name,
ver_info[ver_type][name] or 'Not Installed',
pad=padding)
info.append(ver)
info.append(' ')
for line in info:
yield line | module function_definition identifier parameters default_parameter identifier false block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier generator_expression call identifier argument_list identifier for_in_clause identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier call identifier generator_expression call identifier argument_list identifier for_in_clause identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier binary_operator call identifier argument_list identifier identifier integer expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier list for_statement identifier tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier for_statement identifier call identifier argument_list subscript identifier identifier keyword_argument identifier lambda lambda_parameters identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list identifier boolean_operator subscript subscript identifier identifier identifier string string_start string_content string_end keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end for_statement identifier identifier block expression_statement yield identifier | Yield each version properly formatted for console output. |
def saveToClipboard(sheet, rows, filetype=None):
'copy rows from sheet to system clipboard'
filetype = filetype or options.save_filetype
vs = copy(sheet)
vs.rows = rows
status('copying rows to clipboard')
clipboard().save(vs, filetype) | module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement string string_start string_content string_end expression_statement assignment identifier boolean_operator identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier expression_statement call identifier argument_list string string_start string_content string_end expression_statement call attribute call identifier argument_list identifier argument_list identifier identifier | copy rows from sheet to system clipboard |
def runtime_to_build(runtime_deps):
build_deps = copy.deepcopy(runtime_deps)
for dep in build_deps:
if len(dep) > 0:
dep[0] = 'BuildRequires'
return build_deps | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement identifier identifier block if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment subscript identifier integer string string_start string_content string_end return_statement identifier | Adds all runtime deps to build deps |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.