code stringlengths 51 2.34k | sequence stringlengths 186 3.94k | docstring stringlengths 11 171 |
|---|---|---|
def get(self, r):
if r is None:
return None
if r.lower() == '(sp)' and self.stack:
return self.stack[-1]
if r[:1] == '(':
return self.mem[r[1:-1]]
r = r.lower()
if is_number(r):
return str(valnum(r))
if not is_register(r):
return None
return self.regs[r] | module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier none block return_statement none if_statement boolean_operator comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier block return_statement subscript attribute identifier identifier unary_operator integer if_statement comparison_operator subscript identifier slice integer string string_start string_content string_end block return_statement subscript attribute identifier identifier subscript identifier slice integer unary_operator integer expression_statement assignment identifier call attribute identifier identifier argument_list if_statement call identifier argument_list identifier block return_statement call identifier argument_list call identifier argument_list identifier if_statement not_operator call identifier argument_list identifier block return_statement none return_statement subscript attribute identifier identifier identifier | Returns precomputed value of the given expression |
def _parse_authors(element):
authors = []
items = element.findall("./{%s}author" % WP_NAMESPACE)
for item in items:
login = item.find("./{%s}author_login" % WP_NAMESPACE).text
email = item.find("./{%s}author_email" % WP_NAMESPACE).text
first_name = item.find("./{%s}author_first_name" % WP_NAMESPACE).text
last_name = item.find("./{%s}author_last_name" % WP_NAMESPACE).text
display_name = item.find(
"./{%s}author_display_name" % WP_NAMESPACE).text
authors.append({
"login": login,
"email": email,
"display_name": display_name,
"first_name": first_name,
"last_name": last_name
})
return authors | module function_definition identifier parameters identifier block expression_statement assignment identifier list expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier for_statement identifier identifier block expression_statement assignment identifier attribute call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier identifier expression_statement assignment identifier attribute call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier identifier expression_statement assignment identifier attribute call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier identifier expression_statement assignment identifier attribute call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier identifier expression_statement assignment identifier attribute call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier identifier expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier return_statement identifier | Returns a well formatted list of users that can be matched against posts. |
def use_isolated_bin_view(self):
self._bin_view = ISOLATED
for session in self._get_provider_sessions():
try:
session.use_isolated_bin_view()
except AttributeError:
pass | module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier identifier for_statement identifier call attribute identifier identifier argument_list block try_statement block expression_statement call attribute identifier identifier argument_list except_clause identifier block pass_statement | Pass through to provider ResourceLookupSession.use_isolated_bin_view |
def create_contact(self, email=None, first_name=None, last_name=None, phone_number=None):
result = {}
if email:
result['email'] = email
if first_name is not None:
result['first_name'] = first_name
if last_name is not None:
result['last_name'] = last_name
if phone_number is not None:
result['phone_number'] = phone_number
return result if len(result) > 0 else None | module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier dictionary 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 if_statement comparison_operator identifier none 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 conditional_expression identifier comparison_operator call identifier argument_list identifier integer none | Create a contant which is later passed to payment. |
def find_files(self):
for path in self.paths:
for subpath, dirs, files in os.walk(path):
for filename in files:
(name, ext) = os.path.splitext(filename)
if ext in self.extensions:
yield os.path.join(subpath, filename) | module function_definition identifier parameters identifier block for_statement identifier attribute identifier identifier block for_statement pattern_list identifier identifier identifier call attribute identifier identifier argument_list identifier block for_statement identifier identifier block expression_statement assignment tuple_pattern identifier identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator identifier attribute identifier identifier block expression_statement yield call attribute attribute identifier identifier identifier argument_list identifier identifier | Find files in `paths` which match valid extensions |
def info(self, *args) -> "Err":
error = self._create_err("info", *args)
print(self._errmsg(error))
return error | module function_definition identifier parameters identifier list_splat_pattern identifier type string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end list_splat identifier expression_statement call identifier argument_list call attribute identifier identifier argument_list identifier return_statement identifier | Creates an info message |
def run(self):
if not self._readGroupIds:
for referenceGroupId in self.getAllReadGroups():
self._run(referenceGroupId)
else:
for referenceGroupId in self._readGroupIds:
self._run(referenceGroupId) | module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block for_statement identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier else_clause block for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier | Iterate passed read group ids, or go through all available read groups |
def prepare(self):
for item in self.items():
if isinstance(item, XWalkthroughGraphic):
item.prepare() | module function_definition identifier parameters identifier block for_statement identifier call attribute identifier identifier argument_list block if_statement call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list | Prepares the items for display. |
def dump_to_log(self, logger):
logger.error("Execution ended in %s for cmd %s", self._retcode, self._cmd)
for line in self._collected_stdout:
logger.error(STDOUT_LOG_PREFIX + line) | module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier attribute identifier identifier for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator identifier identifier | Send the cmd info and collected stdout to logger. |
def all_internal_calls(self):
if self._all_internals_calls is None:
self._all_internals_calls = self._explore_functions(lambda x: x.internal_calls)
return self._all_internals_calls | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list lambda lambda_parameters identifier attribute identifier identifier return_statement attribute identifier identifier | recursive version of internal_calls |
def add_task_file_manager(self, task_file_manager):
if not self._loaded:
raise PluginManagerNotLoadedException()
self._task_factory.add_custom_task_file_manager(task_file_manager) | module function_definition identifier parameters identifier identifier block if_statement not_operator attribute identifier identifier block raise_statement call identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list identifier | Add a task file manager. Only available after that the Plugin Manager is loaded |
def save_waypoints_csv(self, filename):
try:
self.wploader.savecsv(filename.strip('"'))
except Exception as msg:
print("Failed to save %s - %s" % (filename, msg))
return
print("Saved %u waypoints to CSV %s" % (self.wploader.count(), filename)) | module function_definition identifier parameters identifier identifier block try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list 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 identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier return_statement expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple call attribute attribute identifier identifier identifier argument_list identifier | save waypoints to a file in a human readable CSV file |
def convertLengthList(self, svgAttr):
return [self.convertLength(a) for a in self.split_attr_list(svgAttr)] | module function_definition identifier parameters identifier identifier block return_statement list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier call attribute identifier identifier argument_list identifier | Convert a list of lengths. |
def parse_string(self, string):
lines = string.split('\n')
reader = vimlparser.StringReader(lines)
parser = vimlparser.VimLParser(self._enable_neovim)
ast = parser.parse(reader)
ast['pos'] = {'col': 1, 'i': 0, 'lnum': 1}
for plugin in self.plugins:
plugin.process(ast)
return ast | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end expression_statement assignment identifier call attribute identifier identifier argument_list 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 expression_statement assignment subscript identifier string string_start string_content string_end dictionary pair string string_start string_content string_end integer pair string string_start string_content string_end integer pair string string_start string_content string_end integer for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | Parse vim script string and return the AST. |
def _get_representative(self, obj):
if obj not in self._parents:
self._parents[obj] = obj
self._weights[obj] = 1
self._prev_next[obj] = [obj, obj]
self._min_values[obj] = obj
return obj
path = [obj]
root = self._parents[obj]
while root != path[-1]:
path.append(root)
root = self._parents[root]
for ancestor in path:
self._parents[ancestor] = root
return root | module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier identifier expression_statement assignment subscript attribute identifier identifier identifier integer expression_statement assignment subscript attribute identifier identifier identifier list identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier return_statement identifier expression_statement assignment identifier list identifier expression_statement assignment identifier subscript attribute identifier identifier identifier while_statement comparison_operator identifier subscript identifier unary_operator integer block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier subscript attribute identifier identifier identifier for_statement identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier identifier return_statement identifier | Finds and returns the root of the set containing `obj`. |
def software_fibonacci(n):
a, b = 0, 1
for i in range(n):
a, b = b, a + b
return a | module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier expression_list integer integer for_statement identifier call identifier argument_list identifier block expression_statement assignment pattern_list identifier identifier expression_list identifier binary_operator identifier identifier return_statement identifier | a normal old python function to return the Nth fibonacci number. |
def install(self, binder, module):
ModuleAdapter(module, self._injector).configure(binder) | module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute call identifier argument_list identifier attribute identifier identifier identifier argument_list identifier | Add another module's bindings to a binder. |
def basic_critic(in_size:int, n_channels:int, n_features:int=64, n_extra_layers:int=0, **conv_kwargs):
"A basic critic for images `n_channels` x `in_size` x `in_size`."
layers = [conv_layer(n_channels, n_features, 4, 2, 1, leaky=0.2, norm_type=None, **conv_kwargs)]
cur_size, cur_ftrs = in_size//2, n_features
layers.append(nn.Sequential(*[conv_layer(cur_ftrs, cur_ftrs, 3, 1, leaky=0.2, **conv_kwargs) for _ in range(n_extra_layers)]))
while cur_size > 4:
layers.append(conv_layer(cur_ftrs, cur_ftrs*2, 4, 2, 1, leaky=0.2, **conv_kwargs))
cur_ftrs *= 2 ; cur_size //= 2
layers += [conv2d(cur_ftrs, 1, 4, padding=0), AvgFlatten()]
return nn.Sequential(*layers) | module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type identifier typed_default_parameter identifier type identifier integer typed_default_parameter identifier type identifier integer dictionary_splat_pattern identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier list call identifier argument_list identifier identifier integer integer integer keyword_argument identifier float keyword_argument identifier none dictionary_splat identifier expression_statement assignment pattern_list identifier identifier expression_list binary_operator identifier integer identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list list_splat list_comprehension call identifier argument_list identifier identifier integer integer keyword_argument identifier float dictionary_splat identifier for_in_clause identifier call identifier argument_list identifier while_statement comparison_operator identifier integer block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier binary_operator identifier integer integer integer integer keyword_argument identifier float dictionary_splat identifier expression_statement augmented_assignment identifier integer expression_statement augmented_assignment identifier integer expression_statement augmented_assignment identifier list call identifier argument_list identifier integer integer keyword_argument identifier integer call identifier argument_list return_statement call attribute identifier identifier argument_list list_splat identifier | A basic critic for images `n_channels` x `in_size` x `in_size`. |
def first(self) -> "QuerySet":
queryset = self._clone()
queryset._limit = 1
queryset._single = True
return queryset | module function_definition identifier parameters identifier type string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier true return_statement identifier | Limit queryset to one object and return one object instead of list. |
def sortby(self, ntd):
if 'reldepth' in self.grprobj.gosubdag.prt_attr['flds']:
return [ntd.NS, -1*ntd.dcnt, ntd.reldepth]
else:
return [ntd.NS, -1*ntd.dcnt, ntd.depth] | module function_definition identifier parameters identifier identifier block if_statement comparison_operator string string_start string_content string_end subscript attribute attribute attribute identifier identifier identifier identifier string string_start string_content string_end block return_statement list attribute identifier identifier binary_operator unary_operator integer attribute identifier identifier attribute identifier identifier else_clause block return_statement list attribute identifier identifier binary_operator unary_operator integer attribute identifier identifier attribute identifier identifier | Return function for sorting. |
def _reader_thread_proc(self, timeout):
for data in self.stream.read_until_close(timeout_ms=timeout):
if self.stdout is not None:
self.stdout.write(data) | module function_definition identifier parameters identifier identifier block for_statement identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list identifier | Read until the stream is closed. |
def mutate(self, node, index):
assert index < len(OFFSETS), 'received count with no associated offset'
assert isinstance(node, parso.python.tree.Number)
val = eval(node.value) + OFFSETS[index]
return parso.python.tree.Number(' ' + str(val), node.start_pos) | module function_definition identifier parameters identifier identifier identifier block assert_statement comparison_operator identifier call identifier argument_list identifier string string_start string_content string_end assert_statement call identifier argument_list identifier attribute attribute attribute identifier identifier identifier identifier expression_statement assignment identifier binary_operator call identifier argument_list attribute identifier identifier subscript identifier identifier return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier attribute identifier identifier | Modify the numeric value on `node`. |
def clean(self, initial_epoch):
self.db.metrics.delete_many({'run_name': self.model_config.run_name, 'epoch_idx': {'$gt': initial_epoch}}) | module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list dictionary pair string string_start string_content string_end attribute attribute identifier identifier identifier pair string string_start string_content string_end dictionary pair string string_start string_content string_end identifier | Remove entries from database that would get overwritten |
def write_extra_resources(self, compile_context):
target = compile_context.target
if isinstance(target, ScalacPlugin):
self._write_scalac_plugin_info(compile_context.classes_dir.path, target)
elif isinstance(target, JavacPlugin):
self._write_javac_plugin_info(compile_context.classes_dir.path, target)
elif isinstance(target, AnnotationProcessor) and target.processors:
processor_info_file = os.path.join(compile_context.classes_dir.path, _PROCESSOR_INFO_FILE)
self._write_processor_info(processor_info_file, target.processors) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier if_statement call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list attribute attribute identifier identifier identifier identifier elif_clause call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list attribute attribute identifier identifier identifier identifier elif_clause boolean_operator call identifier argument_list identifier identifier attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier | Override write_extra_resources to produce plugin and annotation processor files. |
def stem(self, text):
stemmed_text = ''
for word in text.split(' '):
if word not in self.stops:
word, in_que_pass_list = self._checkremove_que(word)
if not in_que_pass_list:
word, was_stemmed = self._matchremove_simple_endings(word)
if not was_stemmed:
word = self._matchremove_verb_endings(word)
stemmed_text += word + ' '
return stemmed_text | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier string string_start string_end for_statement identifier call attribute identifier identifier argument_list string string_start string_content string_end block if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier if_statement not_operator identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier if_statement not_operator identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement augmented_assignment identifier binary_operator identifier string string_start string_content string_end return_statement identifier | Stem each word of the Latin text. |
def decision_list(n_leaves):
def _list(leaves):
if len(leaves) == 2:
return (leaves[0], leaves[1])
else:
return (leaves[0], _list(leaves[1:]))
return _list(np.arange(n_leaves)) | module function_definition identifier parameters identifier block function_definition identifier parameters identifier block if_statement comparison_operator call identifier argument_list identifier integer block return_statement tuple subscript identifier integer subscript identifier integer else_clause block return_statement tuple subscript identifier integer call identifier argument_list subscript identifier slice integer return_statement call identifier argument_list call attribute identifier identifier argument_list identifier | Create a decision list |
def _backup_pb_tqdm(self, dirs):
with ZipFile(self.zip_filename, 'w') as backup_zip:
for path in tqdm(dirs, desc='Writing Zip Files', total=len(dirs)):
backup_zip.write(path, path[len(self.source):len(path)]) | module function_definition identifier parameters identifier identifier block with_statement with_clause with_item as_pattern call identifier argument_list attribute identifier identifier string string_start string_content string_end as_pattern_target identifier block for_statement identifier call identifier argument_list identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier subscript identifier slice call identifier argument_list attribute identifier identifier call identifier argument_list identifier | Create a backup with a tqdm progress bar. |
def filter(self, run_counts, criteria):
wrong_confidence = criteria['wrong_confidence']
below_t = wrong_confidence <= self.t
filtered_counts = deep_copy(run_counts)
for key in filtered_counts:
filtered_counts[key] = filtered_counts[key][below_t]
return filtered_counts | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier comparison_operator identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier for_statement identifier identifier block expression_statement assignment subscript identifier identifier subscript subscript identifier identifier identifier return_statement identifier | Return the counts for only those examples that are below the threshold |
def device_unmounted(self, device):
if not self._mounter.is_handleable(device):
return
self._show_notification(
'device_unmounted',
_('Device unmounted'),
_('{0.ui_label} unmounted', device),
device.icon_name) | module function_definition identifier parameters identifier identifier block if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block return_statement expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list string string_start string_content string_end call identifier argument_list string string_start string_content string_end identifier attribute identifier identifier | Show unmount notification for specified device object. |
def mouseDoubleClickEvent(self, event):
if self.rename_tabs is True and \
event.buttons() == Qt.MouseButtons(Qt.LeftButton):
index = self.tabAt(event.pos())
if index >= 0:
self.tab_name_editor.edit_tab(index)
else:
QTabBar.mouseDoubleClickEvent(self, event) | module function_definition identifier parameters identifier identifier block if_statement boolean_operator comparison_operator attribute identifier identifier true line_continuation comparison_operator call attribute identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list if_statement comparison_operator identifier integer block expression_statement call attribute attribute identifier identifier identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier identifier | Override Qt method to trigger the tab name editor. |
def add(self, data):
assert isinstance(data, bytes)
with self.lock:
self.buf += data | module function_definition identifier parameters identifier identifier block assert_statement call identifier argument_list identifier identifier with_statement with_clause with_item attribute identifier identifier block expression_statement augmented_assignment attribute identifier identifier identifier | Add data to the buffer |
def record_entering(self, time, code, frame_key, parent_stats):
stats = parent_stats.ensure_child(code, RecordingStatistics)
self._times_entered[(code, frame_key)] = time
stats.own_hits += 1 | module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment subscript attribute identifier identifier tuple identifier identifier identifier expression_statement augmented_assignment attribute identifier identifier integer | Entered to a function call. |
def run_module_command(cmd_list, env_vars, exit_on_error=True):
if exit_on_error:
try:
subprocess.check_call(cmd_list, env=env_vars)
except subprocess.CalledProcessError as shelloutexc:
sys.exit(shelloutexc.returncode)
else:
subprocess.check_call(cmd_list, env=env_vars) | module function_definition identifier parameters identifier identifier default_parameter identifier true block if_statement identifier block try_statement block expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier except_clause as_pattern attribute identifier identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier | Shell out to provisioner command. |
def scp(cls, vm_id, login, identity, local_file, remote_file):
cmd = ['scp']
if identity:
cmd.extend(('-i', identity,))
version, ip_addr = cls.vm_ip(vm_id)
if version == 6:
ip_addr = '[%s]' % ip_addr
cmd.extend((local_file, '%s@%s:%s' %
(login, ip_addr, remote_file),))
cls.echo('Running %s' % ' '.join(cmd))
for _ in range(5):
ret = cls.execute(cmd, False)
if ret:
break
time.sleep(.5)
return ret | module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier list string string_start string_content string_end if_statement identifier block expression_statement call attribute identifier identifier argument_list tuple string string_start string_content string_end identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier integer block expression_statement assignment identifier binary_operator string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list tuple identifier binary_operator string string_start string_content string_end tuple identifier identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list identifier for_statement identifier call identifier argument_list integer block expression_statement assignment identifier call attribute identifier identifier argument_list identifier false if_statement identifier block break_statement expression_statement call attribute identifier identifier argument_list float return_statement identifier | Copy file to remote VM. |
def add_arguments(self):
if self.parser is None:
raise TypeError("Parser cannot be None, has create_parser been called?")
for keys, kwargs in self.args.items():
if not isinstance(keys, tuple):
keys = (keys,)
self.parser.add_argument(*keys, **kwargs) | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block raise_statement call identifier argument_list string string_start string_content string_end for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block if_statement not_operator call identifier argument_list identifier identifier block expression_statement assignment identifier tuple identifier expression_statement call attribute attribute identifier identifier identifier argument_list list_splat identifier dictionary_splat identifier | Definition and addition of all arguments. |
def save(self):
saved = 0
if not self.objects:
raise BatchError("Save failed. Batch is empty")
for deserialized_tx in self.objects:
try:
self.model.objects.get(pk=deserialized_tx.pk)
except self.model.DoesNotExist:
data = {}
for field in self.model._meta.get_fields():
try:
data.update({field.name: getattr(deserialized_tx, field.name)})
except AttributeError:
pass
self.model.objects.create(**data)
saved += 1
return saved | module function_definition identifier parameters identifier block expression_statement assignment identifier integer if_statement not_operator attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end for_statement identifier attribute identifier identifier block try_statement block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier except_clause attribute attribute identifier identifier identifier block expression_statement assignment identifier dictionary for_statement identifier call attribute attribute attribute identifier identifier identifier identifier argument_list block try_statement block expression_statement call attribute identifier identifier argument_list dictionary pair attribute identifier identifier call identifier argument_list identifier attribute identifier identifier except_clause identifier block pass_statement expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list dictionary_splat identifier expression_statement augmented_assignment identifier integer return_statement identifier | Saves all model instances in the batch as model. |
def _delete_guest(self, guest_id):
msg = 'Cancelled'
try:
self.guest.deleteObject(id=guest_id)
except SoftLayer.SoftLayerAPIError as e:
msg = 'Exception: ' + e.faultString
return msg | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier string string_start string_content string_end try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier except_clause as_pattern attribute identifier identifier as_pattern_target identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end attribute identifier identifier return_statement identifier | Deletes a guest and returns 'Cancelled' or and Exception message |
def context_import(zap_helper, file_path):
with zap_error_handler():
result = zap_helper.zap.context.import_context(file_path)
if not result.isdigit():
raise ZAPError('Importing context from file failed: {}'.format(result))
console.info('Imported context from {}'.format(file_path)) | module function_definition identifier parameters identifier identifier block with_statement with_clause with_item call identifier argument_list block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier if_statement not_operator call attribute identifier identifier argument_list block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier | Import a saved context file. |
def __get_arg(cls, kwds, kwd):
alt_kwd = '_' + kwd
if alt_kwd in kwds:
return kwds.pop(alt_kwd)
if kwd in kwds:
obj = getattr(cls, kwd, None)
if not isinstance(obj, Property) or isinstance(obj, ModelKey):
return kwds.pop(kwd)
return None | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end identifier if_statement comparison_operator identifier identifier block return_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier none if_statement boolean_operator not_operator call identifier argument_list identifier identifier call identifier argument_list identifier identifier block return_statement call attribute identifier identifier argument_list identifier return_statement none | Internal helper method to parse keywords that may be property names. |
def previous_day(self):
return HDate(self.gdate + datetime.timedelta(-1), self.diaspora,
self.hebrew) | module function_definition identifier parameters identifier block return_statement call identifier argument_list binary_operator attribute identifier identifier call attribute identifier identifier argument_list unary_operator integer attribute identifier identifier attribute identifier identifier | Return the HDate for the previous day. |
def syncView(self):
if not self.updatesEnabled():
return
for item in self.topLevelItems():
try:
item.syncView(recursive=True)
except AttributeError:
continue | module function_definition identifier parameters identifier block if_statement not_operator call attribute identifier identifier argument_list block return_statement for_statement identifier call attribute identifier identifier argument_list block try_statement block expression_statement call attribute identifier identifier argument_list keyword_argument identifier true except_clause identifier block continue_statement | Syncs all the items to the view. |
def all_valid_with_nesting(self, formsets):
"Recursively validate all nested formsets"
if not all_valid(formsets):
return False
for formset in formsets:
if not formset.is_bound:
pass
for form in formset:
if hasattr(form, 'nested_formsets'):
if not self.all_valid_with_nesting(form.nested_formsets):
return False
if (not hasattr(form, 'cleaned_data') or not form.cleaned_data) and self.formset_has_nested_data(form.nested_formsets):
form._errors["__all__"] = form.error_class(["Parent object must be created when creating nested inlines."])
return False
return True | module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end if_statement not_operator call identifier argument_list identifier block return_statement false for_statement identifier identifier block if_statement not_operator attribute identifier identifier block pass_statement for_statement identifier identifier block if_statement call identifier argument_list identifier string string_start string_content string_end block if_statement not_operator call attribute identifier identifier argument_list attribute identifier identifier block return_statement false if_statement boolean_operator parenthesized_expression boolean_operator not_operator call identifier argument_list identifier string string_start string_content string_end not_operator attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end call attribute identifier identifier argument_list list string string_start string_content string_end return_statement false return_statement true | Recursively validate all nested formsets |
def StopProcessing(obj, eng, callbacks, exc_info):
e = exc_info[1]
obj.save(status=eng.object_status.COMPLETED,
id_workflow=eng.uuid)
eng.save(WorkflowStatus.COMPLETED)
obj.log.warning(
"Workflow '%s' stopped at task %s with message: %s",
eng.name, eng.current_taskname or "Unknown", e.message
)
db.session.commit()
super(InvenioTransitionAction, InvenioTransitionAction).StopProcessing(
obj, eng, callbacks, exc_info
) | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier subscript identifier integer expression_statement call attribute identifier identifier argument_list keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end attribute identifier identifier boolean_operator attribute identifier identifier string string_start string_content string_end attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list identifier identifier identifier identifier | Stop the engne and mark the workflow as completed. |
def _augmenting_row_reduction(self):
unassigned = np.where(self._x == -1)[0]
for i in unassigned:
for _ in range(self.c.size):
temp = self.c[i] - self._v
j1 = np.argmin(temp)
u1 = temp[j1]
temp[j1] = np.inf
j2 = np.argmin(temp)
u2 = temp[j2]
if u1 < u2:
self._v[j1] -= u2 - u1
elif self._y[j1] != -1:
j1 = j2
k = self._y[j1]
if k != -1:
self._x[k] = -1
self._x[i] = j1
self._y[j1] = i
i = k
if k == -1 or abs(u1 - u2) < self.epsilon:
break | module function_definition identifier parameters identifier block expression_statement assignment identifier subscript call attribute identifier identifier argument_list comparison_operator attribute identifier identifier unary_operator integer integer for_statement identifier identifier block for_statement identifier call identifier argument_list attribute attribute identifier identifier identifier block expression_statement assignment identifier binary_operator subscript attribute identifier identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier subscript identifier identifier expression_statement assignment subscript identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier subscript identifier identifier if_statement comparison_operator identifier identifier block expression_statement augmented_assignment subscript attribute identifier identifier identifier binary_operator identifier identifier elif_clause comparison_operator subscript attribute identifier identifier identifier unary_operator integer block expression_statement assignment identifier identifier expression_statement assignment identifier subscript attribute identifier identifier identifier if_statement comparison_operator identifier unary_operator integer block expression_statement assignment subscript attribute identifier identifier identifier unary_operator integer expression_statement assignment subscript attribute identifier identifier identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier expression_statement assignment identifier identifier if_statement boolean_operator comparison_operator identifier unary_operator integer comparison_operator call identifier argument_list binary_operator identifier identifier attribute identifier identifier block break_statement | Augmenting row reduction step from LAPJV algorithm |
def close_cache(self):
for server in self.servers:
if self.servers[server]['cache'] == True:
self.servers[server]['file'].close() | module function_definition identifier parameters identifier block for_statement identifier attribute identifier identifier block if_statement comparison_operator subscript subscript attribute identifier identifier identifier string string_start string_content string_end true block expression_statement call attribute subscript subscript attribute identifier identifier identifier string string_start string_content string_end identifier argument_list | Close cache of WS Shinken |
def _check_minions_directories(self):
minions_accepted = os.path.join(self.opts['pki_dir'], self.ACC)
minions_pre = os.path.join(self.opts['pki_dir'], self.PEND)
minions_rejected = os.path.join(self.opts['pki_dir'],
self.REJ)
minions_denied = os.path.join(self.opts['pki_dir'],
self.DEN)
return minions_accepted, minions_pre, minions_rejected, minions_denied | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier return_statement expression_list identifier identifier identifier identifier | Return the minion keys directory paths |
def update_frequency(shell_ctx):
frequency_path = os.path.join(shell_ctx.config.get_config_dir(), shell_ctx.config.get_frequency())
if os.path.exists(frequency_path):
with open(frequency_path, 'r') as freq:
try:
frequency = json.load(freq)
except ValueError:
frequency = {}
else:
frequency = {}
with open(frequency_path, 'w') as freq:
now = day_format(datetime.datetime.utcnow())
val = frequency.get(now)
frequency[now] = val + 1 if val else 1
json.dump(frequency, freq)
return frequency | 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 call attribute attribute identifier identifier identifier argument_list if_statement call attribute attribute identifier identifier identifier argument_list identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause identifier block expression_statement assignment identifier dictionary else_clause block expression_statement assignment identifier dictionary with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment subscript identifier identifier conditional_expression binary_operator identifier integer identifier integer expression_statement call attribute identifier identifier argument_list identifier identifier return_statement identifier | updates the frequency from files |
def restart(self):
_module_finder.reset()
linecache.checkcache()
for module_bpts in self.breakpoints.values():
module_bpts.reset() | module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list for_statement identifier call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list | Restart the debugger after source code changes. |
def update(self, data: TransDict, flags: Flags):
for lang, lang_data in data.items():
self.update_lang(lang, lang_data, flags) | module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier identifier identifier | Update all langs at once |
def toPandas(self):
assert pd is not None
nindices = self.getNumIndices()
headers = self.getHeaders()
columns = {
header: list(self.getColumn(header))
for header in headers[nindices:]
}
index = zip(*[
list(self.getColumn(header))
for header in headers[:nindices]
])
index = [key if len(key) > 1 else key[0] for key in index]
if index == []:
return pd.DataFrame(columns, index=None)
else:
return pd.DataFrame(columns, index=index) | module function_definition identifier parameters identifier block assert_statement comparison_operator identifier none expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier dictionary_comprehension pair identifier call identifier argument_list call attribute identifier identifier argument_list identifier for_in_clause identifier subscript identifier slice identifier expression_statement assignment identifier call identifier argument_list list_splat list_comprehension call identifier argument_list call attribute identifier identifier argument_list identifier for_in_clause identifier subscript identifier slice identifier expression_statement assignment identifier list_comprehension conditional_expression identifier comparison_operator call identifier argument_list identifier integer subscript identifier integer for_in_clause identifier identifier if_statement comparison_operator identifier list block return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier none else_clause block return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier | Return a pandas DataFrame with the DataFrame data. |
def apply(cls, args, run):
try:
priority = float(args)
except ValueError:
raise ValueError("The PRIORITY argument must be a number! "
"(but was '{}')".format(args))
run.meta_info['priority'] = priority | module function_definition identifier parameters identifier identifier identifier block try_statement block expression_statement assignment identifier call identifier argument_list identifier except_clause identifier block raise_statement call identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list identifier expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end identifier | Add priority info for this run. |
def start_recording(self, file='mingus_dump.wav'):
w = wave.open(file, 'wb')
w.setnchannels(2)
w.setsampwidth(2)
w.setframerate(44100)
self.wav = w | module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list integer expression_statement assignment attribute identifier identifier identifier | Initialize a new wave file for recording. |
def add_class(self, cssclass):
if self.has_class(cssclass):
return self
return self.toggle_class(cssclass) | module function_definition identifier parameters identifier identifier block if_statement call attribute identifier identifier argument_list identifier block return_statement identifier return_statement call attribute identifier identifier argument_list identifier | Adds a css class to this element. |
def do_fileplaceholder(parser, token):
name, params = parse_placeholder(parser, token)
return FilePlaceholderNode(name, **params) | module function_definition identifier parameters identifier identifier block expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier identifier return_statement call identifier argument_list identifier dictionary_splat identifier | Method that parse the fileplaceholder template tag. |
def dst_to_src(self, dst_file):
for map in self.mappings:
src_uri = map.dst_to_src(dst_file)
if (src_uri is not None):
return(src_uri)
raise MapperError(
"Unable to translate destination path (%s) "
"into a source URI." % (dst_file)) | module function_definition identifier parameters identifier identifier block for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement parenthesized_expression comparison_operator identifier none block return_statement parenthesized_expression identifier raise_statement call identifier argument_list binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end parenthesized_expression identifier | Map destination path to source URI. |
def make_force(q_vars, mass):
B: int = len(mass)
U = fl.Const(0.0)
for i in range(B):
for j in range(i+1, B):
U += U_ij(q_vars, mass, i, j)
vn_q = np.array([q.var_name for q in q_vars])
vn_fl = np.array(sorted(U.var_names))
q2fl = np.array([np.argmax((vn_q == v)) for v in vn_fl])
fl2q = np.array([np.argmax((vn_fl == v)) for v in vn_q])
force_func = lambda q: -U.diff(q[q2fl]).squeeze()[fl2q]
return force_func | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier type identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list float for_statement identifier call identifier argument_list identifier block for_statement identifier call identifier argument_list binary_operator identifier integer identifier block expression_statement augmented_assignment identifier call identifier argument_list identifier identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list list_comprehension attribute identifier identifier for_in_clause identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list list_comprehension call attribute identifier identifier argument_list parenthesized_expression comparison_operator identifier identifier for_in_clause identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list list_comprehension call attribute identifier identifier argument_list parenthesized_expression comparison_operator identifier identifier for_in_clause identifier identifier expression_statement assignment identifier lambda lambda_parameters identifier unary_operator subscript call attribute call attribute identifier identifier argument_list subscript identifier identifier identifier argument_list identifier return_statement identifier | Fluxion with the potential energy of the eight planets sytem |
def convert_adc(value, output_type, max_volts):
return {
const.ADC_RAW: lambda x: x,
const.ADC_PERCENTAGE: adc_to_percentage,
const.ADC_VOLTS: adc_to_volts,
const.ADC_MILLIVOLTS: adc_to_millivolts
}[output_type](value, max_volts) | module function_definition identifier parameters identifier identifier identifier block return_statement call subscript dictionary pair attribute identifier identifier lambda lambda_parameters identifier identifier pair attribute identifier identifier identifier pair attribute identifier identifier identifier pair attribute identifier identifier identifier identifier argument_list identifier identifier | Converts the output from the ADC into the desired type. |
def _get_target_index(self):
return (self.index + self.source_window * (not self.overlapping) +
self.offset) | module function_definition identifier parameters identifier block return_statement parenthesized_expression binary_operator binary_operator attribute identifier identifier binary_operator attribute identifier identifier parenthesized_expression not_operator attribute identifier identifier attribute identifier identifier | Return the index where the target window starts. |
def validate_unique(self):
form_errors = []
try:
super(LocalisedForm, self).validate_unique()
except ValidationError as e:
form_errors += e.messages
localized_fields_checks = self._get_localized_field_checks()
bad_fields = set()
field_errors, global_errors = self._perform_unique_localized_field_checks(localized_fields_checks)
bad_fields.union(field_errors)
form_errors.extend(global_errors)
for field_name in bad_fields:
del self.cleaned_data[field_name]
if form_errors:
raise ValidationError(form_errors) | module function_definition identifier parameters identifier block expression_statement assignment identifier list try_statement block expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list except_clause as_pattern identifier as_pattern_target identifier block expression_statement augmented_assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier for_statement identifier identifier block delete_statement subscript attribute identifier identifier identifier if_statement identifier block raise_statement call identifier argument_list identifier | Validates the uniqueness of fields, but also handles the localized_fields. |
def from_set(cls, database, key, data, clear=False):
s = cls(database, key)
if clear:
s.clear()
s.add(*data)
return s | module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier false block expression_statement assignment identifier call identifier argument_list identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list list_splat identifier return_statement identifier | Create and populate a Set object from a data set. |
def _record_revisit(self, payload_offset: int):
fields = self._response_record.fields
ref_record_id = self._url_table.get_revisit_id(
fields['WARC-Target-URI'],
fields.get('WARC-Payload-Digest', '').upper().replace('SHA1:', '')
)
if ref_record_id:
try:
self._response_record.block_file.truncate(payload_offset)
except TypeError:
self._response_record.block_file.seek(0)
data = self._response_record.block_file.read(payload_offset)
self._response_record.block_file.truncate()
self._response_record.block_file.seek(0)
self._response_record.block_file.write(data)
self._recorder.set_length_and_maybe_checksums(
self._response_record
)
fields[WARCRecord.WARC_TYPE] = WARCRecord.REVISIT
fields['WARC-Refers-To'] = ref_record_id
fields['WARC-Profile'] = WARCRecord.SAME_PAYLOAD_DIGEST_URI
fields['WARC-Truncated'] = 'length' | module function_definition identifier parameters identifier typed_parameter identifier type identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list subscript identifier string string_start string_content string_end call attribute call attribute call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end identifier argument_list identifier argument_list string string_start string_content string_end string string_start string_end if_statement identifier block try_statement block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier except_clause identifier block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list integer expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list integer expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment subscript identifier attribute identifier identifier attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end | Record the revisit if possible. |
async def load(self, request, resource=None, **kwargs):
schema = self.get_schema(request, resource=resource, **kwargs)
data = await self.parse(request)
resource, errors = schema.load(
data, partial=resource is not None, many=isinstance(data, list))
if errors:
raise RESTBadRequest(reason='Bad request', json={'errors': errors})
return resource | module function_definition identifier parameters identifier identifier default_parameter identifier none dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier dictionary_splat identifier expression_statement assignment identifier await call attribute identifier identifier argument_list identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier keyword_argument identifier comparison_operator identifier none keyword_argument identifier call identifier argument_list identifier identifier if_statement identifier block raise_statement call identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier dictionary pair string string_start string_content string_end identifier return_statement identifier | Load resource from given data. |
def _convert(self, image, output=None):
with Image.open(image) as im:
width, height = im.size
co = CanvasObjects()
co.add(CanvasImg(image, 1.0, w=width, h=height))
return WatermarkDraw(co, tempdir=self.tempdir, pagesize=(width, height)).write(output) | module function_definition identifier parameters identifier identifier default_parameter identifier none block with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list identifier as_pattern_target identifier block expression_statement assignment pattern_list identifier identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier float keyword_argument identifier identifier keyword_argument identifier identifier return_statement call attribute call identifier argument_list identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier tuple identifier identifier identifier argument_list identifier | Private method for converting a single PNG image to a PDF. |
def current_arg_text(self) -> str:
if self._current_arg_text is None:
self._current_arg_text = Message(
self.current_arg).extract_plain_text()
return self._current_arg_text | module function_definition identifier parameters identifier type identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier call attribute call identifier argument_list attribute identifier identifier identifier argument_list return_statement attribute identifier identifier | Plain text part in the current argument, without any CQ codes. |
def _reset(self):
self.bundles = AttrDict()
self._bundles = _DeferredBundleFunctionsStore()
self.babel_bundle = None
self.env = None
self.extensions = AttrDict()
self.services = AttrDict()
self._deferred_functions = []
self._initialized = False
self._models_initialized = False
self._services_initialized = False
self._services_registry = {}
self._shell_ctx = {} | module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call identifier argument_list expression_statement assignment attribute identifier identifier call identifier argument_list expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier call identifier argument_list expression_statement assignment attribute identifier identifier call identifier argument_list expression_statement assignment attribute identifier identifier list expression_statement assignment attribute identifier identifier false expression_statement assignment attribute identifier identifier false expression_statement assignment attribute identifier identifier false expression_statement assignment attribute identifier identifier dictionary expression_statement assignment attribute identifier identifier dictionary | This method is for use by tests only! |
def _decade_ranges_in_date_range(self, begin_date, end_date):
begin_dated = begin_date.year / 10
end_dated = end_date.year / 10
decades = []
for d in range(begin_dated, end_dated + 1):
decades.append('{}-{}'.format(d * 10, d * 10 + 9))
return decades | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier binary_operator attribute identifier identifier integer expression_statement assignment identifier binary_operator attribute identifier identifier integer expression_statement assignment identifier list for_statement identifier call identifier argument_list identifier binary_operator identifier integer block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list binary_operator identifier integer binary_operator binary_operator identifier integer integer return_statement identifier | Return a list of decades which is covered by date range. |
def author_mail_from_git(self):
try:
cmd = Popen(["git", "config", "--get", "user.email"], stdout=PIPE)
stdoutdata = cmd.communicate()
if (stdoutdata[0]):
self.author_mail = stdoutdata[0].rstrip(os.linesep)
except ImportError:
pass
except CalledProcessError:
pass
except OSError:
pass
return self.author_mail | module function_definition identifier parameters identifier block try_statement block expression_statement assignment identifier call identifier argument_list list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end keyword_argument identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement parenthesized_expression subscript identifier integer block expression_statement assignment attribute identifier identifier call attribute subscript identifier integer identifier argument_list attribute identifier identifier except_clause identifier block pass_statement except_clause identifier block pass_statement except_clause identifier block pass_statement return_statement attribute identifier identifier | Get the author mail from git information. |
def find_by_campaign(campaign_id, _connection=None, page_size=100,
page_number=0, sort_by=enums.DEFAULT_SORT_BY,
sort_order=enums.DEFAULT_SORT_ORDER):
return connection.ItemResultSet(
'find_videos_by_campaign_id', Video, _connection, page_size,
page_number, sort_by, sort_order, campaign_id=campaign_id) | module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier integer default_parameter identifier integer default_parameter identifier attribute identifier identifier default_parameter identifier attribute identifier identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier identifier identifier identifier identifier keyword_argument identifier identifier | List all videos for a given campaign. |
def read(self, n=4096):
while True:
try:
if hasattr(self.fd, 'recv'):
return self.fd.recv(n)
return os.read(self.fd.fileno(), n)
except EnvironmentError as e:
if e.errno not in Stream.ERRNO_RECOVERABLE:
raise e | module function_definition identifier parameters identifier default_parameter identifier integer block while_statement true block try_statement block if_statement call identifier argument_list attribute identifier identifier string string_start string_content string_end block return_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block raise_statement identifier | Return `n` bytes of data from the Stream, or None at end of stream. |
def starts_new_line(item: str) -> bool:
if item in TAF_NEWLINE:
return True
for start in TAF_NEWLINE_STARTSWITH:
if item.startswith(start):
return True
return False | module function_definition identifier parameters typed_parameter identifier type identifier type identifier block if_statement comparison_operator identifier identifier block return_statement true for_statement identifier identifier block if_statement call attribute identifier identifier argument_list identifier block return_statement true return_statement false | Returns True if the given element should start a new report line |
def update_image(self, image_id, user_name, desc=None):
desc = desc if desc else ''
data = {"username": user_name,
"description": desc}
return self._post('/images/%s' % image_id, data) | module function_definition identifier parameters identifier identifier identifier default_parameter identifier none block expression_statement assignment identifier conditional_expression identifier identifier string string_start string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier return_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier identifier | Create or update an Image in Image Registry. |
def add_link(app, pagename, templatename, context, doctree):
context['show_slidelink'] = (
app.config.slide_link_html_to_slides and
hasattr(app.builder, 'get_outfilename')
)
if context['show_slidelink']:
context['slide_path'] = slide_path(app.builder, pagename) | module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end parenthesized_expression boolean_operator attribute attribute identifier identifier identifier call identifier argument_list attribute identifier identifier string string_start string_content string_end if_statement subscript identifier string string_start string_content string_end block expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list attribute identifier identifier identifier | Add the slides link to the HTML context. |
def _get_pattern(self, pattern_id):
for key in ('PATTERNS1', 'PATTERNS2', 'PATTERNS3'):
if key in self.tagged_blocks:
data = self.tagged_blocks.get_data(key)
for pattern in data:
if pattern.pattern_id == pattern_id:
return pattern
return None | module function_definition identifier parameters identifier identifier block for_statement identifier tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier for_statement identifier identifier block if_statement comparison_operator attribute identifier identifier identifier block return_statement identifier return_statement none | Get pattern item by id. |
def connection(self):
assert flask.has_request_context(), \
'tried to connect zodb outside request'
if not self.is_connected:
connector = flask.current_app.extensions['zodb']
flask._request_ctx_stack.top.zodb_connection = connector.db.open()
transaction.begin()
return flask._request_ctx_stack.top.zodb_connection | module function_definition identifier parameters identifier block assert_statement call attribute identifier identifier argument_list string string_start string_content string_end if_statement not_operator attribute identifier identifier block expression_statement assignment identifier subscript attribute attribute identifier identifier identifier string string_start string_content string_end expression_statement assignment attribute attribute attribute identifier identifier identifier identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list return_statement attribute attribute attribute identifier identifier identifier identifier | Request-bound database connection. |
def AdjustDescriptor(self, fields):
for f in fields:
if f.name == "args_rdf_name":
f.name = "payload_type"
if f.name == "args":
f.name = "payload"
return fields | module function_definition identifier parameters identifier identifier block for_statement identifier identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier string string_start string_content string_end if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier string string_start string_content string_end return_statement identifier | Payload-aware metadata processor. |
def knowledge_base_path(cls, project, knowledge_base):
return google.api_core.path_template.expand(
'projects/{project}/knowledgeBases/{knowledge_base}',
project=project,
knowledge_base=knowledge_base,
) | module function_definition identifier parameters identifier identifier identifier block return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier | Return a fully-qualified knowledge_base string. |
def encrypt(self, txt, key):
assert isinstance(txt, six.text_type), "txt: %s is not text type!" % repr(txt)
assert isinstance(key, six.text_type), "key: %s is not text type!" % repr(key)
if len(txt) != len(key):
raise SecureJSLoginError("encrypt error: %s and '%s' must have the same length!" % (txt, key))
pbkdf2_hash = PBKDF2SHA1Hasher1().get_salt_hash(txt)
txt=force_bytes(txt)
key=force_bytes(key)
crypted = self.xor(txt, key)
crypted = binascii.hexlify(crypted)
crypted = six.text_type(crypted, "ascii")
return "%s$%s" % (pbkdf2_hash, crypted) | module function_definition identifier parameters identifier identifier identifier block assert_statement call identifier argument_list identifier attribute identifier identifier binary_operator string string_start string_content string_end call identifier argument_list identifier assert_statement call identifier argument_list identifier attribute identifier identifier binary_operator string string_start string_content string_end call identifier argument_list identifier if_statement comparison_operator call identifier argument_list identifier call identifier argument_list identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier expression_statement assignment identifier call attribute call identifier argument_list identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end return_statement binary_operator string string_start string_content string_end tuple identifier identifier | XOR ciphering with a PBKDF2 checksum |
def lineup_user(self,userid):
headers = {"Content-type": "application/x-www-form-urlencoded","Accept": "text/plain",'Referer': 'http://'+self.domain+'/standings.phtml',"User-Agent": user_agent}
req = self.session.get('http://'+self.domain+'/playerInfo.phtml?pid='+userid,headers=headers).content
soup = BeautifulSoup(req)
info = []
for i in soup.find_all('td',{'class':'name_cont'}):
info.append(i.text.strip())
return info | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end binary_operator binary_operator string string_start string_content string_end attribute identifier identifier string string_start string_content string_end pair string string_start string_content string_end identifier expression_statement assignment identifier attribute call attribute attribute identifier identifier identifier argument_list binary_operator binary_operator binary_operator string string_start string_content string_end attribute identifier identifier string string_start string_content string_end identifier keyword_argument identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier list for_statement identifier call attribute identifier identifier argument_list string string_start string_content string_end dictionary pair string string_start string_content string_end string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list return_statement identifier | Get user lineup using a ID |
def uid_something_colon(self, node):
node.op_pos = [
NodeWithPosition(node.uid, (node.first_line, node.first_col))
]
position = (node.body[0].first_line, node.body[0].first_col)
last, first = self.operators[':'].find_previous(position)
node.op_pos.append(NodeWithPosition(last, first))
return last | module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier list call identifier argument_list attribute identifier identifier tuple attribute identifier identifier attribute identifier identifier expression_statement assignment identifier tuple attribute subscript attribute identifier identifier integer identifier attribute subscript attribute identifier identifier integer identifier expression_statement assignment pattern_list identifier identifier call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier identifier return_statement identifier | Creates op_pos for node from uid to colon |
def getExitCode(self, command, env={}, path=None, uid=None, gid=None,
usePTY=0, childFDs=None):
deferred = defer.Deferred()
processProtocol = _SummaryProcessProtocol(deferred)
self.execute(processProtocol, command, env, path, uid, gid,
usePTY, childFDs)
@deferred.addCallback
def getStdOut(tuple_):
_stdout, _stderr, exitCode = tuple_
return exitCode
return deferred | module function_definition identifier parameters identifier identifier default_parameter identifier dictionary default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier integer default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier identifier identifier identifier identifier identifier identifier identifier decorated_definition decorator attribute identifier identifier function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier identifier identifier return_statement identifier return_statement identifier | Execute a command and get the return code of the finished process. |
def parse_metadata(section):
metadata = {}
metadata_lines = section.split('\n')
for line in metadata_lines:
colon_index = line.find(':')
if colon_index != -1:
key = line[:colon_index].strip()
val = line[colon_index + 1:].strip()
metadata[key] = val
return metadata | module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier unary_operator integer block expression_statement assignment identifier call attribute subscript identifier slice identifier identifier argument_list expression_statement assignment identifier call attribute subscript identifier slice binary_operator identifier integer identifier argument_list expression_statement assignment subscript identifier identifier identifier return_statement identifier | Given the first part of a slide, returns metadata associated with it. |
def disable(gandi, resource, backend, port, probe):
result = []
if backend:
backends = backend
for backend in backends:
if 'port' not in backend:
if not port:
backend['port'] = click.prompt('Please set a port for '
'backends. If you want to '
' different port for '
'each backend, use `-b '
'ip:port`', type=int)
else:
backend['port'] = port
result = gandi.webacc.backend_disable(backend)
if probe:
if not resource:
gandi.echo('You need to indicate the Webaccelerator name')
return
result = gandi.webacc.probe_disable(resource)
return result | module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier list if_statement identifier block expression_statement assignment identifier identifier for_statement identifier identifier block if_statement comparison_operator string string_start string_content string_end identifier block if_statement not_operator identifier block expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier 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 string string_start string_content string_end string string_start string_content string_end keyword_argument identifier identifier else_clause block expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement identifier block if_statement not_operator identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier return_statement identifier | Disable a backend or a probe on a webaccelerator |
def update_balance_data(self) -> None:
response = get(
_url(
"/accounts/{0}/balance".format(self._account_uid),
self._sandbox
),
headers=self._auth_headers
)
response.raise_for_status()
response = response.json()
self.cleared_balance = response['clearedBalance']['minorUnits']
self.effective_balance = response['effectiveBalance']['minorUnits']
self.pending_transactions \
= response['pendingTransactions']['minorUnits']
self.available_to_spend = response['availableToSpend']['minorUnits']
self.accepted_overdraft = response['acceptedOverdraft']['minorUnits'] | module function_definition identifier parameters identifier type none block expression_statement assignment identifier call identifier argument_list call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier subscript subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment attribute identifier identifier subscript subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment attribute identifier identifier line_continuation subscript subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment attribute identifier identifier subscript subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment attribute identifier identifier subscript subscript identifier string string_start string_content string_end string string_start string_content string_end | Get the latest balance information for the account. |
def selected_cats(self, items):
cats = []
for item in items:
if 'category' in item and item['category'] not in cats:
cats.append(item['category'])
return cats | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list for_statement identifier identifier block if_statement boolean_operator comparison_operator string string_start string_content string_end identifier comparison_operator subscript identifier string string_start string_content string_end identifier block expression_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end return_statement identifier | return a list of all categories with accredited services |
def count(self):
if self.request["Select"] == "COUNT":
while not self.exhausted:
next(self, None)
return self._count | module function_definition identifier parameters identifier block if_statement comparison_operator subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end block while_statement not_operator attribute identifier identifier block expression_statement call identifier argument_list identifier none return_statement attribute identifier identifier | Number of items that have been loaded from DynamoDB so far, including buffered items. |
def parse(self, line=None):
args = self.parser.parse_args(args=line)
return args.func(args) | module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier return_statement call attribute identifier identifier argument_list identifier | parses the line provided, if None then uses sys.argv |
def convert_to_str(l: Node) -> str:
result = ""
while l:
result += str(l.val)
l = l.next
return result | module function_definition identifier parameters typed_parameter identifier type identifier type identifier block expression_statement assignment identifier string string_start string_end while_statement identifier block expression_statement augmented_assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier attribute identifier identifier return_statement identifier | converts the non-negative number list into a string. |
def gen_oui_str(self, oui_list):
oui_str = []
for oui in oui_list:
oui_str.append('-c')
oui_str.append(oui)
return oui_str | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | Generate the OUI string for vdptool. |
def write_frame(self):
if not hasattr(self, 'mwriter'):
raise AssertionError('This plotter has not opened a movie or GIF file.')
self.mwriter.append_data(self.image) | module function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list identifier string string_start string_content string_end block raise_statement call identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier | Writes a single frame to the movie file |
def rhypergeometric(n, m, N, size=None):
if n == 0:
return np.zeros(size, dtype=int)
elif n == N:
out = np.empty(size, dtype=int)
out.fill(m)
return out
return np.random.hypergeometric(n, N - n, m, size) | module function_definition identifier parameters identifier identifier identifier default_parameter identifier none block if_statement comparison_operator identifier integer block return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier elif_clause comparison_operator identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier binary_operator identifier identifier identifier identifier | Returns hypergeometric random variates. |
def _start_priority_containers(self, groups, group_orders, tool_d):
vent_cfg = Template(self.path_dirs.cfg_file)
cfg_groups = vent_cfg.option('groups', 'start_order')
if cfg_groups[0]:
cfg_groups = cfg_groups[1].split(',')
else:
cfg_groups = []
all_groups = sorted(set(groups))
s_conts = []
f_conts = []
for group in cfg_groups:
if group in all_groups:
all_groups.remove(group)
if group in group_orders:
for cont_t in sorted(group_orders[group]):
if cont_t[1] not in s_conts:
s_conts, f_conts = self._start_container(cont_t[1],
tool_d,
s_conts,
f_conts)
for group in all_groups:
if group in group_orders:
for cont_t in sorted(group_orders[group]):
if cont_t[1] not in s_conts:
s_conts, f_conts = self._start_container(cont_t[1],
tool_d,
s_conts,
f_conts)
return (s_conts, f_conts) | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end if_statement subscript identifier integer block expression_statement assignment identifier call attribute subscript identifier integer identifier argument_list string string_start string_content string_end else_clause block expression_statement assignment identifier list expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier expression_statement assignment identifier list expression_statement assignment identifier list for_statement identifier identifier block if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier identifier block for_statement identifier call identifier argument_list subscript identifier identifier block if_statement comparison_operator subscript identifier integer identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list subscript identifier integer identifier identifier identifier for_statement identifier identifier block if_statement comparison_operator identifier identifier block for_statement identifier call identifier argument_list subscript identifier identifier block if_statement comparison_operator subscript identifier integer identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list subscript identifier integer identifier identifier identifier return_statement tuple identifier identifier | Select containers based on priorities to start |
def cleanup(self):
self.num_puts = 0
cached = []
for i, url_data in enumerate(self.queue):
key = url_data.cache_url
cache = url_data.aggregate.result_cache
if cache.has_result(key):
cached.append(i)
for pos in cached:
self._move_to_top(pos) | module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier integer expression_statement assignment identifier list for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute attribute identifier identifier identifier if_statement call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier | Move cached elements to top. |
def add_data(self, rawdata):
for data in rawdata:
try:
item = data[0]
if item[0] == 2:
continue
if item[0] != 0:
warnings.warn(f"Unknown message type '{item[0]}'", Warning)
continue
item = item[1]
target = str(item[0])
try:
data = item[1]
except IndexError:
data = dict()
try:
method = getattr(self, self.__head + target)
method(data)
except AttributeError:
self._handle_unhandled(target, data)
except IndexError:
LOGGER.warning("Wrongly constructed message received: %r", data)
self.conn.process_queues() | module function_definition identifier parameters identifier identifier block for_statement identifier identifier block try_statement block expression_statement assignment identifier subscript identifier integer if_statement comparison_operator subscript identifier integer integer block continue_statement if_statement comparison_operator subscript identifier integer integer block expression_statement call attribute identifier identifier argument_list string string_start string_content interpolation subscript identifier integer string_content string_end identifier continue_statement expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier call identifier argument_list subscript identifier integer try_statement block expression_statement assignment identifier subscript identifier integer except_clause identifier block expression_statement assignment identifier call identifier argument_list try_statement block expression_statement assignment identifier call identifier argument_list identifier binary_operator attribute identifier identifier identifier expression_statement call identifier argument_list identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list identifier identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute attribute identifier identifier identifier argument_list | Add data to given room's state |
def find_sources(self):
manifest_filename = os.path.join(self.egg_info, "SOURCES.txt")
mm = manifest_maker(self.distribution)
mm.manifest = manifest_filename
mm.run()
self.filelist = mm.filelist | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier attribute identifier identifier | Generate SOURCES.txt manifest file |
def tasks(self):
tasks_response = self.get_request('tasks/')
return [Task(self, tjson['task']) for tjson in tasks_response] | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement list_comprehension call identifier argument_list identifier subscript identifier string string_start string_content string_end for_in_clause identifier identifier | Generates a list of all Tasks. |
def __set_window_title(self):
if self.has_editor_tab():
windowTitle = "{0} - {1}".format(self.__default_window_title, self.get_current_editor().file)
else:
windowTitle = "{0}".format(self.__default_window_title)
LOGGER.debug("> Setting 'Script Editor' window title to '{0}'.".format(windowTitle))
self.setWindowTitle(windowTitle) | module function_definition identifier parameters identifier block if_statement call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier attribute call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier | Sets the Component window title. |
def dot_v3(v, w):
return sum([x * y for x, y in zip(v, w)]) | module function_definition identifier parameters identifier identifier block return_statement call identifier argument_list list_comprehension binary_operator identifier identifier for_in_clause pattern_list identifier identifier call identifier argument_list identifier identifier | Return the dotproduct of two vectors. |
def logout(lancet, service):
if service:
services = [service]
else:
services = ['tracker', 'harvest']
for service in services:
url = lancet.config.get(service, 'url')
key = 'lancet+{}'.format(url)
username = lancet.config.get(service, 'username')
with taskstatus('Logging out from {}', url) as ts:
if keyring.get_password(key, username):
keyring.delete_password(key, username)
ts.ok('Logged out from {}', url)
else:
ts.ok('Already logged out from {}', url) | module function_definition identifier parameters identifier identifier block if_statement identifier block expression_statement assignment identifier list identifier else_clause block expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end for_statement identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end with_statement with_clause with_item as_pattern call identifier argument_list string string_start string_content string_end identifier as_pattern_target identifier block if_statement call attribute identifier identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier | Forget saved passwords for the web services. |
def go_to_next_buffer(self, _previous=False):
if self.active_editor_buffer:
index = self.editor_buffers.index(self.active_editor_buffer)
if _previous:
new_index = (len(self.editor_buffers) + index - 1) % len(self.editor_buffers)
else:
new_index = (index + 1) % len(self.editor_buffers)
self.active_tab.show_editor_buffer(self.editor_buffers[new_index])
self._auto_close_new_empty_buffers() | module function_definition identifier parameters identifier default_parameter identifier false block if_statement attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier if_statement identifier block expression_statement assignment identifier binary_operator parenthesized_expression binary_operator binary_operator call identifier argument_list attribute identifier identifier identifier integer call identifier argument_list attribute identifier identifier else_clause block expression_statement assignment identifier binary_operator parenthesized_expression binary_operator identifier integer call identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list subscript attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list | Open next buffer in active window. |
def scaleSignalCut(img, ratio, nbins=100):
start, stop = scaleSignalCutParams(img, ratio, nbins)
img = img - start
img /= (stop - start)
return img | module function_definition identifier parameters identifier identifier default_parameter identifier integer block expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier identifier identifier expression_statement assignment identifier binary_operator identifier identifier expression_statement augmented_assignment identifier parenthesized_expression binary_operator identifier identifier return_statement identifier | scaling img cutting x percent of top and bottom part of histogram |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.