code stringlengths 51 2.34k | sequence stringlengths 186 3.94k | docstring stringlengths 11 171 |
|---|---|---|
def root(self):
drive = self.drive
for device in self._daemon:
if device.is_drive:
continue
if device.is_toplevel and device.drive == drive:
return device
return None | module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier for_statement identifier attribute identifier identifier block if_statement attribute identifier identifier block continue_statement if_statement boolean_operator attribute identifier identifier comparison_operator attribute identifier identifier identifier block return_statement identifier return_statement none | Get the top level block device in the ancestry of this device. |
def variance_K(K, verbose=False):
c = SP.sum((SP.eye(len(K)) - (1.0 / len(K)) * SP.ones(K.shape)) * SP.array(K))
scalar = (len(K) - 1) / c
return 1.0/scalar | module function_definition identifier parameters identifier default_parameter identifier false block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator parenthesized_expression binary_operator call attribute identifier identifier argument_list call identifier argument_list identifier binary_operator parenthesized_expression binary_operator float call identifier argument_list identifier call attribute identifier identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator parenthesized_expression binary_operator call identifier argument_list identifier integer identifier return_statement binary_operator float identifier | estimate the variance explained by K |
def sort_catalogue_chronologically(self):
dec_time = self.get_decimal_time()
idx = np.argsort(dec_time)
if np.all((idx[1:] - idx[:-1]) > 0.):
return
self.select_catalogue_events(idx) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement call attribute identifier identifier argument_list comparison_operator parenthesized_expression binary_operator subscript identifier slice integer subscript identifier slice unary_operator integer float block return_statement expression_statement call attribute identifier identifier argument_list identifier | Sorts the catalogue into chronological order |
def local_within_block_attention(x,
self_attention_bias,
hparams,
attention_type="local_within_block_mask_right",
q_padding="VALID",
kv_padding="VALID"):
x_new, x_shape, is_4d = maybe_reshape_4d_to_3d(x)
with tf.variable_scope("local_within_block"):
y = common_attention.multihead_attention(
common_layers.layer_preprocess(x_new, hparams),
None,
self_attention_bias,
hparams.attention_key_channels or hparams.hidden_size,
hparams.attention_value_channels or hparams.hidden_size,
hparams.hidden_size,
hparams.num_heads,
hparams.attention_dropout,
attention_type=attention_type,
block_width=hparams.block_width,
block_length=hparams.block_length,
q_padding=q_padding,
kv_padding=kv_padding,
q_filter_width=hparams.q_filter_width,
kv_filter_width=hparams.kv_filter_width,
name="local_within_block")
if is_4d:
y = tf.reshape(y, x_shape)
return y | module function_definition identifier parameters identifier identifier identifier default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_content string_end block expression_statement assignment pattern_list identifier identifier identifier call identifier argument_list identifier with_statement with_clause with_item call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier none identifier boolean_operator attribute identifier identifier attribute identifier identifier boolean_operator attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier string string_start string_content string_end if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier return_statement identifier | Local within block self attention. |
def str2int(string_with_int):
return int("".join([char for char in string_with_int if char in string.digits]) or 0) | module function_definition identifier parameters identifier block return_statement call identifier argument_list boolean_operator call attribute string string_start string_end identifier argument_list list_comprehension identifier for_in_clause identifier identifier if_clause comparison_operator identifier attribute identifier identifier integer | Collect digits from a string |
def namer(cls, imageUrl, pageUrl):
index = int(compile(r'id=(\d+)').search(pageUrl).group(1))
ext = imageUrl.rsplit('.', 1)[1]
return "SnowFlakes-%d.%s" % (index, ext) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list call attribute call attribute call identifier argument_list string string_start string_content string_end identifier argument_list identifier identifier argument_list integer expression_statement assignment identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end integer integer return_statement binary_operator string string_start string_content string_end tuple identifier identifier | Use strip index number for image name. |
def remove_group_roles(request, group, domain=None, project=None):
client = keystoneclient(request, admin=True)
roles = client.roles.list(group=group, domain=domain, project=project)
for role in roles:
remove_group_role(request, role=role.id, group=group,
domain=domain, project=project) | module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier true expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier for_statement identifier identifier block expression_statement call identifier argument_list identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier | Removes all roles from a group on a domain or project. |
def all(self):
self._check_layout()
return LayoutSlice(self.layout, slice(0, len(self.layout.fields), 1)) | module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list return_statement call identifier argument_list attribute identifier identifier call identifier argument_list integer call identifier argument_list attribute attribute identifier identifier identifier integer | Returns all layout objects of first level of depth |
def printmp(msg):
filler = (80 - len(msg)) * ' '
print(msg + filler, end='\r')
sys.stdout.flush() | module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator parenthesized_expression binary_operator integer call identifier argument_list identifier string string_start string_content string_end expression_statement call identifier argument_list binary_operator identifier identifier keyword_argument identifier string string_start string_content escape_sequence string_end expression_statement call attribute attribute identifier identifier identifier argument_list | Print temporarily, until next print overrides it. |
def getParamsByName(elem, name):
name = StripParamName(name)
return elem.getElements(lambda e: (e.tagName == ligolw.Param.tagName) and (e.Name == name)) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier return_statement call attribute identifier identifier argument_list lambda lambda_parameters identifier boolean_operator parenthesized_expression comparison_operator attribute identifier identifier attribute attribute identifier identifier identifier parenthesized_expression comparison_operator attribute identifier identifier identifier | Return a list of params with name name under elem. |
def _request_helper(self, url, params, method):
try:
if method == 'POST':
return self._request_post_helper(url, params)
elif method == 'GET':
return self._request_get_helper(url, params)
raise VultrError('Unsupported method %s' % method)
except requests.RequestException as ex:
raise RuntimeError(ex) | module function_definition identifier parameters identifier identifier identifier identifier block try_statement block if_statement comparison_operator identifier string string_start string_content string_end block return_statement call attribute identifier identifier argument_list identifier identifier elif_clause comparison_operator identifier string string_start string_content string_end block return_statement call attribute identifier identifier argument_list identifier identifier raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier except_clause as_pattern attribute identifier identifier as_pattern_target identifier block raise_statement call identifier argument_list identifier | API request helper method |
def swagger(request):
generator = schemas.SchemaGenerator(title='django-user-tasks REST API')
return response.Response(generator.get_schema()) | 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 return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list | Render Swagger UI and the underlying Open API schema JSON file. |
def append(self, item):
if self.url:
raise TypeError('Menu items with URL cannot have childrens')
if not item.is_leaf():
for current_item in self.items:
if item.name == current_item.name:
for children in item.items:
current_item.append(children)
return
self.items.append(item) | module function_definition identifier parameters identifier identifier block if_statement attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement not_operator call attribute identifier identifier argument_list block for_statement identifier attribute identifier identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement expression_statement call attribute attribute identifier identifier identifier argument_list identifier | Add the given item as children |
def dispatch(self,request,*args,**kwargs):
lessonSession = request.session.get(PRIVATELESSON_VALIDATION_STR,{})
try:
self.lesson = PrivateLessonEvent.objects.get(id=lessonSession.get('lesson'))
except (ValueError, ObjectDoesNotExist):
messages.error(request,_('Invalid lesson identifier passed to sign-up form.'))
return HttpResponseRedirect(reverse('bookPrivateLesson'))
expiry = parse_datetime(lessonSession.get('expiry',''),)
if not expiry or expiry < timezone.now():
messages.info(request,_('Your registration session has expired. Please try again.'))
return HttpResponseRedirect(reverse('bookPrivateLesson'))
self.payAtDoor = lessonSession.get('payAtDoor',False)
return super(PrivateLessonStudentInfoView,self).dispatch(request,*args,**kwargs) | module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier dictionary try_statement block expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list string string_start string_content string_end except_clause tuple identifier identifier block expression_statement call attribute identifier identifier argument_list identifier call identifier argument_list string string_start string_content string_end return_statement call identifier argument_list call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end if_statement boolean_operator not_operator identifier comparison_operator identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier call identifier argument_list string string_start string_content string_end return_statement call identifier argument_list 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 false return_statement call attribute call identifier argument_list identifier identifier identifier argument_list identifier list_splat identifier dictionary_splat identifier | Handle the session data passed by the prior view. |
def on_task_status(self, task):
try:
procesok = task['track']['process']['ok']
if not self.projects[task['project']].task_queue.done(task['taskid']):
logging.error('not processing pack: %(project)s:%(taskid)s %(url)s', task)
return None
except KeyError as e:
logger.error("Bad status pack: %s", e)
return None
if procesok:
ret = self.on_task_done(task)
else:
ret = self.on_task_failed(task)
if task['track']['fetch'].get('time'):
self._cnt['5m_time'].event((task['project'], 'fetch_time'),
task['track']['fetch']['time'])
if task['track']['process'].get('time'):
self._cnt['5m_time'].event((task['project'], 'process_time'),
task['track']['process'].get('time'))
self.projects[task['project']].active_tasks.appendleft((time.time(), task))
return ret | module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment identifier subscript subscript subscript identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end if_statement not_operator call attribute attribute subscript attribute identifier identifier subscript identifier string string_start string_content string_end identifier identifier argument_list subscript identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement none except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement none if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement call attribute subscript subscript identifier string string_start string_content string_end string string_start string_content string_end identifier argument_list 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 tuple subscript identifier string string_start string_content string_end string string_start string_content string_end subscript subscript subscript identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end if_statement call attribute subscript subscript identifier string string_start string_content string_end string string_start string_content string_end identifier argument_list 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 tuple subscript identifier string string_start string_content string_end string string_start string_content string_end call attribute subscript subscript identifier string string_start string_content string_end string string_start string_content string_end identifier argument_list string string_start string_content string_end expression_statement call attribute attribute subscript attribute identifier identifier subscript identifier string string_start string_content string_end identifier identifier argument_list tuple call attribute identifier identifier argument_list identifier return_statement identifier | Called when a status pack is arrived |
def batch_flatten(x):
shape = x.get_shape().as_list()[1:]
if None not in shape:
return tf.reshape(x, [-1, int(np.prod(shape))])
return tf.reshape(x, tf.stack([tf.shape(x)[0], -1])) | module function_definition identifier parameters identifier block expression_statement assignment identifier subscript call attribute call attribute identifier identifier argument_list identifier argument_list slice integer if_statement comparison_operator none identifier block return_statement call attribute identifier identifier argument_list identifier list unary_operator integer call identifier argument_list call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list list subscript call attribute identifier identifier argument_list identifier integer unary_operator integer | Flatten the tensor except the first dimension. |
def add_udev_trigger(self, trigger_action, subsystem):
if self._py3_wrapper.udev_monitor.subscribe(self, trigger_action, subsystem):
if trigger_action == "refresh_and_freeze":
self.module_class.cache_timeout = PY3_CACHE_FOREVER | module function_definition identifier parameters identifier identifier identifier block if_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier identifier identifier block if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment attribute attribute identifier identifier identifier identifier | Subscribe to the requested udev subsystem and apply the given action. |
def merge(left, right, how='inner', key=None, left_key=None, right_key=None,
left_as='left', right_as='right'):
return join(left, right, how, key, left_key, right_key,
join_fn=make_union_join(left_as, right_as)) | module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_content string_end block return_statement call identifier argument_list identifier identifier identifier identifier identifier identifier keyword_argument identifier call identifier argument_list identifier identifier | Performs a join using the union join function. |
def _add_sections(self):
for section in self.template_sections:
try:
sec_start = self._get_section_start_index(section)
except NonextantSectionException:
if section in self.sections_not_required:
continue
raise
sec_end = self._get_section_end_index(section, sec_start)
section_value = self.template_str[sec_start+1:sec_end].strip()
section, section_value = self._transform_key_value(
section,
section_value,
self.section_map
)
self.templ_dict['actions']['definition'][section] = section_value
self.template_str = self.template_str[:sec_start+1] + \
self.template_str[sec_end:] | module function_definition identifier parameters identifier block for_statement identifier attribute identifier identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause identifier block if_statement comparison_operator identifier attribute identifier identifier block continue_statement raise_statement expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute subscript attribute identifier identifier slice binary_operator identifier integer identifier identifier argument_list expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier identifier attribute identifier identifier expression_statement assignment subscript subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end identifier identifier expression_statement assignment attribute identifier identifier binary_operator subscript attribute identifier identifier slice binary_operator identifier integer line_continuation subscript attribute identifier identifier slice identifier | Add the found and required sections to the templ_dict. |
def _evaluate(self):
if self._elements:
for element in self._elements:
yield element
else:
for user_id in self.__user_ids:
element = self._swimlane.users.get(id=user_id)
self._elements.append(element)
yield element | module function_definition identifier parameters identifier block if_statement attribute identifier identifier block for_statement identifier attribute identifier identifier block expression_statement yield identifier else_clause block for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list keyword_argument identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement yield identifier | Lazily retrieve and build User instances from returned data |
def get():
pkgnames = find_packages()
if len(pkgnames) == 0:
raise ValueError("Can't find any packages")
pkgname = pkgnames[0]
content = open(join(pkgname, '__init__.py')).read()
c = re.compile(r"__version__ *= *('[^']+'|\"[^\"]+\")")
m = c.search(content)
if m is None:
raise ValueError("Can't find __version__ = ... in __init__.py")
return m.groups()[0][1: -1] | module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list if_statement comparison_operator call identifier argument_list identifier integer block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier call attribute call identifier argument_list call identifier argument_list identifier string string_start string_content string_end identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block raise_statement call identifier argument_list string string_start string_content string_end return_statement subscript subscript call attribute identifier identifier argument_list integer slice integer unary_operator integer | Returns the current version without importing pymds. |
def split_model(model:nn.Module=None, splits:Collection[Union[nn.Module,ModuleList]]=None):
"Split `model` according to the layers in `splits`."
splits = listify(splits)
if isinstance(splits[0], nn.Module):
layers = flatten_model(model)
idxs = [layers.index(first_layer(s)) for s in splits]
return split_model_idx(model, idxs)
return [nn.Sequential(*s) for s in splits] | module function_definition identifier parameters typed_default_parameter identifier type attribute identifier identifier none typed_default_parameter identifier type generic_type identifier type_parameter type generic_type identifier type_parameter type attribute identifier identifier type identifier none block expression_statement string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier if_statement call identifier argument_list subscript identifier integer attribute identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list call identifier argument_list identifier for_in_clause identifier identifier return_statement call identifier argument_list identifier identifier return_statement list_comprehension call attribute identifier identifier argument_list list_splat identifier for_in_clause identifier identifier | Split `model` according to the layers in `splits`. |
def MergeMessage(
self, source, destination,
replace_message, replace_repeated):
_MergeMessage(
self._root, source, destination, replace_message, replace_repeated) | module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement call identifier argument_list attribute identifier identifier identifier identifier identifier identifier | Merge all fields specified by this tree from source to destination. |
def cli_progress(addr, offset, size):
width = 25
done = offset * width // size
print("\r0x{:08x} {:7d} [{}{}] {:3d}% "
.format(addr, size, '=' * done, ' ' * (width - done),
offset * 100 // size), end="")
try:
sys.stdout.flush()
except OSError:
pass
if offset == size:
print("") | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier integer expression_statement assignment identifier binary_operator binary_operator identifier identifier identifier expression_statement call identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier identifier binary_operator string string_start string_content string_end identifier binary_operator string string_start string_content string_end parenthesized_expression binary_operator identifier identifier binary_operator binary_operator identifier integer identifier keyword_argument identifier string string_start string_end try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list except_clause identifier block pass_statement if_statement comparison_operator identifier identifier block expression_statement call identifier argument_list string string_start string_end | Prints a progress report suitable for use on the command line. |
def _draw(self, context, opacity):
fresh_draw = len(self.__new_instructions or []) > 0
if fresh_draw:
self.paths = []
self.__instruction_cache = self.__new_instructions
self.__new_instructions = []
else:
if not self.__instruction_cache:
return
for instruction, args in self.__instruction_cache:
if fresh_draw:
if instruction in ("new_path", "stroke", "fill", "clip"):
self.paths.append((instruction, "path", context.copy_path()))
elif instruction in ("save", "restore", "translate", "scale", "rotate"):
self.paths.append((instruction, "transform", args))
if instruction == "set_color":
self._set_color(context, args[0], args[1], args[2], args[3] * opacity)
elif instruction == "show_layout":
self._show_layout(context, *args)
elif opacity < 1 and instruction == "paint":
context.paint_with_alpha(opacity)
else:
getattr(context, instruction)(*args) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier comparison_operator call identifier argument_list boolean_operator attribute identifier identifier list integer if_statement identifier block expression_statement assignment attribute identifier identifier list expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier list else_clause block if_statement not_operator attribute identifier identifier block return_statement for_statement pattern_list identifier identifier attribute identifier identifier block if_statement identifier block if_statement comparison_operator identifier tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block expression_statement call attribute attribute identifier identifier identifier argument_list tuple identifier string string_start string_content string_end call attribute identifier identifier argument_list elif_clause comparison_operator identifier tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block expression_statement call attribute attribute identifier identifier identifier argument_list tuple identifier string string_start string_content string_end identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier subscript identifier integer subscript identifier integer subscript identifier integer binary_operator subscript identifier integer identifier elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier list_splat identifier elif_clause boolean_operator comparison_operator identifier integer comparison_operator identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement call call identifier argument_list identifier identifier argument_list list_splat identifier | draw accumulated instructions in context |
def iteritems(self):
for n,v in self.msgobj.__dict__["_headers"]:
yield n.lower(), v
return | module function_definition identifier parameters identifier block for_statement pattern_list identifier identifier subscript attribute attribute identifier identifier identifier string string_start string_content string_end block expression_statement yield expression_list call attribute identifier identifier argument_list identifier return_statement | Present the email headers |
def __get_default_layouts_settings(self):
LOGGER.debug("> Accessing '{0}' default layouts settings file!".format(UiConstants.layouts_file))
self.__default_layouts_settings = QSettings(umbra.ui.common.get_resource_path(UiConstants.layouts_file),
QSettings.IniFormat) | module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier | Gets the default layouts settings. |
def move_vobject(self, uuid, from_project, to_project):
if to_project not in self.get_filesnames():
return
uuid = uuid.split('@')[0]
with self._lock:
run(['task', 'rc.verbose=nothing', 'rc.data.location={self._data_location}'.format(**locals()), 'rc.confirmation=no', uuid, 'modify', 'project:{}'.format(basename(to_project))]) | module function_definition identifier parameters identifier identifier identifier identifier block if_statement comparison_operator identifier call attribute identifier identifier argument_list block return_statement expression_statement assignment identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end integer with_statement with_clause with_item attribute identifier identifier block expression_statement call identifier argument_list list string string_start string_content string_end string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list dictionary_splat call identifier argument_list string string_start string_content string_end identifier string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier | Update the project of the task with the UID uuid |
def equal(self, path_a, path_b):
content_a, _ = self.get_bytes(path_a)
content_b, _ = self.get_bytes(path_b)
return content_a == content_b | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier return_statement comparison_operator identifier identifier | compare if a and b have the same bytes |
def fail(item, fail_type=None, max_tries=None, ttl=None):
if fail_type is not None and fail_type == _c.FSQ_FAIL_TMP:
return fail_tmp(item, max_tries=max_tries, ttl=ttl)
return fail_perm(item) | module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none block if_statement boolean_operator comparison_operator identifier none comparison_operator identifier attribute identifier identifier block return_statement call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier return_statement call identifier argument_list identifier | Fail a work item, either temporarily or permanently |
def _end_del(self):
text = self.edit_text[:self.edit_pos]
self.set_edit_text(text) | module function_definition identifier parameters identifier block expression_statement assignment identifier subscript attribute identifier identifier slice attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier | Deletes the line content after the cursor |
def filter(self, request, queryset, view):
summary_queryset = queryset
filtered_querysets = []
for queryset in summary_queryset.querysets:
filter_class = self._get_filter(queryset)
queryset = filter_class(request.query_params, queryset=queryset).qs
filtered_querysets.append(queryset)
summary_queryset.querysets = filtered_querysets
return summary_queryset | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier identifier expression_statement assignment identifier list for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier attribute call identifier argument_list attribute identifier identifier keyword_argument identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier return_statement identifier | Filter each resource separately using its own filter |
def cluster_forget(self, node_id):
fut = self.execute(b'CLUSTER', b'FORGET', node_id)
return wait_ok(fut) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier return_statement call identifier argument_list identifier | Remove a node from the nodes table. |
def DeleteCronJob(self, cronjob_id):
if cronjob_id not in self.cronjobs:
raise db.UnknownCronJobError("Cron job %s not known." % cronjob_id)
del self.cronjobs[cronjob_id]
try:
del self.cronjob_leases[cronjob_id]
except KeyError:
pass
for job_run in self.ReadCronJobRuns(cronjob_id):
del self.cronjob_runs[(cronjob_id, job_run.run_id)] | module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block raise_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier delete_statement subscript attribute identifier identifier identifier try_statement block delete_statement subscript attribute identifier identifier identifier except_clause identifier block pass_statement for_statement identifier call attribute identifier identifier argument_list identifier block delete_statement subscript attribute identifier identifier tuple identifier attribute identifier identifier | Deletes a cronjob along with all its runs. |
def selection(x_bounds,
x_types,
clusteringmodel_gmm_good,
clusteringmodel_gmm_bad,
minimize_starting_points,
minimize_constraints_fun=None):
results = lib_acquisition_function.next_hyperparameter_lowest_mu(\
_ratio_scores, [clusteringmodel_gmm_good, clusteringmodel_gmm_bad],\
x_bounds, x_types, minimize_starting_points, \
minimize_constraints_fun=minimize_constraints_fun)
return results | module function_definition identifier parameters identifier identifier identifier identifier identifier default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list line_continuation identifier list identifier identifier line_continuation identifier identifier identifier line_continuation keyword_argument identifier identifier return_statement identifier | Select the lowest mu value |
def system_status(self):
flag, timestamp, status = self._query(('GETDAT? 1', (Integer, Float, Integer)))
return {
'timestamp': datetime.datetime.fromtimestamp(timestamp),
'temperature': STATUS_TEMPERATURE[status & 0xf],
'magnet': STATUS_MAGNET[(status >> 4) & 0xf],
'chamber': STATUS_CHAMBER[(status >> 8) & 0xf],
'sample_position': STATUS_SAMPLE_POSITION[(status >> 12) & 0xf],
} | module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier identifier call attribute identifier identifier argument_list tuple string string_start string_content string_end tuple identifier identifier identifier return_statement dictionary pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list identifier pair string string_start string_content string_end subscript identifier binary_operator identifier integer pair string string_start string_content string_end subscript identifier binary_operator parenthesized_expression binary_operator identifier integer integer pair string string_start string_content string_end subscript identifier binary_operator parenthesized_expression binary_operator identifier integer integer pair string string_start string_content string_end subscript identifier binary_operator parenthesized_expression binary_operator identifier integer integer | The system status codes. |
def settled(self, block_identifier: BlockSpecification) -> bool:
return self.token_network.channel_is_settled(
participant1=self.participant1,
participant2=self.participant2,
block_identifier=block_identifier,
channel_identifier=self.channel_identifier,
) | module function_definition identifier parameters identifier typed_parameter identifier type identifier type identifier block return_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier | Returns if the channel is settled. |
def check (self):
if self.aggregate.config["trace"]:
trace.trace_on()
try:
self.local_check()
except (socket.error, select.error):
etype, value = sys.exc_info()[:2]
if etype == errno.EINTR:
raise KeyboardInterrupt(value)
else:
raise | module function_definition identifier parameters identifier block if_statement subscript attribute attribute identifier identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list try_statement block expression_statement call attribute identifier identifier argument_list except_clause tuple attribute identifier identifier attribute identifier identifier block expression_statement assignment pattern_list identifier identifier subscript call attribute identifier identifier argument_list slice integer if_statement comparison_operator identifier attribute identifier identifier block raise_statement call identifier argument_list identifier else_clause block raise_statement | Main check function for checking this URL. |
def __register_driver(self, channel, webdriver):
"Register webdriver to a channel."
if not self.__registered_drivers.has_key(channel):
self.__registered_drivers[channel] = []
self.__registered_drivers[channel].append(webdriver)
self.__webdriver[channel] = webdriver | module function_definition identifier parameters identifier identifier identifier block expression_statement string string_start string_content string_end if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment subscript attribute identifier identifier identifier list expression_statement call attribute subscript attribute identifier identifier identifier identifier argument_list identifier expression_statement assignment subscript attribute identifier identifier identifier identifier | Register webdriver to a channel. |
def parser_feed(parser, text):
encoded_text = text.encode('utf-8')
return _cmark.lib.cmark_parser_feed(
parser, encoded_text, len(encoded_text)) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement call attribute attribute identifier identifier identifier argument_list identifier identifier call identifier argument_list identifier | Direct wrapper over cmark_parser_feed. |
def read_band_blocks(self, blocksize=CHUNK_SIZE):
band = self.filehandle
shape = band.shape
token = tokenize(blocksize, band)
name = 'read_band-' + token
dskx = dict()
if len(band.block_shapes) != 1:
raise NotImplementedError('Bands with multiple shapes not supported.')
else:
chunks = band.block_shapes[0]
def do_read(the_band, the_window, the_lock):
with the_lock:
return the_band.read(1, None, window=the_window)
for ji, window in band.block_windows(1):
dskx[(name, ) + ji] = (do_read, band, window, self.read_lock)
res = da.Array(dskx, name, shape=list(shape),
chunks=chunks,
dtype=band.dtypes[0])
return DataArray(res, dims=('y', 'x')) | module function_definition identifier parameters identifier default_parameter identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list if_statement comparison_operator call identifier argument_list attribute identifier identifier integer block raise_statement call identifier argument_list string string_start string_content string_end else_clause block expression_statement assignment identifier subscript attribute identifier identifier integer function_definition identifier parameters identifier identifier identifier block with_statement with_clause with_item identifier block return_statement call attribute identifier identifier argument_list integer none keyword_argument identifier identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list integer block expression_statement assignment subscript identifier binary_operator tuple identifier identifier tuple identifier identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier keyword_argument identifier call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier subscript attribute identifier identifier integer return_statement call identifier argument_list identifier keyword_argument identifier tuple string string_start string_content string_end string string_start string_content string_end | Read the band in native blocks. |
def withdict(parser, token):
bits = token.split_contents()
if len(bits) != 2:
raise TemplateSyntaxError("{% withdict %} expects one argument")
nodelist = parser.parse(('endwithdict',))
parser.delete_first_token()
return WithDictNode(
nodelist=nodelist,
context_expr=parser.compile_filter(bits[1])
) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator call identifier argument_list identifier integer block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list tuple string string_start string_content string_end expression_statement call attribute identifier identifier argument_list return_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier call attribute identifier identifier argument_list subscript identifier integer | Take a complete context dict as extra layer. |
def undecorate(func):
orig_call_wrapper = lambda x: x
for call_wrapper, unwrap in SUPPORTED_DECORATOR.items():
if isinstance(func, call_wrapper):
func = unwrap(func)
orig_call_wrapper = call_wrapper
break
return orig_call_wrapper, func | module function_definition identifier parameters identifier block expression_statement assignment identifier lambda lambda_parameters identifier identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier identifier break_statement return_statement expression_list identifier identifier | Returns the decorator and the undecorated function of given object. |
def _openai_logging(self, epoch_result):
for key in sorted(epoch_result.keys()):
if key == 'fps':
openai_logger.record_tabular(key, int(epoch_result[key]))
else:
openai_logger.record_tabular(key, epoch_result[key])
openai_logger.dump_tabular() | module function_definition identifier parameters identifier identifier block for_statement identifier call identifier argument_list call attribute identifier identifier argument_list block if_statement comparison_operator identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier call identifier argument_list subscript identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier subscript identifier identifier expression_statement call attribute identifier identifier argument_list | Use OpenAI logging facilities for the same type of logging |
def parse_options(self, prog_name, arguments):
if '--version' in arguments:
self.exit_status(self.version, fh=sys.stdout)
parser = self.create_parser(prog_name)
options, args = parser.parse_args(arguments)
return options, args | module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator string string_start string_content string_end identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier return_statement expression_list identifier identifier | Parse the available options. |
def obj2str(obj):
if isinstance(obj, str_types):
return obj.encode("utf-8")
elif isinstance(obj, pathlib.Path):
return obj2str(str(obj))
elif isinstance(obj, (bool, int, float)):
return str(obj).encode("utf-8")
elif obj is None:
return b"none"
elif isinstance(obj, np.ndarray):
return obj.tostring()
elif isinstance(obj, tuple):
return obj2str(list(obj))
elif isinstance(obj, list):
return b"".join(obj2str(o) for o in obj)
elif isinstance(obj, dict):
return obj2str(list(obj.items()))
elif hasattr(obj, "identifier"):
return obj2str(obj.identifier)
elif isinstance(obj, h5py.Dataset):
return obj2str(obj[0])
else:
raise ValueError("No rule to convert object '{}' to string.".
format(obj.__class__)) | module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end elif_clause call identifier argument_list identifier attribute identifier identifier block return_statement call identifier argument_list call identifier argument_list identifier elif_clause call identifier argument_list identifier tuple identifier identifier identifier block return_statement call attribute call identifier argument_list identifier identifier argument_list string string_start string_content string_end elif_clause comparison_operator identifier none block return_statement string string_start string_content string_end elif_clause call identifier argument_list identifier attribute identifier identifier block return_statement call attribute identifier identifier argument_list elif_clause call identifier argument_list identifier identifier block return_statement call identifier argument_list call identifier argument_list identifier elif_clause call identifier argument_list identifier identifier block return_statement call attribute string string_start string_end identifier generator_expression call identifier argument_list identifier for_in_clause identifier identifier elif_clause call identifier argument_list identifier identifier block return_statement call identifier argument_list call identifier argument_list call attribute identifier identifier argument_list elif_clause call identifier argument_list identifier string string_start string_content string_end block return_statement call identifier argument_list attribute identifier identifier elif_clause call identifier argument_list identifier attribute identifier identifier block return_statement call identifier argument_list subscript identifier integer else_clause block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier | String representation of an object for hashing |
def Pop(self, key):
node = self._hash.get(key)
if node:
del self._hash[key]
self._age.Unlink(node)
return node.data | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement identifier block delete_statement subscript attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement attribute identifier identifier | Remove the object from the cache completely. |
def _gwf_channel(path, series_class=TimeSeries, verbose=False):
channels = list(io_gwf.iter_channel_names(file_path(path)))
if issubclass(series_class, StateVector):
regex = DQMASK_CHANNEL_REGEX
else:
regex = STRAIN_CHANNEL_REGEX
found, = list(filter(regex.match, channels))
if verbose:
print("Using channel {0!r}".format(found))
return found | module function_definition identifier parameters identifier default_parameter identifier identifier default_parameter identifier false block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list call identifier argument_list identifier if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier identifier else_clause block expression_statement assignment identifier identifier expression_statement assignment pattern_list identifier call identifier argument_list call identifier argument_list attribute identifier identifier identifier if_statement identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier return_statement identifier | Find the right channel name for a LOSC GWF file |
def _from_dict(cls, _dict):
args = {}
if 'name' in _dict:
args['name'] = _dict.get('name')
else:
raise ValueError(
'Required property \'name\' not present in ClassifierResult JSON'
)
if 'classifier_id' in _dict:
args['classifier_id'] = _dict.get('classifier_id')
else:
raise ValueError(
'Required property \'classifier_id\' not present in ClassifierResult JSON'
)
if 'classes' in _dict:
args['classes'] = [
ClassResult._from_dict(x) for x in (_dict.get('classes'))
]
else:
raise ValueError(
'Required property \'classes\' not present in ClassifierResult JSON'
)
return cls(**args) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary 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 call attribute identifier identifier argument_list string string_start string_content string_end else_clause block raise_statement call identifier argument_list string string_start string_content escape_sequence escape_sequence string_end 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 call attribute identifier identifier argument_list string string_start string_content string_end else_clause block raise_statement call identifier argument_list string string_start string_content escape_sequence escape_sequence string_end 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 list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier parenthesized_expression call attribute identifier identifier argument_list string string_start string_content string_end else_clause block raise_statement call identifier argument_list string string_start string_content escape_sequence escape_sequence string_end return_statement call identifier argument_list dictionary_splat identifier | Initialize a ClassifierResult object from a json dictionary. |
def data(self):
d = {}
self.token = ''
try:
d = self.viz.data
self.token = d.get('token')
except Exception as e:
logging.exception(e)
d['error'] = str(e)
return {
'datasource': self.datasource_name,
'description': self.description,
'description_markeddown': self.description_markeddown,
'edit_url': self.edit_url,
'form_data': self.form_data,
'slice_id': self.id,
'slice_name': self.slice_name,
'slice_url': self.slice_url,
'modified': self.modified(),
'changed_on_humanized': self.changed_on_humanized,
'changed_on': self.changed_on.isoformat(),
} | module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary expression_statement assignment attribute identifier identifier string string_start string_end try_statement block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list identifier return_statement dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end call attribute identifier identifier argument_list pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list | Data used to render slice in templates |
def raise_figure_window(f=0):
if _fun.is_a_number(f): f = _pylab.figure(f)
f.canvas.manager.window.raise_() | module function_definition identifier parameters default_parameter identifier integer block if_statement call attribute identifier identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute attribute attribute attribute identifier identifier identifier identifier identifier argument_list | Raises the supplied figure number or figure window. |
def _only_main(func):
@wraps(func)
def wrapper(self, *args, **kwargs):
if not self.is_main:
return getattr(self.main, func.__name__)(*args, **kwargs)
return func(self, *args, **kwargs)
return wrapper | module 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 attribute identifier identifier block return_statement call call identifier argument_list attribute identifier identifier attribute identifier identifier argument_list list_splat identifier dictionary_splat identifier return_statement call identifier argument_list identifier list_splat identifier dictionary_splat identifier return_statement identifier | Call the given `func` only from the main project |
def Run(self, request):
self.request = request
filters = self.BuildChecks(request)
files_checked = 0
for f in self.ListDirectory(request.pathspec):
self.Progress()
if not any((check(f) for check in filters)):
self.SendReply(f)
files_checked += 1
if files_checked >= self.MAX_FILES_TO_CHECK:
return | module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier integer for_statement identifier call attribute identifier identifier argument_list attribute identifier identifier block expression_statement call attribute identifier identifier argument_list if_statement not_operator call identifier argument_list generator_expression call identifier argument_list identifier for_in_clause identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement augmented_assignment identifier integer if_statement comparison_operator identifier attribute identifier identifier block return_statement | Runs the Find action. |
def stack_push(self, thing):
sp = self.regs.sp + self.arch.stack_change
self.regs.sp = sp
return self.memory.store(sp, thing, endness=self.arch.memory_endness) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier binary_operator attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier expression_statement assignment attribute attribute identifier identifier identifier identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier | Push 'thing' to the stack, writing the thing to memory and adjusting the stack pointer. |
def pop_result(self, key):
self.pending_callbacks.remove(key)
return self.results.pop(key) | module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier | Returns the result for ``key`` and unregisters it. |
def _convert_trigger(self, trigger_def, parent):
if trigger_def.explicit_stream is None:
stream = parent.resolve_identifier(trigger_def.named_event, DataStream)
trigger = TrueTrigger()
else:
stream = trigger_def.explicit_stream
trigger = trigger_def.explicit_trigger
return (stream, trigger) | module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list else_clause block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier return_statement tuple identifier identifier | Convert a TriggerDefinition into a stream, trigger pair. |
def filter_query(self, query):
for filter_class in list(self.filter_classes):
query = filter_class().filter_query(self.request, query, self)
return query | module function_definition identifier parameters identifier identifier block for_statement identifier call identifier argument_list attribute identifier identifier block expression_statement assignment identifier call attribute call identifier argument_list identifier argument_list attribute identifier identifier identifier identifier return_statement identifier | Filter the given query using the filter classes specified on the view if any are specified. |
def _get_verdict(result):
verdict = result.get("verdict")
if not verdict:
return None
verdict = verdict.strip().lower()
if verdict not in Verdicts.PASS + Verdicts.FAIL + Verdicts.SKIP + Verdicts.WAIT:
return None
return verdict | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement not_operator identifier block return_statement none expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list if_statement comparison_operator identifier binary_operator binary_operator binary_operator attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier block return_statement none return_statement identifier | Gets verdict of the testcase. |
def subnet_create_event(self, subnet_info):
subnet = subnet_info.get('subnet')
if subnet:
self.create_subnet(subnet)
else:
subnets = subnet_info.get('subnets')
if subnets:
for subnet in subnets:
self.create_subnet(subnet) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement identifier block for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier | Process subnet create event. |
def parse_MML(self, mml):
hashes_c = []
mentions_c = []
soup = BeautifulSoup(mml, "lxml")
hashes = soup.find_all('hash', {"tag": True})
for hashe in hashes:
hashes_c.append(hashe['tag'])
mentions = soup.find_all('mention', {"uid": True})
for mention in mentions:
mentions_c.append(mention['uid'])
msg_string = soup.messageml.text.strip()
self.logger.debug('%s : %s : %s' % (hashes_c, mentions_c, msg_string))
return hashes_c, mentions_c, msg_string | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list expression_statement assignment identifier list expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end dictionary pair string string_start string_content string_end true for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end dictionary pair string string_start string_content string_end true for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier identifier return_statement expression_list identifier identifier identifier | parse the MML structure |
def _create_hidden_port(self, context, network_id, device_id, fixed_ips,
port_type=DEVICE_OWNER_ROUTER_INTF):
port = {'port': {
'tenant_id': '',
'network_id': network_id,
'mac_address': ATTR_NOT_SPECIFIED,
'fixed_ips': fixed_ips,
'device_id': device_id,
'device_owner': port_type,
'admin_state_up': True,
'name': ''}}
if extensions.is_extension_supported(self._core_plugin,
"dns-integration"):
port['port'].update(dns_name='')
core_plugin = bc.get_plugin()
return core_plugin.create_port(context, port) | module function_definition identifier parameters identifier identifier identifier identifier identifier default_parameter identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end dictionary pair string string_start string_content string_end string string_start string_end pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end true pair string string_start string_content string_end string string_start string_end if_statement call attribute identifier identifier argument_list attribute identifier identifier string string_start string_content string_end block expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list keyword_argument identifier string string_start string_end expression_statement assignment identifier call attribute identifier identifier argument_list return_statement call attribute identifier identifier argument_list identifier identifier | Creates port used specially for HA purposes. |
def _get_val(record, keys):
data = record
for key in keys:
if key in data:
data = data[key]
else:
return None
return data | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier identifier for_statement identifier identifier block if_statement comparison_operator identifier identifier block expression_statement assignment identifier subscript identifier identifier else_clause block return_statement none return_statement identifier | Internal, get value from record |
def fit_transform(self,
X,
num_epochs=10,
updates_epoch=10,
stop_param_updates=dict(),
batch_size=1,
show_progressbar=False,
show_epoch=False):
self.fit(X,
num_epochs,
updates_epoch,
stop_param_updates,
batch_size,
show_progressbar,
show_epoch)
return self.transform(X, batch_size=batch_size) | module function_definition identifier parameters identifier identifier default_parameter identifier integer default_parameter identifier integer default_parameter identifier call identifier argument_list default_parameter identifier integer default_parameter identifier false default_parameter identifier false block expression_statement call attribute identifier identifier argument_list identifier identifier identifier identifier identifier identifier identifier return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier | First fit, then transform. |
def convert_relational(relational):
rel = relational.rel_op
if rel in ['==', '>=', '>']:
return relational.lhs-relational.rhs
elif rel in ['<=', '<']:
return relational.rhs-relational.lhs
else:
raise Exception("The relational operation ' + rel + ' is not "
"implemented!") | module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block return_statement binary_operator attribute identifier identifier attribute identifier identifier elif_clause comparison_operator identifier list string string_start string_content string_end string string_start string_content string_end block return_statement binary_operator attribute identifier identifier attribute identifier identifier else_clause block raise_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end | Convert all inequalities to >=0 form. |
def collection(data, bins=10, *args, **kwargs):
from physt.histogram_collection import HistogramCollection
if hasattr(data, "columns"):
data = {column: data[column] for column in data.columns}
return HistogramCollection.multi_h1(data, bins, **kwargs) | module function_definition identifier parameters identifier default_parameter identifier integer list_splat_pattern identifier dictionary_splat_pattern identifier block import_from_statement dotted_name identifier identifier dotted_name identifier if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier dictionary_comprehension pair identifier subscript identifier identifier for_in_clause identifier attribute identifier identifier return_statement call attribute identifier identifier argument_list identifier identifier dictionary_splat identifier | Create histogram collection with shared binnning. |
def verify_cert(self):
log.debug('Verifying the %s certificate, keyfile: %s',
self.certificate, self.keyfile)
try:
ssl.create_default_context().load_cert_chain(self.certificate, keyfile=self.keyfile)
except ssl.SSLError:
error_string = 'SSL certificate and key do not match'
log.error(error_string)
raise SSLMismatchException(error_string)
except IOError:
log.error('Unable to open either certificate or key file')
raise
log.debug('Certificate looks good.') | module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier attribute identifier identifier try_statement block expression_statement call attribute call attribute identifier identifier argument_list identifier argument_list attribute identifier identifier keyword_argument identifier attribute identifier identifier except_clause attribute identifier identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier raise_statement call identifier argument_list identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end raise_statement expression_statement call attribute identifier identifier argument_list string string_start string_content string_end | Checks that the provided cert and key are valid and usable |
def import_object(path):
spl = path.split('.')
if len(spl) == 1:
return importlib.import_module(path)
cls = spl[-1]
mods = '.'.join(spl[:-1])
mm = importlib.import_module(mods)
try:
obj = getattr(mm, cls)
return obj
except AttributeError:
pass
rr = importlib.import_module(path)
return rr | 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 comparison_operator call identifier argument_list identifier integer block return_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier subscript identifier unary_operator integer expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list subscript identifier slice unary_operator integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier try_statement block expression_statement assignment identifier call identifier argument_list identifier identifier return_statement identifier except_clause identifier block pass_statement expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement identifier | Import an object given its fully qualified name. |
def map_id(self,id, prefix, closure_list):
prefixc = prefix + ':'
ids = [eid for eid in closure_list if eid.startswith(prefixc)]
if len(ids) == 0:
return id
return ids[0] | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier binary_operator identifier string string_start string_content string_end expression_statement assignment identifier list_comprehension identifier for_in_clause identifier identifier if_clause call attribute identifier identifier argument_list identifier if_statement comparison_operator call identifier argument_list identifier integer block return_statement identifier return_statement subscript identifier integer | Map identifiers based on an equivalence closure list. |
def _gen_get_more_command(cursor_id, coll, batch_size, max_await_time_ms):
cmd = SON([('getMore', cursor_id),
('collection', coll)])
if batch_size:
cmd['batchSize'] = batch_size
if max_await_time_ms is not None:
cmd['maxTimeMS'] = max_await_time_ms
return cmd | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list list tuple string string_start string_content string_end identifier tuple string string_start string_content string_end identifier if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier if_statement comparison_operator identifier none block expression_statement assignment subscript identifier string string_start string_content string_end identifier return_statement identifier | Generate a getMore command document. |
def processing_block_list():
pb_list = ProcessingBlockList()
return dict(active=pb_list.active,
completed=pb_list.completed,
aborted=pb_list.aborted) | module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list return_statement call identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier | Return the list of processing blocks known to SDP. |
def comments(self, extra_params=None):
params = {
'per_page': settings.MAX_PER_PAGE,
}
if extra_params:
params.update(extra_params)
return self.api._get_json(
TicketComment,
space=self,
rel_path=self.space._build_rel_path(
'tickets/%s/ticket_comments' % self['number']
),
extra_params=params,
get_all=True,
) | module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier dictionary pair string string_start string_content string_end attribute identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end subscript identifier string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier true | All Comments in this Ticket |
def arg_to_json(arg):
conversion = json_conversions.get(type(arg))
if conversion:
return conversion(arg)
for type_ in subclass_conversions:
if isinstance(arg, type_):
return json_conversions[type_](arg)
return json_conversions[str](arg) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list identifier if_statement identifier block return_statement call identifier argument_list identifier for_statement identifier identifier block if_statement call identifier argument_list identifier identifier block return_statement call subscript identifier identifier argument_list identifier return_statement call subscript identifier identifier argument_list identifier | Perform necessary JSON conversion on the arg. |
def row2table(soup, table, row):
tr = Tag(soup, name="tr")
table.append(tr)
for attr in row:
td = Tag(soup, name="td")
tr.append(td)
td.append(attr) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list identifier keyword_argument 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 identifier | ad a row to the table |
def display_dataset(self):
header = self.dataset.header
self.parent.setWindowTitle(basename(self.filename))
short_filename = short_strings(basename(self.filename))
self.idx_filename.setText(short_filename)
self.idx_s_freq.setText(str(header['s_freq']))
self.idx_n_chan.setText(str(len(header['chan_name'])))
start_time = header['start_time'].strftime('%b-%d %H:%M:%S')
self.idx_start_time.setText(start_time)
end_time = (header['start_time'] +
timedelta(seconds=header['n_samples'] / header['s_freq']))
self.idx_end_time.setText(end_time.strftime('%b-%d %H:%M:%S')) | module function_definition identifier parameters identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list attribute identifier identifier expression_statement assignment identifier call identifier argument_list call identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list subscript identifier string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list call identifier argument_list subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier parenthesized_expression binary_operator subscript identifier string string_start string_content string_end call identifier argument_list keyword_argument identifier binary_operator subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end | Update the widget with information about the dataset. |
def gc_stop():
global gc_thread
if gc_thread:
log.info("Shutting down GC thread")
gc_thread.signal_stop()
gc_thread.join()
log.info("GC thread joined")
gc_thread = None
else:
log.info("GC thread already joined") | module function_definition identifier parameters block global_statement identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier none else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end | Stop a the optimistic GC thread |
def pub_poll(request, docid):
try:
r = flat.comm.get(request, '/poll/pub/' + docid + '/', False)
except URLError:
return HttpResponseForbidden("Unable to connect to the document server [viewer/poll]")
return HttpResponse(r, content_type='application/json') | module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier binary_operator binary_operator string string_start string_content string_end identifier string string_start string_content string_end false except_clause identifier block return_statement call identifier argument_list string string_start string_content string_end return_statement call identifier argument_list identifier keyword_argument identifier string string_start string_content string_end | The initial viewer, does not provide the document content yet |
def logs(self):
if not self.parent.loaded: self.parent.load()
logs = self.parent.p.logs_dir.flat_directories
logs.sort(key=lambda x: x.mod_time)
return logs | module function_definition identifier parameters identifier block if_statement not_operator attribute attribute identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier attribute attribute attribute attribute identifier identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier lambda lambda_parameters identifier attribute identifier identifier return_statement identifier | Find the log directory and return all the logs sorted. |
def create_index(config):
filename = pathlib.Path(config.cache_path) / "index.json"
index = {"version": __version__}
with open(filename, "w") as out:
out.write(json.dumps(index, indent=2)) | module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier integer | Create the root index. |
def _update_events(self):
events = self._skybell.dev_cache(self, CONST.EVENT) or {}
for activity in self._activities:
event = activity.get(CONST.EVENT)
created_at = activity.get(CONST.CREATED_AT)
old_event = events.get(event)
if old_event and created_at < old_event.get(CONST.CREATED_AT):
continue
else:
events[event] = activity
self._skybell.update_dev_cache(
self,
{
CONST.EVENT: events
}) | module function_definition identifier parameters identifier block expression_statement assignment identifier boolean_operator call attribute attribute identifier identifier identifier argument_list identifier attribute identifier identifier dictionary for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement boolean_operator identifier comparison_operator identifier call attribute identifier identifier argument_list attribute identifier identifier block continue_statement else_clause block expression_statement assignment subscript identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier dictionary pair attribute identifier identifier identifier | Update our cached list of latest activity events. |
def fetch(self):
entries = []
for activity in self.activities['entries']:
entries.append(
[element for element in [activity['title'],
activity['content'][0]['value']]])
return entries[0:self.max_entries] | module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier subscript attribute identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list list_comprehension identifier for_in_clause identifier list subscript identifier string string_start string_content string_end subscript subscript subscript identifier string string_start string_content string_end integer string string_start string_content string_end return_statement subscript identifier slice integer attribute identifier identifier | returns a list of html snippets fetched from github actitivy feed |
def to_escpos(self):
cmd = ''
ordered_cmds = self.cmds.keys()
ordered_cmds.sort(lambda x,y: cmp(self.cmds[x]['_order'], self.cmds[y]['_order']))
for style in ordered_cmds:
cmd += self.cmds[style][self.get(style)]
return cmd | module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list lambda lambda_parameters identifier identifier call identifier argument_list subscript subscript attribute identifier identifier identifier string string_start string_content string_end subscript subscript attribute identifier identifier identifier string string_start string_content string_end for_statement identifier identifier block expression_statement augmented_assignment identifier subscript subscript attribute identifier identifier identifier call attribute identifier identifier argument_list identifier return_statement identifier | converts the current style to an escpos command string |
def update(self, f):
for p in self.__mapper__.attrs:
if p.key == 'oid':
continue
try:
setattr(self, p.key, getattr(f, p.key))
except AttributeError:
continue | module function_definition identifier parameters identifier identifier block for_statement identifier attribute attribute identifier identifier identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block continue_statement try_statement block expression_statement call identifier argument_list identifier attribute identifier identifier call identifier argument_list identifier attribute identifier identifier except_clause identifier block continue_statement | Copy another files properties into this one. |
def extract_lzma(archive, compression, cmd, verbosity, interactive, outdir):
return _extract(archive, compression, cmd, 'alone', verbosity, outdir) | module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block return_statement call identifier argument_list identifier identifier identifier string string_start string_content string_end identifier identifier | Extract an LZMA archive with the lzma Python module. |
def _default_hparams():
return hparam.HParams(
loss_multiplier=1.0,
batch_size_multiplier=1,
stop_at_eos=False,
modality={},
vocab_size={},
input_space_id=SpaceID.GENERIC,
target_space_id=SpaceID.GENERIC) | module function_definition identifier parameters block return_statement call attribute identifier identifier argument_list keyword_argument identifier float keyword_argument identifier integer keyword_argument identifier false keyword_argument identifier dictionary keyword_argument identifier dictionary keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier | A set of basic model hyperparameters. |
def lines2mecab(lines, **kwargs):
sents = []
for line in lines:
sent = txt2mecab(line, **kwargs)
sents.append(sent)
return sents | module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list identifier dictionary_splat identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | Use mecab to parse many lines |
def on_backward_begin(self, smooth_loss:Tensor, **kwargs:Any)->None:
"Record the loss before any other callback has a chance to modify it."
self.losses.append(smooth_loss)
if self.pbar is not None and hasattr(self.pbar,'child'):
self.pbar.child.comment = f'{smooth_loss:.4f}' | module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter dictionary_splat_pattern identifier type identifier type none block expression_statement string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list identifier if_statement boolean_operator comparison_operator attribute identifier identifier none call identifier argument_list attribute identifier identifier string string_start string_content string_end block expression_statement assignment attribute attribute attribute identifier identifier identifier identifier string string_start interpolation identifier format_specifier string_end | Record the loss before any other callback has a chance to modify it. |
def setOrderedRegisterNumbers(order, start):
for i, node in enumerate(order):
node.reg.n = start + i
return start + len(order) | module function_definition identifier parameters identifier identifier block for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement assignment attribute attribute identifier identifier identifier binary_operator identifier identifier return_statement binary_operator identifier call identifier argument_list identifier | Given an order of nodes, assign register numbers. |
def revoke_token(self, token, headers=None, **kwargs):
self._check_configuration("site", "revoke_uri")
url = "%s%s" % (self.site, quote(self.revoke_url))
data = {'token': token}
data.update(kwargs)
return self._make_request(url, data=data, headers=headers) | module function_definition identifier parameters identifier identifier default_parameter identifier none dictionary_splat_pattern identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier binary_operator string string_start string_content string_end tuple attribute identifier identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier | Revoke an access token |
def GetValuesForAttribute(self, attribute, only_one=False):
if not only_one and self.age_policy == NEWEST_TIME:
raise ValueError("Attempting to read all attribute versions for an "
"object opened for NEWEST_TIME. This is probably "
"not what you want.")
if attribute is None:
return []
elif isinstance(attribute, string_types):
attribute = Attribute.GetAttributeByName(attribute)
return attribute.GetValues(self) | module function_definition identifier parameters identifier identifier default_parameter identifier false block if_statement boolean_operator not_operator identifier comparison_operator attribute identifier identifier identifier block raise_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end if_statement comparison_operator identifier none block return_statement list elif_clause call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier | Returns a list of values from this attribute. |
def Get(self):
args = user_pb2.ApiGetHuntApprovalArgs(
hunt_id=self.hunt_id,
approval_id=self.approval_id,
username=self.username)
result = self._context.SendRequest("GetHuntApproval", args)
return HuntApproval(
data=result, username=self._context.username, context=self._context) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier return_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier attribute identifier identifier | Fetch and return a proper HuntApproval object. |
def dump(self, file, sort_keys: bool = True, **kwargs) -> None:
json.dump(self.to_json(), file, sort_keys=sort_keys, **kwargs) | module function_definition identifier parameters identifier identifier typed_default_parameter identifier type identifier true dictionary_splat_pattern identifier type none block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier identifier dictionary_splat identifier | Dump this seeding container to a file as JSON. |
def aws_env_args(subparsers):
env_parser = subparsers.add_parser('aws_environment')
env_parser.add_argument('vault_path',
help='Full path(s) to the AWS secret')
export_arg(env_parser)
base_args(env_parser) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement 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 identifier argument_list identifier expression_statement call identifier argument_list identifier | Add command line options for the aws_environment operation |
def merge(self, frame):
for column, values in frame.iteritems():
counter = self._counters.get(column)
for value in values:
if counter is not None:
counter.merge(value) | module function_definition identifier parameters identifier identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier for_statement identifier identifier block if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list identifier | Add another DataFrame to the PStatCounter. |
def RunSphinxAPIDoc(_):
current_directory = os.path.abspath(os.path.dirname(__file__))
module = os.path.join(current_directory, '..', 'plaso')
api_directory = os.path.join(current_directory, 'sources', 'api')
apidoc.main(['-o', api_directory, module, '--force']) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list list string string_start string_content string_end identifier identifier string string_start string_content string_end | Runs sphinx-apidoc to auto-generate documentation. |
def config_at(self, i):
selections = {}
for key in self.store:
value = self.store[key]
if isinstance(value, list):
selected = i % len(value)
i = i // len(value)
selections[key]= value[selected]
else:
selections[key]= value
return Config(selections) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary for_statement identifier attribute identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier identifier if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier binary_operator identifier call identifier argument_list identifier expression_statement assignment identifier binary_operator identifier call identifier argument_list identifier expression_statement assignment subscript identifier identifier subscript identifier identifier else_clause block expression_statement assignment subscript identifier identifier identifier return_statement call identifier argument_list identifier | Gets the ith config |
def retrieve_authorization_code(self, redirect_func=None):
request_param = {
"client_id": self.client_id,
"redirect_uri": self.redirect_uri,
}
if self.scope:
request_param['scope'] = self.scope
if self._extra_auth_params:
request_param.update(self._extra_auth_params)
r = requests.get(self.auth_uri, params=request_param,
allow_redirects=False)
url = r.headers.get('location')
if self.local:
webbrowser.open_new_tab(url)
authorization_code = raw_input("Code: ")
if self.validate_code(authorization_code):
self.authorization_code = authorization_code
else:
return redirect_func(url) | module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier dictionary pair string string_start string_content string_end attribute identifier identifier pair 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 if_statement attribute 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 keyword_argument identifier identifier keyword_argument identifier false expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list string string_start string_content string_end if_statement call attribute identifier identifier argument_list identifier block expression_statement assignment attribute identifier identifier identifier else_clause block return_statement call identifier argument_list identifier | retrieve authorization code to get access token |
def add(self, name, desc, func=None, args=None, krgs=None):
self.entries.append(MenuEntry(name, desc, func, args or [], krgs or {})) | module function_definition identifier parameters identifier identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier identifier identifier boolean_operator identifier list boolean_operator identifier dictionary | Add a menu entry. |
def _get_distance_scaling_term(self, C, rval, mag):
r_adj = np.sqrt(rval ** 2.0 + C["h"] ** 2.0)
return (
(C["c1"] + C["c2"] * (mag - self.CONSTS["Mref"])) *
np.log10(r_adj / self.CONSTS["Rref"]) -
(C["c3"] * (r_adj - self.CONSTS["Rref"]))) | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator binary_operator identifier float binary_operator subscript identifier string string_start string_content string_end float return_statement parenthesized_expression binary_operator binary_operator parenthesized_expression binary_operator subscript identifier string string_start string_content string_end binary_operator subscript identifier string string_start string_content string_end parenthesized_expression binary_operator identifier subscript attribute identifier identifier string string_start string_content string_end call attribute identifier identifier argument_list binary_operator identifier subscript attribute identifier identifier string string_start string_content string_end parenthesized_expression binary_operator subscript identifier string string_start string_content string_end parenthesized_expression binary_operator identifier subscript attribute identifier identifier string string_start string_content string_end | Returns the distance scaling term of the GMPE described in equation 2 |
def laea2cf(area):
proj_dict = area.proj_dict
args = dict(latitude_of_projection_origin=proj_dict.get('lat_0'),
longitude_of_projection_origin=proj_dict.get('lon_0'),
grid_mapping_name='lambert_azimuthal_equal_area',
)
return args | module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end return_statement identifier | Return the cf grid mapping for the laea projection. |
def install_virtualenv_p3(root, python_version):
import venv
builder = venv.EnvBuilder(system_site_packages=False, clear=True, symlinks=False, upgrade=False)
builder.create(root)
ret_code = subprocess.call([VE_SCRIPT, PROJECT_ROOT, root, python_version])
sys.exit(ret_code) | module function_definition identifier parameters identifier identifier block import_statement dotted_name identifier expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier false keyword_argument identifier true keyword_argument identifier false keyword_argument identifier false expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list list identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier | Install virtual environment for Python 3.3+; removing the old one if it exists |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.