code
stringlengths 51
2.34k
| sequence
stringlengths 186
3.94k
| docstring
stringlengths 11
171
|
|---|---|---|
def update_account_data(self) -> None:
response = get(
_url(
"/accounts/{0}/identifiers".format(self._account_uid),
self._sandbox
),
headers=self._auth_headers
)
response.raise_for_status()
response = response.json()
self.account_identifier = response.get('accountIdentifier')
self.bank_identifier = response.get('bankIdentifier')
self.iban = response.get('iban')
self.bic = response.get('bic')
|
module function_definition identifier parameters identifier type none block expression_statement assignment identifier call identifier argument_list call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end
|
Get basic information for the account.
|
def _kpatch(url, data):
headers = {"Content-Type": "application/json-patch+json"}
ret = http.query(url, method='PATCH', header_dict=headers,
data=salt.utils.json.dumps(data))
if ret.get('error'):
log.error("Got an error: %s", ret.get("error"))
return ret
else:
return salt.utils.json.loads(ret.get('body'))
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement 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 return_statement identifier else_clause block return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end
|
patch any object in kubernetes based on URL
|
def destination(globs, locator, distance, bearing):
globs.locations.destination(distance, bearing, locator)
|
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier identifier
|
Calculate destination from locations.
|
def save(self, filename):
with open(filename, 'wb') as output:
pickle.dump(self, output, protocol=pickle.HIGHEST_PROTOCOL)
|
module function_definition identifier parameters identifier identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier identifier keyword_argument identifier attribute identifier identifier
|
Save validator object to pickle.
|
def emit(self, string, match, pattern, **_):
return grammar.Token(name=pattern.name, value=string,
start=match.start(), end=match.end())
|
module function_definition identifier parameters identifier identifier identifier identifier dictionary_splat_pattern identifier block return_statement call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier call attribute identifier identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list
|
Emits a token using the current pattern match and pattern label.
|
def django_js_init(context, jquery=False, i18n=True, csrf=True, init=True):
return {
'js': {
'jquery': _boolean(jquery),
'i18n': _boolean(i18n),
'csrf': _boolean(csrf),
'init': _boolean(init),
}
}
|
module function_definition identifier parameters identifier default_parameter identifier false default_parameter identifier true default_parameter identifier true default_parameter identifier true block return_statement dictionary pair string string_start string_content string_end dictionary pair string string_start string_content string_end call identifier argument_list identifier pair string string_start string_content string_end call identifier argument_list identifier pair string string_start string_content string_end call identifier argument_list identifier pair string string_start string_content string_end call identifier argument_list identifier
|
Include Django.js javascript library initialization in the page
|
def project_path(cls, user, project):
return google.api_core.path_template.expand(
"users/{user}/projects/{project}", user=user, project=project
)
|
module function_definition identifier parameters identifier identifier identifier block return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier
|
Return a fully-qualified project string.
|
def load_config(self):
self.__config = {}
for section in self.sections:
self.__config[section] = {}
options = self.parser.options(section)
for option in options:
try:
opt = self.parser \
.get(section, option)
try:
self.__config[section][option] = literal_eval(opt)
except (SyntaxError, ValueError):
self.__config[section][option] = opt
self.log_output.append(
{"level": "debug",
"msg": "Option not literal_eval-parsable"
" (maybe string): [{0}] {1}"
.format(section, option)})
if self.__config[section][option] == -1:
self.log_output.append(
{"level": "debug",
"msg": "Skipping: [%s] %s" % (section, option)}
)
except ConfigParser.NoOptionError as exc:
self.log_output.append(
{"level": "error",
"msg": "Exception on [%s] %s: %s"
% (section, option, exc)}
)
self.__config[section][option] = None
|
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier dictionary for_statement identifier attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier dictionary expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier for_statement identifier identifier block try_statement block expression_statement assignment identifier call attribute attribute identifier identifier line_continuation identifier argument_list identifier identifier try_statement block expression_statement assignment subscript subscript attribute identifier identifier identifier identifier call identifier argument_list identifier except_clause tuple identifier identifier block expression_statement assignment subscript subscript attribute identifier identifier identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list identifier identifier if_statement comparison_operator subscript subscript attribute identifier identifier identifier identifier unary_operator integer block expression_statement call attribute attribute identifier identifier identifier argument_list dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end binary_operator string string_start string_content string_end tuple identifier identifier except_clause as_pattern attribute identifier identifier as_pattern_target identifier block expression_statement call attribute attribute identifier identifier identifier argument_list dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end binary_operator string string_start string_content string_end tuple identifier identifier identifier expression_statement assignment subscript subscript attribute identifier identifier identifier identifier none
|
Loads the config-file
|
def queue_raw_jobs(queue, params_list, **kwargs):
from .queue import Queue
queue_obj = Queue(queue)
queue_obj.enqueue_raw_jobs(params_list, **kwargs)
|
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block import_from_statement relative_import import_prefix dotted_name identifier dotted_name identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier dictionary_splat identifier
|
Queue some jobs on a raw queue
|
def sentinels(self, name):
fut = self.execute(b'SENTINELS', name, encoding='utf-8')
return wait_convert(fut, parse_sentinel_slaves_and_sentinels)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier keyword_argument identifier string string_start string_content string_end return_statement call identifier argument_list identifier identifier
|
Returns a list of sentinels for ``name``.
|
def _uncached_match(self, text, pos, cache, error):
m = self.re.match(text, pos)
if m is not None:
span = m.span()
node = RegexNode(self, text, pos, pos + span[1] - span[0])
node.match = m
return node
|
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier identifier identifier binary_operator binary_operator identifier subscript identifier integer subscript identifier integer expression_statement assignment attribute identifier identifier identifier return_statement identifier
|
Return length of match, ``None`` if no match.
|
def copy_columns(self, source_databox):
for k in source_databox.ckeys: self.insert_column(source_databox[k], k)
return self
|
module function_definition identifier parameters identifier identifier block for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list subscript identifier identifier identifier return_statement identifier
|
Loops over the ckeys of the source_databox, updating this databoxes' columns.
|
def _compute_all_deletions(self):
minimum_evil = []
for disabled_qubits in map(set, product(*self._evil)):
newmin = []
for s in minimum_evil:
if s < disabled_qubits:
break
elif disabled_qubits < s:
continue
newmin.append(s)
else:
minimum_evil = newmin + [disabled_qubits]
return minimum_evil
|
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier call identifier argument_list identifier call identifier argument_list list_splat attribute identifier identifier block expression_statement assignment identifier list for_statement identifier identifier block if_statement comparison_operator identifier identifier block break_statement elif_clause comparison_operator identifier identifier block continue_statement expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment identifier binary_operator identifier list identifier return_statement identifier
|
Returns all minimal edge covers of the set of evil edges.
|
def daterange(start, end, delta=timedelta(days=1), lower=Interval.CLOSED, upper=Interval.OPEN):
date_interval = Interval(lower=lower, lower_value=start, upper_value=end, upper=upper)
current = start if start in date_interval else start + delta
while current in date_interval:
yield current
current = current + delta
|
module function_definition identifier parameters identifier identifier default_parameter identifier call identifier argument_list keyword_argument identifier integer default_parameter identifier attribute identifier identifier default_parameter identifier attribute identifier identifier block expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement assignment identifier conditional_expression identifier comparison_operator identifier identifier binary_operator identifier identifier while_statement comparison_operator identifier identifier block expression_statement yield identifier expression_statement assignment identifier binary_operator identifier identifier
|
Returns a generator which creates the next value in the range on demand
|
def _generate_warc_filename(self, meta=False):
if self._params.max_size is None:
sequence_name = ''
elif meta:
sequence_name = '-meta'
else:
sequence_name = '-{0:05d}'.format(self._sequence_num)
if self._params.compress:
extension = 'warc.gz'
else:
extension = 'warc'
return '{0}{1}.{2}'.format(
self._prefix_filename, sequence_name, extension
)
|
module function_definition identifier parameters identifier default_parameter identifier false block if_statement comparison_operator attribute attribute identifier identifier identifier none block expression_statement assignment identifier string string_start string_end elif_clause identifier block expression_statement assignment identifier string string_start string_content string_end else_clause block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier if_statement attribute attribute identifier identifier identifier block expression_statement assignment identifier string string_start string_content string_end else_clause block expression_statement assignment identifier string string_start string_content string_end return_statement call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier identifier identifier
|
Return a suitable WARC filename.
|
def currencies(self):
return [m.currency.code for m in self.monies() if m.amount]
|
module function_definition identifier parameters identifier block return_statement list_comprehension attribute attribute identifier identifier identifier for_in_clause identifier call attribute identifier identifier argument_list if_clause attribute identifier identifier
|
Get all currencies with non-zero values
|
def clicks(self, tag=None, fromdate=None, todate=None):
return self.call("GET", "/stats/outbound/clicks", tag=tag, fromdate=fromdate, todate=todate)
|
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none block return_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
|
Gets total counts of unique links that were clicked.
|
def scaledBy(self, scale):
scaled = deepcopy(self)
if type(scaled.value) in (int, float):
scaled.value *= scale
elif isinstance(scaled.value, numbers):
scaled.value.values = tuple(v * scale for v in scaled.value.values)
return scaled
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator call identifier argument_list attribute identifier identifier tuple identifier identifier block expression_statement augmented_assignment attribute identifier identifier identifier elif_clause call identifier argument_list attribute identifier identifier identifier block expression_statement assignment attribute attribute identifier identifier identifier call identifier generator_expression binary_operator identifier identifier for_in_clause identifier attribute attribute identifier identifier identifier return_statement identifier
|
Return a new Value scaled by a given number for ints and floats.
|
def channel_is_opened(
self,
participant1: Address,
participant2: Address,
block_identifier: BlockSpecification,
channel_identifier: ChannelID,
) -> bool:
try:
channel_state = self._get_channel_state(
participant1=participant1,
participant2=participant2,
block_identifier=block_identifier,
channel_identifier=channel_identifier,
)
except RaidenRecoverableError:
return False
return channel_state == ChannelState.OPENED
|
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier type identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier except_clause identifier block return_statement false return_statement comparison_operator identifier attribute identifier identifier
|
Returns true if the channel is in an open state, false otherwise.
|
def _check_raw(self, file_names, abort_on_missing=False):
strip_file_names = True
check_on = self.filestatuschecker
if not self._is_listtype(file_names):
file_names = [file_names, ]
ids = dict()
for f in file_names:
self.logger.debug(f"checking res file {f}")
fid = FileID(f)
if fid.name is None:
warnings.warn(f"file does not exist: {f}")
if abort_on_missing:
sys.exit(-1)
else:
if strip_file_names:
name = os.path.basename(f)
else:
name = f
if check_on == "size":
ids[name] = int(fid.size)
elif check_on == "modified":
ids[name] = int(fid.last_modified)
else:
ids[name] = int(fid.last_accessed)
return ids
|
module function_definition identifier parameters identifier identifier default_parameter identifier false block expression_statement assignment identifier true expression_statement assignment identifier attribute identifier identifier if_statement not_operator call attribute identifier identifier argument_list identifier block expression_statement assignment identifier list identifier expression_statement assignment identifier call identifier argument_list for_statement identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content interpolation identifier string_end expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute identifier identifier argument_list string string_start string_content interpolation identifier string_end if_statement identifier block expression_statement call attribute identifier identifier argument_list unary_operator integer else_clause block if_statement identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier else_clause block expression_statement assignment identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment subscript identifier identifier call identifier argument_list attribute identifier identifier elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment subscript identifier identifier call identifier argument_list attribute identifier identifier else_clause block expression_statement assignment subscript identifier identifier call identifier argument_list attribute identifier identifier return_statement identifier
|
Get the file-ids for the res_files.
|
def cached(key = None, extradata = {}):
def decorator(f):
@wraps(f)
def wrapper(*args, **kwargs):
uid = key
if not uid:
from hashlib import md5
arguments = list(args) + [(a, kwargs[a]) for a in sorted(kwargs.keys())]
uid = md5(str(arguments)).hexdigest()
if exists(uid):
debug('Item \'%s\' is cached (%s).' % (uid, cache))
return get(uid)
else:
debug('Item \'%s\' is not cached (%s).' % (uid, cache))
result = f(*args, **kwargs)
debug('Caching result \'%s\' as \'%s\' (%s)...' % (result, uid, cache))
debug('Extra data: ' + (str(extradata) or 'None'))
put(uid, result, extradata)
return result
return wrapper
return decorator
|
module function_definition identifier parameters default_parameter identifier none default_parameter identifier dictionary block function_definition identifier parameters identifier block decorated_definition decorator call identifier argument_list identifier function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier identifier if_statement not_operator identifier block import_from_statement dotted_name identifier dotted_name identifier expression_statement assignment identifier binary_operator call identifier argument_list identifier list_comprehension tuple identifier subscript identifier identifier for_in_clause identifier call identifier argument_list call attribute identifier identifier argument_list expression_statement assignment identifier call attribute call identifier argument_list call identifier argument_list identifier identifier argument_list if_statement call identifier argument_list identifier block expression_statement call identifier argument_list binary_operator string string_start string_content escape_sequence escape_sequence string_end tuple identifier identifier return_statement call identifier argument_list identifier else_clause block expression_statement call identifier argument_list binary_operator string string_start string_content escape_sequence escape_sequence string_end tuple identifier identifier expression_statement assignment identifier call identifier argument_list list_splat identifier dictionary_splat identifier expression_statement call identifier argument_list binary_operator string string_start string_content escape_sequence escape_sequence escape_sequence escape_sequence string_end tuple identifier identifier identifier expression_statement call identifier argument_list binary_operator string string_start string_content string_end parenthesized_expression boolean_operator call identifier argument_list identifier string string_start string_content string_end expression_statement call identifier argument_list identifier identifier identifier return_statement identifier return_statement identifier return_statement identifier
|
Decorator used for caching.
|
def _check_classifier(classifier):
predict = getattr(classifier, "predict", None)
if not callable(predict):
raise ValueError('Classifier does not have predict method!')
predict_proba = getattr(classifier, "predict_proba", None)
if not callable(predict_proba):
raise ValueError('Classifier does not have predict_proba method!')
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end none if_statement not_operator call identifier argument_list identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end none if_statement not_operator call identifier argument_list identifier block raise_statement call identifier argument_list string string_start string_content string_end
|
Check if the classifier implements predict and predict_proba methods.
|
def delete_orderrun(backend, orderrun_id):
click.secho('%s - Deleting orderrun %s' % (get_datetime(), orderrun_id), fg='green')
check_and_print(DKCloudCommandRunner.delete_orderrun(backend.dki, orderrun_id.strip()))
|
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 tuple call identifier argument_list identifier keyword_argument identifier string string_start string_content string_end expression_statement call identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list
|
Delete the orderrun specified by the argument.
|
def question_default_add_related_pks(self, obj):
if not hasattr(obj, '_choice_pks'):
obj._choice_pks = list(obj.choices.values_list('pk', flat=True))
|
module function_definition identifier parameters identifier identifier block if_statement not_operator call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier true
|
Add related primary keys to a Question instance.
|
def incremental_value(self, slip_moment, mmax, mag_value, bbar, dbar):
delta_m = mmax - mag_value
a_3 = self._get_a3(bbar, dbar, slip_moment, mmax)
return a_3 * bbar * (np.exp(bbar * delta_m) - 1.0) * (delta_m > 0.0)
|
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier binary_operator identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier identifier return_statement binary_operator binary_operator binary_operator identifier identifier parenthesized_expression binary_operator call attribute identifier identifier argument_list binary_operator identifier identifier float parenthesized_expression comparison_operator identifier float
|
Returns the incremental rate with Mmax = Mag_value
|
def opt_format(self, fmt):
key = get_enum_key(fmt, FORMATTERS)
if key is not None:
self.conf["format"] = key
print("Set format %r" % key)
else:
print("Unknown format %r" % fmt)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier if_statement comparison_operator identifier none block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end identifier expression_statement call identifier argument_list binary_operator string string_start string_content string_end identifier else_clause block expression_statement call identifier argument_list binary_operator string string_start string_content string_end identifier
|
Set value for format option
|
def list_scripts(zap_helper):
scripts = zap_helper.zap.script.list_scripts
output = []
for s in scripts:
if 'enabled' not in s:
s['enabled'] = 'N/A'
output.append([s['name'], s['type'], s['engine'], s['enabled']])
click.echo(tabulate(output, headers=['Name', 'Type', 'Engine', 'Enabled'], tablefmt='grid'))
|
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute attribute attribute identifier identifier identifier identifier expression_statement assignment identifier list for_statement identifier identifier block if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier keyword_argument identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end keyword_argument identifier string string_start string_content string_end
|
List scripts currently loaded into ZAP.
|
def __get_precipfc_data(latitude, longitude):
url = 'https://gpsgadget.buienradar.nl/data/raintext?lat={}&lon={}'
url = url.format(
round(latitude, 2),
round(longitude, 2)
)
result = __get_url(url)
return result
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list identifier integer call identifier argument_list identifier integer expression_statement assignment identifier call identifier argument_list identifier return_statement identifier
|
Get buienradar forecasted precipitation.
|
def items(self):
cart_items = []
for repo, items in self.iterrepos():
cart_items.extend(items)
return cart_items
|
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
|
Build and return a list of all items in this cart
|
def write(self):
with root():
self._write_log()
with open(self.path, 'w') as f:
os.chown(self.path, self.uid(), self.gid())
if self.mode:
oldmask = os.umask(0)
os.chmod(self.path, self.mode)
os.umask(oldmask)
f.write(self.contents())
|
module function_definition identifier parameters identifier block with_statement with_clause with_item call identifier argument_list block expression_statement call attribute identifier identifier argument_list with_statement with_clause with_item as_pattern call identifier argument_list attribute identifier identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list if_statement attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list
|
Write the file, forcing the proper permissions
|
def round_to_scale(number, precision):
if precision < 1:
return round_to_float(number, precision)
return round_to_int(number, precision)
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier integer block return_statement call identifier argument_list identifier identifier return_statement call identifier argument_list identifier identifier
|
Round a number or a float to a precision
|
def _count_elements(mapping, iterable):
'Tally elements from the iterable.'
mapping_get = mapping.get
for elem in iterable:
mapping[elem] = mapping_get(elem, 0) + 1
|
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier attribute identifier identifier for_statement identifier identifier block expression_statement assignment subscript identifier identifier binary_operator call identifier argument_list identifier integer integer
|
Tally elements from the iterable.
|
def export(self, fn:PathOrStr, **kwargs):
"Export the minimal state and save it in `fn` to load an empty version for inference."
pickle.dump(self.get_state(**kwargs), open(fn, 'wb'))
|
module function_definition identifier parameters identifier typed_parameter identifier type identifier dictionary_splat_pattern identifier block expression_statement string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list dictionary_splat identifier call identifier argument_list identifier string string_start string_content string_end
|
Export the minimal state and save it in `fn` to load an empty version for inference.
|
def allow(self, comment, content_object, request):
if settings.COOKIE_KEY not in request.COOKIES \
and (settings.DISCARD_SPAM or settings.DISCARD_NO_COOKIE):
return False
elif settings.COOKIE_KEY not in request.COOKIES:
comment.is_removed = True
comment.is_public = False
return True
return True
|
module function_definition identifier parameters identifier identifier identifier identifier block if_statement boolean_operator comparison_operator attribute identifier identifier attribute identifier identifier line_continuation parenthesized_expression boolean_operator attribute identifier identifier attribute identifier identifier block return_statement false elif_clause comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier true expression_statement assignment attribute identifier identifier false return_statement true return_statement true
|
Tests comment post requests for the djangospam cookie.
|
def unsafe_undefined(self, obj, attribute):
return self.undefined('access to attribute %r of %r '
'object is unsafe.' % (
attribute,
obj.__class__.__name__
), name=attribute, obj=obj, exc=SecurityError)
|
module function_definition identifier parameters identifier identifier identifier block return_statement call attribute identifier identifier argument_list binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end tuple identifier attribute attribute identifier identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
|
Return an undefined object for unsafe attributes.
|
def embedgroupdata(extract_func, fname, debug):
astr = _readfname(fname)
fname = StringIO(astr)
try:
astr = astr.decode('ISO-8859-2')
except Exception as e:
pass
glist = iddgroups.iddtxt2grouplist(astr)
blocklst, commlst, commdct = extract_func(fname)
commlst = iddgroups.group2commlst(commlst, glist)
commdct = iddgroups.group2commdct(commdct, glist)
return blocklst, commlst, commdct
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end except_clause as_pattern identifier as_pattern_target identifier block pass_statement expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment pattern_list identifier identifier identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier return_statement expression_list identifier identifier identifier
|
insert group info into extracted idd
|
def update(self, labels, preds):
cls_prob = preds[0].asnumpy()
loc_loss = preds[1].asnumpy()
cls_label = preds[2].asnumpy()
valid_count = np.sum(cls_label >= 0)
label = cls_label.flatten()
mask = np.where(label >= 0)[0]
indices = np.int64(label[mask])
prob = cls_prob.transpose((0, 2, 1)).reshape((-1, cls_prob.shape[1]))
prob = prob[mask, indices]
self.sum_metric[0] += (-np.log(prob + self.eps)).sum()
self.num_inst[0] += valid_count
self.sum_metric[1] += np.sum(loc_loss)
self.num_inst[1] += valid_count
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute subscript identifier integer identifier argument_list expression_statement assignment identifier call attribute subscript identifier integer identifier argument_list expression_statement assignment identifier call attribute subscript identifier integer identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list comparison_operator identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier subscript call attribute identifier identifier argument_list comparison_operator identifier integer integer expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list tuple integer integer integer identifier argument_list tuple unary_operator integer subscript attribute identifier identifier integer expression_statement assignment identifier subscript identifier identifier identifier expression_statement augmented_assignment subscript attribute identifier identifier integer call attribute parenthesized_expression unary_operator call attribute identifier identifier argument_list binary_operator identifier attribute identifier identifier identifier argument_list expression_statement augmented_assignment subscript attribute identifier identifier integer identifier expression_statement augmented_assignment subscript attribute identifier identifier integer call attribute identifier identifier argument_list identifier expression_statement augmented_assignment subscript attribute identifier identifier integer identifier
|
Implementation of updating metrics
|
def request(community_id, record_id, accept):
c = Community.get(community_id)
assert c is not None
record = Record.get_record(record_id)
if accept:
c.add_record(record)
record.commit()
else:
InclusionRequest.create(community=c, record=record,
notify=False)
db.session.commit()
RecordIndexer().index_by_id(record.id)
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier assert_statement comparison_operator identifier none expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list else_clause block expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier false expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute call identifier argument_list identifier argument_list attribute identifier identifier
|
Request a record acceptance to a community.
|
def runSearchVariantAnnotationSets(self, request):
return self.runSearchRequest(
request, protocol.SearchVariantAnnotationSetsRequest,
protocol.SearchVariantAnnotationSetsResponse,
self.variantAnnotationSetsGenerator)
|
module function_definition identifier parameters identifier identifier block return_statement call attribute identifier identifier argument_list identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier
|
Runs the specified SearchVariantAnnotationSetsRequest.
|
def callsigns(self) -> Set[str]:
sub = self.data.query("callsign == callsign")
return set(cs for cs in sub.callsign if len(cs) > 3 and " " not in cs)
|
module function_definition identifier parameters identifier type generic_type identifier type_parameter type identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end return_statement call identifier generator_expression identifier for_in_clause identifier attribute identifier identifier if_clause boolean_operator comparison_operator call identifier argument_list identifier integer comparison_operator string string_start string_content string_end identifier
|
Return only the most relevant callsigns
|
def add_tags(self):
if self.tags is None:
self.tags = VCFLACDict()
self.metadata_blocks.append(self.tags)
else:
raise FLACVorbisError("a Vorbis comment already exists")
|
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier call identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier else_clause block raise_statement call identifier argument_list string string_start string_content string_end
|
Add a Vorbis comment block to the file.
|
def request(self, url, method, data=None, headers=None):
http_headers = merge_dict(self.default_headers, headers or {})
request_data = merge_dict({'api_key': self.apikey}, data or {})
logger.info('HTTP %s REQUEST TO %s' % (method, url))
start = datetime.datetime.now()
try:
response = requests.request(method=method, url=url, data=json.dumps(request_data),
headers=http_headers)
except exceptions.BadRequestError as e:
return json.loads({'errors': e.content})
duration = datetime.datetime.now() - start
logger.info('RESPONSE %s DURATION %s.%s' % (response.encoding, duration.seconds,
duration.microseconds))
return json.loads(response.content) if response.content else {}
|
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier call identifier argument_list attribute identifier identifier boolean_operator identifier dictionary expression_statement assignment identifier call identifier argument_list dictionary pair string string_start string_content string_end attribute identifier identifier boolean_operator identifier dictionary expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier except_clause as_pattern attribute identifier identifier as_pattern_target identifier block return_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier binary_operator call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple attribute identifier identifier attribute identifier identifier attribute identifier identifier return_statement conditional_expression call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier dictionary
|
Makes a HTTP call, formats response and does error handling.
|
def clean(self):
if any(self.errors):
return
(selects, aliases, froms, wheres, sorts, groups_by,
params) = self.get_query_parts()
if not selects:
validation_message = _(u"At least you must check a row to get.")
raise forms.ValidationError(validation_message)
self._selects = selects
self._aliases = aliases
self._froms = froms
self._wheres = wheres
self._sorts = sorts
self._groups_by = groups_by
self._params = params
|
module function_definition identifier parameters identifier block if_statement call identifier argument_list attribute identifier identifier block return_statement expression_statement assignment tuple_pattern identifier identifier identifier identifier identifier identifier identifier call attribute identifier identifier argument_list if_statement not_operator identifier block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end raise_statement call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier
|
Checks that there is almost one field to select
|
def to_json_path(graph: BELGraph, path: str, **kwargs) -> None:
with open(os.path.expanduser(path), 'w') as f:
to_json_file(graph, file=f, **kwargs)
|
module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type identifier dictionary_splat_pattern identifier type none block with_statement with_clause with_item as_pattern call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call identifier argument_list identifier keyword_argument identifier identifier dictionary_splat identifier
|
Write this graph to the given path as a Node-Link JSON.
|
def score_large_straight_yatzy(dice: List[int]) -> int:
dice_set = set(dice)
if _are_two_sets_equal({2, 3, 4, 5, 6}, dice_set):
return sum(dice)
return 0
|
module function_definition identifier parameters typed_parameter identifier type generic_type identifier type_parameter type identifier type identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement call identifier argument_list set integer integer integer integer integer identifier block return_statement call identifier argument_list identifier return_statement integer
|
Large straight scoring according to yatzy rules
|
def SavePrivateKey(self, private_key):
self.private_key = private_key
config.CONFIG.Set("Client.private_key",
self.private_key.SerializeToString())
config.CONFIG.Write()
|
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list
|
Store the new private key on disk.
|
def calc_A(Ys):
return sum(np.dot(np.reshape(Y, (3,1)), np.reshape(Y, (1, 3)))
for Y in Ys)
|
module function_definition identifier parameters identifier block return_statement call identifier generator_expression call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier tuple integer integer call attribute identifier identifier argument_list identifier tuple integer integer for_in_clause identifier identifier
|
Return the matrix A from a list of Y vectors.
|
def video_status_update_callback(sender, **kwargs):
video = kwargs['instance']
if kwargs['created']:
logger.info('VAL: Video created with id [%s] and status [%s]', video.edx_video_id, video.status)
else:
logger.info('VAL: Status changed to [%s] for video [%s]', video.status, video.edx_video_id)
|
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end if_statement subscript identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier attribute identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier attribute identifier identifier
|
Log video status for an existing video instance
|
def uniqueID(size=6, chars=string.ascii_uppercase + string.digits):
return ''.join(random.choice(chars) for x in xrange(size))
|
module function_definition identifier parameters default_parameter identifier integer default_parameter identifier binary_operator attribute identifier identifier attribute identifier identifier block return_statement call attribute string string_start string_end identifier generator_expression call attribute identifier identifier argument_list identifier for_in_clause identifier call identifier argument_list identifier
|
A quick and dirty way to get a unique string
|
def imagenet_model_fn(features, labels, mode, params):
if params['fine_tune']:
base_lr = .1
else:
base_lr = .128
learning_rate_fn = resnet_run_loop.learning_rate_with_decay(
batch_size=params['batch_size'], batch_denom=256,
num_images=_NUM_IMAGES['train'], boundary_epochs=[30, 60, 80, 90],
decay_rates=[1, 0.1, 0.01, 0.001, 1e-4], base_lr=_BASE_LR,
enable_lars=params['enable_lars'])
return resnet_run_loop.resnet_model_fn(
features=features,
labels=labels,
mode=mode,
model_class=ImagenetModel,
resnet_size=params['resnet_size'],
weight_decay=params['weight_decay'],
learning_rate_fn=learning_rate_fn,
momentum=0.9,
data_format=params['data_format'],
version=params['version'],
loss_scale=params['loss_scale'],
loss_filter_fn=None,
dtype=params['dtype'],
label_smoothing=params['label_smoothing'],
enable_lars=params['enable_lars']
)
|
module function_definition identifier parameters identifier identifier identifier identifier block if_statement subscript identifier string string_start string_content string_end block expression_statement assignment identifier float else_clause block expression_statement assignment identifier float expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier integer keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier list integer integer integer integer keyword_argument identifier list integer float float float float keyword_argument identifier identifier keyword_argument identifier subscript identifier string string_start string_content string_end return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier float keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier none keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end
|
Our model_fn for ResNet to be used with our Estimator.
|
def create_lbaas_l7rule(self, l7policy, body=None):
return self.post(self.lbaas_l7rules_path % l7policy, body=body)
|
module function_definition identifier parameters identifier identifier default_parameter identifier none block return_statement call attribute identifier identifier argument_list binary_operator attribute identifier identifier identifier keyword_argument identifier identifier
|
Creates rule for a certain L7 policy.
|
def select(self, item):
self._on_unselect[self._selected]()
self.selected().unfocus()
if isinstance(item, int):
self._selected = item % len(self)
else:
self._selected = self.items.index(item)
self.selected().focus()
self._on_select[self._selected]()
|
module function_definition identifier parameters identifier identifier block expression_statement call subscript attribute identifier identifier attribute identifier identifier argument_list expression_statement call attribute call attribute identifier identifier argument_list identifier argument_list if_statement call identifier argument_list identifier identifier block expression_statement assignment attribute identifier identifier binary_operator identifier call identifier argument_list identifier else_clause block expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute call attribute identifier identifier argument_list identifier argument_list expression_statement call subscript attribute identifier identifier attribute identifier identifier argument_list
|
Select an arbitrary item, by possition or by reference.
|
def _header(self, pam=False):
if pam or self.magicnum == b'P7':
header = "\n".join((
"P7",
"HEIGHT %i" % self.height,
"WIDTH %i" % self.width,
"DEPTH %i" % self.depth,
"MAXVAL %i" % self.maxval,
"\n".join("TUPLTYPE %s" % unicode(i) for i in self.tupltypes),
"ENDHDR\n"))
elif self.maxval == 1:
header = "P4 %i %i\n" % (self.width, self.height)
elif self.depth == 1:
header = "P5 %i %i %i\n" % (self.width, self.height, self.maxval)
else:
header = "P6 %i %i %i\n" % (self.width, self.height, self.maxval)
if sys.version_info[0] > 2:
header = bytes(header, 'ascii')
return header
|
module function_definition identifier parameters identifier default_parameter identifier false block if_statement boolean_operator identifier comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier call attribute string string_start string_content escape_sequence string_end identifier argument_list tuple string string_start string_content string_end binary_operator string string_start string_content string_end attribute identifier identifier binary_operator string string_start string_content string_end attribute identifier identifier binary_operator string string_start string_content string_end attribute identifier identifier binary_operator string string_start string_content string_end attribute identifier identifier call attribute string string_start string_content escape_sequence string_end identifier generator_expression binary_operator string string_start string_content string_end call identifier argument_list identifier for_in_clause identifier attribute identifier identifier string string_start string_content escape_sequence string_end elif_clause comparison_operator attribute identifier identifier integer block expression_statement assignment identifier binary_operator string string_start string_content escape_sequence string_end tuple attribute identifier identifier attribute identifier identifier elif_clause comparison_operator attribute identifier identifier integer block expression_statement assignment identifier binary_operator string string_start string_content escape_sequence string_end tuple attribute identifier identifier attribute identifier identifier attribute identifier identifier else_clause block expression_statement assignment identifier binary_operator string string_start string_content escape_sequence string_end tuple attribute identifier identifier attribute identifier identifier attribute identifier identifier if_statement comparison_operator subscript attribute identifier identifier integer integer block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end return_statement identifier
|
Return file header as byte string.
|
def commit(self, raise_on_error=True):
cmds = list(chain([(('multi',), {})],
self.command_stack, [(('exec',), {})]))
self.reset()
return self.store.execute_pipeline(cmds, raise_on_error)
|
module function_definition identifier parameters identifier default_parameter identifier true block expression_statement assignment identifier call identifier argument_list call identifier argument_list list tuple tuple string string_start string_content string_end dictionary attribute identifier identifier list tuple tuple string string_start string_content string_end dictionary expression_statement call attribute identifier identifier argument_list return_statement call attribute attribute identifier identifier identifier argument_list identifier identifier
|
Send commands to redis.
|
def create(vm_=None, call=None):
if call:
raise SaltCloudSystemExit(
'You cannot create an instance with -a or -f.'
)
node_info = request_instance(vm_)
if isinstance(node_info, bool):
raise SaltCloudSystemExit(
'There was an error creating the GCE instance.'
)
node_dict = node_info[0]
node_data = node_info[1]
ssh_user, ssh_key = __get_ssh_credentials(vm_)
vm_['ssh_host'] = __get_host(node_data, vm_)
vm_['key_filename'] = ssh_key
ret = __utils__['cloud.bootstrap'](vm_, __opts__)
ret.update(node_dict)
log.info('Created Cloud VM \'%s\'', vm_['name'])
log.trace(
'\'%s\' VM creation details:\n%s',
vm_['name'], pprint.pformat(node_dict)
)
__utils__['cloud.fire_event'](
'event',
'created instance',
'salt/cloud/{0}/created'.format(vm_['name']),
args=__utils__['cloud.filter_event']('created', vm_, ['name', 'profile', 'provider', 'driver']),
sock_dir=__opts__['sock_dir'],
transport=__opts__['transport']
)
return ret
|
module function_definition identifier parameters default_parameter identifier none default_parameter identifier none block if_statement identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier if_statement call identifier argument_list identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier subscript identifier integer expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment identifier call subscript identifier string string_start string_content string_end argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence escape_sequence string_end subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence escape_sequence escape_sequence string_end subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list identifier expression_statement call subscript identifier string string_start string_content string_end argument_list string string_start string_content string_end string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list subscript identifier string string_start string_content string_end keyword_argument identifier call subscript identifier string string_start string_content string_end argument_list string string_start string_content string_end identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end return_statement identifier
|
Create a single GCE instance from a data dict.
|
def pdb(self):
pdb_str = write_pdb(
[self], ' ' if not self.tags['chain_id'] else self.tags['chain_id'])
return pdb_str
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list list identifier conditional_expression string string_start string_content string_end not_operator subscript attribute identifier identifier string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end return_statement identifier
|
Generates a PDB string for the `PseudoMonomer`.
|
def load_json(filename, gzip_mode=False):
open_file = open
if gzip_mode:
open_file = gzip.open
try:
with open_file(filename, 'rt') as fh:
data = json.load(fh)
data = convert_unicode_2_utf8(data)
return data
except AttributeError:
fh = open_file(filename, 'rt')
data = json.load(fh)
fh.close()
data = convert_unicode_2_utf8(data)
return data
|
module function_definition identifier parameters identifier default_parameter identifier false block expression_statement assignment identifier identifier if_statement identifier block expression_statement assignment identifier attribute identifier identifier try_statement block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier return_statement identifier except_clause identifier block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier return_statement identifier
|
Return the json-file data, with all strings utf-8 encoded.
|
def on_open_output_tool_clicked(self):
output_path = self.output_path.text()
if not output_path:
output_path = os.path.expanduser('~')
filename, __ = QFileDialog.getSaveFileName(
self, tr('Output file'), output_path, tr('Raster file (*.tif)'))
if filename:
self.output_path.setText(filename)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list if_statement not_operator identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier call identifier argument_list string string_start string_content string_end identifier call identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier
|
Autoconnect slot activated when open output tool button is clicked.
|
def hash_prefix_list_checksum(self, threat_list):
q =
params = [threat_list.threat_type, threat_list.platform_type, threat_list.threat_entry_type]
with self.get_cursor() as dbc:
dbc.execute(q, params)
all_hashes = b''.join(bytes(h[0]) for h in dbc.fetchall())
checksum = hashlib.sha256(all_hashes).digest()
return checksum
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier assignment identifier list attribute identifier identifier attribute identifier identifier attribute identifier identifier with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute string string_start string_end identifier generator_expression call identifier argument_list subscript identifier integer for_in_clause identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier identifier argument_list return_statement identifier
|
Returns SHA256 checksum for alphabetically-sorted concatenated list of hash prefixes
|
def settings_dir(self):
path = os.path.join(self.dir, '.dsb')
utils.create_dir(path)
return os.path.realpath(path)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier
|
Directory that contains the the settings for the project
|
def bind_events(self, events):
evs = self._events
if evs and events:
for event in evs.values():
if event.name in events:
event.bind(events[event.name])
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier if_statement boolean_operator identifier identifier block for_statement identifier call attribute identifier identifier argument_list block if_statement comparison_operator attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list subscript identifier attribute identifier identifier
|
Register all known events found in ``events`` key-valued parameters.
|
def obj_classes_from_module(module):
for name in dir(module):
if not name.startswith('_'):
cls = getattr(module, name)
if getattr(cls, 'classID', None):
yield (name, cls)
|
module function_definition identifier parameters identifier block for_statement identifier call identifier argument_list identifier block if_statement not_operator call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list identifier identifier if_statement call identifier argument_list identifier string string_start string_content string_end none block expression_statement yield tuple identifier identifier
|
Return a list of classes in a module that have a 'classID' attribute.
|
def format_value(self, value, padding):
if padding:
return "{:0{pad}d}".format(value, pad=padding)
else:
return str(value)
|
module function_definition identifier parameters identifier identifier identifier block if_statement identifier block return_statement call attribute string string_start string_content string_end identifier argument_list identifier keyword_argument identifier identifier else_clause block return_statement call identifier argument_list identifier
|
Get padding adjusting for negative values.
|
def OnUpdateFigurePanel(self, event):
if self.updating:
return
self.updating = True
self.figure_panel.update(self.get_figure(self.code))
self.updating = False
|
module function_definition identifier parameters identifier identifier block if_statement attribute identifier identifier block return_statement expression_statement assignment attribute identifier identifier true expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier false
|
Redraw event handler for the figure panel
|
def visit_ListComp(self, node: ast.ListComp) -> Any:
result = self._execute_comprehension(node=node)
for generator in node.generators:
self.visit(generator.iter)
self.recomputed_values[node] = result
return result
|
module function_definition identifier parameters identifier typed_parameter identifier type attribute identifier identifier type identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier return_statement identifier
|
Compile the list comprehension as a function and call it.
|
def code_binary(item):
code_str = code(item)
if isinstance(code_str, six.string_types):
return code_str.encode('utf-8')
return code_str
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement call identifier argument_list identifier attribute identifier identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier
|
Return a binary 'code' suitable for hashing.
|
def _validate_key(self, key):
return not any([key.startswith(i) for i in self.EXCEPTIONS])
|
module function_definition identifier parameters identifier identifier block return_statement not_operator call identifier argument_list list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier attribute identifier identifier
|
Returns a boolean indicating if the attribute name is valid or not
|
def sdb(opts, functions=None, whitelist=None, utils=None):
if utils is None:
utils = {}
return LazyLoader(
_module_dirs(opts, 'sdb'),
opts,
tag='sdb',
pack={
'__sdb__': functions,
'__opts__': opts,
'__utils__': utils,
'__salt__': minion_mods(opts, utils),
},
whitelist=whitelist,
)
|
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier dictionary return_statement call identifier argument_list call identifier argument_list identifier string string_start string_content string_end identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end call identifier argument_list identifier identifier keyword_argument identifier identifier
|
Make a very small database call
|
def render(self, doc, context=None, math_option=False, img_path='',
css_path=CSS_PATH):
if self.wait():
self.doc = doc
self.context = context
self.math_option = math_option
self.img_path = img_path
self.css_path = css_path
self.start()
|
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier false default_parameter identifier string string_start string_end default_parameter identifier identifier block if_statement call attribute identifier identifier argument_list block expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list
|
Start thread to render a given documentation
|
def create_pod(
name,
namespace,
metadata,
spec,
source,
template,
saltenv,
**kwargs):
body = __create_object_body(
kind='Pod',
obj_class=kubernetes.client.V1Pod,
spec_creator=__dict_to_pod_spec,
name=name,
namespace=namespace,
metadata=metadata,
spec=spec,
source=source,
template=template,
saltenv=saltenv)
cfg = _setup_conn(**kwargs)
try:
api_instance = kubernetes.client.CoreV1Api()
api_response = api_instance.create_namespaced_pod(
namespace, body)
return api_response.to_dict()
except (ApiException, HTTPError) as exc:
if isinstance(exc, ApiException) and exc.status == 404:
return None
else:
log.exception(
'Exception when calling '
'CoreV1Api->create_namespaced_pod'
)
raise CommandExecutionError(exc)
finally:
_cleanup(**cfg)
|
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement assignment identifier call identifier argument_list dictionary_splat identifier try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier return_statement call attribute identifier identifier argument_list except_clause as_pattern tuple identifier identifier as_pattern_target identifier block if_statement boolean_operator call identifier argument_list identifier identifier comparison_operator attribute identifier identifier integer block return_statement none else_clause block expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end raise_statement call identifier argument_list identifier finally_clause block expression_statement call identifier argument_list dictionary_splat identifier
|
Creates the kubernetes deployment as defined by the user.
|
def load_config(self):
for key in self.settings:
value = self.config(key)
if value == '' or value is None:
continue
if value.lower() == 'true':
value = True
elif value.lower() == 'false':
value = False
elif value:
pass
self.settings[key] = value
|
module function_definition identifier parameters identifier block for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement boolean_operator comparison_operator identifier string string_start string_end comparison_operator identifier none block continue_statement if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier true elif_clause comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier false elif_clause identifier block pass_statement expression_statement assignment subscript attribute identifier identifier identifier identifier
|
Load the configuration from git config.
|
def pem_to_der(cert, return_multiple=True):
cert_list = []
if pem.detect(cert):
for _, _, der_bytes in pem.unarmor(cert, multiple=True):
cert_list.append(der_bytes)
else:
cert_list.append(cert)
if return_multiple:
return cert_list
else:
return cert_list.pop()
|
module function_definition identifier parameters identifier default_parameter identifier true block expression_statement assignment identifier list if_statement call attribute identifier identifier argument_list identifier block for_statement pattern_list identifier identifier identifier call attribute identifier identifier argument_list identifier keyword_argument identifier true block expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier if_statement identifier block return_statement identifier else_clause block return_statement call attribute identifier identifier argument_list
|
Converts a given certificate or list to PEM format
|
def textForSaving(self):
lines = self.text.splitlines()
if self.text.endswith('\n'):
lines.append('')
return self.eol.join(lines) + self.eol
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list if_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content escape_sequence string_end block expression_statement call attribute identifier identifier argument_list string string_start string_end return_statement binary_operator call attribute attribute identifier identifier identifier argument_list identifier attribute identifier identifier
|
Get text with correct EOL symbols. Use this method for saving a file to storage
|
def save_related(self, request, form, formsets, change):
super(MenuItemAdmin, self).save_related(request, form, formsets, change)
self.model.objects.rebuild()
|
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list identifier identifier identifier identifier expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list
|
Rebuilds the tree after saving items related to parent.
|
def extent_count(self):
self.open()
count = lvm_vg_get_extent_count(self.handle)
self.close()
return count
|
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list return_statement identifier
|
Returns the volume group extent count.
|
def lex(code, lexer):
try:
return lexer.get_tokens(code)
except TypeError as err:
if (isinstance(err.args[0], str) and
('unbound method get_tokens' in err.args[0] or
'missing 1 required positional argument' in err.args[0])):
raise TypeError('lex() argument must be a lexer instance, '
'not a class')
raise
|
module function_definition identifier parameters identifier identifier block try_statement block return_statement call attribute identifier identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block if_statement parenthesized_expression boolean_operator call identifier argument_list subscript attribute identifier identifier integer identifier parenthesized_expression boolean_operator comparison_operator string string_start string_content string_end subscript attribute identifier identifier integer comparison_operator string string_start string_content string_end subscript attribute identifier identifier integer block raise_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end raise_statement
|
Lex ``code`` with ``lexer`` and return an iterable of tokens.
|
def port(self, port):
if not isinstance(port, int):
raise WebDriverException("Port needs to be an integer")
try:
port = int(port)
if port < 1 or port > 65535:
raise WebDriverException("Port number must be in the range 1..65535")
except (ValueError, TypeError):
raise WebDriverException("Port needs to be an integer")
self._port = port
self.set_preference("webdriver_firefox_port", self._port)
|
module function_definition identifier parameters identifier identifier block if_statement not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end try_statement block expression_statement assignment identifier call identifier argument_list identifier if_statement boolean_operator comparison_operator identifier integer comparison_operator identifier integer block raise_statement call identifier argument_list string string_start string_content string_end except_clause tuple identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier
|
Sets the port that WebDriver will be running on
|
def cancel(self):
with self.selenium.context(self.selenium.CONTEXT_CHROME):
self.find_secondary_button().click()
|
module function_definition identifier parameters identifier block with_statement with_clause with_item call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier block expression_statement call attribute call attribute identifier identifier argument_list identifier argument_list
|
Cancel add-on install.
|
def _draw_ellipse(data, obj, draw_options):
if isinstance(obj, mpl.patches.Circle):
return _draw_circle(data, obj, draw_options)
x, y = obj.center
ff = data["float format"]
if obj.angle != 0:
fmt = "rotate around={{" + ff + ":(axis cs:" + ff + "," + ff + ")}}"
draw_options.append(fmt.format(obj.angle, x, y))
cont = (
"\\draw[{}] (axis cs:"
+ ff
+ ","
+ ff
+ ") ellipse ("
+ ff
+ " and "
+ ff
+ ");\n"
).format(",".join(draw_options), x, y, 0.5 * obj.width, 0.5 * obj.height)
return data, cont
|
module function_definition identifier parameters identifier identifier identifier block if_statement call identifier argument_list identifier attribute attribute identifier identifier identifier block return_statement call identifier argument_list identifier identifier identifier expression_statement assignment pattern_list identifier identifier attribute identifier identifier expression_statement assignment identifier subscript identifier string string_start string_content string_end if_statement comparison_operator attribute identifier identifier integer block expression_statement assignment identifier binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator string string_start string_content string_end identifier string string_start string_content string_end identifier string string_start string_content string_end identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier identifier identifier expression_statement assignment identifier call attribute parenthesized_expression binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator string string_start string_content escape_sequence string_end identifier string string_start string_content string_end identifier string string_start string_content string_end identifier string string_start string_content string_end identifier string string_start string_content escape_sequence string_end identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier identifier binary_operator float attribute identifier identifier binary_operator float attribute identifier identifier return_statement expression_list identifier identifier
|
Return the PGFPlots code for ellipses.
|
def preprocess_belscript(lines):
set_flag = False
for line in lines:
if set_flag is False and re.match("SET", line):
set_flag = True
set_line = [line.rstrip()]
elif set_flag and re.match("SET", line):
yield f"{' '.join(set_line)}\n"
set_line = [line.rstrip()]
elif set_flag and re.match("\s+$", line):
yield f"{' '.join(set_line)}\n"
yield line
set_flag = False
elif set_flag:
set_line.append(line.rstrip())
else:
yield line
|
module function_definition identifier parameters identifier block expression_statement assignment identifier false for_statement identifier identifier block if_statement boolean_operator comparison_operator identifier false call attribute identifier identifier argument_list string string_start string_content string_end identifier block expression_statement assignment identifier true expression_statement assignment identifier list call attribute identifier identifier argument_list elif_clause boolean_operator identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier block expression_statement yield string string_start interpolation call attribute string string_start string_content string_end identifier argument_list identifier string_content escape_sequence string_end expression_statement assignment identifier list call attribute identifier identifier argument_list elif_clause boolean_operator identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier block expression_statement yield string string_start interpolation call attribute string string_start string_content string_end identifier argument_list identifier string_content escape_sequence string_end expression_statement yield identifier expression_statement assignment identifier false elif_clause identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list else_clause block expression_statement yield identifier
|
Convert any multi-line SET statements into single line SET statements
|
async def part(self, channel, message=None):
if not self.in_channel(channel):
raise NotInChannel(channel)
if message:
await self.rawmsg('PART', channel, message)
else:
await self.rawmsg('PART', channel)
|
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement not_operator call attribute identifier identifier argument_list identifier block raise_statement call identifier argument_list identifier if_statement identifier block expression_statement await call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier else_clause block expression_statement await call attribute identifier identifier argument_list string string_start string_content string_end identifier
|
Leave channel, optionally with message.
|
def use_property(kepid, prop):
try:
prov = kicu.DATA.ix[kepid, '{}_prov'.format(prop)]
return any([prov.startswith(s) for s in ['SPE', 'AST']])
except KeyError:
raise MissingStellarError('{} not in stellar table?'.format(kepid))
|
module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment identifier subscript attribute attribute identifier identifier identifier identifier call attribute string string_start string_content string_end identifier argument_list identifier return_statement call identifier argument_list list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier list string string_start string_content string_end string string_start string_content string_end except_clause identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier
|
Returns true if provenance of property is SPE or AST
|
def _send_to_all_rooms(self, message):
for room in self._rooms.values():
room.send_message(message)
|
module function_definition identifier parameters identifier identifier block for_statement identifier call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier
|
Send a message to all connected rooms
|
def folders(self):
if self._folders is None:
self.__init()
if "/" not in self._folders:
self._folders.append("/")
return self._folders
|
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute identifier identifier argument_list if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end return_statement attribute identifier identifier
|
returns a list of all folders
|
def _load_sensors(self, path=None):
if path is None:
path = self.persistence_file
exists = os.path.isfile(path)
if exists and os.access(path, os.R_OK):
if path == self.persistence_bak:
os.rename(path, self.persistence_file)
path = self.persistence_file
_LOGGER.debug('Loading sensors from persistence file %s', path)
self._perform_file_action(path, 'load')
return True
_LOGGER.warning('File does not exist or is not readable: %s', path)
return False
|
module function_definition identifier parameters identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement boolean_operator identifier call attribute identifier identifier argument_list identifier attribute identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier string string_start string_content string_end return_statement true expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement false
|
Load sensors from file.
|
def __discovery_url(self):
port = self.sensor.options.agent_port
if port == 0:
port = AGENT_DEFAULT_PORT
return "http://%s:%s/%s" % (self.host, port, AGENT_DISCOVERY_PATH)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute attribute attribute identifier identifier identifier identifier if_statement comparison_operator identifier integer block expression_statement assignment identifier identifier return_statement binary_operator string string_start string_content string_end tuple attribute identifier identifier identifier identifier
|
URL for announcing to the host agent
|
def as_dict(self):
pk = self.pk
id_type = 3
if pk.type == 'auto':
id_type = 1
return {'id_name': pk.name,
'id_type': id_type,
'sorted': bool(self.ordering),
'autoincr': self.ordering and self.ordering.auto,
'multi_fields': [field.name for field in self.multifields],
'indices': dict(((idx.attname, idx.unique)
for idx in self.indices))}
|
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier integer if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier integer return_statement dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end call identifier argument_list attribute identifier identifier pair string string_start string_content string_end boolean_operator attribute identifier identifier attribute attribute identifier identifier identifier pair string string_start string_content string_end list_comprehension attribute identifier identifier for_in_clause identifier attribute identifier identifier pair string string_start string_content string_end call identifier argument_list generator_expression tuple attribute identifier identifier attribute identifier identifier for_in_clause identifier attribute identifier identifier
|
Model metadata in a dictionary
|
def daemonize(self):
self._double_fork()
self.pid = os.getpid()
LOG.info(
"Succesfully daemonized process {0}.".format(self.pid)
)
|
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier 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 attribute identifier identifier
|
Double fork and set the pid.
|
def run_command(self, command, message):
proc = subprocess.Popen([
'echo \'%s\' | %s' % (fedmsg.encoding.dumps(message), command)
], shell=True, executable='/bin/bash')
return proc.wait()
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list list binary_operator string string_start string_content escape_sequence escape_sequence string_end tuple call attribute attribute identifier identifier identifier argument_list identifier identifier keyword_argument identifier true keyword_argument identifier string string_start string_content string_end return_statement call attribute identifier identifier argument_list
|
Use subprocess; feed the message to our command over stdin
|
def linreg_ols_pinv(y, X, rcond=1e-15):
import numpy as np
try:
return np.dot(np.linalg.pinv(
np.dot(X.T, X), rcond=rcond), np.dot(X.T, y))
except np.linalg.LinAlgError:
print("LinAlgError: SVD does not converge")
return None
|
module function_definition identifier parameters identifier identifier default_parameter identifier float block import_statement aliased_import dotted_name identifier identifier try_statement block return_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier identifier keyword_argument identifier identifier call attribute identifier identifier argument_list attribute identifier identifier identifier except_clause attribute attribute identifier identifier identifier block expression_statement call identifier argument_list string string_start string_content string_end return_statement none
|
Linear Regression, OLS, by multiplying with Pseudoinverse
|
def _path_from_module(module):
paths = list(getattr(module, '__path__', []))
if len(paths) != 1:
filename = getattr(module, '__file__', None)
if filename is not None:
paths = [os.path.dirname(filename)]
else:
paths = list(set(paths))
if len(paths) > 1:
raise ImproperlyConfigured(
"The bot module %r has multiple filesystem locations (%r); "
"you must configure this bot with an AppConfig subclass "
"with a 'path' class attribute." % (module, paths))
elif not paths:
raise ImproperlyConfigured(
"The bot module %r has no filesystem location, "
"you must configure this bot with an AppConfig subclass "
"with a 'path' class attribute." % (module,))
return paths[0]
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier string string_start string_content string_end list if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end none if_statement comparison_operator identifier none block expression_statement assignment identifier list call attribute attribute identifier identifier identifier argument_list identifier else_clause block expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier if_statement comparison_operator call identifier argument_list identifier integer block raise_statement call identifier argument_list binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end tuple identifier identifier elif_clause not_operator identifier block raise_statement call identifier argument_list binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end tuple identifier return_statement subscript identifier integer
|
Attempt to determine bot's filesystem path from its module.
|
def __end_of_list(self, ast_token):
self.list_level -= 1
if self.list_level == 0:
if self.list_entry is not None:
self.final_ast_tokens.append(self.list_entry)
self.list_entry = None
self.final_ast_tokens.append(ast_token)
|
module function_definition identifier parameters identifier identifier block expression_statement augmented_assignment attribute identifier identifier integer if_statement comparison_operator attribute identifier identifier integer block if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier none expression_statement call attribute attribute identifier identifier identifier argument_list identifier
|
Handle end of a list.
|
def fetch_googl():
yql = YQL('GOOGL', '2014-01-01', '2014-01-10')
for item in yql:
print item.get('date'), item.get('price')
yql.select('GOOGL', '2014-01-01', '2014-01-10')
for item in yql:
print item.get('date'), item.get('price')
|
module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end for_statement identifier identifier block print_statement 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 expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end for_statement identifier identifier block print_statement 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
|
Returns stock prices for Google company.
|
def isDirect(self):
direct = (self._messageType == 0x00)
if self.isDirectACK or self.isDirectNAK:
direct = True
return direct
|
module function_definition identifier parameters identifier block expression_statement assignment identifier parenthesized_expression comparison_operator attribute identifier identifier integer if_statement boolean_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier true return_statement identifier
|
Test if the message is a direct message type.
|
def _getModelData(self, modelData, parentItem=None):
if parentItem is None:
parentItem = self.rootItem
for item in parentItem.getChildren():
key = item.getItemData(0)
if item.childCount():
modelData[key] = odict()
self._getModelData(modelData[key], item)
else:
if isinstance(item.getItemData(2), float):
modelData[key] = [item.getItemData(1), item.getItemData(2)]
else:
modelData[key] = item.getItemData(1)
|
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier attribute identifier identifier for_statement identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list integer if_statement call attribute identifier identifier argument_list block expression_statement assignment subscript identifier identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list subscript identifier identifier identifier else_clause block if_statement call identifier argument_list call attribute identifier identifier argument_list integer identifier block expression_statement assignment subscript identifier identifier list call attribute identifier identifier argument_list integer call attribute identifier identifier argument_list integer else_clause block expression_statement assignment subscript identifier identifier call attribute identifier identifier argument_list integer
|
Return the data contained in the model.
|
def remove(self, key):
if key in self.queue:
del self.queue[key]
self.write()
return True
return False
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block delete_statement subscript attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list return_statement true return_statement false
|
Remove a key from the queue, return `False` if no such key exists.
|
def _init_impl(self, data, ctx_list):
self._ctx_list = list(ctx_list)
self._ctx_map = [[], []]
for i, ctx in enumerate(self._ctx_list):
dev_list = self._ctx_map[ctx.device_typeid&1]
while len(dev_list) <= ctx.device_id:
dev_list.append(None)
dev_list[ctx.device_id] = i
self._data = [data.copyto(ctx) for ctx in self._ctx_list]
self._init_grad()
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list identifier expression_statement assignment attribute identifier identifier list list list for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier binary_operator attribute identifier identifier integer while_statement comparison_operator call identifier argument_list identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list none expression_statement assignment subscript identifier attribute identifier identifier identifier expression_statement assignment attribute identifier identifier list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list
|
Sets data and grad.
|
def split_func_name_args_params_handle(tokens):
internal_assert(len(tokens) == 2, "invalid function definition splitting tokens", tokens)
func_name = tokens[0]
func_args = []
func_params = []
for arg in tokens[1]:
if len(arg) > 1 and arg[0] in ("*", "**"):
func_args.append(arg[1])
elif arg[0] != "*":
func_args.append(arg[0])
func_params.append("".join(arg))
return [
func_name,
", ".join(func_args),
"(" + ", ".join(func_params) + ")",
]
|
module function_definition identifier parameters identifier block expression_statement call identifier argument_list comparison_operator call identifier argument_list identifier integer string string_start string_content string_end identifier expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier list expression_statement assignment identifier list for_statement identifier subscript identifier integer block if_statement boolean_operator comparison_operator call identifier argument_list identifier integer comparison_operator subscript identifier integer tuple string string_start string_content string_end string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list subscript identifier integer elif_clause comparison_operator subscript identifier integer string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list subscript identifier integer expression_statement call attribute identifier identifier argument_list call attribute string string_start string_end identifier argument_list identifier return_statement list identifier call attribute string string_start string_content string_end identifier argument_list identifier binary_operator binary_operator string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list identifier string string_start string_content string_end
|
Process splitting a function into name, params, and args.
|
def groups_moderators(self, room_id=None, group=None, **kwargs):
if room_id:
return self.__call_api_get('groups.moderators', roomId=room_id, kwargs=kwargs)
elif group:
return self.__call_api_get('groups.moderators', roomName=group, kwargs=kwargs)
else:
raise RocketMissingParamException('roomId or group required')
|
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none dictionary_splat_pattern identifier block if_statement identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier elif_clause identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier else_clause block raise_statement call identifier argument_list string string_start string_content string_end
|
Lists all moderators of a group.
|
def _connect_func(builder, obj, signal_name, handler_name,
connect_object, flags, cls):
if connect_object is None:
extra = ()
else:
extra = (connect_object,)
template_inst = builder.get_object(cls.__gtype_name__)
if template_inst is None:
errmsg = "Internal error: cannot find template instance! obj: %s; " \
"signal: %s; handler: %s; connect_obj: %s; class: %s" % \
(obj, signal_name, handler_name, connect_object, cls)
warnings.warn(errmsg, GtkTemplateWarning)
return
handler = getattr(template_inst, handler_name)
if flags == GObject.ConnectFlags.AFTER:
obj.connect_after(signal_name, handler, *extra)
else:
obj.connect(signal_name, handler, *extra)
template_inst.__connected_template_signals__.add(handler_name)
|
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier block if_statement comparison_operator identifier none block expression_statement assignment identifier tuple else_clause block expression_statement assignment identifier tuple identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end line_continuation tuple identifier identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier return_statement expression_statement assignment identifier call identifier argument_list identifier identifier if_statement comparison_operator identifier attribute attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier list_splat identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier identifier list_splat identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
|
Handles GtkBuilder signal connect events
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.