code
stringlengths 51
2.34k
| sequence
stringlengths 186
3.94k
| docstring
stringlengths 11
171
|
|---|---|---|
def accept_transfer(transfer, comment=None):
TransferResponsePermission(transfer).test()
transfer.responded = datetime.now()
transfer.responder = current_user._get_current_object()
transfer.status = 'accepted'
transfer.response_comment = comment
transfer.save()
subject = transfer.subject
recipient = transfer.recipient
if isinstance(recipient, Organization):
subject.organization = recipient
elif isinstance(recipient, User):
subject.owner = recipient
subject.save()
return transfer
|
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement call attribute call identifier argument_list identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier if_statement call identifier argument_list identifier identifier block expression_statement assignment attribute identifier identifier identifier elif_clause call identifier argument_list identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list return_statement identifier
|
Accept an incoming a transfer request
|
def parse_problem(self, problem_content):
del problem_content["@order"]
return self.task_factory.get_problem_types().get(problem_content["type"]).parse_problem(problem_content)
|
module function_definition identifier parameters identifier identifier block delete_statement subscript identifier string string_start string_content string_end return_statement call attribute call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list subscript identifier string string_start string_content string_end identifier argument_list identifier
|
Parses a problem, modifying some data
|
def find_by_text(text, _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_text',
Video, _connection, page_size, page_number, sort_by, sort_order,
text=text)
|
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 videos that match the ``text`` in title or description.
|
def char_range(starting_char, ending_char):
assert isinstance(starting_char, str), 'char_range: Wrong argument/s type'
assert isinstance(ending_char, str), 'char_range: Wrong argument/s type'
for char in range(ord(starting_char), ord(ending_char) + 1):
yield chr(char)
|
module function_definition identifier parameters identifier identifier block assert_statement call identifier argument_list identifier identifier string string_start string_content string_end assert_statement call identifier argument_list identifier identifier string string_start string_content string_end for_statement identifier call identifier argument_list call identifier argument_list identifier binary_operator call identifier argument_list identifier integer block expression_statement yield call identifier argument_list identifier
|
Create a range generator for chars
|
def source(self, source):
BaseView.source.fset(self, source)
if self.main_pane:
self.main_pane.object = self.contents
self.label_pane.object = self.label
|
module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier if_statement attribute identifier identifier block expression_statement assignment attribute attribute identifier identifier identifier attribute identifier identifier expression_statement assignment attribute attribute identifier identifier identifier attribute identifier identifier
|
When the source gets updated, update the pane object
|
def unpack(src_dir, dst_dir):
for dirpath, dirnames, filenames in os.walk(src_dir):
subdir = os.path.relpath(dirpath, src_dir)
for f in filenames:
src = os.path.join(dirpath, f)
dst = os.path.join(dst_dir, subdir, f)
os.renames(src, dst)
for n, d in reversed(list(enumerate(dirnames))):
src = os.path.join(dirpath, d)
dst = os.path.join(dst_dir, subdir, d)
if not os.path.exists(dst):
os.renames(src, dst)
del dirnames[n]
for dirpath, dirnames, filenames in os.walk(src_dir, topdown=True):
assert not filenames
os.rmdir(dirpath)
|
module function_definition identifier parameters identifier identifier block for_statement pattern_list identifier identifier identifier call attribute identifier identifier argument_list identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier for_statement identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier for_statement pattern_list identifier identifier call identifier argument_list call identifier argument_list call identifier argument_list identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier identifier if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier identifier delete_statement subscript identifier identifier for_statement pattern_list identifier identifier identifier call attribute identifier identifier argument_list identifier keyword_argument identifier true block assert_statement not_operator identifier expression_statement call attribute identifier identifier argument_list identifier
|
Move everything under `src_dir` to `dst_dir`, and delete the former.
|
def write_remaining(self):
if not self.results:
return
with db.execution_context():
with db.atomic():
Result.insert_many(self.results).execute()
del self.results[:]
|
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block return_statement with_statement with_clause with_item call attribute identifier identifier argument_list block with_statement with_clause with_item call attribute identifier identifier argument_list block expression_statement call attribute call attribute identifier identifier argument_list attribute identifier identifier identifier argument_list delete_statement subscript attribute identifier identifier slice
|
Write the remaning stack content
|
def distclean(ctx=None):
global commands
lst=os.listdir('.')
for f in lst:
if f==Options.lockfile:
try:
proj=Environment.Environment(f)
except:
Logs.warn('could not read %r'%f)
continue
try:
shutil.rmtree(proj[BLDDIR])
except IOError:
pass
except OSError,e:
if e.errno!=errno.ENOENT:
Logs.warn('project %r cannot be removed'%proj[BLDDIR])
try:
os.remove(f)
except OSError,e:
if e.errno!=errno.ENOENT:
Logs.warn('file %r cannot be removed'%f)
if not commands and f.startswith('.waf'):
shutil.rmtree(f,ignore_errors=True)
|
module function_definition identifier parameters default_parameter identifier none block global_statement identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end for_statement identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier continue_statement try_statement block expression_statement call attribute identifier identifier argument_list subscript identifier identifier except_clause identifier block pass_statement except_clause identifier identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end subscript identifier identifier try_statement block expression_statement call attribute identifier identifier argument_list identifier except_clause identifier identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier if_statement boolean_operator not_operator identifier call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier true
|
removes the build directory
|
def _update_questions(self):
if self.is_simple_section():
return
part_list = self._get_parts()
if len(part_list) > len(self._my_map['assessmentParts']):
self._update_assessment_parts_map(part_list)
self._update_questions_list(part_list)
self._save()
|
module function_definition identifier parameters identifier block if_statement call attribute identifier identifier argument_list block return_statement expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator call identifier argument_list identifier call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list
|
Updates questions known to this Section
|
def check_name(name, safe_chars):
regexp = re.compile('[^{0}]'.format(safe_chars))
if regexp.search(name):
raise SaltCloudException(
'{0} contains characters not supported by this cloud provider. '
'Valid characters are: {1}'.format(
name, safe_chars
)
)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier if_statement call attribute identifier identifier argument_list 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 identifier
|
Check whether the specified name contains invalid characters
|
def to(self, unit):
from astropy.units import rad
return (self.radians * rad).to(unit)
from astropy.coordinates import Angle
from astropy.units import rad
return Angle(self.radians, rad).to(unit)
|
module function_definition identifier parameters identifier identifier block import_from_statement dotted_name identifier identifier dotted_name identifier return_statement call attribute parenthesized_expression binary_operator attribute identifier identifier identifier identifier argument_list identifier import_from_statement dotted_name identifier identifier dotted_name identifier import_from_statement dotted_name identifier identifier dotted_name identifier return_statement call attribute call identifier argument_list attribute identifier identifier identifier identifier argument_list identifier
|
Convert this angle to the given AstroPy unit.
|
def view_global_gmfs(token, dstore):
imtls = dstore['oqparam'].imtls
row = dstore['gmf_data/data']['gmv'].mean(axis=0)
return rst_table([row], header=imtls)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute subscript identifier string string_start string_content string_end identifier expression_statement assignment identifier call attribute subscript subscript identifier string string_start string_content string_end string string_start string_content string_end identifier argument_list keyword_argument identifier integer return_statement call identifier argument_list list identifier keyword_argument identifier identifier
|
Display GMFs averaged on everything for debugging purposes
|
def bind_end(self, stream, future):
if not isinstance(stream, Stream):
future.set_result(None)
else:
stream.pipe(TaskEndTransformer(future))
|
module function_definition identifier parameters identifier identifier identifier block if_statement not_operator call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list none else_clause block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier
|
Bind a 'TaskEndTransformer' to a stream.
|
def find_bar_plot(ar, nth):
"Find the NTH barplot of the cluster in area AR."
for plot in ar.plots():
if isinstance(plot, T) and plot.cluster[0] == nth:
return plot
raise Exception("The %dth bar plot in the cluster not found." % nth)
|
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end for_statement identifier call attribute identifier identifier argument_list block if_statement boolean_operator call identifier argument_list identifier identifier comparison_operator subscript attribute identifier identifier integer identifier block return_statement identifier raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier
|
Find the NTH barplot of the cluster in area AR.
|
def _get_data(self, id_list, format='MLDataset'):
format = format.lower()
features = list()
for modality, data in self._modalities.items():
if format in ('ndarray', 'data_matrix'):
subset = np.array(itemgetter(*id_list)(data))
elif format in ('mldataset', 'pyradigm'):
subset = self._dataset.get_subset(id_list)
subset.data = { id_: data[id_] for id_ in id_list }
else:
raise ValueError('Invalid output format - choose only one of '
'MLDataset or data_matrix')
features.append(subset)
return features
|
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block if_statement comparison_operator identifier tuple string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list call call identifier argument_list list_splat identifier argument_list identifier elif_clause comparison_operator identifier tuple string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier dictionary_comprehension pair identifier subscript identifier identifier for_in_clause identifier identifier else_clause block raise_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
|
Returns the data, from all modalities, for a given list of IDs
|
def slistStr(slist):
slist = _fixSlist(slist)
string = ':'.join(['%02d' % x for x in slist[1:]])
return slist[0] + string
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list list_comprehension binary_operator string string_start string_content string_end identifier for_in_clause identifier subscript identifier slice integer return_statement binary_operator subscript identifier integer identifier
|
Converts signed list to angle string.
|
def getvariable(name):
import inspect
fr = inspect.currentframe()
try:
while fr:
fr = fr.f_back
vars = fr.f_locals
if name in vars:
return vars[name]
except:
pass
return None
|
module function_definition identifier parameters identifier block import_statement dotted_name identifier expression_statement assignment identifier call attribute identifier identifier argument_list try_statement block while_statement identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier identifier block return_statement subscript identifier identifier except_clause block pass_statement return_statement none
|
Get the value of a local variable somewhere in the call stack.
|
def clear_roles(user):
roles = get_user_roles(user)
for role in roles:
role.remove_role_from_user(user)
return roles
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
|
Remove all roles from a user.
|
def count(self, request, filter=None):
if filter is None:
filter = create_filter(request, self.mapped_class, self.geom_attr)
query = self.Session().query(self.mapped_class)
if filter is not None:
query = query.filter(filter)
return query.count()
|
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list identifier attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list attribute identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list
|
Return the number of records matching the given filter.
|
def next_blocks(self, quantity=-1):
blocks = (EighthBlock.objects.get_blocks_this_year().order_by(
"date", "block_letter").filter(Q(date__gt=self.date) | (Q(date=self.date) & Q(block_letter__gt=self.block_letter))))
if quantity == -1:
return blocks
return blocks[:quantity]
|
module function_definition identifier parameters identifier default_parameter identifier unary_operator integer block expression_statement assignment identifier parenthesized_expression call attribute call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier argument_list binary_operator call identifier argument_list keyword_argument identifier attribute identifier identifier parenthesized_expression binary_operator call identifier argument_list keyword_argument identifier attribute identifier identifier call identifier argument_list keyword_argument identifier attribute identifier identifier if_statement comparison_operator identifier unary_operator integer block return_statement identifier return_statement subscript identifier slice identifier
|
Get the next blocks in order.
|
def config(path=None, root=None, db=None):
import ambry.run
return ambry.run.load(path=path, root=root, db=db)
|
module function_definition identifier parameters default_parameter identifier none default_parameter identifier none default_parameter identifier none block import_statement dotted_name identifier identifier return_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
|
Return the default run_config object for this installation.
|
def _cosmoid_request(self, resource, cosmoid, **kwargs):
params = {
'cosmoid': cosmoid,
}
params.update(kwargs)
return self.make_request(resource, params)
|
module function_definition identifier parameters identifier identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier identifier
|
Maps to the Generic API method for requests who's only parameter is ``cosmoid``
|
def all_domain_events(self):
for originator_id in self.record_manager.all_sequence_ids():
for domain_event in self.get_domain_events(originator_id=originator_id, page_size=100):
yield domain_event
|
module function_definition identifier parameters identifier block for_statement identifier call attribute attribute identifier identifier identifier argument_list block for_statement identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier integer block expression_statement yield identifier
|
Yields all domain events in the event store.
|
def _create_metadata_converter_action(self):
icon = resources_path('img', 'icons', 'show-metadata-converter.svg')
self.action_metadata_converter = QAction(
QIcon(icon),
self.tr('InaSAFE Metadata Converter'),
self.iface.mainWindow())
self.action_metadata_converter.setStatusTip(self.tr(
'Convert metadata from version 4.3 to version 3.5.'))
self.action_metadata_converter.setWhatsThis(self.tr(
'Use this tool to convert metadata 4.3 to version 3.5'))
self.action_metadata_converter.triggered.connect(
self.show_metadata_converter)
self.add_action(
self.action_metadata_converter, add_to_toolbar=self.full_toolbar)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement assignment attribute identifier identifier call identifier argument_list call identifier argument_list identifier call attribute identifier identifier argument_list string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier attribute identifier identifier
|
Create action for showing metadata converter dialog.
|
def _config_params(base_config, assoc_files, region, out_file, items):
params = []
dbsnp = assoc_files.get("dbsnp")
if dbsnp:
params += ["--dbsnp", dbsnp]
cosmic = assoc_files.get("cosmic")
if cosmic:
params += ["--cosmic", cosmic]
variant_regions = bedutils.population_variant_regions(items)
region = subset_variant_regions(variant_regions, region, out_file, items)
if region:
params += ["-L", bamprep.region_to_gatk(region), "--interval_set_rule",
"INTERSECTION"]
min_af = tz.get_in(["algorithm", "min_allele_fraction"], base_config)
if min_af:
params += ["--minimum_mutation_cell_fraction", "%.2f" % (min_af / 100.0)]
resources = config_utils.get_resources("mutect", base_config)
if resources.get("options") is not None:
params += [str(x) for x in resources.get("options", [])]
if "--enable_qscore_output" not in params:
params.append("--enable_qscore_output")
return params
|
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier list expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement augmented_assignment identifier list string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement augmented_assignment identifier list string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier identifier if_statement identifier block expression_statement augmented_assignment identifier list string string_start string_content string_end call attribute identifier identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list list string string_start string_content string_end string string_start string_content string_end identifier if_statement identifier block expression_statement augmented_assignment identifier list string string_start string_content string_end binary_operator string string_start string_content string_end parenthesized_expression binary_operator identifier float expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end none block expression_statement augmented_assignment identifier list_comprehension call identifier argument_list identifier for_in_clause identifier call attribute identifier identifier argument_list string string_start string_content string_end list if_statement comparison_operator string string_start string_content string_end identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier
|
Add parameters based on configuration variables, associated files and genomic regions.
|
def _do_connect(self):
_, self._protocol = yield from self._loop.create_connection(
lambda: SnapcastProtocol(self._callbacks), self._host, self._port)
|
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier attribute identifier identifier yield call attribute attribute identifier identifier identifier argument_list lambda call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier
|
Perform the connection to the server.
|
def _diff(text_0, text_1):
diff = difflib.ndiff(text_0.splitlines(), text_1.splitlines())
return _diff_removed_lines(diff)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list return_statement call identifier argument_list identifier
|
Return a diff between two strings.
|
def OnSearch(self, event):
search_string = self.search.GetValue()
if search_string not in self.search_history:
self.search_history.append(search_string)
if len(self.search_history) > 10:
self.search_history.pop(0)
self.menu = self.make_menu()
self.search.SetMenu(self.menu)
search_flags = self.search_options + ["FIND_NEXT"]
post_command_event(self, self.FindMsg, text=search_string,
flags=search_flags)
self.search.SetFocus()
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator call identifier argument_list attribute identifier identifier integer block expression_statement call attribute attribute identifier identifier identifier argument_list integer expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier binary_operator attribute identifier identifier list string string_start string_content string_end expression_statement call identifier argument_list identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list
|
Event handler for starting the search
|
def split_taf(txt: str) -> [str]:
lines = []
split = txt.split()
last_index = 0
for i, item in enumerate(split):
if starts_new_line(item) and i != 0 and not split[i - 1].startswith('PROB'):
lines.append(' '.join(split[last_index:i]))
last_index = i
lines.append(' '.join(split[last_index:]))
return lines
|
module function_definition identifier parameters typed_parameter identifier type identifier type list identifier block expression_statement assignment identifier list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier integer for_statement pattern_list identifier identifier call identifier argument_list identifier block if_statement boolean_operator boolean_operator call identifier argument_list identifier comparison_operator identifier integer not_operator call attribute subscript identifier binary_operator identifier integer identifier argument_list string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list subscript identifier slice identifier identifier expression_statement assignment identifier identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list subscript identifier slice identifier return_statement identifier
|
Splits a TAF report into each distinct time period
|
def execute(self, array_id = None, machine_name = None):
self.status = 'executing'
if array_id is not None:
for array_job in self.array:
if array_job.id == array_id:
array_job.status = 'executing'
if machine_name is not None:
array_job.machine_name = machine_name
array_job.start_time = datetime.now()
elif machine_name is not None:
self.machine_name = machine_name
if self.start_time is None:
self.start_time = datetime.now()
for job in self.get_jobs_we_wait_for():
if job.array and job.status == 'executing':
job.finish(0, -1)
|
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block expression_statement assignment attribute identifier identifier string string_start string_content string_end if_statement comparison_operator identifier none block for_statement identifier attribute identifier identifier block if_statement comparison_operator attribute identifier identifier identifier block expression_statement assignment attribute identifier identifier string string_start string_content string_end if_statement comparison_operator identifier none block expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list elif_clause comparison_operator identifier none block expression_statement assignment attribute identifier identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list for_statement identifier call attribute identifier identifier argument_list block if_statement boolean_operator attribute identifier identifier comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list integer unary_operator integer
|
Sets the status of this job to 'executing'.
|
def check_coverage():
with lcd(settings.LOCAL_COVERAGE_PATH):
total_line = local('grep -n Total index.html', capture=True)
match = re.search(r'^(\d+):', total_line)
total_line_number = int(match.groups()[0])
percentage_line_number = total_line_number + 5
percentage_line = local(
'awk NR=={0} index.html'.format(percentage_line_number),
capture=True)
match = re.search(r'(\d.+)%', percentage_line)
try:
percentage = float(match.groups()[0])
except ValueError:
match = re.search(r'(\d+)%', percentage_line)
percentage = float(match.groups()[0])
if percentage < 100:
abort(red('Coverage is {0}%'.format(percentage)))
print(green('Coverage is {0}%'.format(percentage)))
|
module function_definition identifier parameters block with_statement with_clause with_item call identifier argument_list attribute identifier identifier block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end keyword_argument identifier true expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list subscript call attribute identifier identifier argument_list integer expression_statement assignment identifier binary_operator identifier integer expression_statement assignment identifier call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier keyword_argument identifier true expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier try_statement block expression_statement assignment identifier call identifier argument_list subscript call attribute identifier identifier argument_list integer except_clause identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list subscript call attribute identifier identifier argument_list integer if_statement comparison_operator identifier integer block expression_statement call identifier argument_list call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call identifier argument_list call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier
|
Checks if the coverage is 100%.
|
def _get_image_numpy_dtype(self):
try:
ftype = self._info['img_equiv_type']
npy_type = _image_bitpix2npy[ftype]
except KeyError:
raise KeyError("unsupported fits data type: %d" % ftype)
return npy_type
|
module function_definition identifier parameters identifier block try_statement block expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier identifier except_clause identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier return_statement identifier
|
Get the numpy dtype for the image
|
def stem(self):
name = self.name
i = name.rfind('.')
if 0 < i < len(name) - 1:
return name[:i]
else:
return name
|
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator integer identifier binary_operator call identifier argument_list identifier integer block return_statement subscript identifier slice identifier else_clause block return_statement identifier
|
The final path component, minus its last suffix.
|
def wr_hdrs(self, worksheet, row_idx):
for col_idx, hdr in enumerate(self.hdrs):
worksheet.write(row_idx, col_idx, hdr, self.fmt_hdr)
row_idx += 1
return row_idx
|
module function_definition identifier parameters identifier identifier identifier block for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier identifier attribute identifier identifier expression_statement augmented_assignment identifier integer return_statement identifier
|
Print row of column headers
|
def append(self, item):
if not isinstance(item, str):
raise TypeError(
'Members of this object must be strings. '
'You supplied \"%s\"' % type(item))
list.append(self, item)
|
module function_definition identifier parameters identifier identifier block if_statement not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list binary_operator concatenated_string string string_start string_content string_end string string_start string_content escape_sequence escape_sequence string_end call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier identifier
|
Adds an item to the list and checks it's a string.
|
def ask_visualization():
printDebug(
"Please choose an output format for the ontology visualization: (q=quit)\n",
"important")
while True:
text = ""
for viz in VISUALIZATIONS_LIST:
text += "%d) %s\n" % (VISUALIZATIONS_LIST.index(viz) + 1,
viz['Title'])
var = input(text + ">")
if var == "q":
return ""
else:
try:
n = int(var) - 1
test = VISUALIZATIONS_LIST[
n]
return n
except:
printDebug("Invalid selection. Please try again.", "red")
continue
|
module function_definition identifier parameters block expression_statement call identifier argument_list string string_start string_content escape_sequence string_end string string_start string_content string_end while_statement true block expression_statement assignment identifier string string_start string_end for_statement identifier identifier block expression_statement augmented_assignment identifier binary_operator string string_start string_content escape_sequence string_end tuple binary_operator call attribute identifier identifier argument_list identifier integer subscript identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list binary_operator identifier string string_start string_content string_end if_statement comparison_operator identifier string string_start string_content string_end block return_statement string string_start string_end else_clause block try_statement block expression_statement assignment identifier binary_operator call identifier argument_list identifier integer expression_statement assignment identifier subscript identifier identifier return_statement identifier except_clause block expression_statement call identifier argument_list string string_start string_content string_end string string_start string_content string_end continue_statement
|
ask user which viz output to use
|
def force_bytes(value):
if IS_PY3:
if isinstance(value, str):
value = value.encode('utf-8', 'backslashreplace')
else:
if isinstance(value, unicode):
value = value.encode('utf-8')
return value
|
module function_definition identifier parameters identifier block if_statement identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end else_clause block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier
|
Forces a Unicode string to become a bytestring.
|
def stem(self, word):
if self.stemmer:
return unicode_to_ascii(self._stemmer.stem(word))
else:
return word
|
module function_definition identifier parameters identifier identifier block if_statement attribute identifier identifier block return_statement call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier else_clause block return_statement identifier
|
Perform stemming on an input word.
|
def write_data(self, write_finished_cb):
self._write_finished_cb = write_finished_cb
data = bytearray()
for poly4D in self.poly4Ds:
data += struct.pack('<ffffffff', *poly4D.x.values)
data += struct.pack('<ffffffff', *poly4D.y.values)
data += struct.pack('<ffffffff', *poly4D.z.values)
data += struct.pack('<ffffffff', *poly4D.yaw.values)
data += struct.pack('<f', poly4D.duration)
self.mem_handler.write(self, 0x00, data, flush_queue=True)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list for_statement identifier attribute identifier identifier block expression_statement augmented_assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end list_splat attribute attribute identifier identifier identifier expression_statement augmented_assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end list_splat attribute attribute identifier identifier identifier expression_statement augmented_assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end list_splat attribute attribute identifier identifier identifier expression_statement augmented_assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end list_splat attribute attribute identifier identifier identifier expression_statement augmented_assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier integer identifier keyword_argument identifier true
|
Write trajectory data to the Crazyflie
|
def todo(self):
if not os.path.exists(self.migrate_dir):
self.logger.warn('Migration directory: %s does not exist.', self.migrate_dir)
os.makedirs(self.migrate_dir)
return sorted(f[:-3] for f in os.listdir(self.migrate_dir) if self.filemask.match(f))
|
module function_definition identifier parameters identifier block if_statement not_operator call attribute attribute identifier identifier identifier argument_list attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier return_statement call identifier generator_expression subscript identifier slice unary_operator integer for_in_clause identifier call attribute identifier identifier argument_list attribute identifier identifier if_clause call attribute attribute identifier identifier identifier argument_list identifier
|
Scan migrations in file system.
|
def limits(self,variable):
(vmin,vmax), = self.SELECT('min(%(variable)s), max(%(variable)s)' % vars())
return vmin,vmax
|
module function_definition identifier parameters identifier identifier block expression_statement assignment pattern_list tuple_pattern identifier identifier call attribute identifier identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list return_statement expression_list identifier identifier
|
Return minimum and maximum of variable across all rows of data.
|
def column_correlations(self, X):
utils.validation.check_is_fitted(self, 's_')
if isinstance(X, np.ndarray):
X = pd.DataFrame(X)
row_pc = self.row_coordinates(X)
return pd.DataFrame({
component: {
feature: row_pc[component].corr(X[feature])
for feature in X.columns
}
for component in row_pc.columns
})
|
module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end if_statement call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list dictionary_comprehension pair identifier dictionary_comprehension pair identifier call attribute subscript identifier identifier identifier argument_list subscript identifier identifier for_in_clause identifier attribute identifier identifier for_in_clause identifier attribute identifier identifier
|
Returns the column correlations with each principal component.
|
def step_type(self):
if 'stepfc' in self.__class__.__name__.lower():
return STEP_FC
if 'stepkw' in self.__class__.__name__.lower():
return STEP_KW
|
module function_definition identifier parameters identifier block if_statement comparison_operator string string_start string_content string_end call attribute attribute attribute identifier identifier identifier identifier argument_list block return_statement identifier if_statement comparison_operator string string_start string_content string_end call attribute attribute attribute identifier identifier identifier identifier argument_list block return_statement identifier
|
Whether it's a IFCW step or Keyword Wizard Step.
|
def print_plugins(self):
width = console_width()
line = Style.BRIGHT + '=' * width + '\n'
middle = int(width / 2)
if self.available_providers:
print(line + ' ' * middle + 'PROVIDERS')
for provider in sorted(self.available_providers.values(),
key=lambda x: x.identifier):
provider().print()
print()
if self.available_checkers:
print(line + ' ' * middle + 'CHECKERS')
for checker in sorted(self.available_checkers.values(),
key=lambda x: x.identifier):
checker().print()
print()
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier binary_operator binary_operator attribute identifier identifier binary_operator string string_start string_content string_end identifier string string_start string_content escape_sequence string_end expression_statement assignment identifier call identifier argument_list binary_operator identifier integer if_statement attribute identifier identifier block expression_statement call identifier argument_list binary_operator binary_operator identifier binary_operator string string_start string_content string_end identifier string string_start string_content string_end for_statement identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list keyword_argument identifier lambda lambda_parameters identifier attribute identifier identifier block expression_statement call attribute call identifier argument_list identifier argument_list expression_statement call identifier argument_list if_statement attribute identifier identifier block expression_statement call identifier argument_list binary_operator binary_operator identifier binary_operator string string_start string_content string_end identifier string string_start string_content string_end for_statement identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list keyword_argument identifier lambda lambda_parameters identifier attribute identifier identifier block expression_statement call attribute call identifier argument_list identifier argument_list expression_statement call identifier argument_list
|
Print the available plugins.
|
def _from_api_repr(cls, resource):
job_id = resource.get("jobId")
project = resource.get("projectId")
location = resource.get("location")
job_ref = cls(job_id, project, location)
return job_ref
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier identifier identifier return_statement identifier
|
Returns a job reference for an API resource representation.
|
def blacklistClient(self, clientName: str,
reason: str = None, code: int = None):
msg = "{} blacklisting client {}".format(self, clientName)
if reason:
msg += " for reason {}".format(reason)
logger.display(msg)
self.clientBlacklister.blacklist(clientName)
|
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_default_parameter identifier type identifier none typed_default_parameter identifier type identifier none block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier identifier if_statement identifier block expression_statement augmented_assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
|
Add the client specified by `clientName` to this node's blacklist
|
def wc_names(self):
if self.wc_name is None:
res = set()
else:
res = set([self.wc_name])
if self.args is not None:
for arg in self.args:
if isinstance(arg, Pattern):
res.update(arg.wc_names)
if self.kwargs is not None:
for val in self.kwargs.values():
if isinstance(val, Pattern):
res.update(val.wc_names)
return res
|
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier call identifier argument_list else_clause block expression_statement assignment identifier call identifier argument_list list attribute identifier identifier if_statement comparison_operator attribute identifier identifier none block for_statement identifier attribute identifier identifier block if_statement call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier if_statement comparison_operator attribute identifier identifier none block for_statement identifier call attribute attribute identifier identifier identifier argument_list block if_statement call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier return_statement identifier
|
Set of all wildcard names occurring in the pattern
|
def add(self, r):
id = r.get_residue_id()
if self.order:
last_id = self.order[-1]
if id in self.order:
raise colortext.Exception('Warning: using code to "allow for multiresidue noncanonicals" - check this case manually.')
id = '%s.%d'%(str(id),self.special_insertion_count)
self.special_insertion_count += 1
assert(r.Chain == self.sequence[last_id].Chain)
assert(r.residue_type == self.sequence[last_id].residue_type)
self.order.append(id)
self.sequence[id] = r
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement attribute identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier unary_operator integer if_statement comparison_operator identifier attribute identifier identifier block raise_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier binary_operator string string_start string_content string_end tuple call identifier argument_list identifier attribute identifier identifier expression_statement augmented_assignment attribute identifier identifier integer assert_statement parenthesized_expression comparison_operator attribute identifier identifier attribute subscript attribute identifier identifier identifier identifier assert_statement parenthesized_expression comparison_operator attribute identifier identifier attribute subscript attribute identifier identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment subscript attribute identifier identifier identifier identifier
|
Takes an id and a Residue r and adds them to the Sequence.
|
def data_import(self, json_response):
if 'data' not in json_response:
raise PyVLXException('no element data found: {0}'.format(
json.dumps(json_response)))
data = json_response['data']
for item in data:
self.load_scene(item)
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator string string_start string_content string_end identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list identifier expression_statement assignment identifier subscript identifier string string_start string_content string_end for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier
|
Import scenes from JSON response.
|
def authenticate(self, username=None, password=None, **kwargs):
try:
user = User.objects.get(email=username)
if user.check_password(password):
return user
except (User.DoesNotExist, User.MultipleObjectsReturned):
logging.warning('Unsuccessful login attempt using username/email: {0}'.format(username))
return None
|
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none dictionary_splat_pattern identifier block try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier if_statement call attribute identifier identifier argument_list identifier block return_statement identifier except_clause tuple attribute identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier return_statement none
|
"username" being passed is really email address and being compared to as such.
|
def add_source(self, url, *, note=''):
new = {'url': url, 'note': note}
self.sources.append(new)
|
module function_definition identifier parameters identifier identifier keyword_separator default_parameter identifier string string_start string_end block expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
|
Add a source URL from which data was collected
|
def limit_author_choices():
LIMIT_AUTHOR_CHOICES = getattr(settings, 'BLOG_LIMIT_AUTHOR_CHOICES_GROUP', None)
if LIMIT_AUTHOR_CHOICES:
if isinstance(LIMIT_AUTHOR_CHOICES, str):
limit = Q(groups__name=LIMIT_AUTHOR_CHOICES)
else:
limit = Q()
for s in LIMIT_AUTHOR_CHOICES:
limit = limit | Q(groups__name=s)
if getattr(settings, 'BLOG_LIMIT_AUTHOR_CHOICES_ADMIN', False):
limit = limit | Q(is_staff=True)
else:
limit = {'is_staff': True}
return limit
|
module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end none if_statement identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier else_clause block expression_statement assignment identifier call identifier argument_list for_statement identifier identifier block expression_statement assignment identifier binary_operator identifier call identifier argument_list keyword_argument identifier identifier if_statement call identifier argument_list identifier string string_start string_content string_end false block expression_statement assignment identifier binary_operator identifier call identifier argument_list keyword_argument identifier true else_clause block expression_statement assignment identifier dictionary pair string string_start string_content string_end true return_statement identifier
|
Limit choices in blog author field based on config settings
|
def calculate_leapdays(init_date, final_date):
leap_days = (final_date.year - 1) // 4 - (init_date.year - 1) // 4
leap_days -= (final_date.year - 1) // 100 - (init_date.year - 1) // 100
leap_days += (final_date.year - 1) // 400 - (init_date.year - 1) // 400
return datetime.timedelta(days=leap_days)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier binary_operator binary_operator parenthesized_expression binary_operator attribute identifier identifier integer integer binary_operator parenthesized_expression binary_operator attribute identifier identifier integer integer expression_statement augmented_assignment identifier binary_operator binary_operator parenthesized_expression binary_operator attribute identifier identifier integer integer binary_operator parenthesized_expression binary_operator attribute identifier identifier integer integer expression_statement augmented_assignment identifier binary_operator binary_operator parenthesized_expression binary_operator attribute identifier identifier integer integer binary_operator parenthesized_expression binary_operator attribute identifier identifier integer integer return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier
|
Currently unsupported, it only works for differences in years.
|
def _ParseMatchGrp(self, key, val):
if key in self._match_keywords:
self._ParseEntry(key, val)
|
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier
|
Adds valid match group parameters to the configuration.
|
def existing_path(value):
if os.path.exists(value):
return value
else:
raise argparse.ArgumentTypeError("Path {0} not found".format(value))
|
module function_definition identifier parameters identifier block if_statement call attribute attribute identifier identifier identifier argument_list identifier block return_statement identifier else_clause block raise_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier
|
Throws when the path does not exist
|
def load_json(self, json):
for key in json:
if key == "wandb_version":
continue
self._items[key] = json[key].get('value')
self._descriptions[key] = json[key].get('desc')
|
module function_definition identifier parameters identifier identifier block for_statement identifier identifier block if_statement comparison_operator identifier string string_start string_content string_end block continue_statement expression_statement assignment subscript attribute identifier identifier identifier call attribute subscript identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment subscript attribute identifier identifier identifier call attribute subscript identifier identifier identifier argument_list string string_start string_content string_end
|
Loads existing config from JSON
|
def t_ID(self, t):
r'[a-zA-Z_@][a-zA-Z0-9_@\-]*'
t.type = self.reserved_words.get(t.value, 'ID')
return t
|
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier string string_start string_content string_end return_statement identifier
|
r'[a-zA-Z_@][a-zA-Z0-9_@\-]*
|
def render_toctrees(kb_app: kb, sphinx_app: Sphinx, doctree: doctree,
fromdocname: str):
settings: KaybeeSettings = sphinx_app.config.kaybee_settings
if not settings.articles.use_toctree:
return
builder: StandaloneHTMLBuilder = sphinx_app.builder
env: BuildEnvironment = sphinx_app.env
registered_toctree = ToctreeAction.get_for_context(kb_app)
for node in doctree.traverse(toctree):
if node.attributes['hidden']:
continue
custom_toctree = registered_toctree(fromdocname)
context = builder.globalcontext.copy()
context['sphinx_app'] = sphinx_app
entries = node.attributes['entries']
custom_toctree.set_entries(entries, env.titles,
sphinx_app.env.resources)
output = custom_toctree.render(builder, context, sphinx_app)
listing = [nodes.raw('', output, format='html')]
node.replace_self(listing)
|
module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier block expression_statement assignment identifier type identifier attribute attribute identifier identifier identifier if_statement not_operator attribute attribute identifier identifier identifier block return_statement expression_statement assignment identifier type identifier attribute identifier identifier expression_statement assignment identifier type identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement identifier call attribute identifier identifier argument_list identifier block if_statement subscript attribute identifier identifier string string_start string_content string_end block continue_statement expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier expression_statement assignment identifier list call attribute identifier identifier argument_list string string_start string_end identifier keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier
|
Look in doctrees for toctree and replace with custom render
|
def sort(ctx):
head = ctx.parent.head
vcf_handle = ctx.parent.handle
outfile = ctx.parent.outfile
silent = ctx.parent.silent
print_headers(head, outfile=outfile, silent=silent)
for line in sort_variants(vcf_handle):
print_variant(variant_line=line, outfile=outfile, silent=silent)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier for_statement identifier call identifier argument_list identifier block expression_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
|
Sort the variants of a vcf file
|
def cmd_list_identities(self, *args):
identities = self._get_available_identities()
print('Available identities:')
for x in identities:
print(' - {}'.format(x))
|
module function_definition identifier parameters identifier list_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call identifier argument_list string string_start string_content string_end for_statement identifier identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier
|
List the available identities to use for signing.
|
def to_native_units(self, motor):
assert abs(self.degrees_per_second) <= motor.max_dps,\
"invalid degrees-per-second: {} max DPS is {}, {} was requested".format(
motor, motor.max_dps, self.degrees_per_second)
return self.degrees_per_second/motor.max_dps * motor.max_speed
|
module function_definition identifier parameters identifier identifier block assert_statement comparison_operator call identifier argument_list attribute identifier identifier attribute identifier identifier call attribute string string_start string_content string_end identifier argument_list identifier attribute identifier identifier attribute identifier identifier return_statement binary_operator binary_operator attribute identifier identifier attribute identifier identifier attribute identifier identifier
|
Return the native speed measurement required to achieve desired degrees-per-second
|
def integrate(arr, ddim, dim=False, is_pressure=False):
if is_pressure:
dim = vert_coord_name(ddim)
return (arr*ddim).sum(dim=dim)
|
module function_definition identifier parameters identifier identifier default_parameter identifier false default_parameter identifier false block if_statement identifier block expression_statement assignment identifier call identifier argument_list identifier return_statement call attribute parenthesized_expression binary_operator identifier identifier identifier argument_list keyword_argument identifier identifier
|
Integrate along the given dimension.
|
def make_wsgi_app(registry=REGISTRY):
def prometheus_app(environ, start_response):
params = parse_qs(environ.get('QUERY_STRING', ''))
r = registry
encoder, content_type = choose_encoder(environ.get('HTTP_ACCEPT'))
if 'name[]' in params:
r = r.restricted_registry(params['name[]'])
output = encoder(r)
status = str('200 OK')
headers = [(str('Content-type'), content_type)]
start_response(status, headers)
return [output]
return prometheus_app
|
module function_definition identifier parameters default_parameter identifier identifier block function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end expression_statement assignment identifier identifier expression_statement assignment pattern_list identifier identifier call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list string string_start string_content string_end expression_statement assignment identifier list tuple call identifier argument_list string string_start string_content string_end identifier expression_statement call identifier argument_list identifier identifier return_statement list identifier return_statement identifier
|
Create a WSGI app which serves the metrics from a registry.
|
def create_alarm(panel_json, abode, area='1'):
panel_json['name'] = CONST.ALARM_NAME
panel_json['id'] = CONST.ALARM_DEVICE_ID + area
panel_json['type'] = CONST.ALARM_TYPE
panel_json['type_tag'] = CONST.DEVICE_ALARM
panel_json['generic_type'] = CONST.TYPE_ALARM
return AbodeAlarm(panel_json, abode, area)
|
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end block 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 binary_operator attribute identifier identifier 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 attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier return_statement call identifier argument_list identifier identifier identifier
|
Create a new alarm device from a panel response.
|
def _get_handler(self, node_id):
handler = self._get_attrs(node_id).get(self.HANDLER, self._default_handler)
if not isinstance(handler, BasicNodeHandler):
idaapi.msg(("Invalid handler for node {}: {}. All handlers must inherit from"
"`BasicNodeHandler`.").format(node_id, handler))
handler = self._default_handler
return handler
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier identifier argument_list attribute identifier identifier attribute identifier identifier if_statement not_operator call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute parenthesized_expression concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list identifier identifier expression_statement assignment identifier attribute identifier identifier return_statement identifier
|
Get the handler of a given node.
|
def splice(self, mark, newdata):
self.jump_to(mark)
self._data = self._data[:self._offset] + bytearray(newdata)
|
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier binary_operator subscript attribute identifier identifier slice attribute identifier identifier call identifier argument_list identifier
|
Replace the data after the marked location with the specified data.
|
def format_load_balancer_configuration(result):
from collections import OrderedDict
order_dict = OrderedDict()
if result.private_ip_address is not None:
order_dict['privateIpAddress'] = format_private_ip_address(result.private_ip_address)
if result.public_ip_address_resource_id is not None:
order_dict['publicIpAddressResourceId'] = result.public_ip_address_resource_id
if result.load_balancer_resource_id is not None:
order_dict['loadBalancerResourceId'] = result.load_balancer_resource_id
if result.probe_port is not None:
order_dict['probePort'] = result.probe_port
if result.sql_virtual_machine_instances is not None:
order_dict['sqlVirtualMachineInstances'] = result.sql_virtual_machine_instances
return order_dict
|
module function_definition identifier parameters identifier block import_from_statement dotted_name identifier dotted_name identifier expression_statement assignment identifier call identifier argument_list if_statement comparison_operator attribute identifier identifier none block expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list attribute identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier return_statement identifier
|
Formats the LoadBalancerConfiguration object removing arguments that are empty
|
def create_local_module_dir(cache_dir, module_name):
tf_v1.gfile.MakeDirs(cache_dir)
return os.path.join(cache_dir, module_name)
|
module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier identifier
|
Creates and returns the name of directory where to cache a module.
|
def include_original(dec):
def meta_decorator(method):
decorator = dec(method)
decorator._original = method
return decorator
return meta_decorator
|
module function_definition identifier parameters identifier block function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier return_statement identifier return_statement identifier
|
Decorate decorators so they include a copy of the original function.
|
def _linkToParent(self, feature, parentName):
parentParts = self.byFeatureName.get(parentName)
if parentParts is None:
raise GFF3Exception(
"Parent feature does not exist: {}".format(parentName),
self.fileName)
for parentPart in parentParts:
feature.parents.add(parentPart)
parentPart.children.add(feature)
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator identifier none block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier attribute identifier identifier for_statement identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
|
Link a feature with its children
|
def columns(self):
fields = [f.label for f in self.form_fields
if self.cleaned_data["field_%s_export" % f.id]]
if self.cleaned_data["field_0_export"]:
fields.append(self.entry_time_name)
return fields
|
module function_definition identifier parameters identifier block expression_statement assignment identifier list_comprehension attribute identifier identifier for_in_clause identifier attribute identifier identifier if_clause subscript attribute identifier identifier binary_operator string string_start string_content string_end attribute identifier identifier if_statement subscript attribute identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list attribute identifier identifier return_statement identifier
|
Returns the list of selected column names.
|
def verify(backup_path, fast):
from PyHardLinkBackup.phlb.verify import verify_backup
verify_backup(backup_path, fast)
|
module function_definition identifier parameters identifier identifier block import_from_statement dotted_name identifier identifier identifier dotted_name identifier expression_statement call identifier argument_list identifier identifier
|
Verify a existing backup
|
def _post(self, url, attributes=None, **kwargs):
return self._request('post', url, attributes, **kwargs)
|
module function_definition identifier parameters identifier identifier default_parameter identifier none dictionary_splat_pattern identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier dictionary_splat identifier
|
Wrapper for the HTTP POST request.
|
def logs(self):
url = self._url + "/logs"
return _log(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator attribute identifier identifier string string_start string_content string_end return_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier
|
returns the portals log information
|
def create_ambiente(self):
return Ambiente(
self.networkapi_url,
self.user,
self.password,
self.user_ldap)
|
module function_definition identifier parameters identifier block return_statement call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier
|
Get an instance of ambiente services facade.
|
def update_view_count_by_uid(uid):
entry = TabWiki.update(
view_count=TabWiki.view_count + 1
).where(
TabWiki.uid == uid
)
entry.execute()
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list keyword_argument identifier binary_operator attribute identifier identifier integer identifier argument_list comparison_operator attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list
|
update the count of wiki, by uid.
|
def compare_urls(self, url1, url2):
return (self.normalize_url(url1) == self.normalize_url(url2))
|
module function_definition identifier parameters identifier identifier identifier block return_statement parenthesized_expression comparison_operator call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier
|
Compare two repo URLs for identity, ignoring incidental differences.
|
def spammer_view(request):
context = RequestContext(request, {})
template = Template("")
response = HttpResponse(template.render(context))
response.set_cookie(COOKIE_KEY, value=COOKIE_SPAM, httponly=True,
expires=datetime.now()+timedelta(days=3650))
if DJANGOSPAM_LOG:
log("BLOCK RESPONSE", request.method, request.path_info,
request.META.get("HTTP_USER_AGENT", "undefined"))
return response
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier dictionary expression_statement assignment identifier call identifier argument_list string string_start string_end expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier true keyword_argument identifier binary_operator call attribute identifier identifier argument_list call identifier argument_list keyword_argument identifier integer if_statement identifier block expression_statement call identifier argument_list string string_start string_content string_end attribute identifier identifier attribute identifier identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end return_statement identifier
|
View for setting cookies on spammers.
|
def calculate_manual_reading(basic_data: BasicMeterData) -> Reading:
t_start = basic_data.previous_register_read_datetime
t_end = basic_data.current_register_read_datetime
read_start = basic_data.previous_register_read
read_end = basic_data.current_register_read
value = basic_data.quantity
uom = basic_data.uom
quality_method = basic_data.current_quality_method
return Reading(t_start, t_end, value, uom, quality_method, "", "",
read_start, read_end)
|
module function_definition identifier parameters typed_parameter identifier type identifier type identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier return_statement call identifier argument_list identifier identifier identifier identifier identifier string string_start string_end string string_start string_end identifier identifier
|
Calculate the interval between two manual readings
|
def to_rec(samples, default_keys=None):
recs = samples_to_records([normalize_missing(utils.to_single_data(x)) for x in samples], default_keys)
return [[x] for x in recs]
|
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier call identifier argument_list list_comprehension call identifier argument_list call attribute identifier identifier argument_list identifier for_in_clause identifier identifier identifier return_statement list_comprehension list identifier for_in_clause identifier identifier
|
Convert inputs into CWL records, useful for single item parallelization.
|
def current(self):
config = self.alembic_config()
script = ScriptDirectory.from_config(config)
revision = 'base'
def display_version(rev, context):
for rev in script.get_all_current(rev):
nonlocal revision
revision = rev.cmd_format(False)
return []
with EnvironmentContext(config, script, fn=display_version):
script.run_env()
return revision
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier string string_start string_content string_end function_definition identifier parameters identifier identifier block for_statement identifier call attribute identifier identifier argument_list identifier block nonlocal_statement identifier expression_statement assignment identifier call attribute identifier identifier argument_list false return_statement list with_statement with_clause with_item call identifier argument_list identifier identifier keyword_argument identifier identifier block expression_statement call attribute identifier identifier argument_list return_statement identifier
|
Display the current database revision
|
def outfile(self):
return os.path.join(OPTIONS['base_dir'],
'{0}.{1}'.format(self.name, OPTIONS['out_ext']))
|
module function_definition identifier parameters identifier block return_statement call attribute attribute identifier identifier identifier argument_list subscript identifier string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier subscript identifier string string_start string_content string_end
|
Path of the output file
|
def score_small_straight_yatzy(dice: List[int]) -> int:
dice_set = set(dice)
if _are_two_sets_equal({1, 2, 3, 4, 5}, dice_set):
return sum(dice)
return 0
|
module function_definition identifier parameters typed_parameter identifier type generic_type identifier type_parameter type identifier type identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement call identifier argument_list set integer integer integer integer integer identifier block return_statement call identifier argument_list identifier return_statement integer
|
Small straight scoring according to yatzy rules
|
def model(self):
try:
return self.data.get('identity').get('model_name')
except (KeyError, AttributeError):
return self.device_status_simple('')
|
module function_definition identifier parameters identifier block try_statement block return_statement call attribute call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier argument_list string string_start string_content string_end except_clause tuple identifier identifier block return_statement call attribute identifier identifier argument_list string string_start string_end
|
Return the model name of the printer.
|
def tools(self, extra_params=None):
return self.api._get_json(
SpaceTool,
space=self,
rel_path=self._build_rel_path('space_tools'),
extra_params=extra_params,
)
|
module function_definition identifier parameters identifier default_parameter identifier none block return_statement call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier
|
All Tools in this Space
|
def main(port=8222):
loop = asyncio.get_event_loop()
environ = {'hello': 'world'}
def create_server():
return MySSHServer(lambda: environ)
print('Listening on :%i' % port)
print('To connect, do "ssh localhost -p %i"' % port)
loop.run_until_complete(
asyncssh.create_server(create_server, '', port,
server_host_keys=['/etc/ssh/ssh_host_dsa_key']))
loop.run_forever()
|
module function_definition identifier parameters default_parameter identifier integer block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end function_definition identifier parameters block return_statement call identifier argument_list lambda identifier expression_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier string string_start string_end identifier keyword_argument identifier list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list
|
Example that starts the REPL through an SSH server.
|
async def get_devices(self, covers_only: bool = True) -> list:
from .device import MyQDevice
_LOGGER.debug('Retrieving list of devices')
devices_resp = await self._request('get', DEVICE_LIST_ENDPOINT)
device_list = []
if devices_resp is None:
return device_list
for device in devices_resp['Devices']:
if not covers_only or \
device['MyQDeviceTypeName'] in SUPPORTED_DEVICE_TYPE_NAMES:
self._devices.append({
'device_id': device['MyQDeviceId'],
'device_info': device
})
myq_device = MyQDevice(
self._devices[-1], self._brand, self)
device_list.append(myq_device)
self._store_device_states(devices_resp.get('Devices', []))
_LOGGER.debug('List of devices retrieved')
return device_list
|
module function_definition identifier parameters identifier typed_default_parameter identifier type identifier true type identifier block import_from_statement relative_import import_prefix dotted_name identifier dotted_name identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier await call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier list if_statement comparison_operator identifier none block return_statement identifier for_statement identifier subscript identifier string string_start string_content string_end block if_statement boolean_operator not_operator identifier line_continuation comparison_operator subscript identifier string string_start string_content string_end identifier block expression_statement call attribute attribute identifier identifier identifier argument_list dictionary pair string string_start string_content string_end subscript identifier string string_start string_content string_end pair string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list subscript attribute identifier identifier unary_operator integer attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier
|
Get a list of all devices associated with the account.
|
def create_prefix_dir(self, path, fmt):
create_prefix_dir(self._get_os_path(path.strip('/')), fmt)
|
module function_definition identifier parameters identifier identifier identifier block expression_statement call identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end identifier
|
Create the prefix dir, if missing
|
def make_err(self, body: str, key: str = 'report path') -> InvalidRequest:
msg = f'Could not find {key} in {self.__class__.__name__} response\n'
return InvalidRequest(msg + body)
|
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_default_parameter identifier type identifier string string_start string_content string_end type identifier block expression_statement assignment identifier string string_start string_content interpolation identifier string_content interpolation attribute attribute identifier identifier identifier string_content escape_sequence string_end return_statement call identifier argument_list binary_operator identifier identifier
|
Returns an InvalidRequest exception with formatted error message
|
def aes_kdf(key, rounds, password=None, keyfile=None):
cipher = AES.new(key, AES.MODE_ECB)
key_composite = compute_key_composite(
password=password,
keyfile=keyfile
)
transformed_key = key_composite
for _ in range(0, rounds):
transformed_key = cipher.encrypt(transformed_key)
return hashlib.sha256(transformed_key).digest()
|
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier expression_statement assignment identifier identifier for_statement identifier call identifier argument_list integer identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement call attribute call attribute identifier identifier argument_list identifier identifier argument_list
|
Set up a context for AES128-ECB encryption to find transformed_key
|
def shape(self, shape=None):
if shape is None:
return self._shape
data, color = self.renderer.manager.set_shape(self.model.id, shape)
self.model.data = data
self.color = color
self._shape = shape
|
module function_definition identifier parameters identifier default_parameter identifier none block if_statement comparison_operator identifier none block return_statement attribute identifier identifier expression_statement assignment pattern_list identifier identifier call attribute attribute attribute identifier identifier identifier identifier argument_list attribute attribute identifier identifier identifier identifier expression_statement assignment attribute attribute identifier identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier
|
We need to shift buffers in order to change shape
|
def guess_fill_char( left_comp, right_comp ):
return "*"
if ( left_comp.src == right_comp.src and left_comp.strand != right_comp.strand ):
if left_comp.end == right_comp.start:
return "-"
return "*"
|
module function_definition identifier parameters identifier identifier block return_statement string string_start string_content string_end if_statement parenthesized_expression boolean_operator comparison_operator attribute identifier identifier attribute identifier identifier comparison_operator attribute identifier identifier attribute identifier identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block return_statement string string_start string_content string_end return_statement string string_start string_content string_end
|
For the case where there is no annotated synteny we will try to guess it
|
def add(args):
session = c.Session(args)
if args["name"] in session.feeds.sections():
sys.exit("You already have a feed with that name.")
if args["name"] in ["all", "DEFAULT"]:
sys.exit(
("greg uses ""{}"" for a special purpose."
"Please choose another name for your feed.").format(args["name"]))
entry = {}
for key, value in args.items():
if value is not None and key != "func" and key != "name":
entry[key] = value
session.feeds[args["name"]] = entry
with open(session.data_filename, 'w') as configfile:
session.feeds.write(configfile)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator subscript identifier string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator subscript identifier string string_start string_content string_end list 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 parenthesized_expression 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 identifier argument_list subscript identifier string string_start string_content string_end expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement boolean_operator boolean_operator comparison_operator identifier none comparison_operator identifier string string_start string_content string_end comparison_operator identifier string string_start string_content string_end block expression_statement assignment subscript identifier identifier identifier expression_statement assignment subscript attribute identifier identifier subscript identifier string string_start string_content string_end identifier with_statement with_clause with_item as_pattern call identifier argument_list attribute identifier identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier
|
Add a new feed
|
def render_item(self, contentitem):
plugin = contentitem.plugin
if not plugin.search_output and not plugin.search_fields:
raise SkipItem
if not plugin.search_output:
output = ContentItemOutput('', cacheable=False)
else:
output = super(SearchRenderingPipe, self).render_item(contentitem)
if plugin.search_fields:
output.html += plugin.get_search_text(contentitem)
output.cacheable = False
return output
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier if_statement boolean_operator not_operator attribute identifier identifier not_operator attribute identifier identifier block raise_statement identifier if_statement not_operator attribute identifier identifier block expression_statement assignment identifier call identifier argument_list string string_start string_end keyword_argument identifier false else_clause block expression_statement assignment identifier call attribute call identifier argument_list identifier identifier identifier argument_list identifier if_statement attribute identifier identifier block expression_statement augmented_assignment attribute identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier false return_statement identifier
|
Render the item - but render as search text instead.
|
def tool_options_from_global(global_options, num_jobs):
internal_opt = ["whitelist", "blacklist", "fix_what_you_can"]
queue_object = _obtain_queue(num_jobs)
translate = defaultdict(lambda: (lambda x: x),
log_technical_terms_to=lambda _: queue_object)
tool_options = OrderedDict()
for key in sorted(global_options.keys()):
if key not in internal_opt and global_options[key] is not None:
tool_options[key] = translate[key](global_options[key])
return tool_options
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list lambda parenthesized_expression lambda lambda_parameters identifier identifier keyword_argument identifier lambda lambda_parameters identifier identifier expression_statement assignment identifier call identifier argument_list for_statement identifier call identifier argument_list call attribute identifier identifier argument_list block if_statement boolean_operator comparison_operator identifier identifier comparison_operator subscript identifier identifier none block expression_statement assignment subscript identifier identifier call subscript identifier identifier argument_list subscript identifier identifier return_statement identifier
|
From an argparse namespace, get a dict of options for the tools.
|
def convert_bool(key, val, attr_type, attr={}, cdata=False):
LOG.info('Inside convert_bool(): key="%s", val="%s", type(val) is: "%s"' % (
unicode_me(key), unicode_me(val), type(val).__name__)
)
key, attr = make_valid_xml_name(key, attr)
if attr_type:
attr['type'] = get_xml_type(val)
attrstring = make_attrstring(attr)
return '<%s%s>%s</%s>' % (key, attrstring, unicode(val).lower(), key)
|
module function_definition identifier parameters identifier identifier identifier default_parameter identifier dictionary default_parameter identifier false block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple call identifier argument_list identifier call identifier argument_list identifier attribute call identifier argument_list identifier identifier expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier identifier if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier return_statement binary_operator string string_start string_content string_end tuple identifier identifier call attribute call identifier argument_list identifier identifier argument_list identifier
|
Converts a boolean into an XML element
|
def n_yearly_publications(self, refresh=True):
pub_years = [int(ab.coverDate.split('-')[0])
for ab in self.get_journal_abstracts(refresh=refresh)]
return Counter(pub_years)
|
module function_definition identifier parameters identifier default_parameter identifier true block expression_statement assignment identifier list_comprehension call identifier argument_list subscript call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end integer for_in_clause identifier call attribute identifier identifier argument_list keyword_argument identifier identifier return_statement call identifier argument_list identifier
|
Number of journal publications in a given year.
|
def lrn(self, depth_radius, bias, alpha, beta):
name = "lrn" + str(self.counts["lrn"])
self.counts["lrn"] += 1
self.top_layer = tf.nn.lrn(
self.top_layer, depth_radius, bias, alpha, beta, name=name)
return self.top_layer
|
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end expression_statement augmented_assignment subscript attribute identifier identifier string string_start string_content string_end integer expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier identifier identifier identifier keyword_argument identifier identifier return_statement attribute identifier identifier
|
Adds a local response normalization layer.
|
def trylock(self):
"Try to acquire lock and return True; if cannot acquire the lock at this moment, return False."
if self.locked:
return True
if self.lockroutine:
return False
waiter = self.scheduler.send(LockEvent(self.context, self.key, self))
if waiter:
return False
else:
self.locked = True
return True
|
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end if_statement attribute identifier identifier block return_statement true if_statement attribute identifier identifier block return_statement false expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call identifier argument_list attribute identifier identifier attribute identifier identifier identifier if_statement identifier block return_statement false else_clause block expression_statement assignment attribute identifier identifier true return_statement true
|
Try to acquire lock and return True; if cannot acquire the lock at this moment, return False.
|
def update_value(self, block_id, field, value):
block_name = self._db.get_block(block_id)
for name in block_name:
self._db.set_value(name, field, value)
|
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier for_statement identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier identifier
|
Update the value of the given block id and field
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.