code stringlengths 51 2.34k | sequence stringlengths 186 3.94k | docstring stringlengths 11 171 |
|---|---|---|
def _param32(ins):
output = _32bit_oper(ins.quad[1])
output.append('push de')
output.append('push hl')
return output | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list subscript attribute identifier identifier integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier | Pushes 32bit param into the stack |
def lang_match_json(row, hdr, accepted_languages):
if not accepted_languages:
return True
languages = set([row[c].get('xml:lang') for c in hdr
if c in row and row[c]['type'] == 'literal'])
return (not languages) or (languages & accepted_languages) | module function_definition identifier parameters identifier identifier identifier block if_statement not_operator identifier block return_statement true expression_statement assignment identifier call identifier argument_list list_comprehension call attribute subscript identifier identifier identifier argument_list string string_start string_content string_end for_in_clause identifier identifier if_clause boolean_operator comparison_operator identifier identifier comparison_operator subscript subscript identifier identifier string string_start string_content string_end string string_start string_content string_end return_statement boolean_operator parenthesized_expression not_operator identifier parenthesized_expression binary_operator identifier identifier | Find if the JSON row contains acceptable language data |
def removeContinuousSet(self):
self._openRepo()
dataset = self._repo.getDatasetByName(self._args.datasetName)
continuousSet = dataset.getContinuousSetByName(
self._args.continuousSetName)
def func():
self._updateRepo(self._repo.removeContinuousSet, continuousSet)
self._confirmDelete("ContinuousSet", continuousSet.getLocalId(), func) | module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier function_definition identifier parameters block expression_statement call attribute identifier identifier argument_list attribute attribute identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list identifier | Removes a continuous set from this repo |
def sort_top_targets(self, top, orders):
sorted_top = collections.defaultdict(OrderedDict)
for saltenv, targets in six.iteritems(top):
sorted_targets = sorted(targets,
key=lambda target: orders[saltenv][target])
for target in sorted_targets:
sorted_top[saltenv][target] = targets[target]
return sorted_top | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier lambda lambda_parameters identifier subscript subscript identifier identifier identifier for_statement identifier identifier block expression_statement assignment subscript subscript identifier identifier identifier subscript identifier identifier return_statement identifier | Returns the sorted high data from the merged top files |
def parseIBDatetime(s):
if len(s) == 8:
y = int(s[0:4])
m = int(s[4:6])
d = int(s[6:8])
dt = datetime.date(y, m, d)
elif s.isdigit():
dt = datetime.datetime.fromtimestamp(
int(s), datetime.timezone.utc)
else:
dt = datetime.datetime.strptime(s, '%Y%m%d %H:%M:%S')
return dt | module function_definition identifier parameters identifier block if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier call identifier argument_list subscript identifier slice integer integer expression_statement assignment identifier call identifier argument_list subscript identifier slice integer integer expression_statement assignment identifier call identifier argument_list subscript identifier slice integer integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier elif_clause call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier attribute attribute identifier identifier identifier else_clause block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end return_statement identifier | Parse string in IB date or datetime format to datetime. |
def add_errors(self, *errors: Union[BaseSchemaError, List[BaseSchemaError]]) -> None:
self.schema_loader.add_errors(*errors) | module function_definition identifier parameters identifier typed_parameter list_splat_pattern identifier type generic_type identifier type_parameter type identifier type generic_type identifier type_parameter type identifier type none block expression_statement call attribute attribute identifier identifier identifier argument_list list_splat identifier | Adds errors to the error repository in schema loader |
def data_storage_dir(self):
if self._data_storage_dir is None:
self._data_storage_dir = tempfile.mkdtemp(prefix = "openfisca_")
log.warn((
"Intermediate results will be stored on disk in {} in case of memory overflow. "
"You should remove this directory once you're done with your simulation."
).format(self._data_storage_dir))
return self._data_storage_dir | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end 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 attribute identifier identifier return_statement attribute identifier identifier | Temporary folder used to store intermediate calculation data in case the memory is saturated |
def _init_datastore_v3_stub(self, **stub_kwargs):
task_args = dict(datastore_file=self._data_path)
task_args.update(stub_kwargs)
self.testbed.init_datastore_v3_stub(**task_args) | module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list dictionary_splat identifier | Initializes the datastore stub using nosegae config magic |
def filter_python_files(files):
"Get all python files from the list of files."
py_files = []
for f in files:
extension = os.path.splitext(f)[-1]
if extension:
if extension == '.py':
py_files.append(f)
elif 'python' in open(f, 'r').readline():
py_files.append(f)
elif 'python script' in bash('file {}'.format(f)).value().lower():
py_files.append(f)
return py_files | module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier subscript call attribute attribute identifier identifier identifier argument_list identifier unary_operator integer if_statement identifier block if_statement comparison_operator identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier elif_clause comparison_operator string string_start string_content string_end call attribute call identifier argument_list identifier string string_start string_content string_end identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier elif_clause comparison_operator string string_start string_content string_end call attribute call attribute call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier argument_list identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | Get all python files from the list of files. |
def contains(self, url: str):
try:
self.get_one(url)
except NotFound:
return False
else:
return True | module function_definition identifier parameters identifier typed_parameter identifier type identifier block try_statement block expression_statement call attribute identifier identifier argument_list identifier except_clause identifier block return_statement false else_clause block return_statement true | Return whether the URL is in the table. |
def generate_corpus(n_issuers,
n_tracks_per_issuer,
n_utts_per_track,
n_ll_per_utt,
n_label_per_ll,
rand=None):
corpus = audiomate.Corpus()
for issuer in generate_issuers(n_issuers, rand):
corpus.import_issuers(issuer)
n_tracks = rand.randint(*n_tracks_per_issuer)
tracks = generate_tracks(n_tracks, rand)
corpus.import_tracks(tracks)
n_utts = rand.randint(*n_utts_per_track)
for track in tracks:
utts = generate_utterances(
track,
issuer,
n_utts,
n_ll_per_utt,
n_label_per_ll,
rand
)
corpus.import_utterances(utts)
return corpus | module function_definition identifier parameters identifier identifier identifier identifier identifier default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list list_splat identifier expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list list_splat identifier for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | Generate a corpus with mock data. |
def example_lab_to_ipt():
print("=== Simple Example: XYZ->IPT ===")
xyz = XYZColor(0.5, 0.5, 0.5, illuminant='d65')
print(xyz)
ipt = convert_color(xyz, IPTColor)
print(ipt)
print("=== End Example ===\n") | module function_definition identifier parameters block expression_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list float float float keyword_argument identifier string string_start string_content string_end expression_statement call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement call identifier argument_list identifier expression_statement call identifier argument_list string string_start string_content escape_sequence string_end | This function shows a simple conversion of an XYZ color to an IPT color. |
def verify_token_type(self):
try:
token_type = self.payload[api_settings.TOKEN_TYPE_CLAIM]
except KeyError:
raise TokenError(_('Token has no type'))
if self.token_type != token_type:
raise TokenError(_('Token has wrong type')) | module function_definition identifier parameters identifier block try_statement block expression_statement assignment identifier subscript attribute identifier identifier attribute identifier identifier except_clause identifier block raise_statement call identifier argument_list call identifier argument_list string string_start string_content string_end if_statement comparison_operator attribute identifier identifier identifier block raise_statement call identifier argument_list call identifier argument_list string string_start string_content string_end | Ensures that the token type claim is present and has the correct value. |
def idat(self, lenient=False):
while True:
try:
chunk_type, data = self.chunk(lenient=lenient)
except ValueError:
e = sys.exc_info()[1]
raise ChunkError(e.args[0])
if chunk_type == 'IEND':
break
if chunk_type != 'IDAT':
continue
if self.colormap and not self.plte:
warnings.warn("PLTE chunk is required before IDAT chunk")
yield data | module function_definition identifier parameters identifier default_parameter identifier false block while_statement true block try_statement block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list keyword_argument identifier identifier except_clause identifier block expression_statement assignment identifier subscript call attribute identifier identifier argument_list integer raise_statement call identifier argument_list subscript attribute identifier identifier integer if_statement comparison_operator identifier string string_start string_content string_end block break_statement if_statement comparison_operator identifier string string_start string_content string_end block continue_statement if_statement boolean_operator attribute identifier identifier not_operator attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement yield identifier | Iterator that yields all the ``IDAT`` chunks as strings. |
def _do_layout(self):
sizer_csvoptions = wx.FlexGridSizer(5, 4, 5, 5)
leftpos = wx.LEFT | wx.ADJUST_MINSIZE
rightpos = wx.RIGHT | wx.EXPAND
current_label_margin = 0
other_label_margin = 15
for label, widget in zip(self.param_labels, self.param_widgets):
sizer_csvoptions.Add(label, 0, leftpos, current_label_margin)
sizer_csvoptions.Add(widget, 0, rightpos, current_label_margin)
current_label_margin, other_label_margin = \
other_label_margin, current_label_margin
sizer_csvoptions.AddGrowableCol(1)
sizer_csvoptions.AddGrowableCol(3)
self.sizer_csvoptions = sizer_csvoptions | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list integer integer integer integer expression_statement assignment identifier binary_operator attribute identifier identifier attribute identifier identifier expression_statement assignment identifier binary_operator attribute identifier identifier attribute identifier identifier expression_statement assignment identifier integer expression_statement assignment identifier integer for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier integer identifier identifier expression_statement call attribute identifier identifier argument_list identifier integer identifier identifier expression_statement assignment pattern_list identifier identifier line_continuation expression_list identifier identifier expression_statement call attribute identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list integer expression_statement assignment attribute identifier identifier identifier | Sizer hell, returns a sizer that contains all widgets |
def _process_rule(self, rule: dict, context: dict):
if not rule or not self._shall_proceed(rule):
return
self.context.update(context)
self.context.update(rule.get('context', {}))
self.path = rule.get('path', None)
self.source = rule.get('source', None)
for entry in rule.get('documents', []):
target, source = self._resolve_rule_document(entry)
self.write(target, source)
for entry in rule.get('preserve', []):
target, source = self._resolve_rule_document(entry)
self.write(target, source, preserve=True) | module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type identifier block if_statement boolean_operator not_operator identifier not_operator call attribute identifier identifier argument_list identifier block return_statement expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end dictionary expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end none expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end none for_statement identifier call attribute identifier identifier argument_list string string_start string_content string_end list block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier identifier for_statement identifier call attribute identifier identifier argument_list string string_start string_content string_end list block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier identifier keyword_argument identifier true | process a single rule |
def create_multi(cls, jid, password, msg, recipients=None, rooms=None,
nick="SaltStack Bot"):
obj = SendMsgBot(jid, password, None, msg)
obj.recipients = [] if recipients is None else recipients
obj.rooms = [] if rooms is None else rooms
obj.nick = nick
return obj | module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list identifier identifier none identifier expression_statement assignment attribute identifier identifier conditional_expression list comparison_operator identifier none identifier expression_statement assignment attribute identifier identifier conditional_expression list comparison_operator identifier none identifier expression_statement assignment attribute identifier identifier identifier return_statement identifier | Alternate constructor that accept multiple recipients and rooms |
def username(self):
if len(self._inp_username.value.strip()) == 0:
if not self.hostname is None:
config = parse_sshconfig(self.hostname)
if 'user' in config:
return config['user']
else:
return None
else:
return self._inp_username.value | module function_definition identifier parameters identifier block if_statement comparison_operator call identifier argument_list call attribute attribute attribute identifier identifier identifier identifier argument_list integer block if_statement not_operator comparison_operator attribute identifier identifier none block expression_statement assignment identifier call identifier argument_list attribute identifier identifier if_statement comparison_operator string string_start string_content string_end identifier block return_statement subscript identifier string string_start string_content string_end else_clause block return_statement none else_clause block return_statement attribute attribute identifier identifier identifier | Loking for username in user's input and config file |
def handle(self, *args, **options):
qs = get_subscriber_model().objects.filter(djstripe_customers__isnull=True)
count = 0
total = qs.count()
for subscriber in qs:
count += 1
perc = int(round(100 * (float(count) / float(total))))
print(
"[{0}/{1} {2}%] Syncing {3} [{4}]".format(
count, total, perc, subscriber.email, subscriber.pk
)
)
sync_subscriber(subscriber) | module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute attribute call identifier argument_list identifier identifier argument_list keyword_argument identifier true expression_statement assignment identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier identifier block expression_statement augmented_assignment identifier integer expression_statement assignment identifier call identifier argument_list call identifier argument_list binary_operator integer parenthesized_expression binary_operator call identifier argument_list identifier call identifier argument_list identifier expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier identifier attribute identifier identifier attribute identifier identifier expression_statement call identifier argument_list identifier | Call sync_subscriber on Subscribers without customers associated to them. |
def add_row(self, row_data, resize_x=True):
if not resize_x:
self._check_row_size(row_data)
self.body(Tr()(Td()(cell) for cell in row_data))
return self | module function_definition identifier parameters identifier identifier default_parameter identifier true block if_statement not_operator identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call call identifier argument_list generator_expression call call identifier argument_list argument_list identifier for_in_clause identifier identifier return_statement identifier | Adds a row at the end of the table |
def combine_tax_scales(node):
combined_tax_scales = None
for child_name in node:
child = node[child_name]
if not isinstance(child, AbstractTaxScale):
log.info('Skipping {} with value {} because it is not a tax scale'.format(child_name, child))
continue
if combined_tax_scales is None:
combined_tax_scales = MarginalRateTaxScale(name = child_name)
combined_tax_scales.add_bracket(0, 0)
combined_tax_scales.add_tax_scale(child)
return combined_tax_scales | module function_definition identifier parameters identifier block expression_statement assignment identifier none for_statement identifier identifier block expression_statement assignment identifier subscript identifier identifier if_statement not_operator call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier continue_statement if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list integer integer expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | Combine all the MarginalRateTaxScales in the node into a single MarginalRateTaxScale. |
def gevent_start(self):
import gevent
import gevent.select
self._poller_greenlet = gevent.spawn(self.poll)
self._select = gevent.select.select
self.heartbeat()
self.update() | module function_definition identifier parameters identifier block import_statement dotted_name identifier import_statement dotted_name identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier attribute attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list | Helper method to start the node for gevent-based applications. |
def by_id(cls, _id, engine_or_session):
ses, auto_close = ensure_session(engine_or_session)
obj = ses.query(cls).get(_id)
if auto_close:
ses.close()
return obj | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier identifier argument_list identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list return_statement identifier | Get one object by primary_key value. |
async def prepare_conn(self, conn):
client_id = str(uuid.uuid4())
monitor = functools.partial(self.send_event, client_id)
self._logger.info("New client connection: %s", client_id)
self.service_manager.add_monitor(monitor)
self.clients[client_id] = dict(connection=conn, monitor=monitor)
return client_id | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment subscript attribute identifier identifier identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier return_statement identifier | Setup a new connection from a client. |
def filter(self, f):
def func(iterator):
return filter(f, iterator)
return self.mapPartitions(func, True) | module function_definition identifier parameters identifier identifier block function_definition identifier parameters identifier block return_statement call identifier argument_list identifier identifier return_statement call attribute identifier identifier argument_list identifier true | Return a new DStream containing only the elements that satisfy predicate. |
def dom_table(self):
if self._dom_table is None:
data = defaultdict(list)
for dom_id, (du, floor, _) in self.doms.items():
data['dom_id'].append(dom_id)
data['du'].append(du)
data['floor'].append(floor)
dom_position = self.dom_positions[dom_id]
data['pos_x'].append(dom_position[0])
data['pos_y'].append(dom_position[1])
data['pos_z'].append(dom_position[2])
self._dom_table = Table(data, name='DOMs', h5loc='/dom_table')
return self._dom_table | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier call identifier argument_list identifier for_statement pattern_list identifier tuple_pattern identifier identifier identifier call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list identifier expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list identifier expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier subscript attribute identifier identifier identifier expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list subscript identifier integer expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list subscript identifier integer expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list subscript identifier integer expression_statement assignment attribute identifier identifier call identifier argument_list identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end return_statement attribute identifier identifier | A `Table` containing DOM attributes |
def parse_options(cls, options):
cls.ignore_decorators = options.ignore_decorators
cls.exclude_from_doctest = options.exclude_from_doctest
if not isinstance(cls.exclude_from_doctest, list):
cls.exclude_from_doctest = [cls.exclude_from_doctest] | module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier if_statement not_operator call identifier argument_list attribute identifier identifier identifier block expression_statement assignment attribute identifier identifier list attribute identifier identifier | Pass options through to this plugin. |
def _get_addresses(self, text):
addresses = []
matches = utils.findall(
self.rules,
text,
flags=re.VERBOSE | re.U)
if(matches):
for match in matches:
addresses.append(match[0].strip())
return addresses | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier identifier keyword_argument identifier binary_operator attribute identifier identifier attribute identifier identifier if_statement parenthesized_expression identifier block for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute subscript identifier integer identifier argument_list return_statement identifier | Returns a list of addresses found in text |
def regex(r):
if isinstance(r, stringtypes):
p = re.compile(r)
else:
p = r
msg = 'Expected to match: {}'.format(p.pattern)
def match_regex(s, grm=None, pos=0):
m = p.match(s)
if m is not None:
start, end = m.span()
data = m.groupdict() if p.groupindex else m.group()
return PegreResult(s[m.end():], data, (pos+start, pos+end))
raise PegreError(msg, pos)
return match_regex | module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment identifier identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier integer block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list expression_statement assignment identifier conditional_expression call attribute identifier identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list return_statement call identifier argument_list subscript identifier slice call attribute identifier identifier argument_list identifier tuple binary_operator identifier identifier binary_operator identifier identifier raise_statement call identifier argument_list identifier identifier return_statement identifier | Create a PEG function to match a regular expression. |
def deactivate_version(self, service_id, version_number):
content = self._fetch("/service/%s/version/%d/deactivate" % (service_id, version_number), method="PUT")
return FastlyVersion(self, content) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier keyword_argument identifier string string_start string_content string_end return_statement call identifier argument_list identifier identifier | Deactivate the current version. |
def output(self, msg, indent, status=None):
color = None
if self.use_color:
color = get_color_from_status(status)
print_indent_msg(msg, indent, color) | module function_definition identifier parameters identifier identifier identifier default_parameter identifier none block expression_statement assignment identifier none if_statement attribute identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement call identifier argument_list identifier identifier identifier | Alias for print_indent_msg with color determined by status. |
def repackage_hidden(self, h):
if isinstance(h, Variable):
return torch.tensor(h.data, device=h.device)
else:
return tuple(self.repackage_hidden(v) for v in h) | module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier identifier block return_statement call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier attribute identifier identifier else_clause block return_statement call identifier generator_expression call attribute identifier identifier argument_list identifier for_in_clause identifier identifier | Wraps hidden states in new Variables, to detach them from their history. |
def walletpassphrase(self, passphrase, timeout=99999999, mint_only=True):
return self.req("walletpassphrase", [passphrase, timeout, mint_only]) | module function_definition identifier parameters identifier identifier default_parameter identifier integer default_parameter identifier true block return_statement call attribute identifier identifier argument_list string string_start string_content string_end list identifier identifier identifier | used to unlock wallet for minting |
def revoke_api_key():
build = g.build
form = forms.RevokeApiKeyForm()
if form.validate_on_submit():
api_key = models.ApiKey.query.get(form.id.data)
if api_key.build_id != build.id:
logging.debug('User does not have access to API key=%r',
api_key.id)
abort(403)
api_key.active = False
save_admin_log(build, revoked_api_key=True, message=api_key.id)
db.session.add(api_key)
db.session.commit()
ops = operations.ApiKeyOps(api_key.id, api_key.secret)
ops.evict()
return redirect(url_for('manage_api_keys', build_id=build.id)) | module function_definition identifier parameters block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list attribute attribute identifier identifier identifier if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call identifier argument_list integer expression_statement assignment attribute identifier identifier false expression_statement call identifier argument_list identifier keyword_argument identifier true keyword_argument identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list return_statement call identifier argument_list call identifier argument_list string string_start string_content string_end keyword_argument identifier attribute identifier identifier | Form submission handler for revoking API keys. |
def _updateNamespace(item, new_namespace):
temp_item = ''
i = item.tag.find('}')
if i >= 0:
temp_item = item.tag[i+1:]
else:
temp_item = item.tag
item.tag = '{{{0}}}{1}'.format(new_namespace, temp_item)
for child in item.getiterator():
if isinstance(child.tag, six.string_types):
temp_item = ''
i = child.tag.find('}')
if i >= 0:
temp_item = child.tag[i+1:]
else:
temp_item = child.tag
child.tag = '{{{0}}}{1}'.format(new_namespace, temp_item)
return item | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier string string_start string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier integer block expression_statement assignment identifier subscript attribute identifier identifier slice binary_operator identifier integer else_clause block expression_statement assignment identifier attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute string string_start string_content string_end identifier argument_list identifier identifier for_statement identifier call attribute identifier identifier argument_list block if_statement call identifier argument_list attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier string string_start string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier integer block expression_statement assignment identifier subscript attribute identifier identifier slice binary_operator identifier integer else_clause block expression_statement assignment identifier attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute string string_start string_content string_end identifier argument_list identifier identifier return_statement identifier | helper function to recursively update the namespaces of an item |
def create_image(self, image_file, caption):
suffix = 'png'
if image_file:
img = Image.open(os.path.join(self.gallery, image_file))
width, height = img.size
ratio = width/WIDTH
img = img.resize((int(width // ratio),
int(height // ratio)),
Image.ANTIALIAS)
else:
img = Image.new('RGB', (WIDTH, HEIGHT), 'black')
image = self.add_caption(img, caption)
image = img
return image | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier string string_start string_content string_end if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier expression_statement assignment pattern_list identifier identifier attribute identifier identifier expression_statement assignment identifier binary_operator identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list tuple call identifier argument_list binary_operator identifier identifier call identifier argument_list binary_operator identifier identifier attribute identifier identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end tuple identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier identifier return_statement identifier | Create an image with a caption |
def _skip_frame(self):
for line in self._f:
if line == 'ITEM: ATOMS\n':
break
for i in range(self.num_atoms):
next(self._f) | module function_definition identifier parameters identifier block for_statement identifier attribute identifier identifier block if_statement comparison_operator identifier string string_start string_content escape_sequence string_end block break_statement for_statement identifier call identifier argument_list attribute identifier identifier block expression_statement call identifier argument_list attribute identifier identifier | Skip the next time frame |
def to_nibabel(image):
if image.dimension != 3:
raise ValueError('Only 3D images currently supported')
import nibabel as nib
array_data = image.numpy()
affine = np.hstack([image.direction*np.diag(image.spacing),np.array(image.origin).reshape(3,1)])
affine = np.vstack([affine, np.array([0,0,0,1.])])
affine[:2,:] *= -1
new_img = nib.Nifti1Image(array_data, affine)
return new_img | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier integer block raise_statement call identifier argument_list string string_start string_content string_end import_statement aliased_import dotted_name identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list list binary_operator attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier call attribute call attribute identifier identifier argument_list attribute identifier identifier identifier argument_list integer integer expression_statement assignment identifier call attribute identifier identifier argument_list list identifier call attribute identifier identifier argument_list list integer integer integer float expression_statement augmented_assignment subscript identifier slice integer slice unary_operator integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier return_statement identifier | Convert an ANTsImage to a Nibabel image |
def to_xml(self):
ret = '<exif>'
for k in self.__dict__:
ret += '<%s>%s</%s>' % (k, self.__dict__[k], k)
ret += '</exif>'
return ret | module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_content string_end for_statement identifier attribute identifier identifier block expression_statement augmented_assignment identifier binary_operator string string_start string_content string_end tuple identifier subscript attribute identifier identifier identifier identifier expression_statement augmented_assignment identifier string string_start string_content string_end return_statement identifier | Serialize all properties as XML |
def handle_dump(self, params):
print("Clients:", self.server.clients)
for client in self.server.clients.values():
print(" ", client)
for channel in client.channels.values():
print(" ", channel.name)
print("Channels:", self.server.channels)
for channel in self.server.channels.values():
print(" ", channel.name, channel)
for client in channel.clients:
print(" ", client.nick, client) | module function_definition identifier parameters identifier identifier block expression_statement call identifier argument_list string string_start string_content string_end attribute attribute identifier identifier identifier for_statement identifier call attribute attribute attribute identifier identifier identifier identifier argument_list block expression_statement call identifier argument_list string string_start string_content string_end identifier for_statement identifier call attribute attribute identifier identifier identifier argument_list block expression_statement call identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call identifier argument_list string string_start string_content string_end attribute attribute identifier identifier identifier for_statement identifier call attribute attribute attribute identifier identifier identifier identifier argument_list block expression_statement call identifier argument_list string string_start string_content string_end attribute identifier identifier identifier for_statement identifier attribute identifier identifier block expression_statement call identifier argument_list string string_start string_content string_end attribute identifier identifier identifier | Dump internal server information for debugging purposes. |
def add_size_info (self):
if self.headers and "Content-Length" in self.headers and \
"Transfer-Encoding" not in self.headers:
try:
self.size = int(self.getheader("Content-Length"))
except (ValueError, OverflowError):
pass
else:
self.size = -1 | module function_definition identifier parameters identifier block if_statement boolean_operator boolean_operator attribute identifier identifier comparison_operator string string_start string_content string_end attribute identifier identifier comparison_operator string string_start string_content string_end attribute identifier identifier block try_statement block expression_statement assignment attribute identifier identifier call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end except_clause tuple identifier identifier block pass_statement else_clause block expression_statement assignment attribute identifier identifier unary_operator integer | Get size of URL content from HTTP header. |
def evict(self):
logging.debug('Evicting cache for %r', self.cache_key)
_clear_version_cache(self.cache_key)
self.versioned_cache_key = None | module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier none | Evict all caches related to these operations. |
def removeNotification(self, notificationId):
fn = self.function_table.removeNotification
result = fn(notificationId)
return result | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier return_statement identifier | Destroy a notification, hiding it first if it currently shown to the user. |
def _exists(self, path):
if path.endswith('/'):
return True
return self.storage.exists(path) | module function_definition identifier parameters identifier identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block return_statement true return_statement call attribute attribute identifier identifier identifier argument_list identifier | S3 directory is not S3Ojbect. |
def include_theme_files(self, fragment):
theme = self.get_theme()
if not theme or 'package' not in theme:
return
theme_package, theme_files = theme.get('package', None), theme.get('locations', [])
resource_loader = ResourceLoader(theme_package)
for theme_file in theme_files:
fragment.add_css(resource_loader.load_unicode(theme_file)) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement boolean_operator not_operator identifier comparison_operator string string_start string_content string_end identifier block return_statement expression_statement assignment pattern_list identifier identifier expression_list call attribute identifier identifier argument_list string string_start string_content string_end none call attribute identifier identifier argument_list string string_start string_content string_end list expression_statement assignment identifier call identifier argument_list identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier | Gets theme configuration and renders theme css into fragment |
async def fetch_device_list(self):
url = '{}/users/me'.format(API_URL)
dlist = await self.api_get(url)
if dlist is None:
_LOGGER.error('Unable to fetch eight devices.')
else:
self._devices = dlist['user']['devices']
_LOGGER.debug('Devices: %s', self._devices) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier await call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end else_clause block expression_statement assignment attribute identifier identifier subscript subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier | Fetch list of devices. |
def verify_integrity(self):
if not self.__integrity_check:
if not self.__appid:
raise Exception('U2F_APPID was not defined! Please define it in configuration file.')
if self.__facets_enabled and not len(self.__facets_list):
raise Exception(
)
undefined_message = 'U2F {name} handler is not defined! Please import {name} through {method}!'
if not self.__get_u2f_devices:
raise Exception(undefined_message.format(name='Read', method='@u2f.read'))
if not self.__save_u2f_devices:
raise Exception(undefined_message.format(name='Save', method='@u2f.save'))
if not self.__call_success_enroll:
raise Exception(undefined_message.format(name='enroll onSuccess', method='@u2f.enroll_on_success'))
if not self.__call_success_sign:
raise Exception(undefined_message.format(name='sign onSuccess', method='@u2f.sign_on_success'))
self.__integrity_check = True
return True | module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block if_statement not_operator attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement boolean_operator attribute identifier identifier not_operator call identifier argument_list attribute identifier identifier block raise_statement call identifier argument_list expression_statement assignment identifier string string_start string_content string_end if_statement not_operator attribute identifier identifier block raise_statement call identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end if_statement not_operator attribute identifier identifier block raise_statement call identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end if_statement not_operator attribute identifier identifier block raise_statement call identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end if_statement not_operator attribute identifier identifier block raise_statement call identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier true return_statement true | Verifies that all required functions been injected. |
def add_child(self, child, name=None, index=None):
self.m1.add_child(child, name, index)
if index is None:
index = len(self.m2._children)
self.children_for_m2.append((child, name, index)) | module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list attribute attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list tuple identifier identifier identifier | Add object `child` to the first map and store it for the second. |
def add_adjust(self, data, prehashed=False):
subtrees = self._get_whole_subtrees()
new_node = Node(data, prehashed=prehashed)
self.leaves.append(new_node)
for node in reversed(subtrees):
new_parent = Node(node.val + new_node.val)
node.p, new_node.p = new_parent, new_parent
new_parent.l, new_parent.r = node, new_node
node.sib, new_node.sib = new_node, node
node.side, new_node.side = 'L', 'R'
new_node = new_node.p
self.root = new_node | module function_definition identifier parameters identifier identifier default_parameter identifier false block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier for_statement identifier call identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list binary_operator attribute identifier identifier attribute identifier identifier expression_statement assignment pattern_list attribute identifier identifier attribute identifier identifier expression_list identifier identifier expression_statement assignment pattern_list attribute identifier identifier attribute identifier identifier expression_list identifier identifier expression_statement assignment pattern_list attribute identifier identifier attribute identifier identifier expression_list identifier identifier expression_statement assignment pattern_list attribute identifier identifier attribute identifier identifier expression_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier attribute identifier identifier expression_statement assignment attribute identifier identifier identifier | Add a new leaf, and adjust the tree, without rebuilding the whole thing. |
def append(self, data):
for k in self._entries.keys():
self._entries[k].append(data._entries[k]) | module function_definition identifier parameters identifier identifier block for_statement identifier call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute subscript attribute identifier identifier identifier identifier argument_list subscript attribute identifier identifier identifier | Append a Data instance to self |
def extract_status_code(error):
try:
return int(error.code)
except (AttributeError, TypeError, ValueError):
try:
return int(error.status_code)
except (AttributeError, TypeError, ValueError):
try:
return int(error.errno)
except (AttributeError, TypeError, ValueError):
return 500 | module function_definition identifier parameters identifier block try_statement block return_statement call identifier argument_list attribute identifier identifier except_clause tuple identifier identifier identifier block try_statement block return_statement call identifier argument_list attribute identifier identifier except_clause tuple identifier identifier identifier block try_statement block return_statement call identifier argument_list attribute identifier identifier except_clause tuple identifier identifier identifier block return_statement integer | Extract an error code from a message. |
def init_nvidia(self):
if import_error_tag:
self.nvml_ready = False
try:
pynvml.nvmlInit()
self.device_handles = get_device_handles()
self.nvml_ready = True
except Exception:
logger.debug("pynvml could not be initialized.")
self.nvml_ready = False
return self.nvml_ready | module function_definition identifier parameters identifier block if_statement identifier block expression_statement assignment attribute identifier identifier false try_statement block expression_statement call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier call identifier argument_list expression_statement assignment attribute identifier identifier true except_clause identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier false return_statement attribute identifier identifier | Init the NVIDIA API. |
def action_spatial(self, action):
if self.surf.surf_type & SurfType.FEATURE:
return action.action_feature_layer
elif self.surf.surf_type & SurfType.RGB:
return action.action_render
else:
assert self.surf.surf_type & (SurfType.RGB | SurfType.FEATURE) | module function_definition identifier parameters identifier identifier block if_statement binary_operator attribute attribute identifier identifier identifier attribute identifier identifier block return_statement attribute identifier identifier elif_clause binary_operator attribute attribute identifier identifier identifier attribute identifier identifier block return_statement attribute identifier identifier else_clause block assert_statement binary_operator attribute attribute identifier identifier identifier parenthesized_expression binary_operator attribute identifier identifier attribute identifier identifier | Given an Action, return the right spatial action. |
def transpose(self, rows):
res = OrderedDict()
for row, cols in rows.items():
for col, cell in cols.items():
if col not in res:
res[col] = OrderedDict()
res[col][row] = cell
return res | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement comparison_operator identifier identifier block expression_statement assignment subscript identifier identifier call identifier argument_list expression_statement assignment subscript subscript identifier identifier identifier identifier return_statement identifier | Transposes the grid to allow for cols |
def _postprocess_variants(record_file, data, ref_file, out_file):
if not utils.file_uptodate(out_file, record_file):
with file_transaction(data, out_file) as tx_out_file:
cmd = ["dv_postprocess_variants.py", "--ref", ref_file,
"--infile", record_file, "--outfile", tx_out_file]
do.run(cmd, "DeepVariant postprocess_variants %s" % dd.get_sample_name(data))
return out_file | module function_definition identifier parameters identifier identifier identifier identifier block if_statement not_operator call attribute identifier identifier argument_list identifier identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier identifier as_pattern_target identifier block expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end identifier string string_start string_content string_end identifier string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier binary_operator string string_start string_content string_end call attribute identifier identifier argument_list identifier return_statement identifier | Post-process variants, converting into standard VCF file. |
def track_list(self,*args):
noargs = len(args) == 0
return np.unique(self.track) if noargs else np.unique(self.track.compress(args[0])) | module function_definition identifier parameters identifier list_splat_pattern identifier block expression_statement assignment identifier comparison_operator call identifier argument_list identifier integer return_statement conditional_expression call attribute identifier identifier argument_list attribute identifier identifier identifier call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list subscript identifier integer | return the list of tracks contained if the dataset |
def signed_cell_areas(self):
assert (
self.node_coords.shape[1] == 2
), "Signed areas only make sense for triangles in 2D."
if self._signed_cell_areas is None:
p = self.node_coords[self.cells["nodes"]].T
self._signed_cell_areas = (
+p[0][2] * (p[1][0] - p[1][1])
+ p[0][0] * (p[1][1] - p[1][2])
+ p[0][1] * (p[1][2] - p[1][0])
) / 2
return self._signed_cell_areas | module function_definition identifier parameters identifier block assert_statement parenthesized_expression comparison_operator subscript attribute attribute identifier identifier identifier integer integer string string_start string_content string_end if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier attribute subscript attribute identifier identifier subscript attribute identifier identifier string string_start string_content string_end identifier expression_statement assignment attribute identifier identifier binary_operator parenthesized_expression binary_operator binary_operator binary_operator unary_operator subscript subscript identifier integer integer parenthesized_expression binary_operator subscript subscript identifier integer integer subscript subscript identifier integer integer binary_operator subscript subscript identifier integer integer parenthesized_expression binary_operator subscript subscript identifier integer integer subscript subscript identifier integer integer binary_operator subscript subscript identifier integer integer parenthesized_expression binary_operator subscript subscript identifier integer integer subscript subscript identifier integer integer integer return_statement attribute identifier identifier | Signed area of a triangle in 2D. |
def _apply_mask(self, roi_mask):
rows_to_delete = list()
if isinstance(roi_mask,
np.ndarray):
self._set_roi_mask(roi_mask)
rows_roi = np.where(self.roi_mask.flatten() == cfg.background_value)
self.carpet = np.delete(self.carpet, rows_roi, axis=0)
else:
self.roi_mask = np.ones(self.carpet.shape) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list if_statement call identifier argument_list identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list comparison_operator call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier identifier keyword_argument identifier integer else_clause block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier | Removes voxels outside the given mask or ROI set. |
def _next_job(self):
if self.__job_queue:
job = self.__job_queue.pop()
job.process() | module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list | execute the next job from the top of the queue |
def to_xdr_object(self):
return Xdr.types.Memo(type=Xdr.const.MEMO_ID, id=self.memo_id) | module function_definition identifier parameters identifier block return_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier attribute identifier identifier | Creates an XDR Memo object for a transaction with MEMO_ID. |
def calculate_dimensions(self):
x_coordinates = np.sort(self.grid['x'][:, 0])
self.nr_nodes_z = np.where(x_coordinates == x_coordinates[0])[0].size
self.nr_elements_x = self.elements.shape[0] / (self.nr_nodes_z - 1)
self.nr_nodes_x = self.nr_elements_x + 1
self.nr_elements_z = self.nr_nodes_z - 1 | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list subscript subscript attribute identifier identifier string string_start string_content string_end slice integer expression_statement assignment attribute identifier identifier attribute subscript call attribute identifier identifier argument_list comparison_operator identifier subscript identifier integer integer identifier expression_statement assignment attribute identifier identifier binary_operator subscript attribute attribute identifier identifier identifier integer parenthesized_expression binary_operator attribute identifier identifier integer expression_statement assignment attribute identifier identifier binary_operator attribute identifier identifier integer expression_statement assignment attribute identifier identifier binary_operator attribute identifier identifier integer | For a regular grid, calculate the element and node dimensions |
def datapoint_indices_for_tensor(self, tensor_index):
if tensor_index >= self._num_tensors:
raise ValueError('Tensor index %d is greater than the number of tensors (%d)' %(tensor_index, self._num_tensors))
return self._file_num_to_indices[tensor_index] | module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier attribute identifier identifier return_statement subscript attribute identifier identifier identifier | Returns the indices for all datapoints in the given tensor. |
def type_last(self, obj: JsonObj) -> JsonObj:
def _tl_list(v: List) -> List:
return [self.type_last(e) if isinstance(e, JsonObj)
else _tl_list(e) if isinstance(e, list) else e for e in v if e is not None]
rval = JsonObj()
for k in as_dict(obj).keys():
v = obj[k]
if v is not None and k not in ('type', '_context'):
rval[k] = _tl_list(v) if isinstance(v, list) else self.type_last(v) if isinstance(v, JsonObj) else v
if 'type' in obj and obj.type:
rval.type = obj.type
return rval | module function_definition identifier parameters identifier typed_parameter identifier type identifier type identifier block function_definition identifier parameters typed_parameter identifier type identifier type identifier block return_statement list_comprehension conditional_expression call attribute identifier identifier argument_list identifier call identifier argument_list identifier identifier conditional_expression call identifier argument_list identifier call identifier argument_list identifier identifier identifier for_in_clause identifier identifier if_clause comparison_operator identifier none expression_statement assignment identifier call identifier argument_list for_statement identifier call attribute call identifier argument_list identifier identifier argument_list block expression_statement assignment identifier subscript identifier identifier if_statement boolean_operator comparison_operator identifier none comparison_operator identifier tuple string string_start string_content string_end string string_start string_content string_end block expression_statement assignment subscript identifier identifier conditional_expression call identifier argument_list identifier call identifier argument_list identifier identifier conditional_expression call attribute identifier identifier argument_list identifier call identifier argument_list identifier identifier identifier if_statement boolean_operator comparison_operator string string_start string_content string_end identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier attribute identifier identifier return_statement identifier | Move the type identifiers to the end of the object for print purposes |
def write_training_metrics(self):
with open(self.path, 'w') as file:
writer = csv.writer(file)
writer.writerow(FIELD_NAMES)
for row in self.rows:
writer.writerow(row) | module function_definition identifier parameters identifier block with_statement with_clause with_item as_pattern call identifier argument_list attribute identifier identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier | Write Training Metrics to CSV |
def chown(dirs, user=None, group=None):
if isinstance(dirs, basestring):
dirs = [dirs]
args = ' '.join(dirs)
if user and group:
return sudo('chown {}:{} {}'.format(user, group, args))
elif user:
return sudo('chown {} {}'.format(user, args))
elif group:
return sudo('chgrp {} {}'.format(group, args))
else:
return None | module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier list identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier if_statement boolean_operator identifier identifier block return_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier identifier elif_clause identifier block return_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier elif_clause identifier block return_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier else_clause block return_statement none | User sudo to set user and group ownership |
def window_open(dev, temp, duration):
click.echo("Window open: %s" % dev.window_open)
if temp and duration:
click.echo("Setting window open conf, temp: %s duration: %s" % (temp, duration))
dev.window_open_config(temp, duration) | module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier if_statement boolean_operator identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier | Gets and sets the window open settings. |
def reset_status(self):
for row in range(self.table.rowCount()):
status_item = self.table.item(row, 1)
status_item.setText(self.tr('')) | module function_definition identifier parameters identifier block for_statement identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier integer expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_end | Set all scenarios' status to empty in the table. |
def parsemsg(s):
prefix = ''
trailing = []
if not s:
raise Exception("Empty line.")
if s[0] == ':':
prefix, s = s[1:].split(' ', 1)
if s.find(' :') != -1:
s, trailing = s.split(' :', 1)
args = s.split()
args.append(trailing)
else:
args = s.split()
command = args.pop(0)
return prefix, command, args | module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_end expression_statement assignment identifier list if_statement not_operator identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator subscript identifier integer string string_start string_content string_end block expression_statement assignment pattern_list identifier identifier call attribute subscript identifier slice integer identifier argument_list string string_start string_content string_end integer if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end unary_operator integer block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end integer expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list integer return_statement expression_list identifier identifier identifier | Breaks a message from an IRC server into its prefix, command, and arguments. |
def reach_process_json():
if request.method == 'OPTIONS':
return {}
response = request.body.read().decode('utf-8')
body = json.loads(response)
json_str = body.get('json')
rp = reach.process_json_str(json_str)
return _stmts_from_proc(rp) | module function_definition identifier parameters block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block return_statement dictionary expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement call identifier argument_list identifier | Process REACH json and return INDRA Statements. |
def resolved_task(cls, task):
for t in cls.tasks:
if t is task or t.execute is task:
return t | module function_definition identifier parameters identifier identifier block for_statement identifier attribute identifier identifier block if_statement boolean_operator comparison_operator identifier identifier comparison_operator attribute identifier identifier identifier block return_statement identifier | Task instance representing 'task', if any |
def compute_agreement_score(num_matches, num1, num2):
denom = num1 + num2 - num_matches
if denom == 0:
return 0
return num_matches / denom | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier binary_operator binary_operator identifier identifier identifier if_statement comparison_operator identifier integer block return_statement integer return_statement binary_operator identifier identifier | Agreement score is used as a criteria to match unit1 and unit2. |
def generate(engine, database, models, **kwargs):
validate_args(engine, database, models)
generator = Generator(engine, database, models)
generator.run() | module function_definition identifier parameters identifier identifier identifier dictionary_splat_pattern identifier block expression_statement call identifier argument_list identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list | Generate the migrations by introspecting the db |
def mode(dev, target):
click.echo("Current mode: %s" % dev.mode_readable)
if target:
click.echo("Setting mode: %s" % target)
dev.mode = target | module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment attribute identifier identifier identifier | Gets or sets the active mode. |
def rebuild_app(app_name, quiet=False, force=True, without_exec=False,
restart=False):
user = 'cozy-{app_name}'.format(app_name=app_name)
home = '{prefix}/{app_name}'.format(prefix=PREFIX, app_name=app_name)
command_line = 'cd {home}'.format(home=home)
command_line += ' && git pull'
if force:
command_line += ' && ([ -d node_modules ] && rm -rf node_modules || true)'
command_line += ' && ([ -d .node-gyp ] && rm -rf .node-gyp || true)'
command_line += ' && ([ -d .npm ] && rm -rf .npm || true)'
command_line += ' && chown -R {user}:{user} .'.format(user=user)
command_line += ' && sudo -u {user} env HOME={home} npm install --production'.format(
user=user,
home=home
)
if restart:
command_line += ' && cozy-monitor update {app_name}'.format(
app_name=app_name)
command_line += ' && cozy-monitor restart {app_name}'.format(
app_name=app_name)
if not quiet:
print 'Execute:'
print command_line
if not without_exec:
result = helpers.cmd_exec(command_line)
print result['stdout']
print result['stderr']
print result['error'] | module function_definition identifier parameters identifier default_parameter identifier false default_parameter identifier true default_parameter identifier false default_parameter identifier false block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier expression_statement augmented_assignment identifier string string_start string_content string_end if_statement identifier block expression_statement augmented_assignment identifier string string_start string_content string_end expression_statement augmented_assignment identifier string string_start string_content string_end expression_statement augmented_assignment identifier string string_start string_content string_end expression_statement augmented_assignment identifier call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier expression_statement augmented_assignment identifier call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier if_statement identifier block expression_statement augmented_assignment identifier call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier expression_statement augmented_assignment identifier call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier if_statement not_operator identifier block print_statement string string_start string_content string_end print_statement identifier if_statement not_operator identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier print_statement subscript identifier string string_start string_content string_end print_statement subscript identifier string string_start string_content string_end print_statement subscript identifier string string_start string_content string_end | Rebuild cozy apps with deletion of npm directory & new npm build |
def make_statistics_information(info):
if not info.splits.total_num_examples:
return "None computed"
stats = [(info.splits.total_num_examples, "ALL")]
for split_name, split_info in info.splits.items():
stats.append((split_info.num_examples, split_name.upper()))
stats.sort(reverse=True)
stats = "\n".join([
"{0:10} | {1:>10,}".format(name, num_exs) for (num_exs, name) in stats
])
return STATISTICS_TABLE.format(split_statistics=stats) | module function_definition identifier parameters identifier block if_statement not_operator attribute attribute identifier identifier identifier block return_statement string string_start string_content string_end expression_statement assignment identifier list tuple attribute attribute identifier identifier identifier string string_start string_content string_end for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list tuple attribute identifier identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list keyword_argument identifier true expression_statement assignment identifier call attribute string string_start string_content escape_sequence string_end identifier argument_list list_comprehension call attribute string string_start string_content string_end identifier argument_list identifier identifier for_in_clause tuple_pattern identifier identifier identifier return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier | Make statistics information table. |
def run_fba_minimized(self, reaction):
epsilon = self._args.epsilon
solver = self._get_solver()
p = fluxanalysis.FluxBalanceProblem(self._mm, solver)
start_time = time.time()
try:
p.maximize(reaction)
except fluxanalysis.FluxBalanceError as e:
self.report_flux_balance_error(e)
fluxes = {r: p.get_flux(r) for r in self._mm.reactions}
flux_var = p.get_flux_var(reaction)
p.prob.add_linear_constraints(flux_var == p.get_flux(reaction))
p.minimize_l1()
logger.info('Solving took {:.2f} seconds'.format(
time.time() - start_time))
count = 0
for reaction_id in self._mm.reactions:
flux = p.get_flux(reaction_id)
if abs(flux - fluxes[reaction_id]) > epsilon:
count += 1
yield reaction_id, flux
logger.info('Minimized reactions: {}'.format(count)) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list try_statement block expression_statement call attribute identifier identifier argument_list identifier except_clause as_pattern attribute identifier identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier dictionary_comprehension pair identifier call attribute identifier identifier argument_list identifier for_in_clause identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list comparison_operator identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list binary_operator call attribute identifier identifier argument_list identifier expression_statement assignment identifier integer for_statement identifier attribute attribute identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator call identifier argument_list binary_operator identifier subscript identifier identifier identifier block expression_statement augmented_assignment identifier integer expression_statement yield expression_list identifier identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier | Run normal FBA and flux minimization on model. |
def _connect(cls):
post_save.connect(
notify_items, sender=cls,
dispatch_uid='knocker_{0}'.format(cls.__name__)
) | module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier | Connect signal to current model |
def runRmFile(self, path, timeout=None, **kwargs):
cmd_args = {'path': path, 'logEnviron': self.logEnviron}
if timeout:
cmd_args['timeout'] = timeout
if self.workerVersionIsOlderThan('rmfile', '3.1'):
cmd_args['dir'] = os.path.abspath(path)
return self.runRemoteCommand('rmdir', cmd_args, **kwargs)
return self.runRemoteCommand('rmfile', cmd_args, **kwargs) | module function_definition identifier parameters identifier identifier default_parameter identifier none dictionary_splat_pattern identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end attribute identifier identifier if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier if_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end block expression_statement assignment subscript identifier string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier dictionary_splat identifier return_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier dictionary_splat identifier | remove a file from the worker |
def sort(line):
x0, y0, x1, y1 = line
turn = False
if abs(x1 - x0) > abs(y1 - y0):
if x1 < x0:
turn = True
elif y1 < y0:
turn = True
if turn:
return (x1, y1, x0, y0)
return line | module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier identifier identifier identifier expression_statement assignment identifier false if_statement comparison_operator call identifier argument_list binary_operator identifier identifier call identifier argument_list binary_operator identifier identifier block if_statement comparison_operator identifier identifier block expression_statement assignment identifier true elif_clause comparison_operator identifier identifier block expression_statement assignment identifier true if_statement identifier block return_statement tuple identifier identifier identifier identifier return_statement identifier | change point position if x1,y0 < x0,y0 |
def load_config(options):
global opts, pform
opts = options
pform = options.pform
global_ns = globals()
if pform.hicolor:
global_ns['dim_templ'] = ansi.dim8t
global_ns['swap_clr_templ'] = ansi.csi8_blk % ansi.blu8
else:
global_ns['dim_templ'] = ansi.dim4t
global_ns['swap_clr_templ'] = ansi.fbblue
for varname in dir(pform):
if varname.startswith('_') and varname.endswith('ico'):
global_ns[varname] = getattr(pform, varname) | module function_definition identifier parameters identifier block global_statement identifier identifier expression_statement assignment identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list if_statement attribute identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end binary_operator attribute identifier identifier attribute identifier identifier else_clause 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 attribute identifier identifier for_statement identifier call identifier argument_list identifier block if_statement boolean_operator call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment subscript identifier identifier call identifier argument_list identifier identifier | Load options, platform, colors, and icons. |
def _download_py2(link, path, __hdr__):
try:
req = urllib2.Request(link, headers=__hdr__)
u = urllib2.urlopen(req)
except Exception as e:
raise Exception(' Download failed with the error:\n{}'.format(e))
with open(path, 'wb') as outf:
for l in u:
outf.write(l)
u.close() | module function_definition identifier parameters identifier identifier identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block raise_statement call identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list | Download a file from a link in Python 2. |
def process_objects(kls):
if 'Meta' not in kls.__dict__:
kls.Meta = type('Meta', (object,), {})
if 'unique_together' not in kls.Meta.__dict__:
kls.Meta.unique_together = []
if 'verbose_name' not in kls.Meta.__dict__:
kls.Meta.verbose_name = kls.__name__
if 'verbose_name_plural' not in kls.Meta.__dict__:
kls.Meta.verbose_name_plural = kls.Meta.verbose_name + 's' | module function_definition identifier parameters identifier block if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list string string_start string_content string_end tuple identifier dictionary if_statement comparison_operator string string_start string_content string_end attribute attribute identifier identifier identifier block expression_statement assignment attribute attribute identifier identifier identifier list if_statement comparison_operator string string_start string_content string_end attribute attribute identifier identifier identifier block expression_statement assignment attribute attribute identifier identifier identifier attribute identifier identifier if_statement comparison_operator string string_start string_content string_end attribute attribute identifier identifier identifier block expression_statement assignment attribute attribute identifier identifier identifier binary_operator attribute attribute identifier identifier identifier string string_start string_content string_end | Applies default Meta properties. |
def add_automation_link(testcase):
automation_link = (
'<a href="{}">Test Source</a>'.format(testcase["automation_script"])
if testcase.get("automation_script")
else ""
)
testcase["description"] = "{}<br/>{}".format(testcase.get("description") or "", automation_link) | module function_definition identifier parameters identifier block expression_statement assignment identifier parenthesized_expression conditional_expression call attribute string string_start string_content string_end identifier argument_list subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end expression_statement assignment subscript identifier string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list boolean_operator call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end identifier | Appends link to automation script to the test description. |
def prettyprint(datastr):
maxwidth = WPToolsQuery.MAXWIDTH
rpad = WPToolsQuery.RPAD
extent = maxwidth - (rpad + 2)
for line in datastr:
if len(line) >= maxwidth:
line = line[:extent] + '...'
utils.stderr(line) | module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier binary_operator identifier parenthesized_expression binary_operator identifier integer for_statement identifier identifier block if_statement comparison_operator call identifier argument_list identifier identifier block expression_statement assignment identifier binary_operator subscript identifier slice identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier | Print page data strings to stderr |
def bulk_add_units(unit_list, **kwargs):
added_units = []
for unit in unit_list:
added_units.append(add_unit(unit, **kwargs))
return JSONObject({"units": added_units}) | module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier list for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier dictionary_splat identifier return_statement call identifier argument_list dictionary pair string string_start string_content string_end identifier | Save all the units contained in the passed list, with the name of their dimension. |
def daterange_(self, datecol, date_start, op, **args):
df = self._daterange(datecol, date_start, op, **args)
if df is None:
self.err("Can not select date range data")
return self._duplicate_(df) | module function_definition identifier parameters identifier identifier identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier dictionary_splat identifier if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement call attribute identifier identifier argument_list identifier | Returns a DataSwim instance with rows in a date range |
def up(force=True, env=None, **kwargs):
"Starts a new experiment"
inventory = os.path.join(os.getcwd(), "hosts")
conf = Configuration.from_dictionnary(provider_conf)
provider = Enos_vagrant(conf)
roles, networks = provider.init()
check_networks(roles, networks)
env["roles"] = roles
env["networks"] = networks | module function_definition identifier parameters default_parameter identifier true default_parameter identifier none dictionary_splat_pattern identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list expression_statement call identifier argument_list identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier | Starts a new experiment |
def broadcast_status(self, status):
self._broadcast(
"transient.status",
json.dumps(status),
headers={"expires": str(int((15 + time.time()) * 1000))},
) | module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list identifier keyword_argument identifier dictionary pair string string_start string_content string_end call identifier argument_list call identifier argument_list binary_operator parenthesized_expression binary_operator integer call attribute identifier identifier argument_list integer | Broadcast transient status information to all listeners |
def convert_to_unit(self, unit):
self._values = self._header.data_type.to_unit(
self._values, unit, self._header.unit)
self._header._unit = unit | module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier identifier attribute attribute identifier identifier identifier expression_statement assignment attribute attribute identifier identifier identifier identifier | Convert the Data Collection to the input unit. |
def hash(value):
if not value:
return
elif len(value) == 32:
type = 'md5'
elif len(value) == 40:
type = 'sha1'
elif len(value) == 64:
type = 'sha256'
else:
return None
return {'type': type, 'value': value} | module function_definition identifier parameters identifier block if_statement not_operator identifier block return_statement elif_clause comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier string string_start string_content string_end elif_clause comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier string string_start string_content string_end elif_clause comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier string string_start string_content string_end else_clause block return_statement none return_statement dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier | Detect an hash type |
def items(self):
query = self.get_queryset()
fields = self.get_model_config().get_list_fields()
for item in query.iterator():
row = OrderedDict()
for field_name in self.get_current_fields():
field = fields.get(field_name)
if not field_name:
row[field_name] = ''
if hasattr(item, field['field']):
row[field_name] = getattr(item, field['field'])
else:
row[field_name] = ''
yield row | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list for_statement identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call identifier argument_list for_statement identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator identifier block expression_statement assignment subscript identifier identifier string string_start string_end if_statement call identifier argument_list identifier subscript identifier string string_start string_content string_end block expression_statement assignment subscript identifier identifier call identifier argument_list identifier subscript identifier string string_start string_content string_end else_clause block expression_statement assignment subscript identifier identifier string string_start string_end expression_statement yield identifier | Get all list items |
def visit_Num(self, node: AST, dfltChaining: bool = True) -> str:
return str(node.n) | module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_default_parameter identifier type identifier true type identifier block return_statement call identifier argument_list attribute identifier identifier | Return `node`s number as string. |
def Operate(self, values):
for val in values:
try:
if self.Operation(val, self.right_operand):
return True
except (TypeError, ValueError):
pass
return False | module function_definition identifier parameters identifier identifier block for_statement identifier identifier block try_statement block if_statement call attribute identifier identifier argument_list identifier attribute identifier identifier block return_statement true except_clause tuple identifier identifier block pass_statement return_statement false | Takes a list of values and if at least one matches, returns True. |
def import_from_dict(session, data, sync=[]):
if isinstance(data, dict):
logging.info('Importing %d %s',
len(data.get(DATABASES_KEY, [])),
DATABASES_KEY)
for database in data.get(DATABASES_KEY, []):
Database.import_from_dict(session, database, sync=sync)
logging.info('Importing %d %s',
len(data.get(DRUID_CLUSTERS_KEY, [])),
DRUID_CLUSTERS_KEY)
for datasource in data.get(DRUID_CLUSTERS_KEY, []):
DruidCluster.import_from_dict(session, datasource, sync=sync)
session.commit()
else:
logging.info('Supplied object is not a dictionary.') | module function_definition identifier parameters identifier identifier default_parameter identifier list block if_statement call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list call attribute identifier identifier argument_list identifier list identifier for_statement identifier call attribute identifier identifier argument_list identifier list block expression_statement call attribute identifier identifier argument_list identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list call attribute identifier identifier argument_list identifier list identifier for_statement identifier call attribute identifier identifier argument_list identifier list block expression_statement call attribute identifier identifier argument_list identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end | Imports databases and druid clusters from dictionary |
def object_version_choices(obj):
choices = BLANK_CHOICE_DASH + [(PublishAction.UNPUBLISH_CHOICE, 'Unpublish current version')]
if obj is not None:
saved_versions = Version.objects.filter(
content_type=ContentType.objects.get_for_model(obj),
object_id=obj.pk,
).exclude(
version_number=None,
)
for version in saved_versions:
choices.append((version.version_number, version))
return choices | module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator identifier list tuple attribute identifier identifier string string_start string_content string_end if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list keyword_argument identifier call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier identifier argument_list keyword_argument identifier none for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list tuple attribute identifier identifier identifier return_statement identifier | Return a list of form choices for versions of this object which can be published. |
def analysis_title_header_element(feature, parent):
_ = feature, parent
header = analysis_title_header['string_format']
return header.capitalize() | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier expression_list identifier identifier expression_statement assignment identifier subscript identifier string string_start string_content string_end return_statement call attribute identifier identifier argument_list | Retrieve analysis title header string from definitions. |
def save(self, commit=True, **kwargs):
org = super(OrganizationForm, self).save(commit=False, **kwargs)
if not org.id:
user = current_user._get_current_object()
member = Member(user=user, role='admin')
org.members.append(member)
if commit:
org.save()
return org | module function_definition identifier parameters identifier default_parameter identifier true dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute call identifier argument_list identifier identifier identifier argument_list keyword_argument identifier false dictionary_splat identifier if_statement not_operator attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list return_statement identifier | Register the current user as admin on creation |
def fastaWrite(fileHandleOrFile, name, seq, mode="w"):
fileHandle = _getFileHandle(fileHandleOrFile, mode)
valid_chars = {x for x in string.ascii_letters + "-"}
try:
assert any([isinstance(seq, unicode), isinstance(seq, str)])
except AssertionError:
raise RuntimeError("Sequence is not unicode or string")
try:
assert all(x in valid_chars for x in seq)
except AssertionError:
bad_chars = {x for x in seq if x not in valid_chars}
raise RuntimeError("Invalid FASTA character(s) see in fasta sequence: {}".format(bad_chars))
fileHandle.write(">%s\n" % name)
chunkSize = 100
for i in xrange(0, len(seq), chunkSize):
fileHandle.write("%s\n" % seq[i:i+chunkSize])
if isinstance(fileHandleOrFile, "".__class__):
fileHandle.close() | module function_definition identifier parameters identifier identifier identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier set_comprehension identifier for_in_clause identifier binary_operator attribute identifier identifier string string_start string_content string_end try_statement block assert_statement call identifier argument_list list call identifier argument_list identifier identifier call identifier argument_list identifier identifier except_clause identifier block raise_statement call identifier argument_list string string_start string_content string_end try_statement block assert_statement call identifier generator_expression comparison_operator identifier identifier for_in_clause identifier identifier except_clause identifier block expression_statement assignment identifier set_comprehension identifier for_in_clause identifier identifier if_clause comparison_operator identifier identifier raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end identifier expression_statement assignment identifier integer for_statement identifier call identifier argument_list integer call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end subscript identifier slice identifier binary_operator identifier identifier if_statement call identifier argument_list identifier attribute string string_start string_end identifier block expression_statement call attribute identifier identifier argument_list | Writes out fasta file |
def requeue(self):
job_requeue_interval = float(
self.config.get('sharq', 'job_requeue_interval'))
while True:
self.sq.requeue()
gevent.sleep(job_requeue_interval / 1000.00) | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end while_statement true block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list binary_operator identifier float | Loop endlessly and requeue expired jobs. |
def render(file):
with file.open() as fp:
encoding = detect_encoding(fp, default='utf-8')
file_content = fp.read().decode(encoding)
json_data = json.loads(file_content, object_pairs_hook=OrderedDict)
return json.dumps(json_data, indent=4, separators=(',', ': ')) | module function_definition identifier parameters identifier block with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list as_pattern_target identifier block expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier integer keyword_argument identifier tuple string string_start string_content string_end string string_start string_content string_end | Pretty print the JSON file for rendering. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.