code
stringlengths 51
2.34k
| sequence
stringlengths 186
3.94k
| docstring
stringlengths 11
171
|
|---|---|---|
def change_username_view(self):
form = self.ChangeUsernameFormClass(request.form)
if request.method == 'POST' and form.validate():
new_username = form.new_username.data
current_user.username=new_username
self.db_manager.save_object(current_user)
self.db_manager.commit()
self.email_manager.send_username_changed_email(current_user)
signals.user_changed_username.send(current_app._get_current_object(), user=current_user)
flash(_("Your username has been changed to '%(username)s'.", username=new_username), 'success')
safe_next_url = self._get_safe_next_url('next', self.USER_AFTER_CHANGE_USERNAME_ENDPOINT)
return redirect(safe_next_url)
self.prepare_domain_translations()
return render_template(self.USER_CHANGE_USERNAME_TEMPLATE, form=form)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier if_statement boolean_operator comparison_operator attribute identifier identifier string string_start string_content string_end call attribute identifier identifier argument_list block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier identifier expression_statement call identifier argument_list call identifier argument_list string string_start string_content string_end keyword_argument identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier return_statement call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list return_statement call identifier argument_list attribute identifier identifier keyword_argument identifier identifier
|
Prompt for new username and old password and change the user's username.
|
def transformer_wikitext103_l4k_memory_v0():
hparams = transformer_wikitext103_l4k_v0()
hparams.split_targets_chunk_length = 64
hparams.split_targets_max_chunks = 64
hparams.split_targets_strided_training = True
hparams.add_hparam("memory_type", "transformer_xl")
target_tokens_per_batch = 4096
hparams.batch_size = int(target_tokens_per_batch * (
hparams.max_length / hparams.split_targets_chunk_length))
hparams.pos = None
hparams.self_attention_type = "dot_product_relative"
hparams.max_relative_position = 2 * hparams.split_targets_chunk_length
hparams.add_hparam("unconditional", True)
hparams.add_hparam("recurrent_memory_batch_size", 0)
hparams.add_hparam("num_memory_items", hparams.split_targets_chunk_length)
return hparams
|
module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier true expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier integer expression_statement assignment attribute identifier identifier call identifier argument_list binary_operator identifier parenthesized_expression binary_operator attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier binary_operator integer attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end true expression_statement call attribute identifier identifier argument_list string string_start string_content string_end integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier return_statement identifier
|
HParams for training languagemodel_wikitext103_l4k with memory.
|
def show(title, lst, full=-1):
txt = title + ' (' + str(len(lst)) + ') items :\n '
num = 0
for i in lst:
if full == -1 or num < full:
if type(i) is str:
txt = txt + i + ',\n '
else:
txt = txt + i + ', ['
for j in i:
txt = txt + j + ', '
txt = txt + ']\n'
num = num + 1
try:
print(txt)
except Exception as ex:
print('index.show() - cant print line, error ' + str(ex))
|
module function_definition identifier parameters identifier identifier default_parameter identifier unary_operator integer block expression_statement assignment identifier binary_operator binary_operator binary_operator identifier string string_start string_content string_end call identifier argument_list call identifier argument_list identifier string string_start string_content escape_sequence string_end expression_statement assignment identifier integer for_statement identifier identifier block if_statement boolean_operator comparison_operator identifier unary_operator integer comparison_operator identifier identifier block if_statement comparison_operator call identifier argument_list identifier identifier block expression_statement assignment identifier binary_operator binary_operator identifier identifier string string_start string_content escape_sequence string_end else_clause block expression_statement assignment identifier binary_operator binary_operator identifier identifier string string_start string_content string_end for_statement identifier identifier block expression_statement assignment identifier binary_operator binary_operator identifier identifier string string_start string_content string_end expression_statement assignment identifier binary_operator identifier string string_start string_content escape_sequence string_end expression_statement assignment identifier binary_operator identifier integer try_statement block expression_statement call identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier
|
for testing, simply shows a list details
|
def _login(self, user, provider=None, remember=False, force=False, **attrs):
user.last_login_at = datetime.datetime.now()
user.last_login_provider = provider or self.options["default_auth_provider_name"]
user.last_login_from = request.remote_addr
populate_obj(user, attrs)
save_model(user)
flask_login.login_user(user, remember=remember, force=force)
|
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier false default_parameter identifier false dictionary_splat_pattern identifier block expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier boolean_operator identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement call identifier argument_list identifier identifier expression_statement call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier
|
Updates user attributes and login the user in flask-login
|
def getLibraryFiles(self, engineRoot, delimiter=' '):
return delimiter.join(self.resolveRoot(self.libs, engineRoot))
|
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end block return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier identifier
|
Returns the list of library files for this library, joined using the specified delimiter
|
def fib(n):
v = n.value
return v if v < 2 else fib2(PythonInt(v-1)) + fib(PythonInt(v-2))
|
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier return_statement conditional_expression identifier comparison_operator identifier integer binary_operator call identifier argument_list call identifier argument_list binary_operator identifier integer call identifier argument_list call identifier argument_list binary_operator identifier integer
|
Terrible Fibonacci number generator.
|
def identifier_md5(self):
as_int = (self.identifier * 1e4).astype(np.int64)
hashed = util.md5_object(as_int.tostring(order='C'))
return hashed
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute parenthesized_expression binary_operator attribute identifier identifier float identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end return_statement identifier
|
Return an MD5 of the identifier
|
def load_yaml(filepath):
with open(filepath) as f:
txt = f.read()
return yaml.load(txt)
|
module function_definition identifier parameters identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list return_statement call attribute identifier identifier argument_list identifier
|
Convenience function for loading yaml-encoded data from disk.
|
def value(self):
return self._ads.read(self._pin_setting, is_differential=self.is_differential)
|
module function_definition identifier parameters identifier block return_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier keyword_argument identifier attribute identifier identifier
|
Returns the value of an ADC pin as an integer.
|
def onselection(self, widget):
self._selected_key = None
for k in self.children:
if self.children[k] == widget:
self._selected_key = k
if (self._selected_item is not None) and self._selectable:
self._selected_item.attributes['selected'] = False
self._selected_item = self.children[self._selected_key]
if self._selectable:
self._selected_item.attributes['selected'] = True
break
return (self._selected_key,)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier none for_statement identifier attribute identifier identifier block if_statement comparison_operator subscript attribute identifier identifier identifier identifier block expression_statement assignment attribute identifier identifier identifier if_statement boolean_operator parenthesized_expression comparison_operator attribute identifier identifier none attribute identifier identifier block expression_statement assignment subscript attribute attribute identifier identifier identifier string string_start string_content string_end false expression_statement assignment attribute identifier identifier subscript attribute identifier identifier attribute identifier identifier if_statement attribute identifier identifier block expression_statement assignment subscript attribute attribute identifier identifier identifier string string_start string_content string_end true break_statement return_statement tuple attribute identifier identifier
|
Called when a new item gets selected in the list.
|
def filter_pythons(path):
if not isinstance(path, vistir.compat.Path):
path = vistir.compat.Path(str(path))
if not path.is_dir():
return path if path_is_python(path) else None
return filter(path_is_python, path.iterdir())
|
module function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list identifier attribute attribute identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier if_statement not_operator call attribute identifier identifier argument_list block return_statement conditional_expression identifier call identifier argument_list identifier none return_statement call identifier argument_list identifier call attribute identifier identifier argument_list
|
Return all valid pythons in a given path
|
def _validate_no_rels(param, rels):
if param.field in rels:
raise InvalidQueryParams(**{
'detail': 'The sort query param value of "%s" is not '
'supported. Sorting on relationships is not '
'currently supported' % param.raw_field,
'links': LINK,
'parameter': PARAM,
})
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier identifier block raise_statement call identifier argument_list dictionary_splat dictionary pair string string_start string_content string_end binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier
|
Ensure the sortable field is not on a relationship
|
def addPlayer(settings):
_validate(settings)
player = PlayerRecord(settings)
player.save()
getKnownPlayers()[player.name] = player
return player
|
module function_definition identifier parameters identifier block expression_statement call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list expression_statement assignment subscript call identifier argument_list attribute identifier identifier identifier return_statement identifier
|
define a new PlayerRecord setting and save to disk file
|
def write_to_datastore(self):
client = self._datastore_client
with client.no_transact_batch() as client_batch:
for batch_id, batch_data in iteritems(self._data):
batch_key = client.key(self._entity_kind_batches, batch_id)
batch_entity = client.entity(batch_key)
for k, v in iteritems(batch_data):
if k != 'images':
batch_entity[k] = v
client_batch.put(batch_entity)
self._write_single_batch_images_internal(batch_id, client_batch)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list as_pattern_target identifier block for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement pattern_list identifier identifier call identifier argument_list identifier block if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment subscript identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier identifier
|
Writes all image batches to the datastore.
|
def project_point(cb, msg, attributes=('x', 'y')):
if skip(cb, msg, attributes): return msg
plot = get_cb_plot(cb)
x, y = msg.get('x', 0), msg.get('y', 0)
crs = plot.current_frame.crs
coordinates = crs.transform_points(plot.projection, np.array([x]), np.array([y]))
msg['x'], msg['y'] = coordinates[0, :2]
return {k: v for k, v in msg.items() if k in attributes}
|
module function_definition identifier parameters identifier identifier default_parameter identifier tuple string string_start string_content string_end string string_start string_content string_end block if_statement call identifier argument_list identifier identifier identifier block return_statement identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment pattern_list identifier identifier expression_list call attribute identifier identifier argument_list string string_start string_content string_end integer call attribute identifier identifier argument_list string string_start string_content string_end integer expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list list identifier call attribute identifier identifier argument_list list identifier expression_statement assignment pattern_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier integer slice integer return_statement dictionary_comprehension pair identifier identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list if_clause comparison_operator identifier identifier
|
Projects a single point supplied by a callback
|
def flatten(self):
size = prod(self.shape[:-1])
return self.reshape(size, self.shape[-1])
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list subscript attribute identifier identifier slice unary_operator integer return_statement call attribute identifier identifier argument_list identifier subscript attribute identifier identifier unary_operator integer
|
Reshape all dimensions but the last into a single dimension
|
def _gen_tasks(self):
for filename in self.args:
path = os.path.abspath(filename)
yield {
'name': path,
'actions': [(self.fun, (filename,))],
}
|
module function_definition identifier parameters identifier block for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement yield dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end list tuple attribute identifier identifier tuple identifier
|
generate doit tasks for each file
|
def handle_valid(self, form=None, *args, **kwargs):
if hasattr(form, 'save'):
form.save()
if hasattr(form, 'handle_valid'):
form.handle_valid(*args, **kwargs)
|
module function_definition identifier parameters identifier default_parameter identifier none list_splat_pattern identifier dictionary_splat_pattern identifier block if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list list_splat identifier dictionary_splat identifier
|
Called after the form has validated.
|
async def bluetooth(dev: Device, target, value):
if target and value:
await dev.set_bluetooth_settings(target, value)
print_settings(await dev.get_bluetooth_settings())
|
module function_definition identifier parameters typed_parameter identifier type identifier identifier identifier block if_statement boolean_operator identifier identifier block expression_statement await call attribute identifier identifier argument_list identifier identifier expression_statement call identifier argument_list await call attribute identifier identifier argument_list
|
Get or set bluetooth settings.
|
def rules(self):
rule = lib.EnvGetNextDefrule(self._env, ffi.NULL)
while rule != ffi.NULL:
yield Rule(self._env, rule)
rule = lib.EnvGetNextDefrule(self._env, rule)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier while_statement comparison_operator identifier attribute identifier identifier block expression_statement yield call identifier argument_list attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier identifier
|
Iterate over the defined Rules.
|
def find_commands(cls):
cmds = []
for subclass in cls.__subclasses__():
cmds.append(subclass)
cmds.extend(find_commands(subclass))
return cmds
|
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier return_statement identifier
|
Finds commands by finding the subclasses of Command
|
def _call(self, x, out=None):
if out is None:
out = self.range.element()
out.lincomb(self.a, x[0], self.b, x[1])
return out
|
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list attribute identifier identifier subscript identifier integer attribute identifier identifier subscript identifier integer return_statement identifier
|
Linearly combine ``x`` and write to ``out`` if given.
|
def on_transparency_value_changed(self, hscale):
value = hscale.get_value()
self.prefDlg.set_colors_from_settings()
self.settings.styleBackground.set_int('transparency', MAX_TRANSPARENCY - int(value))
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end binary_operator identifier call identifier argument_list identifier
|
Changes the value of background_transparency in dconf
|
def add(self, command):
self.add_command(command.config)
command.set_application(self)
return self
|
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
|
Adds a command object.
|
def hex(self):
props = self._message_properties()
msg = bytearray([MESSAGE_START_CODE_0X02, self._code])
for prop in props:
for key, val in prop.items():
if val is None:
pass
elif isinstance(val, int):
msg.append(val)
elif isinstance(val, Address):
if val.addr is None:
pass
else:
msg.extend(val.bytes)
elif isinstance(val, MessageFlags):
msg.extend(val.bytes)
elif isinstance(val, bytearray):
msg.extend(val)
elif isinstance(val, bytes):
msg.extend(val)
elif isinstance(val, Userdata):
msg.extend(val.bytes)
return binascii.hexlify(msg).decode()
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list list identifier attribute identifier identifier for_statement identifier identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement comparison_operator identifier none block pass_statement elif_clause call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list identifier elif_clause call identifier argument_list identifier identifier block if_statement comparison_operator attribute identifier identifier none block pass_statement else_clause block expression_statement call attribute identifier identifier argument_list attribute identifier identifier elif_clause call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier elif_clause call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list identifier elif_clause call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list identifier elif_clause call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier return_statement call attribute call attribute identifier identifier argument_list identifier identifier argument_list
|
Hexideciaml representation of the message in bytes.
|
def sum_over_energy(self):
return Map(np.sum(self.counts, axis=0), self.wcs.dropaxis(2))
|
module function_definition identifier parameters identifier block return_statement call identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier integer call attribute attribute identifier identifier identifier argument_list integer
|
Reduce a 3D counts cube to a 2D counts map
|
def focusOutEvent(self, event):
if not self.is_valid():
lineedit = self.lineEdit()
QTimer.singleShot(50, lambda: lineedit.setText(self.selected_text))
hide_status = getattr(self.lineEdit(), 'hide_status_icon', None)
if hide_status:
hide_status()
QComboBox.focusOutEvent(self, event)
|
module function_definition identifier parameters identifier identifier block if_statement not_operator call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list integer lambda call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end none if_statement identifier block expression_statement call identifier argument_list expression_statement call attribute identifier identifier argument_list identifier identifier
|
Handle focus out event restoring the last valid selected path.
|
def to_list(stringlist, unquote=True):
stringlist = stringlist[1:-1]
return [
string.strip('"') if unquote else string
for string in stringlist.split(",")
]
|
module function_definition identifier parameters identifier default_parameter identifier true block expression_statement assignment identifier subscript identifier slice integer unary_operator integer return_statement list_comprehension conditional_expression call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier for_in_clause identifier call attribute identifier identifier argument_list string string_start string_content string_end
|
Convert a string representing a list to real list.
|
def sanitize(value):
value = unicodedata.normalize('NFKD', value)
value = value.strip()
value = re.sub('[^./\w\s-]', '', value)
value = re.sub('[-\s]+', '-', value)
return value
|
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 expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier return_statement identifier
|
Strips all undesirable characters out of potential file paths.
|
def make_param_dict_from_file(self,path_to_params):
param_list = list(csv.reader(open(path_to_params,"rb")))
param_file = [x for x in param_list if x != []]
name_list = []
param_list = []
param_colnames = param_file[0][1:]
for i in np.arange(1, len(param_file)):
name_list.append(param_file[i][0])
param_list.append(param_file[i][1:])
param_list = [[x.strip() for x in y] for y in param_list]
param_dict = {}
for i in np.arange(0, len(param_colnames)):
param_dict[param_colnames[i]] = []
for j in np.arange(0,len(name_list)):
param_dict[param_colnames[i]].append(param_list[j][i])
self._param_dict = param_dict
self._row_names = name_list
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list call identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier list_comprehension identifier for_in_clause identifier identifier if_clause comparison_operator identifier list expression_statement assignment identifier list expression_statement assignment identifier list expression_statement assignment identifier subscript subscript identifier integer slice integer for_statement identifier call attribute identifier identifier argument_list integer call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list subscript subscript identifier identifier integer expression_statement call attribute identifier identifier argument_list subscript subscript identifier identifier slice integer expression_statement assignment identifier list_comprehension list_comprehension call attribute identifier identifier argument_list for_in_clause identifier identifier for_in_clause identifier identifier expression_statement assignment identifier dictionary for_statement identifier call attribute identifier identifier argument_list integer call identifier argument_list identifier block expression_statement assignment subscript identifier subscript identifier identifier list for_statement identifier call attribute identifier identifier argument_list integer call identifier argument_list identifier block expression_statement call attribute subscript identifier subscript identifier identifier identifier argument_list subscript subscript identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier
|
make param dict from a file on disk
|
def find_top_pyfile():
import os
frame = currentframe()
while True:
if frame.f_back is None:
finfo = getframeinfo(frame)
return os.path.abspath(finfo.filename)
frame = frame.f_back
|
module function_definition identifier parameters block import_statement dotted_name identifier expression_statement assignment identifier call identifier argument_list while_statement true block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier call identifier argument_list identifier return_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier attribute identifier identifier
|
This function inspects the Cpython frame to find the path of the script.
|
def plot_energy(time, H, T, U):
T0 = T[0]
H = H / T0
T = T / T0
U = U / T0
fig, ax = plt.subplots(figsize=[16,8])
ax.set_title('System Energy vs. Time')
ax.set_xlabel('Time in Days')
ax.set_ylabel('Energy (Ratio Initial KE)')
ax.plot(time, T, label='T', color='r')
ax.plot(time, U, label='U', color='b')
ax.plot(time, H, label='H', color='k')
ax.legend()
ax.grid()
plt.show()
|
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier binary_operator identifier identifier expression_statement assignment identifier binary_operator identifier identifier expression_statement assignment identifier binary_operator identifier identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list keyword_argument identifier list integer integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list
|
Plot kinetic and potential energy of system over time
|
def delete_bandwidth_limit_rule(self, rule, policy):
return self.delete(self.qos_bandwidth_limit_rule_path %
(policy, rule))
|
module function_definition identifier parameters identifier identifier identifier block return_statement call attribute identifier identifier argument_list binary_operator attribute identifier identifier tuple identifier identifier
|
Deletes a bandwidth limit rule.
|
def _load_preset(self, path):
try:
with open(path, 'r') as f:
presetBody = json.load(f)
except IOError as e:
raise PresetException("IOError: " + e.strerror)
except ValueError as e:
raise PresetException("JSON decoding error: " + str(e))
except Exception as e:
raise PresetException(str(e))
try:
preset = Preset(presetBody)
except PresetException as e:
e.message = "Bad format: " + e.message
raise
if(preset.id in self.presets):
raise PresetException("Duplicate preset id: " + preset.id)
else:
self.presets[preset.id] = preset
|
module function_definition identifier parameters identifier identifier block try_statement block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier except_clause as_pattern identifier as_pattern_target identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block raise_statement call identifier argument_list call identifier argument_list identifier try_statement block expression_statement assignment identifier call identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement assignment attribute identifier identifier binary_operator string string_start string_content string_end attribute identifier identifier raise_statement if_statement parenthesized_expression comparison_operator attribute identifier identifier attribute identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier else_clause block expression_statement assignment subscript attribute identifier identifier attribute identifier identifier identifier
|
load, validate and store a single preset file
|
def stop(self):
self.working = False
for w in self.workers:
w.join()
self.workers = []
|
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier false for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier list
|
Stops the worker threads and waits for them to finish
|
def subscribe(self, observer):
sid = self._sn
self.observers[sid] = observer
self._sn += 1
return SubscribeID(self, sid)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier expression_statement augmented_assignment attribute identifier identifier integer return_statement call identifier argument_list identifier identifier
|
Subscribe an observer to this subject and return a subscription id
|
def unique(seq):
seen = {}
result = []
for item in seq:
marker = item
if marker in seen:
continue
seen[marker] = 1
result.append(item)
return result
|
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier identifier if_statement comparison_operator identifier identifier block continue_statement expression_statement assignment subscript identifier identifier integer expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
|
Helper function to include only unique monomials in a basis.
|
def read(self, size=-1):
if size < 0 and self._offset:
size = self._size
return self._fh.read(size)
|
module function_definition identifier parameters identifier default_parameter identifier unary_operator integer block if_statement boolean_operator comparison_operator identifier integer attribute identifier identifier block expression_statement assignment identifier attribute identifier identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier
|
Read 'size' bytes from file, or until EOF is reached.
|
def imagetransformer_b12l_4h_b128_uncond_dr03_tpu():
hparams = imagetransformer_bas8l_8h_big_uncond_dr03_imgnet()
update_hparams_for_tpu(hparams)
hparams.batch_size = 2
hparams.num_heads = 4
hparams.num_decoder_layers = 12
hparams.block_length = 128
hparams.hidden_size = 256
hparams.filter_size = 2048
hparams.layer_preprocess_sequence = "none"
hparams.layer_postprocess_sequence = "dan"
hparams.layer_prepostprocess_dropout = 0.1
hparams.optimizer = "Adafactor"
hparams.learning_rate_schedule = "rsqrt_decay"
hparams.learning_rate_warmup_steps = 10000
return hparams
|
module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list expression_statement call identifier argument_list identifier expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier float expression_statement assignment attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier integer return_statement identifier
|
TPU config for cifar 10.
|
def unflag_field(self, move_x, move_y):
field_status = self.info_map[move_y, move_x]
if field_status == 9 or field_status == 10:
self.info_map[move_y, move_x] = 11
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier identifier identifier if_statement boolean_operator comparison_operator identifier integer comparison_operator identifier integer block expression_statement assignment subscript attribute identifier identifier identifier identifier integer
|
Unflag or unquestion a grid by given position.
|
def galprop_rings_yaml(self, **kwargs):
kwargs_copy = self.base_dict.copy()
kwargs_copy.update(**kwargs)
self._replace_none(kwargs_copy)
localpath = NameFactory.galprop_rings_yaml_format.format(**kwargs_copy)
if kwargs.get('fullpath', False):
return self.fullpath(localpath=localpath)
return localpath
|
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list dictionary_splat identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list dictionary_splat identifier if_statement call attribute identifier identifier argument_list string string_start string_content string_end false block return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier return_statement identifier
|
return the name of a galprop rings merging yaml file
|
def handle_end_signal(self):
try:
signal.signal(signal.SIGTERM, self.catch_end_signal)
signal.signal(signal.SIGINT, self.catch_end_signal)
except ValueError:
self.log('Signals cannot be caught in a Thread', level='warning')
|
module function_definition identifier parameters identifier block try_statement block expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end
|
Catch some system signals to handle them internaly
|
def make_catalog_comp_dict(**kwargs):
library_yamlfile = kwargs.pop('library', 'models/library.yaml')
csm = kwargs.pop('CatalogSourceManager', CatalogSourceManager(**kwargs))
if library_yamlfile is None or library_yamlfile == 'None':
yamldict = {}
else:
yamldict = yaml.safe_load(open(library_yamlfile))
catalog_info_dict, comp_info_dict = csm.make_catalog_comp_info_dict(yamldict)
return dict(catalog_info_dict=catalog_info_dict,
comp_info_dict=comp_info_dict,
CatalogSourceManager=csm)
|
module function_definition identifier parameters dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list dictionary_splat identifier if_statement boolean_operator comparison_operator identifier none comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier dictionary else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier return_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
|
Build and return the information about the catalog components
|
def generate(basename, xml_list):
for xml in xml_list:
generate_one(basename, xml)
generate_enums(basename, xml)
generate_MAVLinkMessage(basename, xml_list)
copy_fixed_headers(basename, xml_list[0])
|
module function_definition identifier parameters identifier identifier block for_statement identifier identifier block expression_statement call identifier argument_list identifier identifier expression_statement call identifier argument_list identifier identifier expression_statement call identifier argument_list identifier identifier expression_statement call identifier argument_list identifier subscript identifier integer
|
generate complete MAVLink Java implemenation
|
def buildNavigation(self):
if self.buildSpec['navigation'] == constants.TABBED:
navigation = Tabbar(self, self.buildSpec, self.configs)
else:
navigation = Sidebar(self, self.buildSpec, self.configs)
if self.buildSpec['navigation'] == constants.HIDDEN:
navigation.Hide()
return navigation
|
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 expression_statement assignment identifier call identifier argument_list identifier attribute identifier identifier attribute identifier identifier else_clause block expression_statement assignment identifier call identifier argument_list identifier attribute identifier identifier attribute identifier identifier 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 return_statement identifier
|
Chooses the appropriate layout navigation component based on user prefs
|
def rgb_to_hsv(r, g, b):
h, s, v = colorsys.rgb_to_hsv(r / 255., g / 255., b / 255.)
return round2(h * 360), round2(s * 100), round2(v * 100)
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment pattern_list identifier identifier identifier call attribute identifier identifier argument_list binary_operator identifier float binary_operator identifier float binary_operator identifier float return_statement expression_list call identifier argument_list binary_operator identifier integer call identifier argument_list binary_operator identifier integer call identifier argument_list binary_operator identifier integer
|
Convert RGB color to HSV.
|
def skypipe_input_stream(endpoint, name=None):
name = name or ''
class context_manager(object):
def __enter__(self):
self.socket = ctx.socket(zmq.DEALER)
self.socket.connect(endpoint)
return self
def send(self, data):
data_msg = sp_msg(SP_CMD_DATA, name, data)
self.socket.send_multipart(data_msg)
def __exit__(self, *args, **kwargs):
eof_msg = sp_msg(SP_CMD_DATA, name, SP_DATA_EOF)
self.socket.send_multipart(eof_msg)
self.socket.close()
return context_manager()
|
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier boolean_operator identifier string string_start string_end class_definition identifier argument_list identifier block function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement identifier function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list return_statement call identifier argument_list
|
Returns a context manager for streaming data into skypipe
|
def pretty_print(n):
if type(n) != int:
return n
ret = []
n = str(n)
for i in range(len(n) - 1, -1, -1):
ret.append(n[i])
if (len(n) - i) % 3 == 0:
ret.append(',')
ret.reverse()
return ''.join(ret[1:]) if ret[0] == ',' else ''.join(ret)
|
module function_definition identifier parameters identifier block if_statement comparison_operator call identifier argument_list identifier identifier block return_statement identifier expression_statement assignment identifier list expression_statement assignment identifier call identifier argument_list identifier for_statement identifier call identifier argument_list binary_operator call identifier argument_list identifier integer unary_operator integer unary_operator integer block expression_statement call attribute identifier identifier argument_list subscript identifier identifier if_statement comparison_operator binary_operator parenthesized_expression binary_operator call identifier argument_list identifier identifier integer integer block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list return_statement conditional_expression call attribute string string_start string_end identifier argument_list subscript identifier slice integer comparison_operator subscript identifier integer string string_start string_content string_end call attribute string string_start string_end identifier argument_list identifier
|
Pretty print function for very big integers
|
def run_mp(songs):
stats = Stats()
if CONFIG['debug']:
good = open('found', 'w')
bad = open('notfound', 'w')
logger.debug('Launching a pool of %d processes\n', CONFIG['jobcount'])
chunksize = math.ceil(len(songs) / os.cpu_count())
try:
with Pool(CONFIG['jobcount']) as pool:
for result in pool.imap_unordered(get_lyrics, songs, chunksize):
if result is None:
continue
for source, runtime in result.runtimes.items():
stats.add_result(source, result.source == source, runtime)
found = process_result(result)
if CONFIG['debug']:
if found:
good.write(f'{id_source(source)}: {result.song}\n')
good.flush()
else:
bad.write(str(result.song) + '\n')
bad.flush()
finally:
if CONFIG['debug']:
good.close()
bad.close()
return stats
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list if_statement subscript identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier 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 string string_start string_content escape_sequence string_end subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator call identifier argument_list identifier call attribute identifier identifier argument_list try_statement block with_statement with_clause with_item as_pattern call identifier argument_list subscript identifier string string_start string_content string_end as_pattern_target identifier block for_statement identifier call attribute identifier identifier argument_list identifier identifier identifier block if_statement comparison_operator identifier none block continue_statement for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier comparison_operator attribute identifier identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier if_statement subscript identifier string string_start string_content string_end block if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start interpolation call identifier argument_list identifier string_content interpolation attribute identifier identifier string_content escape_sequence string_end expression_statement call attribute identifier identifier argument_list else_clause block expression_statement call attribute identifier identifier argument_list binary_operator call identifier argument_list attribute identifier identifier string string_start string_content escape_sequence string_end expression_statement call attribute identifier identifier argument_list finally_clause block if_statement subscript identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list return_statement identifier
|
Concurrently calls get_lyrics to fetch the lyrics of a large list of songs.
|
def _set_properties(self):
self.codetext_ctrl.SetToolTipString(_("Enter python code here."))
self.apply_button.SetToolTipString(_("Apply changes to current macro"))
self.splitter.SetBackgroundStyle(wx.BG_STYLE_COLOUR)
self.result_ctrl.SetMinSize((10, 10))
|
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list tuple integer integer
|
Setup title, size and tooltips
|
def measure_float_put(self, measure, value):
if value < 0:
logger.warning("Cannot record negative values")
self._measurement_map[measure] = value
|
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator identifier integer block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment subscript attribute identifier identifier identifier identifier
|
associates the measure of type Float with the given value
|
def operate(config):
"Interface to do simple operations on the database."
app = make_app(config=config)
print "Operate Mode"
with app.app_context():
operate_menu()
|
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier print_statement string string_start string_content string_end with_statement with_clause with_item call attribute identifier identifier argument_list block expression_statement call identifier argument_list
|
Interface to do simple operations on the database.
|
def delete_node(self, node: str):
if self.has_node(node):
self.remove_node(node)
|
module function_definition identifier parameters identifier typed_parameter identifier type identifier block if_statement call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier
|
Removes a node if it is in the graph.
|
def getQueryParams(url):
query = urlsplit(url)[3]
out.debug(u'Extracting query parameters from %r (%r)...' % (url, query))
return cgi.parse_qs(query)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript call identifier argument_list identifier integer expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier return_statement call attribute identifier identifier argument_list identifier
|
Get URL query parameters.
|
def reopen(self):
if self._con:
self._con.reopen()
else:
self._con = self._pool.connection()
|
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list else_clause block expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list
|
Reopen the pooled connection.
|
def _all_spec(self):
base = self._mod_spec
for spec in self.basic_spec:
base[spec] = self.basic_spec[spec]
return base
|
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier for_statement identifier attribute identifier identifier block expression_statement assignment subscript identifier identifier subscript attribute identifier identifier identifier return_statement identifier
|
All specifiers and their lengths.
|
def load_p2th_privkey_into_local_node(provider: RpcNode, prod: bool=True) -> None:
assert isinstance(provider, RpcNode), {"error": "Import only works with local node."}
error = {"error": "Loading P2TH privkey failed."}
pa_params = param_query(provider.network)
if prod:
provider.importprivkey(pa_params.P2TH_wif, "PAPROD")
if not provider.validateaddress(pa_params.P2TH_addr)['ismine']:
raise P2THImportFailed(error)
else:
provider.importprivkey(pa_params.test_P2TH_wif, "PATEST")
if not provider.validateaddress(pa_params.test_P2TH_addr)['ismine']:
raise P2THImportFailed(error)
|
module function_definition identifier parameters typed_parameter identifier type identifier typed_default_parameter identifier type identifier true type none block assert_statement call identifier argument_list identifier identifier dictionary pair string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call identifier argument_list attribute identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier string string_start string_content string_end if_statement not_operator subscript call attribute identifier identifier argument_list attribute identifier identifier string string_start string_content string_end block raise_statement call identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list attribute identifier identifier string string_start string_content string_end if_statement not_operator subscript call attribute identifier identifier argument_list attribute identifier identifier string string_start string_content string_end block raise_statement call identifier argument_list identifier
|
Load PeerAssets P2TH privkey into the local node.
|
def refresh(self):
self._update_id_list()
for _id in self.history[:]:
if _id not in self.id_list:
self.history.remove(_id)
|
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list for_statement identifier subscript attribute identifier identifier slice block if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier
|
Remove editors that are not longer open.
|
def cat(self, numlines=None):
if len(self.titles) == 1:
lines = self.lines()
if numlines is not None:
lines = lines[len(lines)-numlines:]
log("\n".join(lines))
else:
lines = [self._printtuple(line[0], line[1]) for line in self.lines()]
if numlines is not None:
lines = lines[len(lines)-numlines:]
log("".join(lines))
|
module function_definition identifier parameters identifier default_parameter identifier none block if_statement comparison_operator call identifier argument_list attribute identifier identifier integer block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier none block expression_statement assignment identifier subscript identifier slice binary_operator call identifier argument_list identifier identifier expression_statement call identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier else_clause block expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list subscript identifier integer subscript identifier integer for_in_clause identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier none block expression_statement assignment identifier subscript identifier slice binary_operator call identifier argument_list identifier identifier expression_statement call identifier argument_list call attribute string string_start string_end identifier argument_list identifier
|
Return a list of lines output by this service.
|
def loads(self, data):
st = BytesIO(data)
try:
return self.load(st)
finally:
st.close()
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier try_statement block return_statement call attribute identifier identifier argument_list identifier finally_clause block expression_statement call attribute identifier identifier argument_list
|
Deserializes the given byte array into an object and returns it.
|
def lesson_nums(self):
lesson_nums = {}
for brain_name, curriculum in self.brains_to_curriculums.items():
lesson_nums[brain_name] = curriculum.lesson_num
return lesson_nums
|
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block expression_statement assignment subscript identifier identifier attribute identifier identifier return_statement identifier
|
A dict from brain name to the brain's curriculum's lesson number.
|
def relocate(self):
name=self.SearchVar.get()
if kbos.has_key(name):
import orbfit,ephem,math
jdate=ephem.julian_date(w.date.get())
try:
(ra,dec,a,b,ang)=orbfit.predict(kbos[name],jdate,568)
except:
return
ra=math.radians(ra)
dec=math.radians(dec)
elif mpc_objs.has_key(name):
ra=mpc_objs[name].ra
dec=mpc_objs[name].dec
self.recenter(ra,dec)
self.create_point(ra,dec,color='blue',size=4)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list if_statement call attribute identifier identifier argument_list identifier block import_statement dotted_name identifier dotted_name identifier dotted_name identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list try_statement block expression_statement assignment tuple_pattern identifier identifier identifier identifier identifier call attribute identifier identifier argument_list subscript identifier identifier identifier integer except_clause block return_statement expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier elif_clause call attribute identifier identifier argument_list identifier block expression_statement assignment identifier attribute subscript identifier identifier identifier expression_statement assignment identifier attribute subscript identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier integer
|
Move to the postion of self.SearchVar
|
def mount2name(self, mount):
if not self.is_mount(mount):
raise ValueError('%r is not a supported mount name' % (mount,))
return mount.replace(self.mount_prefix, self.module_prefix)
|
module function_definition identifier parameters identifier identifier block if_statement not_operator call attribute identifier identifier argument_list identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier return_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier
|
Convert a mount name to a module name
|
def validate_price(price):
if isinstance(price, str):
try:
price = int(price)
except ValueError:
price = float(price)
if not isinstance(price, (int, float)):
raise TypeError('Price should be a number: ' + repr(price))
return price
|
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block try_statement block expression_statement assignment identifier call identifier argument_list identifier except_clause identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement not_operator call identifier argument_list identifier tuple identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier return_statement identifier
|
validation checks for price argument
|
def _get_binding_keys(self, port, host):
binding_keys = list()
switch_binding = port[portbindings.PROFILE].get(
'local_link_information', None)
if switch_binding:
for binding in switch_binding:
switch_id = binding.get('switch_id')
port_id = binding.get('port_id')
binding_keys.append((port['id'], (switch_id, port_id)))
else:
binding_keys.append((port['id'], host))
return binding_keys
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call attribute subscript identifier attribute identifier identifier identifier argument_list string string_start string_content string_end none if_statement identifier block for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list tuple subscript identifier string string_start string_content string_end tuple identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list tuple subscript identifier string string_start string_content string_end identifier return_statement identifier
|
Get binding keys from the port binding
|
def properties_operator(cls, name):
def wrapper(self, *args, **kwargs):
output = getattr(super(cls, self), name)(*args, **kwargs)
return cls(output)
wrapped = getattr(cls, name)
wrapper.__name__ = wrapped.__name__
wrapper.__doc__ = wrapped.__doc__
return wrapper
|
module function_definition identifier parameters identifier identifier block function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call call identifier argument_list call identifier argument_list identifier identifier identifier argument_list list_splat identifier dictionary_splat identifier return_statement call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier return_statement identifier
|
Wraps a container operator to ensure container class is maintained
|
def create_where():
conjunction = Forward().setResultsName("conjunction")
nested = Group(Suppress("(") + conjunction + Suppress(")")).setResultsName(
"conjunction"
)
maybe_nested = nested | constraint
inverted = Group(not_ + maybe_nested).setResultsName("not")
full_constraint = maybe_nested | inverted
conjunction <<= full_constraint + OneOrMore(and_or + full_constraint)
return upkey("where") + Group(conjunction | full_constraint).setResultsName("where")
|
module function_definition identifier parameters block expression_statement assignment identifier call attribute call identifier argument_list identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute call identifier argument_list binary_operator binary_operator call identifier argument_list string string_start string_content string_end identifier call identifier argument_list string string_start string_content string_end identifier argument_list string string_start string_content string_end expression_statement assignment identifier binary_operator identifier identifier expression_statement assignment identifier call attribute call identifier argument_list binary_operator identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier binary_operator identifier identifier expression_statement augmented_assignment identifier binary_operator identifier call identifier argument_list binary_operator identifier identifier return_statement binary_operator call identifier argument_list string string_start string_content string_end call attribute call identifier argument_list binary_operator identifier identifier identifier argument_list string string_start string_content string_end
|
Create a grammar for the 'where' clause used by 'select'
|
def to_api_data(self):
data = {
self._cc('flagStatus'): self._cc(self.__status.value)
}
if self.__status is Flag.Flagged:
data[self._cc('startDateTime')] = self._build_date_time_time_zone(self.__start)
data[self._cc('dueDateTime')] = self._build_date_time_time_zone(self.__due_date)
if self.__status is Flag.Complete:
data[self._cc('completedDateTime')] = self._build_date_time_time_zone(self.__completed)
return data
|
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary pair call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list attribute attribute identifier identifier identifier if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment subscript identifier call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment subscript identifier call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list attribute identifier identifier if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment subscript identifier call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list attribute identifier identifier return_statement identifier
|
Returns this data as a dict to be sent to the server
|
def message(
*tokens: Token,
end: str = "\n",
sep: str = " ",
fileobj: FileObj = sys.stdout,
update_title: bool = False
) -> None:
if using_colorama():
global _INITIALIZED
if not _INITIALIZED:
colorama.init()
_INITIALIZED = True
with_color, without_color = process_tokens(tokens, end=end, sep=sep)
if CONFIG["record"]:
_MESSAGES.append(without_color)
if update_title and with_color:
write_title_string(without_color, fileobj)
to_write = with_color if config_color(fileobj) else without_color
write_and_flush(fileobj, to_write)
|
module function_definition identifier parameters typed_parameter list_splat_pattern identifier type identifier typed_default_parameter identifier type identifier string string_start string_content escape_sequence string_end typed_default_parameter identifier type identifier string string_start string_content string_end typed_default_parameter identifier type identifier attribute identifier identifier typed_default_parameter identifier type identifier false type none block if_statement call identifier argument_list block global_statement identifier if_statement not_operator identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier true expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier if_statement subscript identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier if_statement boolean_operator identifier identifier block expression_statement call identifier argument_list identifier identifier expression_statement assignment identifier conditional_expression identifier call identifier argument_list identifier identifier expression_statement call identifier argument_list identifier identifier
|
Helper method for error, warning, info, debug
|
def _get_stack_events(h_client, stack_id, event_args):
event_args['stack_id'] = stack_id
event_args['resource_name'] = None
try:
events = h_client.events.list(**event_args)
except heatclient.exc.HTTPNotFound as exc:
raise heatclient.exc.CommandError(six.text_type(exc))
else:
for event in events:
event.stack_name = stack_id.split('/')[0]
return events
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment subscript identifier string string_start string_content string_end none try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list dictionary_splat identifier except_clause as_pattern attribute attribute identifier identifier identifier as_pattern_target identifier block raise_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier else_clause block for_statement identifier identifier block expression_statement assignment attribute identifier identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end integer return_statement identifier
|
Get event for stack
|
def cancelEdit( self ):
if ( self._partsWidget.isVisible() ):
return False
self._completerTree.hide()
self.completer().popup().hide()
self.setText(self._originalText)
return True
|
module function_definition identifier parameters identifier block if_statement parenthesized_expression call attribute attribute identifier identifier identifier argument_list block return_statement false expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute call attribute call attribute identifier identifier argument_list identifier argument_list identifier argument_list expression_statement call attribute identifier identifier argument_list attribute identifier identifier return_statement true
|
Rejects the current edit and shows the parts widget.
|
def _change_mode(self, mode, major, minor):
if self._mode:
if self._mode != mode:
raise RuntimeError('Can\'t change mode (from %s to %s)' % (self._mode, mode))
self._require_version(major=major, minor=minor)
self._mode = mode
self.ticket_flags = YubiKeyConfigBits(0x0)
self.config_flags = YubiKeyConfigBits(0x0)
self.extended_flags = YubiKeyConfigBits(0x0)
if mode != 'YUBIKEY_OTP':
self.ticket_flag(mode, True)
|
module function_definition identifier parameters identifier identifier identifier identifier block if_statement attribute identifier identifier block if_statement comparison_operator attribute identifier identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content escape_sequence string_end tuple attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list integer expression_statement assignment attribute identifier identifier call identifier argument_list integer expression_statement assignment attribute identifier identifier call 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 identifier true
|
Change mode of operation, with some sanity checks.
|
def own_time(self):
sub_time = sum(stats.deep_time for stats in self)
return max(0., self.deep_time - sub_time)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier generator_expression attribute identifier identifier for_in_clause identifier identifier return_statement call identifier argument_list float binary_operator attribute identifier identifier identifier
|
The exclusive execution time.
|
def account_groups_and_extra_data(account, resource,
refresh_timedelta=None):
updated = datetime.utcnow()
modified_since = updated
if refresh_timedelta is not None:
modified_since += refresh_timedelta
modified_since = modified_since.isoformat()
last_update = account.extra_data.get('updated', modified_since)
if last_update > modified_since:
return account.extra_data.get('groups', [])
groups = fetch_groups(resource['Group'])
extra_data = current_app.config.get(
'OAUTHCLIENT_CERN_EXTRA_DATA_SERIALIZER',
fetch_extra_data
)(resource)
account.extra_data.update(
groups=groups,
updated=updated.isoformat(),
**extra_data
)
return groups
|
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier identifier if_statement comparison_operator identifier none block expression_statement augmented_assignment identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier if_statement comparison_operator identifier identifier block return_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end list expression_statement assignment identifier call identifier argument_list subscript identifier string string_start string_content string_end expression_statement assignment identifier call call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier call attribute identifier identifier argument_list dictionary_splat identifier return_statement identifier
|
Fetch account groups and extra data from resource if necessary.
|
def object(self):
if self.type == EntryType.category:
return self.category
elif self.type == EntryType.event:
return self.event
elif self.type == EntryType.session:
return self.session
elif self.type == EntryType.contribution:
return self.contribution
elif self.type == EntryType.subcontribution:
return self.subcontribution
|
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block return_statement attribute identifier identifier elif_clause comparison_operator attribute identifier identifier attribute identifier identifier block return_statement attribute identifier identifier elif_clause comparison_operator attribute identifier identifier attribute identifier identifier block return_statement attribute identifier identifier elif_clause comparison_operator attribute identifier identifier attribute identifier identifier block return_statement attribute identifier identifier elif_clause comparison_operator attribute identifier identifier attribute identifier identifier block return_statement attribute identifier identifier
|
Return the changed object.
|
def _preprocess(self, filehandle, metadata):
"Runs all attached preprocessors on the provided filehandle."
for process in self._preprocessors:
filehandle = process(filehandle, metadata)
return filehandle
|
module function_definition identifier parameters identifier identifier identifier block expression_statement string string_start string_content string_end for_statement identifier attribute identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier return_statement identifier
|
Runs all attached preprocessors on the provided filehandle.
|
def keyring_refresh(**kwargs):
ctx = Context(**kwargs)
ctx.execute_action('keyring:refresh', **{
'tvm': ctx.repo.create_secure_service('tvm'),
})
|
module function_definition identifier parameters dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list dictionary_splat identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end dictionary_splat dictionary pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end
|
Refresh the keyring in the cocaine-runtime.
|
def list_syslogs(self, service_id, version_number):
content = self._fetch("/service/%s/version/%d/syslog" % (service_id, version_number))
return map(lambda x: FastlySyslog(self, x), content)
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier return_statement call identifier argument_list lambda lambda_parameters identifier call identifier argument_list identifier identifier identifier
|
List all of the Syslogs for a particular service and version.
|
def interface_by_ipaddr(self, ipaddr):
ipaddr = IPAddr(ipaddr)
for devname,iface in self._devinfo.items():
if iface.ipaddr == ipaddr:
return iface
raise KeyError("No device has IP address {}".format(ipaddr))
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block if_statement comparison_operator attribute identifier identifier identifier block return_statement identifier raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier
|
Given an IP address, return the interface that 'owns' this address
|
def read(self, *args, **kwargs):
with self.open('r') as f:
return f.read(*args, **kwargs)
|
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list string string_start string_content string_end as_pattern_target identifier block return_statement call attribute identifier identifier argument_list list_splat identifier dictionary_splat identifier
|
Reads the node as a file
|
def match_host (host, domainlist):
if not host:
return False
for domain in domainlist:
if domain.startswith('.'):
if host.endswith(domain):
return True
elif host == domain:
return True
return False
|
module function_definition identifier parameters identifier identifier block if_statement not_operator identifier block return_statement false for_statement identifier identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block if_statement call attribute identifier identifier argument_list identifier block return_statement true elif_clause comparison_operator identifier identifier block return_statement true return_statement false
|
Return True if host matches an entry in given domain list.
|
def add(self, priority, observer, callble):
ins = 0
for pr, _, _ in self:
if priority > pr:
break
ins += 1
self._poc.insert(ins, (priority, weakref.ref(observer), callble))
|
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier integer for_statement pattern_list identifier identifier identifier identifier block if_statement comparison_operator identifier identifier block break_statement expression_statement augmented_assignment identifier integer expression_statement call attribute attribute identifier identifier identifier argument_list identifier tuple identifier call attribute identifier identifier argument_list identifier identifier
|
Add an observer with priority and callble
|
def run_cufflinks(data):
if "cufflinks" in dd.get_tools_off(data):
return [[data]]
work_bam = dd.get_work_bam(data)
ref_file = dd.get_sam_ref(data)
out_dir, fpkm_file, fpkm_isoform_file = cufflinks.run(work_bam, ref_file, data)
data = dd.set_cufflinks_dir(data, out_dir)
data = dd.set_fpkm(data, fpkm_file)
data = dd.set_fpkm_isoform(data, fpkm_isoform_file)
return [[data]]
|
module function_definition identifier parameters identifier block if_statement comparison_operator string string_start string_content string_end call attribute identifier identifier argument_list identifier block return_statement list list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment pattern_list identifier identifier identifier call attribute identifier identifier argument_list identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier return_statement list list identifier
|
Quantitate transcript expression with Cufflinks
|
def as_requirement(self):
if isinstance(self.parsed_version, packaging.version.Version):
spec = "%s==%s" % (self.project_name, self.parsed_version)
else:
spec = "%s===%s" % (self.project_name, self.parsed_version)
return Requirement.parse(spec)
|
module function_definition identifier parameters identifier block if_statement call identifier argument_list attribute identifier identifier attribute attribute identifier identifier identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple attribute identifier identifier attribute identifier identifier else_clause block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple attribute identifier identifier attribute identifier identifier return_statement call attribute identifier identifier argument_list identifier
|
Return a ``Requirement`` that matches this distribution exactly
|
def Channels(module):
nums = {2: 1, 3: 5, 4: 9, 6: 13, 7: 17, 8: 21, 9: 25,
10: 29, 11: 33, 12: 37, 13: 41, 14: 45, 15: 49,
16: 53, 17: 57, 18: 61, 19: 65, 20: 69, 22: 73,
23: 77, 24: 81}
if module in nums:
return [nums[module], nums[module] + 1,
nums[module] + 2, nums[module] + 3]
else:
return None
|
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary pair integer integer pair integer integer pair integer integer pair integer integer pair integer integer pair integer integer pair integer integer pair integer integer pair integer integer pair integer integer pair integer integer pair integer integer pair integer integer pair integer integer pair integer integer pair integer integer pair integer integer pair integer integer pair integer integer pair integer integer pair integer integer if_statement comparison_operator identifier identifier block return_statement list subscript identifier identifier binary_operator subscript identifier identifier integer binary_operator subscript identifier identifier integer binary_operator subscript identifier identifier integer else_clause block return_statement none
|
Returns the channels contained in the given K2 module.
|
def add_text_to_image(fname, txt, opFilename):
ft = ImageFont.load("T://user//dev//src//python//_AS_LIB//timR24.pil")
print("Adding text ", txt, " to ", fname, " pixels wide to file " , opFilename)
im = Image.open(fname)
draw = ImageDraw.Draw(im)
draw.text((0, 0), txt, fill=(0, 0, 0), font=ft)
del draw
im.save(opFilename)
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list string string_start string_content string_end identifier string string_start string_content string_end identifier string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list tuple integer integer identifier keyword_argument identifier tuple integer integer integer keyword_argument identifier identifier delete_statement identifier expression_statement call attribute identifier identifier argument_list identifier
|
convert an image by adding text
|
def apply_fixes(args, tmpdir):
invocation = [args.clang_apply_replacements_binary]
if args.format:
invocation.append('-format')
if args.style:
invocation.append('-style=' + args.style)
invocation.append(tmpdir)
subprocess.call(invocation)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list attribute identifier identifier if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier
|
Calls clang-apply-fixes on a given directory.
|
def do_buggers(self, args):
args = args.split()
if _debug: ConsoleCmd._debug("do_buggers %r", args)
if not self.handlers:
self.stdout.write("no handlers\n")
else:
self.stdout.write("handlers: ")
self.stdout.write(', '.join(loggerName or '__root__' for loggerName in self.handlers))
self.stdout.write("\n")
loggers = logging.Logger.manager.loggerDict.keys()
for loggerName in sorted(loggers):
if args and (not args[0] in loggerName):
continue
if loggerName in self.handlers:
self.stdout.write("* %s\n" % loggerName)
else:
self.stdout.write(" %s\n" % loggerName)
self.stdout.write("\n")
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement not_operator attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content escape_sequence string_end else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier generator_expression boolean_operator identifier string string_start string_content string_end for_in_clause identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content escape_sequence string_end expression_statement assignment identifier call attribute attribute attribute attribute identifier identifier identifier identifier identifier argument_list for_statement identifier call identifier argument_list identifier block if_statement boolean_operator identifier parenthesized_expression not_operator comparison_operator subscript identifier integer identifier block continue_statement if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end identifier else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content escape_sequence string_end
|
buggers - list the console logging handlers
|
def join_path(base, *parts: str):
_parts = "/".join((_part.strip("/") for _part in parts))
if base.endswith("/"):
url = base + _parts
else:
url = base + "/" + _parts
return url
|
module function_definition identifier parameters identifier typed_parameter list_splat_pattern identifier type identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list generator_expression call attribute identifier identifier argument_list string string_start string_content string_end for_in_clause identifier identifier if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier binary_operator identifier identifier else_clause block expression_statement assignment identifier binary_operator binary_operator identifier string string_start string_content string_end identifier return_statement identifier
|
Creates urls from base path and additional parts.
|
def _plugins_inventory(self, entities):
import os
from ansible.plugins.loader import vars_loader
from ansible.utils.vars import combine_vars
data = {}
for inventory_dir in self.variable_manager._inventory._sources:
if ',' in inventory_dir:
continue
elif not os.path.isdir(inventory_dir):
inventory_dir = os.path.dirname(inventory_dir)
for plugin in vars_loader.all():
data = combine_vars(data, self._get_plugin_vars(plugin, inventory_dir, entities))
return data
|
module function_definition identifier parameters identifier identifier block import_statement dotted_name identifier import_from_statement dotted_name identifier identifier identifier dotted_name identifier import_from_statement dotted_name identifier identifier identifier dotted_name identifier expression_statement assignment identifier dictionary for_statement identifier attribute attribute attribute identifier identifier identifier identifier block if_statement comparison_operator string string_start string_content string_end identifier block continue_statement elif_clause not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier for_statement identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call identifier argument_list identifier call attribute identifier identifier argument_list identifier identifier identifier return_statement identifier
|
merges all entities by inventory source
|
def cp(source, bucket, checksum, key_prefix):
from .models import Bucket
from .helpers import populate_from_path
for object_version in populate_from_path(
Bucket.get(bucket), source, checksum=checksum,
key_prefix=key_prefix):
click.secho(str(object_version))
db.session.commit()
|
module function_definition identifier parameters identifier identifier identifier identifier block import_from_statement relative_import import_prefix dotted_name identifier dotted_name identifier import_from_statement relative_import import_prefix dotted_name identifier dotted_name identifier for_statement identifier call identifier argument_list call attribute identifier identifier argument_list identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list
|
Create new bucket from all files in directory.
|
def pWMWrite(fileHandle, pWM, alphabetSize=4):
for i in xrange(0, alphabetSize):
fileHandle.write("%s\n" % ' '.join([ str(pWM[j][i]) for j in xrange(0, len(pWM)) ]))
|
module function_definition identifier parameters identifier identifier default_parameter identifier integer block for_statement identifier call identifier argument_list integer identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end call attribute string string_start string_content string_end identifier argument_list list_comprehension call identifier argument_list subscript subscript identifier identifier identifier for_in_clause identifier call identifier argument_list integer call identifier argument_list identifier
|
Writes file in standard PWM format, is reverse of pWMParser
|
def remove_accounts_from_institute(accounts_query, institute):
query = accounts_query.filter(date_deleted__isnull=True)
for account in query:
remove_account_from_institute(account, institute)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier true for_statement identifier identifier block expression_statement call identifier argument_list identifier identifier
|
Remove accounts from institute.
|
def _log_future_exception(future, logger):
if not future.done():
return
try:
future.result()
except:
logger.warning("Exception in ignored future: %s", future, exc_info=True)
|
module function_definition identifier parameters identifier identifier block if_statement not_operator call attribute identifier identifier argument_list block return_statement try_statement block 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 keyword_argument identifier true
|
Log any exception raised by future.
|
def _from_dict(cls, _dict):
args = {}
if 'words' in _dict:
args['words'] = [Word._from_dict(x) for x in (_dict.get('words'))]
else:
raise ValueError(
'Required property \'words\' not present in Words JSON')
return cls(**args)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier parenthesized_expression call attribute identifier identifier argument_list string string_start string_content string_end else_clause block raise_statement call identifier argument_list string string_start string_content escape_sequence escape_sequence string_end return_statement call identifier argument_list dictionary_splat identifier
|
Initialize a Words object from a json dictionary.
|
def make_map(declarations):
mapper = routes.Mapper()
for route, methods in ROUTE_LIST:
allowed_methods = []
for method, func in methods.items():
mapper.connect(route, action=func,
conditions=dict(method=[method]))
allowed_methods.append(method)
allowed_methods = ', '.join(allowed_methods)
mapper.connect(route, action=handle_not_allowed,
_methods=allowed_methods)
return mapper
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list for_statement pattern_list identifier identifier identifier block expression_statement assignment identifier list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier call identifier argument_list keyword_argument identifier list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier return_statement identifier
|
Process route declarations to create a Route Mapper.
|
def invoke(self, function_name, raw_python=False, command=None, no_color=False):
key = command if command is not None else 'command'
if raw_python:
command = {'raw_command': function_name}
else:
command = {key: function_name}
import json as json
response = self.zappa.invoke_lambda_function(
self.lambda_name,
json.dumps(command),
invocation_type='RequestResponse',
)
if 'LogResult' in response:
if no_color:
print(base64.b64decode(response['LogResult']))
else:
decoded = base64.b64decode(response['LogResult']).decode()
formatted = self.format_invoke_command(decoded)
colorized = self.colorize_invoke_command(formatted)
print(colorized)
else:
print(response)
if 'FunctionError' in response:
raise ClickException(
"{} error occurred while invoking command.".format(response['FunctionError'])
)
|
module function_definition identifier parameters identifier identifier default_parameter identifier false default_parameter identifier none default_parameter identifier false block expression_statement assignment identifier conditional_expression identifier comparison_operator identifier none string string_start string_content string_end if_statement identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier else_clause block expression_statement assignment identifier dictionary pair identifier identifier import_statement aliased_import dotted_name identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block if_statement identifier block expression_statement call identifier argument_list call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end else_clause block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list identifier else_clause block expression_statement call identifier argument_list identifier if_statement comparison_operator string string_start string_content string_end identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list subscript identifier string string_start string_content string_end
|
Invoke a remote function.
|
def render(self, request, context, status=codes.ok, content_type=None,
args=None, kwargs=None):
"Expects the method handler to return the `context` for the template."
if isinstance(self.template_name, (list, tuple)):
template = loader.select_template(self.template_name)
elif self.template_name:
template = loader.get_template(self.template_name)
else:
template = loader.Template(self.template_string)
context = RequestContext(request, context)
content = template.render(context)
return HttpResponse(content, status=status, content_type=content_type)
|
module function_definition identifier parameters identifier identifier identifier default_parameter identifier attribute identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none block expression_statement string string_start string_content string_end if_statement call identifier argument_list attribute identifier identifier tuple identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier elif_clause attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier
|
Expects the method handler to return the `context` for the template.
|
def restart_listener(self, topics):
if self.listener is not None:
if self.listener.running:
self.stop()
self.__init__(topics=topics)
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier none block if_statement attribute attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier
|
Restart listener after configuration update.
|
def _validate_allowed_settings(self, application_id, application_config, allowed_settings):
for setting_key in application_config.keys():
if setting_key not in allowed_settings:
raise ImproperlyConfigured(
"Platform {}, app {} does not support the setting: {}.".format(
application_config["PLATFORM"], application_id, setting_key
)
)
|
module function_definition identifier parameters identifier identifier identifier identifier block for_statement identifier call attribute identifier identifier argument_list block if_statement comparison_operator identifier identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list subscript identifier string string_start string_content string_end identifier identifier
|
Confirm only allowed settings are present.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.