code
stringlengths 51
2.34k
| sequence
stringlengths 186
3.94k
| docstring
stringlengths 11
171
|
|---|---|---|
def resolve_targetfile(self, args, require_sim_name=False):
ttype = args.get('ttype')
if is_null(ttype):
sys.stderr.write('Target type must be specified')
return (None, None)
sim = args.get('sim')
if is_null(sim):
if require_sim_name:
sys.stderr.write('Simulation scenario must be specified')
return (None, None)
else:
sim = None
name_keys = dict(target_type=ttype,
targetlist='target_list.yaml',
sim_name=sim,
fullpath=True)
if sim is None:
targetfile = self.targetfile(**name_keys)
else:
targetfile = self.sim_targetfile(**name_keys)
targets_override = args.get('targetfile')
if is_not_null(targets_override):
targetfile = targets_override
return (targetfile, sim)
|
module function_definition identifier parameters identifier identifier default_parameter identifier false block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement call identifier argument_list identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end return_statement tuple none none expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement call identifier argument_list identifier block if_statement identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end return_statement tuple none none else_clause block expression_statement assignment identifier none expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier true if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list dictionary_splat identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list dictionary_splat identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement call identifier argument_list identifier block expression_statement assignment identifier identifier return_statement tuple identifier identifier
|
Get the name of the targetfile based on the job arguments
|
def CheckIfCanStartClientFlow(self, username, flow_name):
del username
flow_cls = flow.GRRFlow.GetPlugin(flow_name)
if not flow_cls.category:
raise access_control.UnauthorizedAccess(
"Flow %s can't be started via the API." % flow_name)
|
module function_definition identifier parameters identifier identifier identifier block delete_statement identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement not_operator attribute identifier identifier block raise_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier
|
Checks whether a given user can start a given flow.
|
def compound_id(obj):
if isinstance(obj, (Category, Session)):
raise TypeError('Compound IDs are not supported for this entry type')
elif isinstance(obj, Event):
return unicode(obj.id)
elif isinstance(obj, Contribution):
return '{}.{}'.format(obj.event_id, obj.id)
elif isinstance(obj, SubContribution):
return '{}.{}.{}'.format(obj.contribution.event_id, obj.contribution_id, obj.id)
|
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier tuple identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end elif_clause call identifier argument_list identifier identifier block return_statement call identifier argument_list attribute identifier identifier elif_clause call identifier argument_list identifier identifier block return_statement call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier attribute identifier identifier elif_clause call identifier argument_list identifier identifier block return_statement call attribute string string_start string_content string_end identifier argument_list attribute attribute identifier identifier identifier attribute identifier identifier attribute identifier identifier
|
Generate a hierarchical compound ID, separated by dots.
|
def add_dup(self, pkt):
log.debug("Recording a dup of %s", pkt)
s = str(pkt)
if s in self.dups:
self.dups[s] += 1
else:
self.dups[s] = 1
tftpassert(self.dups[s] < MAX_DUPS, "Max duplicates reached")
|
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier attribute identifier identifier block expression_statement augmented_assignment subscript attribute identifier identifier identifier integer else_clause block expression_statement assignment subscript attribute identifier identifier identifier integer expression_statement call identifier argument_list comparison_operator subscript attribute identifier identifier identifier identifier string string_start string_content string_end
|
This method adds a dup for a packet to the metrics.
|
def __normalize_progress(self):
progress = self['funding_progress']
if progress % 10 != 0:
progress = round(float(progress) / 10)
progress = int(progress) * 10
self['funding_progress'] = progress
|
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end if_statement comparison_operator binary_operator identifier integer integer block expression_statement assignment identifier call identifier argument_list binary_operator call identifier argument_list identifier integer expression_statement assignment identifier binary_operator call identifier argument_list identifier integer expression_statement assignment subscript identifier string string_start string_content string_end identifier
|
Adjust the funding progress filter to be a factor of 10
|
def check_unique(self):
errors = []
service_id = getattr(self, 'id', None)
fields = [('location', views.service_location),
('name', views.service_name)]
for field, view in fields:
value = getattr(self, field, None)
if not value:
continue
result = yield view.values(key=value)
matched = {x['id'] for x in result if x['id'] != service_id}
if matched:
errors.append("Service with {} '{}' already exists"
.format(field, value))
if errors:
raise exceptions.ValidationError(errors)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier list expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end none expression_statement assignment identifier list tuple string string_start string_content string_end attribute identifier identifier tuple string string_start string_content string_end attribute identifier identifier for_statement pattern_list identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier none if_statement not_operator identifier block continue_statement expression_statement assignment identifier yield call attribute identifier identifier argument_list keyword_argument identifier identifier expression_statement assignment identifier set_comprehension subscript identifier string string_start string_content string_end for_in_clause identifier identifier if_clause comparison_operator subscript identifier string string_start string_content string_end identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier if_statement identifier block raise_statement call attribute identifier identifier argument_list identifier
|
Check the service's name and location are unique
|
def _convert_type(self, data_type):
if (data_type == 1) or (data_type == 41):
dt_string = 'b'
elif data_type == 2:
dt_string = 'h'
elif data_type == 4:
dt_string = 'i'
elif (data_type == 8) or (data_type == 33):
dt_string = 'q'
elif data_type == 11:
dt_string = 'B'
elif data_type == 12:
dt_string = 'H'
elif data_type == 14:
dt_string = 'I'
elif (data_type == 21) or (data_type == 44):
dt_string = 'f'
elif (data_type == 22) or (data_type == 45) or (data_type == 31):
dt_string = 'd'
elif (data_type == 32):
dt_string = 'd'
elif (data_type == 51) or (data_type == 52):
dt_string = 's'
return dt_string
|
module function_definition identifier parameters identifier identifier block if_statement boolean_operator parenthesized_expression comparison_operator identifier integer parenthesized_expression comparison_operator identifier integer block expression_statement assignment identifier string string_start string_content string_end elif_clause comparison_operator identifier integer block expression_statement assignment identifier string string_start string_content string_end elif_clause comparison_operator identifier integer block expression_statement assignment identifier string string_start string_content string_end elif_clause boolean_operator parenthesized_expression comparison_operator identifier integer parenthesized_expression comparison_operator identifier integer block expression_statement assignment identifier string string_start string_content string_end elif_clause comparison_operator identifier integer block expression_statement assignment identifier string string_start string_content string_end elif_clause comparison_operator identifier integer block expression_statement assignment identifier string string_start string_content string_end elif_clause comparison_operator identifier integer block expression_statement assignment identifier string string_start string_content string_end elif_clause boolean_operator parenthesized_expression comparison_operator identifier integer parenthesized_expression comparison_operator identifier integer block expression_statement assignment identifier string string_start string_content string_end elif_clause boolean_operator boolean_operator parenthesized_expression comparison_operator identifier integer parenthesized_expression comparison_operator identifier integer parenthesized_expression comparison_operator identifier integer block expression_statement assignment identifier string string_start string_content string_end elif_clause parenthesized_expression comparison_operator identifier integer block expression_statement assignment identifier string string_start string_content string_end elif_clause boolean_operator parenthesized_expression comparison_operator identifier integer parenthesized_expression comparison_operator identifier integer block expression_statement assignment identifier string string_start string_content string_end return_statement identifier
|
CDF data types to python struct data types
|
def _create_body(self, name, description=None, volume=None, force=False):
body = {"snapshot": {
"display_name": name,
"display_description": description,
"volume_id": volume.id,
"force": str(force).lower(),
}}
return body
|
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier false block expression_statement assignment identifier dictionary pair string string_start string_content string_end 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 attribute identifier identifier pair string string_start string_content string_end call attribute call identifier argument_list identifier identifier argument_list return_statement identifier
|
Used to create the dict required to create a new snapshot
|
def init_app(application):
for code in werkzeug.exceptions.default_exceptions:
application.register_error_handler(code, handle_http_exception)
|
module function_definition identifier parameters identifier block for_statement identifier attribute attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier
|
Associates the error handler
|
def param(name, help=""):
def decorator(func):
params = getattr(func, "params", [])
_param = Param(name, help)
params.insert(0, _param)
func.params = params
return func
return decorator
|
module function_definition identifier parameters identifier default_parameter identifier string string_start string_end block function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end list expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list integer identifier expression_statement assignment attribute identifier identifier identifier return_statement identifier return_statement identifier
|
Decorator that add a parameter to the wrapped command or function.
|
def load_cash_balances_with_children(self, root_account_fullname: str):
assert isinstance(root_account_fullname, str)
svc = AccountsAggregate(self.book)
root_account = svc.get_by_fullname(root_account_fullname)
if not root_account:
raise ValueError("Account not found", root_account_fullname)
accounts = self.__get_all_child_accounts_as_array(root_account)
model = {}
for account in accounts:
if account.commodity.namespace != "CURRENCY" or account.placeholder:
continue
currency_symbol = account.commodity.mnemonic
if not currency_symbol in model:
currency_record = {
"name": currency_symbol,
"total": 0,
"rows": []
}
model[currency_symbol] = currency_record
else:
currency_record = model[currency_symbol]
balance = account.get_balance()
row = {
"name": account.name,
"fullname": account.fullname,
"currency": currency_symbol,
"balance": balance
}
currency_record["rows"].append(row)
total = Decimal(currency_record["total"])
total += balance
currency_record["total"] = total
return model
|
module function_definition identifier parameters identifier typed_parameter identifier type identifier block assert_statement call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator identifier block raise_statement call identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier dictionary for_statement identifier identifier block if_statement boolean_operator comparison_operator attribute attribute identifier identifier identifier string string_start string_content string_end attribute identifier identifier block continue_statement expression_statement assignment identifier attribute attribute identifier identifier identifier if_statement not_operator comparison_operator identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end integer pair string string_start string_content string_end list expression_statement assignment subscript identifier identifier identifier else_clause block expression_statement assignment identifier subscript identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier call identifier argument_list subscript identifier string string_start string_content string_end expression_statement augmented_assignment identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier return_statement identifier
|
loads data for cash balances
|
def _dissect_msg(self, match):
recvfrom = match.group(1)
frame = bytes.fromhex(match.group(2))
if recvfrom == 'E':
_LOGGER.warning("Received erroneous message, ignoring: %s", frame)
return (None, None, None, None, None)
msgtype = self._get_msgtype(frame[0])
if msgtype in (READ_ACK, WRITE_ACK, READ_DATA, WRITE_DATA):
data_id = frame[1:2]
data_msb = frame[2:3]
data_lsb = frame[3:4]
return (recvfrom, msgtype, data_id, data_msb, data_lsb)
return (None, None, None, None, None)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list integer expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list integer if_statement comparison_operator identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement tuple none none none none none expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier integer if_statement comparison_operator identifier tuple identifier identifier identifier identifier block expression_statement assignment identifier subscript identifier slice integer integer expression_statement assignment identifier subscript identifier slice integer integer expression_statement assignment identifier subscript identifier slice integer integer return_statement tuple identifier identifier identifier identifier identifier return_statement tuple none none none none none
|
Split messages into bytes and return a tuple of bytes.
|
def scheduler(rq, ctx, verbose, burst, queue, interval, pid):
"Periodically checks for scheduled jobs."
scheduler = rq.get_scheduler(interval=interval, queue=queue)
if pid:
with open(os.path.expanduser(pid), 'w') as fp:
fp.write(str(os.getpid()))
if verbose:
level = 'DEBUG'
else:
level = 'INFO'
setup_loghandlers(level)
scheduler.run(burst=burst)
|
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier if_statement identifier 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 attribute identifier identifier argument_list call identifier argument_list call attribute identifier identifier argument_list if_statement 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 expression_statement call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier
|
Periodically checks for scheduled jobs.
|
def _auth(self, username, password) :
self.user_credentials = self.call('auth', {'username': username, 'password': password})
if 'error' in self.user_credentials:
raise T411Exception('Error while fetching authentication token: %s'\
% self.user_credentials['error'])
user_data = dumps({'uid': '%s' % self.user_credentials['uid'], 'token': '%s' % self.user_credentials['token']})
with open(USER_CREDENTIALS_FILE, 'w') as user_cred_file:
user_cred_file.write(user_data)
return True
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end line_continuation subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list dictionary pair string string_start string_content string_end binary_operator string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end pair string string_start string_content string_end binary_operator string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end 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 return_statement true
|
Authentificate user and store token
|
def erank(self):
r = self.r
n = self.n
d = self.d
if d <= 1:
er = 0e0
else:
sz = _np.dot(n * r[0:d], r[1:])
if sz == 0:
er = 0e0
else:
b = r[0] * n[0] + n[d - 1] * r[d]
if d is 2:
er = sz * 1.0 / b
else:
a = _np.sum(n[1:d - 1])
er = (_np.sqrt(b * b + 4 * a * sz) - b) / (2 * a)
return er
|
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier integer block expression_statement assignment identifier float else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator identifier subscript identifier slice integer identifier subscript identifier slice integer if_statement comparison_operator identifier integer block expression_statement assignment identifier float else_clause block expression_statement assignment identifier binary_operator binary_operator subscript identifier integer subscript identifier integer binary_operator subscript identifier binary_operator identifier integer subscript identifier identifier if_statement comparison_operator identifier integer block expression_statement assignment identifier binary_operator binary_operator identifier float identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier slice integer binary_operator identifier integer expression_statement assignment identifier binary_operator parenthesized_expression binary_operator call attribute identifier identifier argument_list binary_operator binary_operator identifier identifier binary_operator binary_operator integer identifier identifier identifier parenthesized_expression binary_operator integer identifier return_statement identifier
|
Effective rank of the TT-vector
|
def rotateCD(self,orient):
_delta = self.get_orient() - orient
if _delta == 0.:
return
_rot = fileutil.buildRotMatrix(_delta)
_cd = N.array([[self.cd11,self.cd12],[self.cd21,self.cd22]],dtype=N.float64)
_cdrot = N.dot(_cd,_rot)
self.cd11 = _cdrot[0][0]
self.cd12 = _cdrot[0][1]
self.cd21 = _cdrot[1][0]
self.cd22 = _cdrot[1][1]
self.orient = orient
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier float block return_statement expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list list list attribute identifier identifier attribute identifier identifier list attribute identifier identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment attribute identifier identifier subscript subscript identifier integer integer expression_statement assignment attribute identifier identifier subscript subscript identifier integer integer expression_statement assignment attribute identifier identifier subscript subscript identifier integer integer expression_statement assignment attribute identifier identifier subscript subscript identifier integer integer expression_statement assignment attribute identifier identifier identifier
|
Rotates WCS CD matrix to new orientation given by 'orient'
|
def as_text(self, max_rows=0, sep=" | "):
if not max_rows or max_rows > self.num_rows:
max_rows = self.num_rows
omitted = max(0, self.num_rows - max_rows)
labels = self._columns.keys()
fmts = self._get_column_formatters(max_rows, False)
rows = [[fmt(label, label=True) for fmt, label in zip(fmts, labels)]]
for row in itertools.islice(self.rows, max_rows):
rows.append([f(v, label=False) for v, f in zip(row, fmts)])
lines = [sep.join(row) for row in rows]
if omitted:
lines.append('... ({} rows omitted)'.format(omitted))
return '\n'.join([line.rstrip() for line in lines])
|
module function_definition identifier parameters identifier default_parameter identifier integer default_parameter identifier string string_start string_content string_end block if_statement boolean_operator not_operator identifier comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list integer binary_operator attribute identifier identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier false expression_statement assignment identifier list list_comprehension call identifier argument_list identifier keyword_argument identifier true for_in_clause pattern_list identifier identifier call identifier argument_list identifier identifier for_statement identifier call attribute identifier identifier argument_list attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list list_comprehension call identifier argument_list identifier keyword_argument identifier false for_in_clause pattern_list identifier identifier call identifier argument_list identifier identifier expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier return_statement call attribute string string_start string_content escape_sequence string_end identifier argument_list list_comprehension call attribute identifier identifier argument_list for_in_clause identifier identifier
|
Format table as text.
|
def remove_index(self, index):
'remove one or more indices'
index_rm, single = convert_key_to_index(force_list(self.indices.keys()), index)
if single:
index_rm = [index_rm]
index_new = [i for i in range(len(self.indices)) if i not in index_rm]
if not index_new:
self.clear(True)
return
names = mget_list(force_list(self.indices.keys()), index_new)
items = [mget_list(i, index_new) for i in self.items()]
self.clear(True)
_MI_init(self, items, names)
|
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end expression_statement assignment pattern_list identifier identifier call identifier argument_list call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier if_statement identifier block expression_statement assignment identifier list identifier expression_statement assignment identifier list_comprehension identifier for_in_clause identifier call identifier argument_list call identifier argument_list attribute identifier identifier if_clause comparison_operator identifier identifier if_statement not_operator identifier block expression_statement call attribute identifier identifier argument_list true return_statement expression_statement assignment identifier call identifier argument_list call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier list_comprehension call identifier argument_list identifier identifier for_in_clause identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list true expression_statement call identifier argument_list identifier identifier identifier
|
remove one or more indices
|
def fincre(oldname):
x=re.search('_(?P<version>[0-9][0-9][0-9])_syn',oldname)
version=x.group('version')
newversion="%03d"%(int(version)+1)
ans=oldname.replace(version,newversion)
return ans
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier binary_operator string string_start string_content string_end parenthesized_expression binary_operator call identifier argument_list identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier return_statement identifier
|
Increment the synphot version number from a filename
|
def _parse_entity(self):
reset = self._head
try:
self._push(contexts.HTML_ENTITY)
self._really_parse_entity()
except BadRoute:
self._head = reset
self._emit_text(self._read())
else:
self._emit_all(self._pop())
|
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier try_statement block expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list except_clause identifier block expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list else_clause block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list
|
Parse an HTML entity at the head of the wikicode string.
|
def check_length_of_initial_values(self, init_values):
num_nests = self.rows_to_nests.shape[1]
num_index_coefs = self.design.shape[1]
assumed_param_dimensions = num_index_coefs + num_nests
if init_values.shape[0] != assumed_param_dimensions:
msg = "The initial values are of the wrong dimension"
msg_1 = "It should be of dimension {}"
msg_2 = "But instead it has dimension {}"
raise ValueError(msg +
msg_1.format(assumed_param_dimensions) +
msg_2.format(init_values.shape[0]))
return None
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript attribute attribute identifier identifier identifier integer expression_statement assignment identifier subscript attribute attribute identifier identifier identifier integer expression_statement assignment identifier binary_operator identifier identifier if_statement comparison_operator subscript attribute identifier identifier integer identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end raise_statement call identifier argument_list binary_operator binary_operator identifier call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list subscript attribute identifier identifier integer return_statement none
|
Ensures that the initial values are of the correct length.
|
def detect_fts(conn, table):
"Detect if table has a corresponding FTS virtual table and return it"
rows = conn.execute(detect_fts_sql(table)).fetchall()
if len(rows) == 0:
return None
else:
return rows[0][0]
|
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call attribute call attribute identifier identifier argument_list call identifier argument_list identifier identifier argument_list if_statement comparison_operator call identifier argument_list identifier integer block return_statement none else_clause block return_statement subscript subscript identifier integer integer
|
Detect if table has a corresponding FTS virtual table and return it
|
def position_p(self):
self._position_p, value = self.get_attr_int(self._position_p, 'hold_pid/Kp')
return value
|
module function_definition identifier parameters identifier block expression_statement assignment pattern_list attribute identifier identifier identifier call attribute identifier identifier argument_list attribute identifier identifier string string_start string_content string_end return_statement identifier
|
The proportional constant for the position PID.
|
def squarelim():
fig = gcf()
xmin, xmax = fig.xlim
ymin, ymax = fig.ylim
zmin, zmax = fig.zlim
width = max([abs(xmax - xmin), abs(ymax - ymin), abs(zmax - zmin)])
xc = (xmin + xmax) / 2
yc = (ymin + ymax) / 2
zc = (zmin + zmax) / 2
xlim(xc - width / 2, xc + width / 2)
ylim(yc - width / 2, yc + width / 2)
zlim(zc - width / 2, zc + width / 2)
|
module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list expression_statement assignment pattern_list identifier identifier attribute identifier identifier expression_statement assignment pattern_list identifier identifier attribute identifier identifier expression_statement assignment pattern_list identifier identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list list call identifier argument_list binary_operator identifier identifier call identifier argument_list binary_operator identifier identifier call identifier argument_list binary_operator identifier identifier expression_statement assignment identifier binary_operator parenthesized_expression binary_operator identifier identifier integer expression_statement assignment identifier binary_operator parenthesized_expression binary_operator identifier identifier integer expression_statement assignment identifier binary_operator parenthesized_expression binary_operator identifier identifier integer expression_statement call identifier argument_list binary_operator identifier binary_operator identifier integer binary_operator identifier binary_operator identifier integer expression_statement call identifier argument_list binary_operator identifier binary_operator identifier integer binary_operator identifier binary_operator identifier integer expression_statement call identifier argument_list binary_operator identifier binary_operator identifier integer binary_operator identifier binary_operator identifier integer
|
Set all axes with equal aspect ratio, such that the space is 'square'.
|
def node_detail(node_name):
token = session.get('token')
node = nago.core.get_node(token)
if not node.get('access') == 'master':
return jsonify(status='error', error="You need master access to view this page")
node = nago.core.get_node(node_name)
return render_template('node_detail.html', node=node)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement not_operator comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end block return_statement call identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier return_statement call identifier argument_list string string_start string_content string_end keyword_argument identifier identifier
|
View one specific node
|
def _api_model_patch_replace(conn, restApiId, modelName, path, value):
response = conn.update_model(restApiId=restApiId, modelName=modelName,
patchOperations=[{'op': 'replace', 'path': path, 'value': value}])
return response
|
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier 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 identifier pair string string_start string_content string_end identifier return_statement identifier
|
the replace patch operation on a Model resource
|
def line_break(self):
for i in range(self.slide.insert_line_break):
if not self._in_tag(ns("text", "p")):
self.add_node(ns("text", "p"))
self.add_node(ns("text", "line-break"))
self.pop_node()
if self.cur_node.tag == ns("text", "p"):
return
if self.cur_node.getparent().tag != ns("text", "p"):
self.pop_node()
self.slide.insert_line_break = 0
|
module function_definition identifier parameters identifier block for_statement identifier call identifier argument_list attribute attribute identifier identifier identifier block if_statement not_operator call attribute identifier identifier argument_list call identifier argument_list string string_start string_content string_end string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list call identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list if_statement comparison_operator attribute attribute identifier identifier identifier call identifier argument_list string string_start string_content string_end string string_start string_content string_end block return_statement if_statement comparison_operator attribute call attribute attribute identifier identifier identifier argument_list identifier call identifier argument_list string string_start string_content string_end string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list expression_statement assignment attribute attribute identifier identifier identifier integer
|
insert as many line breaks as the insert_line_break variable says
|
def _get_root(self):
_DEFAULT_USER_DETAILS = {"level": 20, "password": "", "sshkeys": []}
root = {}
root_table = junos_views.junos_root_table(self.device)
root_table.get()
root_items = root_table.items()
for user_entry in root_items:
username = "root"
user_details = _DEFAULT_USER_DETAILS.copy()
user_details.update({d[0]: d[1] for d in user_entry[1] if d[1]})
user_details = {
key: py23_compat.text_type(user_details[key])
for key in user_details.keys()
}
user_details["level"] = int(user_details["level"])
user_details["sshkeys"] = [
user_details.pop(key)
for key in ["ssh_rsa", "ssh_dsa", "ssh_ecdsa"]
if user_details.get(key, "")
]
root[username] = user_details
return root
|
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end integer pair string string_start string_content string_end string string_start string_end pair string string_start string_content string_end list expression_statement assignment identifier dictionary expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list dictionary_comprehension pair subscript identifier integer subscript identifier integer for_in_clause identifier subscript identifier integer if_clause subscript identifier integer expression_statement assignment identifier dictionary_comprehension pair identifier call attribute identifier identifier argument_list subscript identifier identifier for_in_clause identifier call attribute identifier identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list subscript identifier string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end if_clause call attribute identifier identifier argument_list identifier string string_start string_end expression_statement assignment subscript identifier identifier identifier return_statement identifier
|
get root user password.
|
def Godeps(self):
dict = []
for package in sorted(self._packages.keys()):
dict.append({
"ImportPath": str(package),
"Rev": str(self._packages[package])
})
return dict
|
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list 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 subscript attribute identifier identifier identifier return_statement identifier
|
Return the snapshot in Godeps.json form
|
def assets(self) -> List[Asset]:
return list(filter(is_element(Asset), self.content))
|
module function_definition identifier parameters identifier type generic_type identifier type_parameter type identifier block return_statement call identifier argument_list call identifier argument_list call identifier argument_list identifier attribute identifier identifier
|
Returns the assets in the transaction.
|
def _write(self, session, openFile, replaceParamFile):
openFile.write('GRIDSTREAMFILE\n')
openFile.write('STREAMCELLS %s\n' % self.streamCells)
for cell in self.gridStreamCells:
openFile.write('CELLIJ %s %s\n' % (cell.cellI, cell.cellJ))
openFile.write('NUMNODES %s\n' % cell.numNodes)
for node in cell.gridStreamNodes:
openFile.write('LINKNODE %s %s %.6f\n' % (
node.linkNumber,
node.nodeNumber,
node.nodePercentGrid))
|
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end attribute identifier identifier for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end tuple attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end attribute identifier identifier for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end tuple attribute identifier identifier attribute identifier identifier attribute identifier identifier
|
Grid Stream File Write to File Method
|
def com_google_fonts_check_family_panose_familytype(ttFonts):
failed = False
familytype = None
for ttfont in ttFonts:
if familytype is None:
familytype = ttfont['OS/2'].panose.bFamilyType
if familytype != ttfont['OS/2'].panose.bFamilyType:
failed = True
if failed:
yield FAIL, ("PANOSE family type is not"
" the same accross this family."
" In order to fix this,"
" please make sure that the panose.bFamilyType value"
" is the same in the OS/2 table of all of this family"
" font files.")
else:
yield PASS, "Fonts have consistent PANOSE family type."
|
module function_definition identifier parameters identifier block expression_statement assignment identifier false expression_statement assignment identifier none for_statement identifier identifier block if_statement comparison_operator identifier none block expression_statement assignment identifier attribute attribute subscript identifier string string_start string_content string_end identifier identifier if_statement comparison_operator identifier attribute attribute subscript identifier string string_start string_content string_end identifier identifier block expression_statement assignment identifier true if_statement identifier block expression_statement yield expression_list identifier parenthesized_expression concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end else_clause block expression_statement yield expression_list identifier string string_start string_content string_end
|
Fonts have consistent PANOSE family type?
|
def WriteProtoFile(self, printer):
self.Validate()
extended_descriptor.WriteMessagesFile(
self.__file_descriptor, self.__package, self.__client_info.version,
printer)
|
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier attribute attribute identifier identifier identifier identifier
|
Write the messages file to out as proto.
|
def flush(self):
if self.__buffer.tell() > 0:
self.__logger._log(level=self.__log_level, msg=self.__buffer.getvalue().strip(),
record_filter=StdErrWrapper.__filter_record)
self.__buffer.truncate(0)
self.__buffer.seek(0)
|
module function_definition identifier parameters identifier block if_statement comparison_operator call attribute attribute identifier identifier identifier argument_list integer block expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list keyword_argument identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list integer expression_statement call attribute attribute identifier identifier identifier argument_list integer
|
Flush the buffer, if applicable.
|
def fmt_duration(duration):
try:
return fmt.human_duration(float(duration), 0, 2, True)
except (ValueError, TypeError):
return "N/A".rjust(len(fmt.human_duration(0, 0, 2, True)))
|
module function_definition identifier parameters identifier block try_statement block return_statement call attribute identifier identifier argument_list call identifier argument_list identifier integer integer true except_clause tuple identifier identifier block return_statement call attribute string string_start string_content string_end identifier argument_list call identifier argument_list call attribute identifier identifier argument_list integer integer integer true
|
Format a duration value in seconds to a readable form.
|
def value(self, units=None):
if units is None:
return self._value
if not units.upper() in CustomPressure.legal_units:
raise UnitsError("unrecognized pressure unit: '" + units + "'")
units = units.upper()
if units == self._units:
return self._value
if self._units == "IN":
mb_value = self._value * 33.86398
elif self._units == "MM":
mb_value = self._value * 1.3332239
else:
mb_value = self._value
if units in ("MB", "HPA"):
return mb_value
if units == "IN":
return mb_value / 33.86398
if units == "MM":
return mb_value / 1.3332239
raise UnitsError("unrecognized pressure unit: '" + units + "'")
|
module function_definition identifier parameters identifier default_parameter identifier none block if_statement comparison_operator identifier none block return_statement attribute identifier identifier if_statement not_operator comparison_operator call attribute identifier identifier argument_list attribute identifier identifier block raise_statement call identifier argument_list binary_operator binary_operator string string_start string_content string_end identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier attribute identifier identifier block return_statement attribute identifier identifier if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier binary_operator attribute identifier identifier float elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier binary_operator attribute identifier identifier float else_clause block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier tuple string string_start string_content string_end string string_start string_content string_end block return_statement identifier if_statement comparison_operator identifier string string_start string_content string_end block return_statement binary_operator identifier float if_statement comparison_operator identifier string string_start string_content string_end block return_statement binary_operator identifier float raise_statement call identifier argument_list binary_operator binary_operator string string_start string_content string_end identifier string string_start string_content string_end
|
Return the pressure in the specified units.
|
def write_area_data(self, file):
file.write("%% area data" + "\n")
file.write("%\tno.\tprice_ref_bus" + "\n")
file.write("areas = [" + "\n")
file.write("\t1\t1;" + "\n")
file.write("];" + "\n")
|
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 string string_start string_content escape_sequence string_end expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content escape_sequence escape_sequence string_end string string_start string_content escape_sequence string_end expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end string string_start string_content escape_sequence string_end expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content escape_sequence escape_sequence string_end string string_start string_content escape_sequence string_end expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end string string_start string_content escape_sequence string_end
|
Writes area data to file.
|
def concatenate_attributes(attributes):
tpl = attributes[0]
attr = InstanceAttribute(tpl.name, tpl.shape,
tpl.dtype, tpl.dim, alias=None)
if all(a.size == 0 for a in attributes):
return attr
else:
attr.value = np.concatenate([a.value for a in attributes if a.size > 0], axis=0)
return attr
|
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier keyword_argument identifier none if_statement call identifier generator_expression comparison_operator attribute identifier identifier integer for_in_clause identifier identifier block return_statement identifier else_clause block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list list_comprehension attribute identifier identifier for_in_clause identifier identifier if_clause comparison_operator attribute identifier identifier integer keyword_argument identifier integer return_statement identifier
|
Concatenate InstanceAttribute to return a bigger one.
|
def shell_join(delim, it):
'Joins an iterable of ShellQuoted with a delimiter between each two'
return ShellQuoted(delim.join(raw_shell(s) for s in it))
|
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end return_statement call identifier argument_list call attribute identifier identifier generator_expression call identifier argument_list identifier for_in_clause identifier identifier
|
Joins an iterable of ShellQuoted with a delimiter between each two
|
def override(self, value):
if self._value is not value:
return _ScopedValueOverrideContext(self, value)
else:
return empty_context
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier identifier block return_statement call identifier argument_list identifier identifier else_clause block return_statement identifier
|
Temporarily overrides the old value with the new one.
|
def copy(self):
data = QMimeData()
text = '\n'.join([cursor.selectedText() \
for cursor in self.cursors()])
data.setText(text)
data.setData(self.MIME_TYPE, text.encode('utf8'))
QApplication.clipboard().setMimeData(data)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call attribute string string_start string_content escape_sequence string_end identifier argument_list list_comprehension call attribute identifier identifier argument_list line_continuation for_in_clause identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute call attribute identifier identifier argument_list identifier argument_list identifier
|
Copy to the clipboard
|
def encode(self):
return '{:.6f} {:.6f} {:.6f} {:.6f} {:.6f} {:.6f}'.format(
self.a, self.b, self.c, self.d, self.e, self.f
).encode()
|
module function_definition identifier parameters identifier block return_statement call attribute call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier identifier argument_list
|
Encode this matrix in binary suitable for including in a PDF
|
def _autobounds(self):
bounds = {}
def check(prop, compare, extreme, val):
opp = min if compare is max else max
bounds.setdefault(prop, val)
bounds[prop] = opp(compare(bounds[prop], val), extreme)
def bound_check(lat_lon):
lat, lon = lat_lon
check('max_lat', max, 90, lat)
check('min_lat', min, -90, lat)
check('max_lon', max, 180, lon)
check('min_lon', min, -180, lon)
lat_lons = [lat_lon for feature in self._features.values() for
lat_lon in feature.lat_lons]
if not lat_lons:
lat_lons.append(self._default_lat_lon)
for lat_lon in lat_lons:
bound_check(lat_lon)
return bounds
|
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier conditional_expression identifier comparison_operator identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement assignment subscript identifier identifier call identifier argument_list call identifier argument_list subscript identifier identifier identifier identifier function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier identifier expression_statement call identifier argument_list string string_start string_content string_end identifier integer identifier expression_statement call identifier argument_list string string_start string_content string_end identifier unary_operator integer identifier expression_statement call identifier argument_list string string_start string_content string_end identifier integer identifier expression_statement call identifier argument_list string string_start string_content string_end identifier unary_operator integer identifier expression_statement assignment identifier list_comprehension identifier for_in_clause identifier call attribute attribute identifier identifier identifier argument_list for_in_clause identifier attribute identifier identifier if_statement not_operator identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier for_statement identifier identifier block expression_statement call identifier argument_list identifier return_statement identifier
|
Simple calculation for bounds.
|
def nvrtcCreateProgram(self, src, name, headers, include_names):
res = c_void_p()
headers_array = (c_char_p * len(headers))()
headers_array[:] = encode_str_list(headers)
include_names_array = (c_char_p * len(include_names))()
include_names_array[:] = encode_str_list(include_names)
code = self._lib.nvrtcCreateProgram(byref(res),
c_char_p(encode_str(src)), c_char_p(encode_str(name)),
len(headers),
headers_array, include_names_array)
self._throw_on_error(code)
return res
|
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call parenthesized_expression binary_operator identifier call identifier argument_list identifier argument_list expression_statement assignment subscript identifier slice call identifier argument_list identifier expression_statement assignment identifier call parenthesized_expression binary_operator identifier call identifier argument_list identifier argument_list expression_statement assignment subscript identifier slice call identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier call identifier argument_list call identifier argument_list identifier call identifier argument_list call identifier argument_list identifier call identifier argument_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
|
Creates and returns a new NVRTC program object.
|
def _extract_file(zip_fp, info, path):
zip_fp.extract(info.filename, path=path)
out_path = os.path.join(path, info.filename)
perm = info.external_attr >> 16
perm |= stat.S_IREAD
os.chmod(out_path, perm)
|
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier attribute identifier identifier expression_statement assignment identifier binary_operator attribute identifier identifier integer expression_statement augmented_assignment identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier
|
Extract files while explicitly setting the proper permissions
|
def _generate_standard_transitions(cls):
allowed_transitions = cls.context.get_config('transitions', {})
for key, transitions in allowed_transitions.items():
key = cls.context.new_meta['translator'].translate(key)
new_transitions = set()
for trans in transitions:
if not isinstance(trans, Enum):
trans = cls.context.new_meta['translator'].translate(trans)
new_transitions.add(trans)
cls.context.new_transitions[key] = new_transitions
for state in cls.context.states_enum:
if state not in cls.context.new_transitions:
cls.context.new_transitions[state] = set()
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end dictionary for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute subscript attribute attribute identifier identifier identifier string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier call identifier argument_list for_statement identifier identifier block if_statement not_operator call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute subscript attribute attribute identifier identifier identifier string string_start string_content string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment subscript attribute attribute identifier identifier identifier identifier identifier for_statement identifier attribute attribute identifier identifier identifier block if_statement comparison_operator identifier attribute attribute identifier identifier identifier block expression_statement assignment subscript attribute attribute identifier identifier identifier identifier call identifier argument_list
|
Generate methods used for transitions.
|
def setOverlayDualAnalogTransform(self, ulOverlay, eWhich, fRadius):
fn = self.function_table.setOverlayDualAnalogTransform
pvCenter = HmdVector2_t()
result = fn(ulOverlay, eWhich, byref(pvCenter), fRadius)
return result, pvCenter
|
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call identifier argument_list identifier identifier call identifier argument_list identifier identifier return_statement expression_list identifier identifier
|
Sets the analog input to Dual Analog coordinate scale for the specified overlay.
|
def _job_statistics(self):
statistics = self._properties.get("statistics", {})
return statistics.get(self._JOB_TYPE, {})
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end dictionary return_statement call attribute identifier identifier argument_list attribute identifier identifier dictionary
|
Helper for job-type specific statistics-based properties.
|
def prune_missing(table):
try:
for item in table.select():
if not os.path.isfile(item.file_path):
logger.info("File disappeared: %s", item.file_path)
item.delete()
except:
logger.exception("Error pruning %s", table)
|
module function_definition identifier parameters identifier block try_statement block for_statement identifier call attribute identifier identifier argument_list block if_statement not_operator call attribute attribute identifier identifier identifier argument_list attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list except_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier
|
Prune any files which are missing from the specified table
|
def list_themes_user():
themes = [*os.scandir(os.path.join(CONF_DIR, "colorschemes/dark/")),
*os.scandir(os.path.join(CONF_DIR, "colorschemes/light/"))]
return [t for t in themes if os.path.isfile(t.path)]
|
module function_definition identifier parameters block expression_statement assignment identifier list list_splat call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end list_splat call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end return_statement list_comprehension identifier for_in_clause identifier identifier if_clause call attribute attribute identifier identifier identifier argument_list attribute identifier identifier
|
List user theme files.
|
def degrees_of_freedom(self):
if len(self._set_xdata)==0 or len(self._set_ydata)==0: return None
r = self.studentized_residuals()
if r == None: return
N = 0.0
for i in range(len(r)): N += len(r[i])
return N-len(self._pnames)
|
module function_definition identifier parameters identifier block if_statement boolean_operator comparison_operator call identifier argument_list attribute identifier identifier integer comparison_operator call identifier argument_list attribute identifier identifier integer block return_statement none expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier none block return_statement expression_statement assignment identifier float for_statement identifier call identifier argument_list call identifier argument_list identifier block expression_statement augmented_assignment identifier call identifier argument_list subscript identifier identifier return_statement binary_operator identifier call identifier argument_list attribute identifier identifier
|
Returns the number of degrees of freedom.
|
def description(self):
result = self.query.result()
return [field for field in result.schema]
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list return_statement list_comprehension identifier for_in_clause identifier attribute identifier identifier
|
Get the fields of the result set's schema.
|
def add_image_info_cb(self, gshell, channel, iminfo):
timestamp = iminfo.time_modified
if timestamp is None:
return
self.add_entry(channel.name, iminfo)
|
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier none block return_statement expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier
|
Add entries related to an added image.
|
def spell_check_no_pipeline(self, sources, options, personal_dict):
for source in sources:
if source._has_error():
yield Results([], source.context, source.category, source.error)
cmd = self.setup_command(source.encoding, options, personal_dict, source.context)
self.log('', 3)
self.log("Command: " + str(cmd), 4)
try:
wordlist = util.call_spellchecker(cmd, input_text=None, encoding=source.encoding)
yield Results(
[w for w in sorted(set(wordlist.replace('\r', '').split('\n'))) if w],
source.context,
source.category
)
except Exception as e:
err = self.get_error(e)
yield Results([], source.context, source.category, err)
|
module function_definition identifier parameters identifier identifier identifier identifier block for_statement identifier identifier block if_statement call attribute identifier identifier argument_list block expression_statement yield call identifier argument_list list attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_end integer expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier integer try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier none keyword_argument identifier attribute identifier identifier expression_statement yield call identifier argument_list list_comprehension identifier for_in_clause identifier call identifier argument_list call identifier argument_list call attribute call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end string string_start string_end identifier argument_list string string_start string_content escape_sequence string_end if_clause identifier attribute identifier identifier attribute identifier identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement yield call identifier argument_list list attribute identifier identifier attribute identifier identifier identifier
|
Spell check without the pipeline.
|
def add_method(obj, func, name=None):
if name is None:
name = func.__name__
if sys.version_info < (3,):
method = types.MethodType(func, obj, obj.__class__)
else:
method = types.MethodType(func, obj)
setattr(obj, name, method)
|
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 if_statement comparison_operator attribute identifier identifier tuple integer block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier attribute identifier identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement call identifier argument_list identifier identifier identifier
|
Adds an instance method to an object.
|
def people(self):
people_response = self.get_request('people/')
return [Person(self, pjson['user']) for pjson in people_response]
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement list_comprehension call identifier argument_list identifier subscript identifier string string_start string_content string_end for_in_clause identifier identifier
|
Generates a list of all People.
|
def enter_unlink_mode(self):
self.logger.info("enter_unlink_mode Group %s", self.group_id)
self.scene_command('0A')
status = self.hub.get_buffer_status()
return status
|
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list return_statement identifier
|
Enter unlinking mode for a group
|
def disable_radio_button(self):
checked = self.default_input_button_group.checkedButton()
if checked:
self.default_input_button_group.setExclusive(False)
checked.setChecked(False)
self.default_input_button_group.setExclusive(True)
for button in self.default_input_button_group.buttons():
button.setDisabled(True)
self.custom_value.setDisabled(True)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list if_statement identifier block expression_statement call attribute attribute identifier identifier identifier argument_list false expression_statement call attribute identifier identifier argument_list false expression_statement call attribute attribute identifier identifier identifier argument_list true for_statement identifier call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list true expression_statement call attribute attribute identifier identifier identifier argument_list true
|
Disable radio button group and custom value input area.
|
def trim(sequences, start, end):
logging.info("Trimming from %d to %d", start, end)
return (sequence[start:end] for sequence in sequences)
|
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier return_statement generator_expression subscript identifier slice identifier identifier for_in_clause identifier identifier
|
Slice the input sequences from start to end
|
def utc_book_close_time(self):
tz = pytz.timezone(self.timezone)
close_time = datetime.datetime.strptime(self.close_time, '%H:%M:%S').time()
close_time = tz.localize(datetime.datetime.combine(datetime.datetime.now(tz), close_time))
return close_time.astimezone(pytz.utc).time()
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list attribute identifier identifier string string_start string_content string_end identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier return_statement call attribute call attribute identifier identifier argument_list attribute identifier identifier identifier argument_list
|
The book close time in utc.
|
def _get_geocoding(self, key, location):
url = self._location_query_base % quote_plus(key)
if self.api_key:
url += "&key=%s" % self.api_key
data = self._read_from_url(url)
response = json.loads(data)
if response["status"] == "OK":
formatted_address = response["results"][0]["formatted_address"]
pos = formatted_address.find(",")
if pos == -1:
location.name = formatted_address
location.region = ""
else:
location.name = formatted_address[:pos].strip()
location.region = formatted_address[pos + 1 :].strip()
geo_location = response["results"][0]["geometry"]["location"]
location.latitude = float(geo_location["lat"])
location.longitude = float(geo_location["lng"])
else:
raise AstralError("GoogleGeocoder: Unable to locate %s. Server Response=%s" %
(key, response["status"]))
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier binary_operator attribute identifier identifier call identifier argument_list identifier if_statement attribute identifier identifier block expression_statement augmented_assignment identifier binary_operator string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier subscript subscript subscript identifier string string_start string_content string_end integer string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier unary_operator integer block expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier string string_start string_end else_clause block expression_statement assignment attribute identifier identifier call attribute subscript identifier slice identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute subscript identifier slice binary_operator identifier integer identifier argument_list expression_statement assignment identifier subscript subscript subscript subscript identifier string string_start string_content string_end integer string string_start string_content string_end string string_start string_content string_end expression_statement assignment attribute identifier identifier call identifier argument_list subscript identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier call identifier argument_list subscript identifier string string_start string_content string_end else_clause block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier subscript identifier string string_start string_content string_end
|
Lookup the Google geocoding API information for `key`
|
def all(self, query=None, **kwargs):
if query is None:
query = {}
normalize_select(query)
return super(AssetsProxy, self).all(query, **kwargs)
|
module function_definition identifier parameters identifier default_parameter identifier none dictionary_splat_pattern identifier block if_statement comparison_operator identifier none block expression_statement assignment identifier dictionary expression_statement call identifier argument_list identifier return_statement call attribute call identifier argument_list identifier identifier identifier argument_list identifier dictionary_splat identifier
|
Gets all assets of a space.
|
def make_gtp_instance(load_file, cgos_mode=False, kgs_mode=False,
minigui_mode=False):
n = DualNetwork(load_file)
if cgos_mode:
player = CGOSPlayer(network=n, seconds_per_move=5, timed_match=True,
two_player_mode=True)
else:
player = MCTSPlayer(network=n, two_player_mode=True)
name = "Minigo-" + os.path.basename(load_file)
version = "0.2"
engine = gtp_engine.Engine()
engine.add_cmd_handler(
gtp_engine.EngineCmdHandler(engine, name, version))
if kgs_mode:
engine.add_cmd_handler(KgsCmdHandler(player))
engine.add_cmd_handler(RegressionsCmdHandler(player))
engine.add_cmd_handler(GoGuiCmdHandler(player))
if minigui_mode:
engine.add_cmd_handler(MiniguiBasicCmdHandler(player, courtesy_pass=kgs_mode))
else:
engine.add_cmd_handler(BasicCmdHandler(player, courtesy_pass=kgs_mode))
return engine
|
module function_definition identifier parameters identifier default_parameter identifier false default_parameter identifier false default_parameter identifier false block expression_statement assignment identifier call identifier argument_list identifier if_statement identifier block expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier integer keyword_argument identifier true keyword_argument identifier true else_clause block expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier true expression_statement assignment identifier binary_operator string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier keyword_argument identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier keyword_argument identifier identifier return_statement identifier
|
Takes a path to model files and set up a GTP engine instance.
|
def install(path, remove=False, prefix=sys.prefix, recursing=False):
if sys.platform == 'win32' and not exists(join(sys.prefix, '.nonadmin')):
if isUserAdmin():
_install(path, remove, prefix, mode='system')
else:
from pywintypes import error
try:
if not recursing:
retcode = runAsAdmin([join(sys.prefix, 'python'), '-c',
"import menuinst; menuinst.install(%r, %r, %r, %r)" % (
path, bool(remove), prefix, True)])
else:
retcode = 1
except error:
retcode = 1
if retcode != 0:
logging.warn("Insufficient permissions to write menu folder. "
"Falling back to user location")
_install(path, remove, prefix, mode='user')
else:
_install(path, remove, prefix, mode='user')
|
module function_definition identifier parameters identifier default_parameter identifier false default_parameter identifier attribute identifier identifier default_parameter identifier false block if_statement boolean_operator comparison_operator attribute identifier identifier string string_start string_content string_end not_operator call identifier argument_list call identifier argument_list attribute identifier identifier string string_start string_content string_end block if_statement call identifier argument_list block expression_statement call identifier argument_list identifier identifier identifier keyword_argument identifier string string_start string_content string_end else_clause block import_from_statement dotted_name identifier dotted_name identifier try_statement block if_statement not_operator identifier block expression_statement assignment identifier call identifier argument_list list call identifier argument_list attribute identifier identifier string string_start string_content string_end string string_start string_content string_end binary_operator string string_start string_content string_end tuple identifier call identifier argument_list identifier identifier true else_clause block expression_statement assignment identifier integer except_clause identifier block expression_statement assignment identifier integer if_statement comparison_operator identifier integer 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 expression_statement call identifier argument_list identifier identifier identifier keyword_argument identifier string string_start string_content string_end else_clause block expression_statement call identifier argument_list identifier identifier identifier keyword_argument identifier string string_start string_content string_end
|
install Menu and shortcuts
|
def _parse_comma_list(self):
if self._cur_token['type'] not in self._literals:
raise Exception(
"Parser failed, _parse_comma_list was called on non-literal"
" {} on line {}.".format(
repr(self._cur_token['value']), self._cur_token['line']
)
)
array = []
while self._cur_token['type'] in self._literals and not self._finished:
array.append(self._cur_token['value'])
self._increment()
self._skip_whitespace()
if self._cur_token['type'] is TT.comma:
self._increment()
self._skip_whitespace()
elif (
not self._finished and
self._cur_token['type'] not in (TT.ws, TT.lbreak)
):
raise ParseError('comma or newline', self._cur_token)
return array
|
module function_definition identifier parameters identifier block if_statement comparison_operator subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier block raise_statement call identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier list while_statement boolean_operator comparison_operator subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier not_operator attribute identifier identifier block expression_statement call attribute identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list if_statement comparison_operator subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list elif_clause parenthesized_expression boolean_operator not_operator attribute identifier identifier comparison_operator subscript attribute identifier identifier string string_start string_content string_end tuple attribute identifier identifier attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end attribute identifier identifier return_statement identifier
|
Parse a comma seperated list.
|
def add_class2fields(self, html_class, fields=[], exclude=[], include_all_if_empty=True):
self.add_attr2fields('class', html_class, fields, exclude)
|
module function_definition identifier parameters identifier identifier default_parameter identifier list default_parameter identifier list default_parameter identifier true block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier identifier
|
add class to html widgets.
|
def show_filetypes(extensions):
for item in extensions.items():
val = item[1]
if type(item[1]) == list:
val = ", ".join(str(x) for x in item[1])
print("{0:4}: {1}".format(val, item[0]))
|
module function_definition identifier parameters identifier block for_statement identifier call attribute identifier identifier argument_list block expression_statement assignment identifier subscript identifier integer if_statement comparison_operator call identifier argument_list subscript identifier integer identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier generator_expression call identifier argument_list identifier for_in_clause identifier subscript identifier integer expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier subscript identifier integer
|
function to show valid file extensions
|
def in_cmd(argv):
if len(argv) == 1:
return workon_cmd(argv)
parse_envname(argv, lambda : sys.exit('You must provide a valid virtualenv to target'))
return inve(*argv)
|
module function_definition identifier parameters identifier block if_statement comparison_operator call identifier argument_list identifier integer block return_statement call identifier argument_list identifier expression_statement call identifier argument_list identifier lambda call attribute identifier identifier argument_list string string_start string_content string_end return_statement call identifier argument_list list_splat identifier
|
Run a command in the given virtualenv.
|
def getOntology(self, id_):
if id_ not in self._ontologyIdMap:
raise exceptions.OntologyNotFoundException(id_)
return self._ontologyIdMap[id_]
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block raise_statement call attribute identifier identifier argument_list identifier return_statement subscript attribute identifier identifier identifier
|
Returns the ontology with the specified ID.
|
def _make_matchers(self, crontab):
crontab = _aliases.get(crontab, crontab)
ct = crontab.split()
if len(ct) == 5:
ct.insert(0, '0')
ct.append('*')
elif len(ct) == 6:
ct.insert(0, '0')
_assert(len(ct) == 7,
"improper number of cron entries specified; got %i need 5 to 7"%(len(ct,)))
matchers = [_Matcher(which, entry) for which, entry in enumerate(ct)]
return Matcher(*matchers)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator call identifier argument_list identifier integer block expression_statement call attribute identifier identifier argument_list integer string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end elif_clause comparison_operator call identifier argument_list identifier integer block expression_statement call attribute identifier identifier argument_list integer string string_start string_content string_end expression_statement call identifier argument_list comparison_operator call identifier argument_list identifier integer binary_operator string string_start string_content string_end parenthesized_expression call identifier argument_list identifier expression_statement assignment identifier list_comprehension call identifier argument_list identifier identifier for_in_clause pattern_list identifier identifier call identifier argument_list identifier return_statement call identifier argument_list list_splat identifier
|
This constructs the full matcher struct.
|
def _clean_kwargs(keep_name=False, **kwargs):
if 'name' in kwargs and not keep_name:
kwargs['name_or_id'] = kwargs.pop('name')
return __utils__['args.clean_kwargs'](**kwargs)
|
module function_definition identifier parameters default_parameter identifier false dictionary_splat_pattern identifier block if_statement boolean_operator comparison_operator string string_start string_content string_end identifier not_operator identifier block expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end return_statement call subscript identifier string string_start string_content string_end argument_list dictionary_splat identifier
|
Sanatize the the arguments for use with shade
|
async def model_uuids(self):
controller_facade = client.ControllerFacade.from_connection(
self.connection())
for attempt in (1, 2, 3):
try:
response = await controller_facade.AllModels()
return {um.model.name: um.model.uuid
for um in response.user_models}
except errors.JujuAPIError as e:
if 'has been removed' not in e.message or attempt == 3:
raise
await asyncio.sleep(attempt, loop=self._connector.loop)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list for_statement identifier tuple integer integer integer block try_statement block expression_statement assignment identifier await call attribute identifier identifier argument_list return_statement dictionary_comprehension pair attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier for_in_clause identifier attribute identifier identifier except_clause as_pattern attribute identifier identifier as_pattern_target identifier block if_statement boolean_operator comparison_operator string string_start string_content string_end attribute identifier identifier comparison_operator identifier integer block raise_statement expression_statement await call attribute identifier identifier argument_list identifier keyword_argument identifier attribute attribute identifier identifier identifier
|
Return a mapping of model names to UUIDs.
|
def runs_to_xml(self, runSet, runs, blockname=None):
runsElem = util.copy_of_xml_element(self.xml_header)
runsElem.set("options", " ".join(runSet.options))
if blockname is not None:
runsElem.set("block", blockname)
runsElem.set("name", ((runSet.real_name + ".") if runSet.real_name else "") + blockname)
elif runSet.real_name:
runsElem.set("name", runSet.real_name)
for run in runs:
runsElem.append(run.xml)
return runsElem
|
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end binary_operator parenthesized_expression conditional_expression parenthesized_expression binary_operator attribute identifier identifier string string_start string_content string_end attribute identifier identifier string string_start string_end identifier elif_clause attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier return_statement identifier
|
This function creates the XML structure for a list of runs
|
def soap_attribute(self, name, value):
setattr(self, name, value)
self._attributes.add(name)
|
module function_definition identifier parameters identifier identifier identifier block expression_statement call identifier argument_list identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
|
Marks an attribute as being a part of the data defined by the soap datatype
|
def _validate_changeset(self, changeset_id: uuid.UUID) -> None:
if not self.journal.has_changeset(changeset_id):
raise ValidationError("Changeset not found in journal: {0}".format(
str(changeset_id)
))
|
module function_definition identifier parameters identifier typed_parameter identifier type attribute identifier identifier type none block if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier
|
Checks to be sure the changeset is known by the journal
|
def process_request_thread(self, mainthread):
life_time = time.time()
nb_requests = 0
while not mainthread.killed():
if self.max_life_time > 0:
if (time.time() - life_time) >= self.max_life_time:
mainthread.add_worker(1)
return
try:
SocketServer.ThreadingTCPServer.process_request_thread(self, *self.requests.get(True, 0.5))
except Queue.Empty:
continue
else:
SocketServer.ThreadingTCPServer.process_request_thread(self, *self.requests.get())
LOG.debug("nb_requests: %d, max_requests: %d", nb_requests, self.max_requests)
nb_requests += 1
if self.max_requests > 0 and nb_requests >= self.max_requests:
mainthread.add_worker(1)
return
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier integer while_statement not_operator call attribute identifier identifier argument_list block if_statement comparison_operator attribute identifier identifier integer block if_statement comparison_operator parenthesized_expression binary_operator call attribute identifier identifier argument_list identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list integer return_statement try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list identifier list_splat call attribute attribute identifier identifier identifier argument_list true float except_clause attribute identifier identifier block continue_statement else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list identifier list_splat call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier attribute identifier identifier expression_statement augmented_assignment identifier integer if_statement boolean_operator comparison_operator attribute identifier identifier integer comparison_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list integer return_statement
|
obtain request from queue instead of directly from server socket
|
def _make_sections(self, **section_hdr_params):
sect_story = []
if not self.section_headings and len(self.sections):
self.section_headings = self.sections.keys()
for section_name in self.section_headings:
section_story = self.sections[section_name]
line = '-'*20
section_head_text = '%s %s %s' % (line, section_name, line)
title, title_sp = self._preformat_text(section_head_text,
**section_hdr_params)
sect_story += [title, title_sp] + section_story
return sect_story
|
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier list if_statement boolean_operator not_operator attribute identifier identifier call identifier argument_list attribute identifier identifier block expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list for_statement identifier attribute identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier identifier expression_statement assignment identifier binary_operator string string_start string_content string_end integer expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier identifier identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier dictionary_splat identifier expression_statement augmented_assignment identifier binary_operator list identifier identifier identifier return_statement identifier
|
Flatten the sections into a single story list.
|
def getDict(self):
badList = self.checkSetSaveEntries(doSave=False)
if badList:
self.processBadEntries(badList, self.taskName, canCancel=False)
return self._taskParsObj.dict()
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier false if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier keyword_argument identifier false return_statement call attribute attribute identifier identifier identifier argument_list
|
Retrieve the current parameter settings from the GUI.
|
def _get_events(self, result):
events = []
for event_data in result:
event = Event.factory(event_data)
if event is not None:
events.append(event)
if isinstance(event, DeviceStateChangedEvent):
if self.__devices[event.device_url] is None:
raise Exception(
"Received device change " +
"state for unknown device '" +
event.device_url + "'")
self.__devices[event.device_url].set_active_states(
event.states)
return events
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list identifier if_statement call identifier argument_list identifier identifier block if_statement comparison_operator subscript attribute identifier identifier attribute identifier identifier none block raise_statement call identifier argument_list binary_operator binary_operator binary_operator string string_start string_content string_end string string_start string_content string_end attribute identifier identifier string string_start string_content string_end expression_statement call attribute subscript attribute identifier identifier attribute identifier identifier identifier argument_list attribute identifier identifier return_statement identifier
|
Internal method for being able to run unit tests.
|
def login():
if request.method == "POST":
username = request.form["username"]
password = request.form["password"]
error = None
user = User.query.filter_by(username=username).first()
if user is None:
error = "Incorrect username."
elif not user.check_password(password):
error = "Incorrect password."
if error is None:
session.clear()
session["user_id"] = user.id
return redirect(url_for("index"))
flash(error)
return render_template("auth/login.html")
|
module function_definition identifier parameters block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier none expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier identifier argument_list if_statement comparison_operator identifier none block expression_statement assignment identifier string string_start string_content string_end elif_clause not_operator call attribute identifier identifier argument_list identifier block expression_statement assignment identifier string string_start string_content string_end if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier return_statement call identifier argument_list call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list identifier return_statement call identifier argument_list string string_start string_content string_end
|
Log in a registered user by adding the user id to the session.
|
def _number_type_helper(national_number, metadata):
if not _is_number_matching_desc(national_number, metadata.general_desc):
return PhoneNumberType.UNKNOWN
if _is_number_matching_desc(national_number, metadata.premium_rate):
return PhoneNumberType.PREMIUM_RATE
if _is_number_matching_desc(national_number, metadata.toll_free):
return PhoneNumberType.TOLL_FREE
if _is_number_matching_desc(national_number, metadata.shared_cost):
return PhoneNumberType.SHARED_COST
if _is_number_matching_desc(national_number, metadata.voip):
return PhoneNumberType.VOIP
if _is_number_matching_desc(national_number, metadata.personal_number):
return PhoneNumberType.PERSONAL_NUMBER
if _is_number_matching_desc(national_number, metadata.pager):
return PhoneNumberType.PAGER
if _is_number_matching_desc(national_number, metadata.uan):
return PhoneNumberType.UAN
if _is_number_matching_desc(national_number, metadata.voicemail):
return PhoneNumberType.VOICEMAIL
if _is_number_matching_desc(national_number, metadata.fixed_line):
if metadata.same_mobile_and_fixed_line_pattern:
return PhoneNumberType.FIXED_LINE_OR_MOBILE
elif _is_number_matching_desc(national_number, metadata.mobile):
return PhoneNumberType.FIXED_LINE_OR_MOBILE
return PhoneNumberType.FIXED_LINE
if (not metadata.same_mobile_and_fixed_line_pattern and
_is_number_matching_desc(national_number, metadata.mobile)):
return PhoneNumberType.MOBILE
return PhoneNumberType.UNKNOWN
|
module function_definition identifier parameters identifier identifier block if_statement not_operator call identifier argument_list identifier attribute identifier identifier block return_statement attribute identifier identifier if_statement call identifier argument_list identifier attribute identifier identifier block return_statement attribute identifier identifier if_statement call identifier argument_list identifier attribute identifier identifier block return_statement attribute identifier identifier if_statement call identifier argument_list identifier attribute identifier identifier block return_statement attribute identifier identifier if_statement call identifier argument_list identifier attribute identifier identifier block return_statement attribute identifier identifier if_statement call identifier argument_list identifier attribute identifier identifier block return_statement attribute identifier identifier if_statement call identifier argument_list identifier attribute identifier identifier block return_statement attribute identifier identifier if_statement call identifier argument_list identifier attribute identifier identifier block return_statement attribute identifier identifier if_statement call identifier argument_list identifier attribute identifier identifier block return_statement attribute identifier identifier if_statement call identifier argument_list identifier attribute identifier identifier block if_statement attribute identifier identifier block return_statement attribute identifier identifier elif_clause call identifier argument_list identifier attribute identifier identifier block return_statement attribute identifier identifier return_statement attribute identifier identifier if_statement parenthesized_expression boolean_operator not_operator attribute identifier identifier call identifier argument_list identifier attribute identifier identifier block return_statement attribute identifier identifier return_statement attribute identifier identifier
|
Return the type of the given number against the metadata
|
def _after_request(self, response):
if not getattr(g, '_has_exception', False):
extra = self.summary_extra()
self.summary_logger.info('', extra=extra)
return response
|
module function_definition identifier parameters identifier identifier block if_statement not_operator call identifier argument_list identifier string string_start string_content string_end false block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_end keyword_argument identifier identifier return_statement identifier
|
The signal handler for the request_finished signal.
|
def _write_recordio(f, data):
length = len(data)
f.write(struct.pack('I', _kmagic))
f.write(struct.pack('I', length))
pad = (((length + 3) >> 2) << 2) - length
f.write(data)
f.write(padding[pad])
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier binary_operator parenthesized_expression binary_operator parenthesized_expression binary_operator parenthesized_expression binary_operator identifier integer integer integer identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list subscript identifier identifier
|
Writes a single data point as a RecordIO record to the given file.
|
def formatSubclassOf(fmt, cls, ontology, visited):
if URIRef(fmt) == URIRef(cls):
return True
if ontology is None:
return False
if fmt in visited:
return False
visited.add(fmt)
uriRefFmt = URIRef(fmt)
for s, p, o in ontology.triples((uriRefFmt, RDFS.subClassOf, None)):
if formatSubclassOf(o, cls, ontology, visited):
return True
for s, p, o in ontology.triples((uriRefFmt, OWL.equivalentClass, None)):
if formatSubclassOf(o, cls, ontology, visited):
return True
for s, p, o in ontology.triples((None, OWL.equivalentClass, uriRefFmt)):
if formatSubclassOf(s, cls, ontology, visited):
return True
return False
|
module function_definition identifier parameters identifier identifier identifier identifier block if_statement comparison_operator call identifier argument_list identifier call identifier argument_list identifier block return_statement true if_statement comparison_operator identifier none block return_statement false if_statement comparison_operator identifier identifier block return_statement false expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier for_statement pattern_list identifier identifier identifier call attribute identifier identifier argument_list tuple identifier attribute identifier identifier none block if_statement call identifier argument_list identifier identifier identifier identifier block return_statement true for_statement pattern_list identifier identifier identifier call attribute identifier identifier argument_list tuple identifier attribute identifier identifier none block if_statement call identifier argument_list identifier identifier identifier identifier block return_statement true for_statement pattern_list identifier identifier identifier call attribute identifier identifier argument_list tuple none attribute identifier identifier identifier block if_statement call identifier argument_list identifier identifier identifier identifier block return_statement true return_statement false
|
Determine if `fmt` is a subclass of `cls`.
|
def paragraph(self, content):
if not self._out.description:
self._out.description = content
return ' '
|
module function_definition identifier parameters identifier identifier block if_statement not_operator attribute attribute identifier identifier identifier block expression_statement assignment attribute attribute identifier identifier identifier identifier return_statement string string_start string_content string_end
|
Turn the first paragraph of text into the summary text
|
def version(self):
response = self.get(version="", base="/version")
response.raise_for_status()
data = response.json()
return (data["major"], data["minor"])
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier string string_start string_end keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list return_statement tuple subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end
|
Get Kubernetes API version
|
def _move_here(self):
cu = self.scraper.current_item
if self is cu:
return
if cu.items and self in cu.items:
self.scraper.move_to(self)
return
if self is cu.parent:
self.scraper.move_up()
if self.parent and self in self.parent.items:
self.scraper.move_up()
self.scraper.move_to(self)
return
self.scraper.move_to_top()
for step in self.path:
self.scraper.move_to(step)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier if_statement comparison_operator identifier identifier block return_statement if_statement boolean_operator attribute identifier identifier comparison_operator identifier attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list if_statement boolean_operator attribute identifier identifier comparison_operator identifier attribute attribute identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement expression_statement call attribute attribute identifier identifier identifier argument_list for_statement identifier attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier
|
Move the cursor to this item.
|
def clear( self ):
item = self.uiActionTREE.currentItem()
if ( not item ):
return
self.uiShortcutTXT.setText('')
item.setText(1, '')
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list if_statement parenthesized_expression not_operator identifier block return_statement expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_end expression_statement call attribute identifier identifier argument_list integer string string_start string_end
|
Clears the current settings for the current action.
|
def OnContentChanged(self, event):
self.main_window.grid.update_attribute_toolbar()
title = self.main_window.GetTitle()
if undo.stack().haschanged():
if title[:2] != "* ":
new_title = "* " + title
post_command_event(self.main_window, self.main_window.TitleMsg,
text=new_title)
elif title[:2] == "* ":
new_title = title[2:]
post_command_event(self.main_window, self.main_window.TitleMsg,
text=new_title)
|
module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list if_statement call attribute call attribute identifier identifier argument_list identifier argument_list block if_statement comparison_operator subscript identifier slice integer string string_start string_content string_end block expression_statement assignment identifier binary_operator string string_start string_content string_end identifier expression_statement call identifier argument_list attribute identifier identifier attribute attribute identifier identifier identifier keyword_argument identifier identifier elif_clause comparison_operator subscript identifier slice integer string string_start string_content string_end block expression_statement assignment identifier subscript identifier slice integer expression_statement call identifier argument_list attribute identifier identifier attribute attribute identifier identifier identifier keyword_argument identifier identifier
|
Titlebar star adjustment event handler
|
def _equivalent_node_iterator_helper(self, node: BaseEntity, visited: Set[BaseEntity]) -> BaseEntity:
for v in self[node]:
if v in visited:
continue
if self._has_no_equivalent_edge(node, v):
continue
visited.add(v)
yield v
yield from self._equivalent_node_iterator_helper(v, visited)
|
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type generic_type identifier type_parameter type identifier type identifier block for_statement identifier subscript identifier identifier block if_statement comparison_operator identifier identifier block continue_statement if_statement call attribute identifier identifier argument_list identifier identifier block continue_statement expression_statement call attribute identifier identifier argument_list identifier expression_statement yield identifier expression_statement yield call attribute identifier identifier argument_list identifier identifier
|
Iterate over nodes and their data that are equal to the given node, starting with the original.
|
async def on_isupport_maxlist(self, value):
self._list_limits = {}
for entry in value.split(','):
modes, limit = entry.split(':')
self._list_limits[frozenset(modes)] = int(limit)
for mode in modes:
self._list_limit_groups[mode] = frozenset(modes)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier dictionary for_statement identifier call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment subscript attribute identifier identifier call identifier argument_list identifier call identifier argument_list identifier for_statement identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier call identifier argument_list identifier
|
Limits on channel modes involving lists.
|
def _update_simulation_start_cards(self):
if self.simulation_start is not None:
self._update_card("START_DATE", self.simulation_start.strftime("%Y %m %d"))
self._update_card("START_TIME", self.simulation_start.strftime("%H %M"))
|
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call attribute attribute identifier 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 call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end
|
Update GSSHA cards for simulation start
|
def reset_state(self):
super(AugmentorList, self).reset_state()
for a in self.augmentors:
a.reset_state()
|
module function_definition identifier parameters identifier block expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list
|
Will reset state of each augmentor
|
def gen_nop():
empty_reg = ReilEmptyOperand()
return ReilBuilder.build(ReilMnemonic.NOP, empty_reg, empty_reg, empty_reg)
|
module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list return_statement call attribute identifier identifier argument_list attribute identifier identifier identifier identifier identifier
|
Return a NOP instruction.
|
def revert(self, strip=0, root=None):
reverted = copy.deepcopy(self)
reverted._reverse()
return reverted.apply(strip, root)
|
module function_definition identifier parameters identifier default_parameter identifier integer default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list return_statement call attribute identifier identifier argument_list identifier identifier
|
apply patch in reverse order
|
def _urls_for_js(urls=None):
if urls is None:
from .urls import urlpatterns
urls = [url.name for url in urlpatterns if getattr(url, 'name', None)]
urls = dict(zip(urls, [get_uri_template(url) for url in urls]))
urls.update(getattr(settings, 'LEAFLET_STORAGE_EXTRA_URLS', {}))
return urls
|
module function_definition identifier parameters default_parameter identifier none block if_statement comparison_operator identifier none block import_from_statement relative_import import_prefix dotted_name identifier dotted_name identifier expression_statement assignment identifier list_comprehension attribute identifier identifier for_in_clause identifier identifier if_clause call identifier argument_list identifier string string_start string_content string_end none expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier list_comprehension call identifier argument_list identifier for_in_clause identifier identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier string string_start string_content string_end dictionary return_statement identifier
|
Return templated URLs prepared for javascript.
|
async def get_json(self, url, timeout=30, astext=False, exceptions=False):
try:
with async_timeout.timeout(timeout):
res = await self._aio_session.get(url)
if res.status != 200:
_LOGGER.error("QSUSB returned %s [%s]", res.status, url)
return None
res_text = await res.text()
except (aiohttp.client_exceptions.ClientError,
asyncio.TimeoutError) as exc:
if exceptions:
raise exc
return None
if astext:
return res_text
try:
return json.loads(res_text)
except json.decoder.JSONDecodeError:
if res_text.strip(" ") == "":
return None
_LOGGER.error("Could not decode %s [%s]", res_text, url)
|
module function_definition identifier parameters identifier identifier default_parameter identifier integer default_parameter identifier false default_parameter identifier false block try_statement block with_statement with_clause with_item call attribute identifier identifier argument_list identifier block expression_statement assignment identifier await call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator attribute identifier identifier integer block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier identifier return_statement none expression_statement assignment identifier await call attribute identifier identifier argument_list except_clause as_pattern tuple attribute attribute identifier identifier identifier attribute identifier identifier as_pattern_target identifier block if_statement identifier block raise_statement identifier return_statement none if_statement identifier block return_statement identifier try_statement block return_statement call attribute identifier identifier argument_list identifier except_clause attribute attribute identifier identifier identifier block if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end block return_statement none expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier
|
Get URL and parse JSON from text.
|
def _get_erred_shared_settings_module(self):
result_module = modules.LinkList(title=_('Shared provider settings in erred state'))
result_module.template = 'admin/dashboard/erred_link_list.html'
erred_state = structure_models.SharedServiceSettings.States.ERRED
queryset = structure_models.SharedServiceSettings.objects
settings_in_erred_state = queryset.filter(state=erred_state).count()
if settings_in_erred_state:
result_module.title = '%s (%s)' % (result_module.title, settings_in_erred_state)
for service_settings in queryset.filter(state=erred_state).iterator():
module_child = self._get_link_to_instance(service_settings)
module_child['error'] = service_settings.error_message
result_module.children.append(module_child)
else:
result_module.pre_content = _('Nothing found.')
return result_module
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier call identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier attribute attribute attribute identifier identifier identifier identifier expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list keyword_argument identifier identifier identifier argument_list if_statement identifier block expression_statement assignment attribute identifier identifier binary_operator string string_start string_content string_end tuple attribute identifier identifier identifier for_statement identifier call attribute call attribute identifier identifier argument_list keyword_argument identifier identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier else_clause block expression_statement assignment attribute identifier identifier call identifier argument_list string string_start string_content string_end return_statement identifier
|
Returns a LinkList based module which contains link to shared service setting instances in ERRED state.
|
def __create_profile_from_identities(self, identities, uuid, verbose):
import re
EMAIL_ADDRESS_REGEX = r"^(?P<email>[^\s@]+@[^\s@.]+\.[^\s@]+)$"
NAME_REGEX = r"^\w+\s\w+"
name = None
email = None
username = None
for identity in identities:
if not name and identity.name:
m = re.match(NAME_REGEX, identity.name)
if m:
name = identity.name
if not email and identity.email:
m = re.match(EMAIL_ADDRESS_REGEX, identity.email)
if m:
email = identity.email
if not username:
if identity.username and identity.username != 'None':
username = identity.username
if not name:
if email:
name = email.split('@')[0]
elif username:
name = username.split('@')[0]
else:
name = None
kw = {'name': name,
'email': email}
api.edit_profile(self.db, uuid, **kw)
self.log("-- profile %s updated" % uuid, verbose)
|
module function_definition identifier parameters identifier identifier identifier identifier block import_statement dotted_name identifier expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier none expression_statement assignment identifier none expression_statement assignment identifier none for_statement identifier identifier block if_statement boolean_operator not_operator identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier if_statement identifier block expression_statement assignment identifier attribute identifier identifier if_statement boolean_operator not_operator identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier if_statement identifier block expression_statement assignment identifier attribute identifier identifier if_statement not_operator identifier block if_statement boolean_operator attribute identifier identifier comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier attribute identifier identifier if_statement not_operator identifier block if_statement identifier block expression_statement assignment identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end integer elif_clause identifier block expression_statement assignment identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end integer else_clause block expression_statement assignment identifier none expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier dictionary_splat identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier identifier
|
Create a profile using the data from the identities
|
def simple_prot(x, start):
for i in range(start,len(x)-1):
a,b,c = x[i-1], x[i], x[i+1]
if b - a > 0 and b -c >= 0:
return i
else:
return None
|
module function_definition identifier parameters identifier identifier block for_statement identifier call identifier argument_list identifier binary_operator call identifier argument_list identifier integer block expression_statement assignment pattern_list identifier identifier identifier expression_list subscript identifier binary_operator identifier integer subscript identifier identifier subscript identifier binary_operator identifier integer if_statement boolean_operator comparison_operator binary_operator identifier identifier integer comparison_operator binary_operator identifier identifier integer block return_statement identifier else_clause block return_statement none
|
Find the first peak to the right of start
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.