code stringlengths 51 2.34k | sequence stringlengths 186 3.94k | docstring stringlengths 11 171 |
|---|---|---|
def load_tf_lib():
from os.path import join as pjoin
import pkg_resources
import tensorflow as tf
path = pjoin('ext', 'rime.so')
rime_lib_path = pkg_resources.resource_filename("montblanc", path)
return tf.load_op_library(rime_lib_path) | module function_definition identifier parameters block import_from_statement dotted_name identifier identifier aliased_import dotted_name identifier identifier import_statement dotted_name identifier import_statement aliased_import dotted_name identifier identifier 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 attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement call attribute identifier identifier argument_list identifier | Load the tensorflow library |
def save_log_entry(self, log_entry_form, *args, **kwargs):
if log_entry_form.is_for_update():
return self.update_log_entry(log_entry_form, *args, **kwargs)
else:
return self.create_log_entry(log_entry_form, *args, **kwargs) | module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block if_statement call attribute identifier identifier argument_list block return_statement call attribute identifier identifier argument_list identifier list_splat identifier dictionary_splat identifier else_clause block return_statement call attribute identifier identifier argument_list identifier list_splat identifier dictionary_splat identifier | Pass through to provider LogEntryAdminSession.update_log_entry |
def _disconnect_signals(self, model):
for signal, receiver in self._signals.items():
signal.disconnect(sender=model, dispatch_uid=self._dispatch_uid(signal, model)) | module function_definition identifier parameters identifier identifier block for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier call attribute identifier identifier argument_list identifier identifier | Disconnect signals for the model. |
def print_plugin_args(plugin_path):
args = config_utils.get_config_parameters(plugin_path)
args_format = "{:20} {:10} {:^15} {:^10} {:25}"
title = args_format.format(defs.NAME.upper(), defs.TYPE.upper(), defs.DEFAULT.upper(),
defs.REQUIRED.upper(), defs.DESCRIPTION.upper())
click.secho(title)
click.secho("-" * len(title))
for arg in args:
help_text = " ({})".format(arg[defs.HELP_TEXT]) if defs.HELP_TEXT in arg else ""
options = _parse_select_options(arg)
description = arg[defs.LABEL] + options + help_text
click.secho(args_format.format(arg[defs.VALUE], arg[defs.TYPE], str(arg.get(defs.DEFAULT, None)),
str(arg.get(defs.REQUIRED, False)), description)) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier for_statement identifier identifier block expression_statement assignment identifier conditional_expression call attribute string string_start string_content string_end identifier argument_list subscript identifier attribute identifier identifier comparison_operator attribute identifier identifier identifier string string_start string_end expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier binary_operator binary_operator subscript identifier attribute identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list subscript identifier attribute identifier identifier subscript identifier attribute identifier identifier call identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier none call identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier false identifier | Print plugin parameters table. |
def output_json(data, code, headers=None):
settings = current_app.config.get('RESTFUL_JSON', {})
if current_app.debug:
settings.setdefault('indent', 4)
settings.setdefault('sort_keys', not PY3)
dumped = dumps(data, **settings) + "\n"
resp = make_response(dumped, code)
resp.headers.extend(headers or {})
return resp | module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end dictionary if_statement attribute identifier identifier block 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 not_operator identifier expression_statement assignment identifier binary_operator call identifier argument_list identifier dictionary_splat identifier string string_start string_content escape_sequence string_end expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list boolean_operator identifier dictionary return_statement identifier | Makes a Flask response with a JSON encoded body |
def store_async_marker(async_id, status):
logging.debug("Attempting to mark Async %s complete.", async_id)
marker = FuriousAsyncMarker.get_by_id(async_id)
if marker:
logging.debug("Marker already exists for %s.", async_id)
return
key = FuriousAsyncMarker(id=async_id, status=status).put()
logging.debug("Marked Async complete using marker: %s.", key) | module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement expression_statement assignment identifier call attribute call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier | Persist a marker indicating the Async ran to the datastore. |
def load_corpus(path):
if not os.path.exists(path):
raise ValueError((
"'{}' dataset has not been downloaded, "
"use the yellowbrick.download module to fetch datasets"
).format(path))
categories = [
cat for cat in os.listdir(path)
if os.path.isdir(os.path.join(path, cat))
]
files = []
data = []
target = []
for cat in categories:
for name in os.listdir(os.path.join(path, cat)):
files.append(os.path.join(path, cat, name))
target.append(cat)
with open(os.path.join(path, cat, name), 'r') as f:
data.append(f.read())
return Bunch(
categories=categories,
files=files,
data=data,
target=target,
) | module function_definition identifier parameters identifier block if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block raise_statement call identifier argument_list call attribute parenthesized_expression concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier list_comprehension identifier for_in_clause identifier call attribute identifier identifier argument_list identifier if_clause call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement assignment identifier list expression_statement assignment identifier list expression_statement assignment identifier list for_statement identifier identifier block for_statement identifier call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier with_statement with_clause with_item as_pattern call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list return_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier | Loads and wrangles the passed in text corpus by path. |
def timeInfo(self):
time_info = self._json_struct.get('timeInfo', {})
if not time_info:
return None
time_info = time_info.copy()
if 'timeExtent' in time_info:
time_info['timeExtent'] = utils.timetopythonvalue(
time_info['timeExtent'])
return time_info | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end dictionary if_statement not_operator identifier block return_statement none expression_statement assignment identifier call attribute identifier identifier argument_list 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 call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end return_statement identifier | Return the time info for this Map Service |
def add_intf_router(self, rout_id, tenant_id, subnet_lst):
try:
for subnet_id in subnet_lst:
body = {'subnet_id': subnet_id}
intf = self.neutronclient.add_interface_router(rout_id,
body=body)
intf.get('port_id')
except Exception as exc:
LOG.error("Failed to create router intf ID %(id)s,"
" Exc %(exc)s", {'id': rout_id, 'exc': str(exc)})
return False
return True | module function_definition identifier parameters identifier identifier identifier identifier block try_statement block for_statement identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end call identifier argument_list identifier return_statement false return_statement true | Add the interfaces to a router. |
def submit_string(self):
required = []
optional = []
for file_verifier in self.file_verifiers:
if file_verifier.optional:
optional.append('[{0}]'.format(file_verifier.filename))
else:
required.append(file_verifier.filename)
return ' '.join(sorted(required) + sorted(optional)) | module function_definition identifier parameters identifier block expression_statement assignment identifier list expression_statement assignment identifier list for_statement identifier attribute identifier identifier block if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list attribute identifier identifier return_statement call attribute string string_start string_content string_end identifier argument_list binary_operator call identifier argument_list identifier call identifier argument_list identifier | Return a string specifying the files to submit for this project. |
def _serialize(self, uri, node):
meta = self._decode_meta(node['meta'], is_published=bool(node['is_published']))
return {
'uri': uri.clone(ext=node['plugin'], version=node['version']),
'content': node['content'],
'meta': meta
} | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end keyword_argument identifier call identifier argument_list subscript identifier string string_start string_content string_end return_statement dictionary pair string string_start string_content string_end call attribute identifier identifier argument_list keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end pair string string_start string_content string_end subscript identifier string string_start string_content string_end pair string string_start string_content string_end identifier | Serialize node result as dict |
def feed_data(self, data):
if data:
self._bytes.append(data)
if self.parser.stream:
self.parser.stream(self)
else:
self.parser.buffer.extend(data) | module function_definition identifier parameters identifier identifier block if_statement identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier if_statement attribute attribute identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier else_clause block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier | Feed new data into the MultiPart parser or the data stream |
def dKdiag_dX(self, dL_dKdiag, X, target):
target += 2.*self.mapping.df_dX(dL_dKdiag[:, None], X)*self.mapping.f(X) | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement augmented_assignment identifier binary_operator binary_operator float call attribute attribute identifier identifier identifier argument_list subscript identifier slice none identifier call attribute attribute identifier identifier identifier argument_list identifier | Gradient of diagonal of covariance with respect to X. |
def _set_combobox(self, attrname, vals, default=0):
combobox = getattr(self.w, attrname)
for val in vals:
combobox.append_text(val)
if default > len(vals):
default = 0
val = vals[default]
combobox.show_text(val)
return val | module function_definition identifier parameters identifier identifier identifier default_parameter identifier integer block expression_statement assignment identifier call identifier argument_list attribute identifier identifier identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier call identifier argument_list identifier block expression_statement assignment identifier integer expression_statement assignment identifier subscript identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | Populate combobox with given list. |
def format_output(self, rendered_widgets):
ret = [u'<ul class="formfield">']
for i, field in enumerate(self.fields):
label = self.format_label(field, i)
help_text = self.format_help_text(field, i)
ret.append(u'<li>%s %s %s</li>' % (
label, rendered_widgets[i], field.help_text and help_text))
ret.append(u'</ul>')
return ''.join(ret) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list string string_start string_content string_end for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier subscript identifier identifier boolean_operator attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement call attribute string string_start string_end identifier argument_list identifier | This output will yeild all widgets grouped in a un-ordered list |
def transformFilter(actor, transformation):
tf = vtk.vtkTransformPolyDataFilter()
tf.SetTransform(transformation)
prop = None
if isinstance(actor, vtk.vtkPolyData):
tf.SetInputData(actor)
else:
tf.SetInputData(actor.polydata())
prop = vtk.vtkProperty()
prop.DeepCopy(actor.GetProperty())
tf.Update()
tfa = Actor(tf.GetOutput())
if prop:
tfa.SetProperty(prop)
return tfa | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier none if_statement call identifier argument_list identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | Transform a ``vtkActor`` and return a new object. |
def create_entity_type(project_id, display_name, kind):
import dialogflow_v2 as dialogflow
entity_types_client = dialogflow.EntityTypesClient()
parent = entity_types_client.project_agent_path(project_id)
entity_type = dialogflow.types.EntityType(
display_name=display_name, kind=kind)
response = entity_types_client.create_entity_type(parent, entity_type)
print('Entity type created: \n{}'.format(response)) | module function_definition identifier parameters identifier identifier identifier block import_statement aliased_import dotted_name identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier expression_statement assignment identifier call attribute identifier 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 | Create an entity type with the given display name. |
def where(self, relation, filter_fn):
assert type(relation).__name__ in {'str','unicode'}, 'where needs the first arg to be a string'
assert callable(filter_fn), 'filter_fn needs to be callable'
return VList(i for i in self if relation in i._relations() and any(filter_fn(_()) for _ in i[relation])) | module function_definition identifier parameters identifier identifier identifier block assert_statement comparison_operator attribute call identifier argument_list identifier identifier set string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end assert_statement call identifier argument_list identifier string string_start string_content string_end return_statement call identifier generator_expression identifier for_in_clause identifier identifier if_clause boolean_operator comparison_operator identifier call attribute identifier identifier argument_list call identifier generator_expression call identifier argument_list call identifier argument_list for_in_clause identifier subscript identifier identifier | use this to filter VLists, simply provide a filter function and what relation to apply it to |
def makedirs(self, path):
root = ""
assert path.startswith('/')
p = path.strip('/')
for item in p.split('/'):
root += "/" + item
if not self.exists(root):
self.makedir(root)
return self.find(path) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier string string_start string_end assert_statement 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 for_statement identifier call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement augmented_assignment identifier binary_operator string string_start string_content string_end identifier if_statement not_operator call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier | Recursive storage DirEntry creation function. |
def add(self, value):
ind = int(self._ind % self.shape)
self._pos = self._ind % self.shape
self._values[ind] = value
if self._ind < self.shape:
self._ind += 1
else:
self._ind += self._splitValue
self._splitPos += self._splitValue
self._cached = False | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list binary_operator attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier binary_operator attribute identifier identifier attribute identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement augmented_assignment attribute identifier identifier integer else_clause block expression_statement augmented_assignment attribute identifier identifier attribute identifier identifier expression_statement augmented_assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier false | Add a value to the buffer. |
def _loadSession(self, filename):
try:
self.eval(open(filename).read())
except RuntimeError as e:
print(e) | module function_definition identifier parameters identifier identifier block try_statement block expression_statement call attribute identifier identifier argument_list call attribute call identifier argument_list identifier identifier argument_list except_clause as_pattern identifier as_pattern_target identifier block expression_statement call identifier argument_list identifier | Load a recorded session. |
def coerce(cls, key, value):
if not isinstance(value, MutationList):
if isinstance(value, list):
return MutationList(value)
return Mutable.coerce(key, value)
else:
return value | module function_definition identifier parameters identifier identifier identifier block if_statement not_operator call identifier argument_list identifier identifier block if_statement call identifier argument_list identifier identifier block return_statement call identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier identifier else_clause block return_statement identifier | Convert list to MutationList. |
def ladders(session, game_id):
if isinstance(game_id, str):
game_id = lookup_game_id(game_id)
lobbies = get_lobbies(session, game_id)
ladder_ids = set()
for lobby in lobbies:
ladder_ids |= set(lobby['ladders'])
return list(ladder_ids) | module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list for_statement identifier identifier block expression_statement augmented_assignment identifier call identifier argument_list subscript identifier string string_start string_content string_end return_statement call identifier argument_list identifier | Get a list of ladder IDs. |
def element_id_by_label(browser, label):
label = XPathSelector(browser,
unicode('//label[contains(., "%s")]' % label))
if not label:
return False
return label.get_attribute('for') | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier call identifier argument_list binary_operator string string_start string_content string_end identifier if_statement not_operator identifier block return_statement false return_statement call attribute identifier identifier argument_list string string_start string_content string_end | Return the id of a label's for attribute |
def clean(self):
if os.path.exists(self.buildroot):
log.info('Clearing the build area.')
log.debug('Deleting: %s', self.buildroot)
shutil.rmtree(self.buildroot)
os.makedirs(self.buildroot) | module function_definition identifier parameters identifier block if_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier | Clear the contents of the build area. |
def cublasCtrmv(handle, uplo, trans, diag, n, A, lda, x, incx):
status = _libcublas.cublasCtrmv_v2(handle,
_CUBLAS_FILL_MODE[uplo],
_CUBLAS_OP[trans],
_CUBLAS_DIAG[diag],
n, int(A), lda, int(x), incx)
cublasCheckStatus(status) | module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier subscript identifier identifier subscript identifier identifier subscript identifier identifier identifier call identifier argument_list identifier identifier call identifier argument_list identifier identifier expression_statement call identifier argument_list identifier | Matrix-vector product for complex triangular matrix. |
def covars_(self):
return fill_covars(self._covars_, self.covariance_type,
self.n_components, self.n_features) | module function_definition identifier parameters identifier block return_statement call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier | Return covars as a full matrix. |
def _subclassed(base, *classes):
return all(map(lambda obj: isinstance(obj, base), classes)) | module function_definition identifier parameters identifier list_splat_pattern identifier block return_statement call identifier argument_list call identifier argument_list lambda lambda_parameters identifier call identifier argument_list identifier identifier identifier | Check if all classes are subclassed from base. |
def flush(self, meta=None):
pattern = self.basekey(meta) if meta else self.namespace
return self.client.delpattern('%s*' % pattern) | module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier conditional_expression call attribute identifier identifier argument_list identifier identifier attribute identifier identifier return_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end identifier | Flush all model keys from the database |
def _rle_decode(data):
if not data:
return data
new = b''
last = b''
for cur in data:
if last == b'\0':
new += last * cur
last = b''
else:
new += last
last = bytes([cur])
return new + last | module function_definition identifier parameters identifier block if_statement not_operator identifier block return_statement identifier expression_statement assignment identifier string string_start string_end expression_statement assignment identifier string string_start string_end for_statement identifier identifier block if_statement comparison_operator identifier string string_start string_content escape_sequence string_end block expression_statement augmented_assignment identifier binary_operator identifier identifier expression_statement assignment identifier string string_start string_end else_clause block expression_statement augmented_assignment identifier identifier expression_statement assignment identifier call identifier argument_list list identifier return_statement binary_operator identifier identifier | Decodes run-length-encoded `data`. |
def contains_pts(self, pts):
obj1, obj2 = self.objects
arg1 = obj2.contains_pts(pts)
arg2 = np.logical_not(obj1.contains_pts(pts))
return np.logical_and(arg1, arg2) | module function_definition identifier parameters identifier identifier block expression_statement assignment pattern_list identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier identifier | Containment test on arrays. |
def match(self, device):
return all(match_value(getattr(device, k), v)
for k, v in self._match.items()) | module function_definition identifier parameters identifier identifier block return_statement call identifier generator_expression call identifier argument_list call identifier argument_list identifier identifier identifier for_in_clause pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list | Check if the device object matches this filter. |
def generate_proxy(
prefix, base_url='', verify_ssl=True, middleware=None,
append_middleware=None, cert=None, timeout=None):
middleware = list(middleware or HttpProxy.proxy_middleware)
middleware += list(append_middleware or [])
return type('ProxyClass', (HttpProxy,), {
'base_url': base_url,
'reverse_urls': [(prefix, base_url)],
'verify_ssl': verify_ssl,
'proxy_middleware': middleware,
'cert': cert,
'timeout': timeout
}) | module function_definition identifier parameters identifier default_parameter identifier string string_start string_end default_parameter identifier true default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier call identifier argument_list boolean_operator identifier attribute identifier identifier expression_statement augmented_assignment identifier call identifier argument_list boolean_operator identifier list return_statement call identifier argument_list string string_start string_content string_end tuple identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end list tuple identifier identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier | Generate a ProxyClass based view that uses the passed base_url. |
def _new_mock_response(self, response, file_path):
mock_response = copy.copy(response)
mock_response.body = Body(open(file_path, 'rb'))
mock_response.fields = NameValueRecord()
for name, value in response.fields.get_all():
mock_response.fields.add(name, value)
mock_response.fields['Content-Type'] = 'text/html; charset="utf-8"'
return mock_response | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier call identifier argument_list call identifier argument_list identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier call identifier argument_list for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end return_statement identifier | Return a new mock Response with the content. |
def git_tag(repo_dir, tagname, message=None, force=True):
message = message or "%s" % tagname
command = ['git', 'tag', '--annotate', '--message', message]
if force:
command.append('--force')
command.append(tagname)
return execute_git_command(command, repo_dir=repo_dir) | module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier true block expression_statement assignment identifier boolean_operator identifier binary_operator string string_start string_content string_end identifier expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier return_statement call identifier argument_list identifier keyword_argument identifier identifier | Create an annotated tag at the current head. |
def _convert_date_time_string(dt_string):
dt_string = dt_string.split('.')[0]
dt_obj = datetime.strptime(dt_string, '%Y%m%d%H%M%S')
return dt_obj.strftime('%Y-%m-%d %H:%M:%S') | module function_definition identifier parameters identifier block expression_statement assignment identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end return_statement call attribute identifier identifier argument_list string string_start string_content string_end | convert string to date time object |
def bitop_not(self, dest, key):
return self.execute(b'BITOP', b'NOT', dest, key) | module function_definition identifier parameters identifier identifier identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier identifier | Perform bitwise NOT operations between strings. |
def parse_row(self, row, row_index, cell_mode=CellMode.cooked):
return [self.parse_cell(cell, (col_index, row_index), cell_mode) \
for col_index, cell in enumerate(row)] | module function_definition identifier parameters identifier identifier identifier default_parameter identifier attribute identifier identifier block return_statement list_comprehension call attribute identifier identifier argument_list identifier tuple identifier identifier identifier line_continuation for_in_clause pattern_list identifier identifier call identifier argument_list identifier | Parse a row according to the given cell_mode. |
def connect(self, host, port):
self._connected = False
self._host = "%s:%d" % (host, port)
self._closed = False
self._close_info = {
'reply_code': 0,
'reply_text': 'failed to connect to %s' % (self._host),
'class_id': 0,
'method_id': 0
}
self._transport.connect((host, port))
self._transport.write(PROTOCOL_HEADER)
self._last_octet_time = time.time()
if self._synchronous_connect:
self._channels[0].add_synchronous_cb(self._channels[0]._recv_start)
while not self._connected:
self.read_frames() | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment attribute identifier identifier false expression_statement assignment attribute identifier identifier binary_operator string string_start string_content string_end tuple identifier identifier expression_statement assignment attribute identifier identifier false expression_statement assignment attribute identifier identifier dictionary pair string string_start string_content string_end integer pair string string_start string_content string_end binary_operator string string_start string_content string_end parenthesized_expression attribute identifier identifier pair string string_start string_content string_end integer pair string string_start string_content string_end integer expression_statement call attribute attribute identifier identifier identifier argument_list tuple identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list if_statement attribute identifier identifier block expression_statement call attribute subscript attribute identifier identifier integer identifier argument_list attribute subscript attribute identifier identifier integer identifier while_statement not_operator attribute identifier identifier block expression_statement call attribute identifier identifier argument_list | Connect to a host and port. |
def hold_policy(document, policy, server=False):
old_policy = document._hold
document._hold = policy
try:
yield
finally:
if server and not old_policy:
document.unhold()
else:
document._hold = old_policy | module function_definition identifier parameters identifier identifier default_parameter identifier false block expression_statement assignment identifier attribute identifier identifier expression_statement assignment attribute identifier identifier identifier try_statement block expression_statement yield finally_clause block if_statement boolean_operator identifier not_operator identifier block expression_statement call attribute identifier identifier argument_list else_clause block expression_statement assignment attribute identifier identifier identifier | Context manager to temporary override the hold policy. |
def _version_less_than_or_equal_to(self, v1, v2):
from distutils.version import LooseVersion
return LooseVersion(v1) <= LooseVersion(v2) | module function_definition identifier parameters identifier identifier identifier block import_from_statement dotted_name identifier identifier dotted_name identifier return_statement comparison_operator call identifier argument_list identifier call identifier argument_list identifier | Returns true if v1 <= v2. |
def backtrack(self, source):
key = self.get_tok(source)
s = self[key]()
meta = s.metadata['original_source']
cls = meta['cls']
args = meta['args']
kwargs = meta['kwargs']
cls = import_name(cls)
sout = cls(*args, **kwargs)
sout.metadata = s.metadata['original_metadata']
sout.name = s.metadata['original_name']
return sout | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call subscript identifier identifier argument_list expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list list_splat identifier dictionary_splat identifier expression_statement assignment attribute identifier identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier subscript attribute identifier identifier string string_start string_content string_end return_statement identifier | Given a unique key in the store, recreate original source |
def on_rule(self, *args):
if self.rule is None:
return
self.rule.connect(self._listen_to_rule) | module function_definition identifier parameters identifier list_splat_pattern identifier block if_statement comparison_operator attribute identifier identifier none block return_statement expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier | Make sure to update when the rule changes |
def standard_block(self, _bytes):
self.out(self.BLOCK_STANDARD)
self.out(self.LH(1000))
self.out(self.LH(len(_bytes) + 1))
checksum = 0
for i in _bytes:
checksum ^= (int(i) & 0xFF)
self.out(i)
self.out(checksum) | 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 call attribute identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list binary_operator call identifier argument_list identifier integer expression_statement assignment identifier integer for_statement identifier identifier block expression_statement augmented_assignment identifier parenthesized_expression binary_operator call identifier argument_list identifier integer expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier | Adds a standard block of bytes |
def _run_lint_on_file_stamped(*args):
stamp_args, stamp_kwargs = _run_lint_on_file_stamped_args(*args,
**{})
return jobstamp.run(_run_lint_on_file_exceptions,
*stamp_args,
**stamp_kwargs) | module function_definition identifier parameters list_splat_pattern identifier block expression_statement assignment pattern_list identifier identifier call identifier argument_list list_splat identifier dictionary_splat dictionary return_statement call attribute identifier identifier argument_list identifier list_splat identifier dictionary_splat identifier | Run linter functions on file_path, stamping in stamp_file_path. |
def dim_range_key(eldim):
if isinstance(eldim, dim):
dim_name = repr(eldim)
if dim_name.startswith("'") and dim_name.endswith("'"):
dim_name = dim_name[1:-1]
else:
dim_name = eldim.name
return dim_name | module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement boolean_operator call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier subscript identifier slice integer unary_operator integer else_clause block expression_statement assignment identifier attribute identifier identifier return_statement identifier | Returns the key to look up a dimension range. |
def _summarize_o_mutation_type(model):
from nautilus.api.util import summarize_mutation_io
object_type_name = get_model_string(model)
return summarize_mutation_io(
name=object_type_name,
type=_summarize_object_type(model),
required=False
) | module function_definition identifier parameters identifier block import_from_statement dotted_name identifier identifier identifier dotted_name identifier expression_statement assignment identifier call identifier argument_list identifier return_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier call identifier argument_list identifier keyword_argument identifier false | This function create the actual mutation io summary corresponding to the model |
def getidfkeyswithnodes():
idf = IDF(StringIO(""))
keys = idfobjectkeys(idf)
keysfieldnames = ((key, idf.newidfobject(key.upper()).fieldnames)
for key in keys)
keysnodefdnames = ((key, (name for name in fdnames
if (name.endswith('Node_Name'))))
for key, fdnames in keysfieldnames)
nodekeys = [key for key, fdnames in keysnodefdnames if list(fdnames)]
return nodekeys | module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list call identifier argument_list string string_start string_end expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier generator_expression tuple identifier attribute call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier for_in_clause identifier identifier expression_statement assignment identifier generator_expression tuple identifier generator_expression identifier for_in_clause identifier identifier if_clause parenthesized_expression call attribute identifier identifier argument_list string string_start string_content string_end for_in_clause pattern_list identifier identifier identifier expression_statement assignment identifier list_comprehension identifier for_in_clause pattern_list identifier identifier identifier if_clause call identifier argument_list identifier return_statement identifier | return a list of keys of idfobjects that hve 'None Name' fields |
def _viewset_results(self):
results = []
try:
response = self._viewset_method(
self._viewset.request, *self._request.args, **self._request.kwargs
)
if response.status_code == 200:
results = response.data
if not isinstance(results, list):
if isinstance(results, dict):
if 'results' in results and isinstance(
results['results'], list
):
results = results['results']
else:
results.setdefault(self._meta.primary_key, 1)
results = [collections.OrderedDict(results)]
else:
raise ValueError(
"Observable views must return a dictionary or a list of dictionaries!"
)
except Http404:
pass
except django_exceptions.ObjectDoesNotExist:
pass
return results | module function_definition identifier parameters identifier block expression_statement assignment identifier list try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier list_splat attribute attribute identifier identifier identifier dictionary_splat attribute attribute identifier identifier identifier if_statement comparison_operator attribute identifier identifier integer block expression_statement assignment identifier attribute identifier identifier if_statement not_operator call identifier argument_list identifier identifier block if_statement call identifier argument_list identifier identifier block if_statement boolean_operator comparison_operator string string_start string_content string_end identifier call identifier argument_list subscript identifier string string_start string_content string_end identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end else_clause block expression_statement call attribute identifier identifier argument_list attribute attribute identifier identifier identifier integer expression_statement assignment identifier list call attribute identifier identifier argument_list identifier else_clause block raise_statement call identifier argument_list string string_start string_content string_end except_clause identifier block pass_statement except_clause attribute identifier identifier block pass_statement return_statement identifier | Parse results from the viewset response. |
def VSInstallDir(self):
name = 'Microsoft Visual Studio %0.1f' % self.vc_ver
default = os.path.join(self.ProgramFilesx86, name)
return self.ri.lookup(self.ri.vs, '%0.1f' % self.vc_ver) or default | module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier return_statement boolean_operator call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier binary_operator string string_start string_content string_end attribute identifier identifier identifier | Microsoft Visual Studio directory. |
def submit_form_id(step, id):
form = world.browser.find_element_by_xpath(str('id("{id}")'.format(id=id)))
form.submit() | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list | Submit the form having given id. |
def count_empty(self, field):
try:
df2 = self.df[[field]]
vals = where(df2.applymap(lambda x: x == ''))
num = len(vals[0])
except Exception as e:
self.err(e, "Can not count empty values")
return
self.ok("Found", num, "empty rows in column " + field) | module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment identifier subscript attribute identifier identifier list identifier expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list lambda lambda_parameters identifier comparison_operator identifier string string_start string_end expression_statement assignment identifier call identifier argument_list subscript identifier integer except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier string string_start string_content string_end return_statement expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier binary_operator string string_start string_content string_end identifier | List of empty row indices |
def display_list(prefix, l, color):
for itm in l: print colored(prefix + itm['path'], color) | module function_definition identifier parameters identifier identifier identifier block for_statement identifier identifier block print_statement call identifier argument_list binary_operator identifier subscript identifier string string_start string_content string_end identifier | Prints a file list to terminal, allows colouring output. |
def impact_parameter(a, R, inc, ecc=0, w=0, return_occ=False):
b_tra = a*AU*np.cos(inc)/(R*RSUN) * (1-ecc**2)/(1 + ecc*np.sin(w))
if return_occ:
b_tra = a*AU*np.cos(inc)/(R*RSUN) * (1-ecc**2)/(1 - ecc*np.sin(w))
return b_tra, b_occ
else:
return b_tra | module function_definition identifier parameters identifier identifier identifier default_parameter identifier integer default_parameter identifier integer default_parameter identifier false block expression_statement assignment identifier binary_operator binary_operator binary_operator binary_operator binary_operator identifier identifier call attribute identifier identifier argument_list identifier parenthesized_expression binary_operator identifier identifier parenthesized_expression binary_operator integer binary_operator identifier integer parenthesized_expression binary_operator integer binary_operator identifier call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement assignment identifier binary_operator binary_operator binary_operator binary_operator binary_operator identifier identifier call attribute identifier identifier argument_list identifier parenthesized_expression binary_operator identifier identifier parenthesized_expression binary_operator integer binary_operator identifier integer parenthesized_expression binary_operator integer binary_operator identifier call attribute identifier identifier argument_list identifier return_statement expression_list identifier identifier else_clause block return_statement identifier | a in AU, R in Rsun, inc & w in radians |
def route(obj, rule, *args, **kwargs):
def decorator(cls):
endpoint = kwargs.get('endpoint', camel_to_snake(cls.__name__))
kwargs['view_func'] = cls.as_view(endpoint)
obj.add_url_rule(rule, *args, **kwargs)
return cls
return decorator | module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier list_splat identifier dictionary_splat identifier return_statement identifier return_statement identifier | Decorator for the View classes. |
def _assemble_regulate_amount(stmt):
obj_str = _assemble_agent_str(stmt.obj)
if stmt.subj is not None:
subj_str = _assemble_agent_str(stmt.subj)
if isinstance(stmt, ist.IncreaseAmount):
rel_str = ' increases the amount of '
elif isinstance(stmt, ist.DecreaseAmount):
rel_str = ' decreases the amount of '
stmt_str = subj_str + rel_str + obj_str
else:
if isinstance(stmt, ist.IncreaseAmount):
stmt_str = obj_str + ' is produced'
elif isinstance(stmt, ist.DecreaseAmount):
stmt_str = obj_str + ' is degraded'
return _make_sentence(stmt_str) | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier call identifier argument_list attribute identifier identifier if_statement call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier string string_start string_content string_end elif_clause call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier binary_operator binary_operator identifier identifier identifier else_clause block if_statement call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier binary_operator identifier string string_start string_content string_end elif_clause call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier binary_operator identifier string string_start string_content string_end return_statement call identifier argument_list identifier | Assemble RegulateAmount statements into text. |
def getPitchForIntervals(data, tgFN, tierName):
tg = tgio.openTextgrid(tgFN)
data = tg.tierDict[tierName].getValuesInIntervals(data)
data = [dataList for _, dataList in data]
return data | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute subscript attribute identifier identifier identifier identifier argument_list identifier expression_statement assignment identifier list_comprehension identifier for_in_clause pattern_list identifier identifier identifier return_statement identifier | Preps data for use in f0Morph |
def createElement(self, token):
name = token["name"]
namespace = token.get("namespace", self.defaultNamespace)
element = self.elementClass(name, namespace)
element.attributes = token["data"]
return element | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript 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 expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end return_statement identifier | Create an element but don't insert it anywhere |
def check_threat_timeout(self):
for id in self.threat_vehicles.keys():
if self.threat_vehicles[id].update_time == 0:
self.threat_vehicles[id].update_time = self.get_time()
dt = self.get_time() - self.threat_vehicles[id].update_time
if dt > self.ADSB_settings.timeout:
del self.threat_vehicles[id]
for mp in self.module_matching('map*'):
mp.map.remove_object(id)
mp.map.remove_object(id+":circle")
return | module function_definition identifier parameters identifier block for_statement identifier call attribute attribute identifier identifier identifier argument_list block if_statement comparison_operator attribute subscript attribute identifier identifier identifier identifier integer block expression_statement assignment attribute subscript attribute identifier identifier identifier identifier call attribute identifier identifier argument_list expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list attribute subscript attribute identifier identifier identifier identifier if_statement comparison_operator identifier attribute attribute identifier identifier identifier block delete_statement subscript attribute identifier identifier identifier for_statement identifier call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator identifier string string_start string_content string_end return_statement | check and handle threat time out |
def fill_view(self, view):
other = view.hist
_other_x_center = other.axis(0).GetBinCenter
_other_y_center = other.axis(1).GetBinCenter
_other_z_center = other.axis(2).GetBinCenter
_other_get = other.GetBinContent
_other_get_bin = super(_HistBase, other).GetBin
other_sum_w2 = other.GetSumw2()
_other_sum_w2_at = other_sum_w2.At
_find = self.FindBin
sum_w2 = self.GetSumw2()
_sum_w2_at = sum_w2.At
_sum_w2_setat = sum_w2.SetAt
_set = self.SetBinContent
_get = self.GetBinContent
for x, y, z in view.points:
idx = _find(
_other_x_center(x),
_other_y_center(y),
_other_z_center(z))
other_idx = _other_get_bin(x, y, z)
_set(idx, _get(idx) + _other_get(other_idx))
_sum_w2_setat(
_sum_w2_at(idx) + _other_sum_w2_at(other_idx),
idx) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute call attribute identifier identifier argument_list integer identifier expression_statement assignment identifier attribute call attribute identifier identifier argument_list integer identifier expression_statement assignment identifier attribute call attribute identifier identifier argument_list integer identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute call identifier argument_list identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier for_statement pattern_list identifier identifier identifier attribute identifier identifier block expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier call identifier argument_list identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier expression_statement call identifier argument_list identifier binary_operator call identifier argument_list identifier call identifier argument_list identifier expression_statement call identifier argument_list binary_operator call identifier argument_list identifier call identifier argument_list identifier identifier | Fill this histogram from a view of another histogram |
def curve(self):
return HelicalCurve.pitch_and_radius(
self.major_pitch, self.major_radius,
handedness=self.major_handedness) | module function_definition identifier parameters identifier block return_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier | Curve of the super helix. |
def from_iterable(cls, iterable: Iterable) -> 'List':
iterator = iter(iterable)
def recurse() -> List:
try:
value = next(iterator)
except StopIteration:
return List.empty()
return List.unit(value).append(recurse())
return List.empty().append(recurse()) | module function_definition identifier parameters identifier typed_parameter identifier type identifier type string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list identifier function_definition identifier parameters type identifier block try_statement block expression_statement assignment identifier call identifier argument_list identifier except_clause identifier block return_statement call attribute identifier identifier argument_list return_statement call attribute call attribute identifier identifier argument_list identifier identifier argument_list call identifier argument_list return_statement call attribute call attribute identifier identifier argument_list identifier argument_list call identifier argument_list | Create list from iterable. |
def returner(ret):
try:
with _get_serv(ret, commit=True) as cur:
sql =
cur.execute(sql, (ret['fun'], ret['jid'],
psycopg2.extras.Json(ret['return']),
ret['id'],
ret.get('success', False),
psycopg2.extras.Json(ret),
time.time()))
except salt.exceptions.SaltMasterError:
log.critical('Could not store return with pgjsonb returner. PostgreSQL server unavailable.') | module function_definition identifier parameters identifier block try_statement block with_statement with_clause with_item as_pattern call identifier argument_list identifier keyword_argument identifier true as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier tuple subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end false call attribute attribute identifier identifier identifier argument_list identifier call attribute identifier identifier argument_list except_clause attribute attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end | Return data to a Pg server |
def icanhazascii(client, channel, nick, message, found):
global FLOOD_RATE, LAST_USED
now = time.time()
if channel in LAST_USED and (now - LAST_USED[channel]) < FLOOD_RATE:
return
LAST_USED[channel] = now
return found | module function_definition identifier parameters identifier identifier identifier identifier identifier block global_statement identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement boolean_operator comparison_operator identifier identifier comparison_operator parenthesized_expression binary_operator identifier subscript identifier identifier identifier block return_statement expression_statement assignment subscript identifier identifier identifier return_statement identifier | A plugin for generating showing ascii artz |
def _import(func):
func_name = func.__name__
if func_name in globals():
return func_name
module_name = func.__module__
submodules = module_name.split('.')
if submodules[0] in globals():
return module_name + '.' + func_name
for i in range(len(submodules)):
m = submodules[i]
if m in globals():
return '.'.join(submodules[i:]) + '.' + func_name
module_ref = sys.modules[func.__module__]
all_globals = globals()
for n in all_globals:
if all_globals[n] == module_ref:
return n + '.' + func_name
return func_name | module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier call identifier argument_list block return_statement identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator subscript identifier integer call identifier argument_list block return_statement binary_operator binary_operator identifier string string_start string_content string_end identifier for_statement identifier call identifier argument_list call identifier argument_list identifier block expression_statement assignment identifier subscript identifier identifier if_statement comparison_operator identifier call identifier argument_list block return_statement binary_operator binary_operator call attribute string string_start string_content string_end identifier argument_list subscript identifier slice identifier string string_start string_content string_end identifier expression_statement assignment identifier subscript attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list for_statement identifier identifier block if_statement comparison_operator subscript identifier identifier identifier block return_statement binary_operator binary_operator identifier string string_start string_content string_end identifier return_statement identifier | Return the namespace path to the function |
def remove_for_target(self, target, classpath_elements):
self._classpaths.remove_for_target(target, self._wrap_path_elements(classpath_elements)) | module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier | Removes the given entries for the target. |
def create_proteinquant_lookup(fns, pqdb, poolnames, protacc_colnr,
ms1_qcolpattern=None, isobqcolpattern=None,
psmnrpattern=None, probcolpattern=None,
fdrcolpattern=None, pepcolpattern=None):
patterns = [ms1_qcolpattern, probcolpattern, fdrcolpattern, pepcolpattern]
storefuns = [pqdb.store_precursor_quants, pqdb.store_probability,
pqdb.store_fdr, pqdb.store_pep]
create_pep_protein_quant_lookup(fns, pqdb, poolnames, protacc_colnr,
patterns, storefuns, isobqcolpattern,
psmnrpattern) | module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier list identifier identifier identifier identifier expression_statement assignment identifier list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement call identifier argument_list identifier identifier identifier identifier identifier identifier identifier identifier | Calls lower level function to create a protein quant lookup |
def run(samples, run_parallel):
to_process = []
extras = []
for data in (xs[0] for xs in samples):
hlacaller = tz.get_in(["config", "algorithm", "hlacaller"], data)
if hlacaller:
to_process.append(data)
else:
extras.append([data])
processed = run_parallel("call_hla", ([x] for x in to_process))
return extras + processed | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list expression_statement assignment identifier list for_statement identifier generator_expression subscript identifier integer for_in_clause identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list list identifier expression_statement assignment identifier call identifier argument_list string string_start string_content string_end generator_expression list identifier for_in_clause identifier identifier return_statement binary_operator identifier identifier | Run HLA detection on the input samples. |
def validate_name(err, value, source):
'Tests a manifest name value for trademarks.'
ff_pattern = re.compile('(mozilla|firefox)', re.I)
err.metadata['name'] = value
if ff_pattern.search(value):
err.warning(
('metadata_helpers', '_test_name', 'trademark'),
'Add-on has potentially illegal name.',
'Add-on names cannot contain the Mozilla or Firefox '
'trademarks. These names should not be contained in add-on '
'names if at all possible.',
source) | module function_definition identifier parameters identifier identifier identifier block expression_statement 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 expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end identifier if_statement call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier | Tests a manifest name value for trademarks. |
def _guess_type(self, full_path):
magic = self._match_magic(full_path)
if magic is not None:
return (mimetypes.guess_type(magic.old_path(full_path))[0]
or 'text/plain')
else:
return mimetypes.guess_type(full_path)[0] or 'text/plain' | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block return_statement parenthesized_expression boolean_operator subscript call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier integer string string_start string_content string_end else_clause block return_statement boolean_operator subscript call attribute identifier identifier argument_list identifier integer string string_start string_content string_end | Guess the mime type magically or using the mimetypes module. |
def store_file(self, folder, name):
path = os.path.join(folder, name)
length = self.headers['content-length']
with open(path, 'wb') as sample:
sample.write(self.rfile.read(int(length)))
return path | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier return_statement identifier | Stores the uploaded file in the given path. |
def wait_for_stats(self):
logging.debug("waiting for statistics to finish")
for job in self.stat_jobs:
job.get()
sleep(2) | module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement call identifier argument_list integer | Make sure all jobs are finished. |
def define_log_processors():
return [
structlog.processors.TimeStamper(fmt="iso"),
_structlog_default_keys_processor,
structlog.stdlib.PositionalArgumentsFormatter(),
structlog.processors.StackInfoRenderer(),
structlog.processors.format_exc_info,
] | module function_definition identifier parameters block return_statement list call attribute attribute identifier identifier identifier argument_list keyword_argument identifier string string_start string_content string_end identifier call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier | log processors that structlog executes before final rendering |
def find_associated_with_address(self, instance):
objects = []
objects += list(Project.objects.filter(address=instance))
objects += list(Organization.objects.filter(address=instance))
return objects | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list expression_statement augmented_assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier expression_statement augmented_assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier return_statement identifier | Returns list with projects and organizations associated with given address |
def page_title(step, title):
with AssertContextManager(step):
assert_equals(world.browser.title, title) | module function_definition identifier parameters identifier identifier block with_statement with_clause with_item call identifier argument_list identifier block expression_statement call identifier argument_list attribute attribute identifier identifier identifier identifier | Check that the page title matches the given one. |
def run_validators(self, values):
for val in values:
super(CommaSepFloatField, self).run_validators(val) | module function_definition identifier parameters identifier identifier block for_statement identifier identifier block expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list identifier | Run validators for each item separately. |
def _build_metric_list_to_collect(self, additional_metrics):
metrics_to_collect = {}
for default_metrics in itervalues(self.DEFAULT_METRICS):
metrics_to_collect.update(default_metrics)
for option in additional_metrics:
additional_metrics = self.AVAILABLE_METRICS.get(option)
if not additional_metrics:
if option in self.DEFAULT_METRICS:
self.log.warning(
u"`%s` option is deprecated. The corresponding metrics are collected by default.", option
)
else:
self.log.warning(
u"Failed to extend the list of metrics to collect: unrecognized `%s` option", option
)
continue
self.log.debug(u"Adding `%s` corresponding metrics to the list of metrics to collect.", option)
metrics_to_collect.update(additional_metrics)
return metrics_to_collect | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary for_statement identifier call identifier argument_list attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier for_statement identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement not_operator identifier block if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier continue_statement expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | Build the metric list to collect based on the instance preferences. |
def list_images(path=['.']):
for image_dir in set(path):
if not os.path.isdir(image_dir):
continue
for filename in os.listdir(image_dir):
bname, ext = os.path.splitext(filename)
if ext.lower() not in VALID_IMAGE_EXTS:
continue
filepath = os.path.join(image_dir, filename)
yield strutils.decode(filepath) | module function_definition identifier parameters default_parameter identifier list string string_start string_content string_end block for_statement identifier call identifier argument_list identifier block if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block continue_statement for_statement identifier call attribute identifier identifier argument_list identifier block expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator call attribute identifier identifier argument_list identifier block continue_statement expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement yield call attribute identifier identifier argument_list identifier | Return list of image files |
def query_paths(self):
output = self.namespace.alias_to_query_paths.get(self.name)
if output:
return output
Log.error("Can not find index {{index|quote}}", index=self.name) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier if_statement identifier block return_statement identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier attribute identifier identifier | RETURN A LIST OF ALL NESTED COLUMNS |
def UpdateProtoResources(self, status):
user_cpu = status.cpu_time_used.user_cpu_time
system_cpu = status.cpu_time_used.system_cpu_time
self.context.client_resources.cpu_usage.user_cpu_time += user_cpu
self.context.client_resources.cpu_usage.system_cpu_time += system_cpu
user_cpu_total = self.context.client_resources.cpu_usage.user_cpu_time
system_cpu_total = self.context.client_resources.cpu_usage.system_cpu_time
self.context.network_bytes_sent += status.network_bytes_sent
if self.runner_args.cpu_limit:
if self.runner_args.cpu_limit < (user_cpu_total + system_cpu_total):
raise FlowRunnerError("CPU limit exceeded.")
if self.runner_args.network_bytes_limit:
if (self.runner_args.network_bytes_limit <
self.context.network_bytes_sent):
raise FlowRunnerError("Network bytes limit exceeded.") | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement augmented_assignment attribute attribute attribute attribute identifier identifier identifier identifier identifier identifier expression_statement augmented_assignment attribute attribute attribute attribute identifier identifier identifier identifier identifier identifier expression_statement assignment identifier attribute attribute attribute attribute identifier identifier identifier identifier identifier expression_statement assignment identifier attribute attribute attribute attribute identifier identifier identifier identifier identifier expression_statement augmented_assignment attribute attribute identifier identifier identifier attribute identifier identifier if_statement attribute attribute identifier identifier identifier block if_statement comparison_operator attribute attribute identifier identifier identifier parenthesized_expression binary_operator identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement attribute attribute identifier identifier identifier block if_statement parenthesized_expression comparison_operator attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end | Save cpu and network stats, check limits. |
def robo_avatar_url(user_data, size=80):
hash = md5(str(user_data).strip().lower().encode('utf-8')).hexdigest()
url = "https://robohash.org/{hash}.png?size={size}x{size}".format(
hash=hash, size=size)
return url | module function_definition identifier parameters identifier default_parameter identifier integer block expression_statement assignment identifier call attribute call identifier argument_list call attribute call attribute call attribute call identifier argument_list identifier identifier argument_list identifier argument_list identifier argument_list string string_start string_content string_end identifier argument_list expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier return_statement identifier | Return the gravatar image for the given email address. |
def raw_message(self, message, silent=False):
vim = self._vim
cmd = 'echo "{}"'.format(message.replace('"', '\\"'))
if silent:
cmd = 'silent ' + cmd
if self.isneovim:
vim.async_call(vim.command, cmd)
else:
vim.command(cmd) | module function_definition identifier parameters identifier identifier default_parameter identifier false block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content escape_sequence string_end if_statement identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end identifier if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier | Display a message in the Vim status line. |
def list2dict(list_of_options):
d = {}
for key, value in list_of_options:
d[key] = value
return d | module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier identifier block expression_statement assignment subscript identifier identifier identifier return_statement identifier | Transforms a list of 2 element tuples to a dictionary |
def run(conf, only):
with errorprint():
config = ConfModule(conf)
spawned = config.spawn_uwsgi(only)
for alias, pid in spawned:
click.secho("Spawned uWSGI for configuration aliased '%s'. PID %s" % (alias, pid), fg='green') | module function_definition identifier parameters identifier identifier block with_statement with_clause with_item call identifier argument_list block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement pattern_list identifier identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier keyword_argument identifier string string_start string_content string_end | Runs uWSGI passing to it using the default or another `uwsgiconf` configuration module. |
def _filter_options(self, aliases=True, comments=True, historical=True):
options = []
if not aliases:
options.append('noaliases')
if not comments:
options.append('nocomments')
if not historical:
options.append('nohistorical')
return options | module function_definition identifier parameters identifier default_parameter identifier true default_parameter identifier true default_parameter identifier true block expression_statement assignment identifier list if_statement not_operator identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end if_statement not_operator identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end if_statement not_operator identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier | Converts a set of boolean-valued options into the relevant HTTP values. |
def printAggregateJobStats(self, properties, childNumber):
for job in self.jobsToReport:
lf = lambda x: "%s:%s" % (x, str(x in properties))
print("\t".join(("JOB:%s" % job,
"LOG_FILE:%s" % job.logJobStoreFileID,
"TRYS_REMAINING:%i" % job.remainingRetryCount,
"CHILD_NUMBER:%s" % childNumber,
lf("READY_TO_RUN"), lf("IS_ZOMBIE"),
lf("HAS_SERVICES"), lf("IS_SERVICE")))) | module function_definition identifier parameters identifier identifier identifier block for_statement identifier attribute identifier identifier block expression_statement assignment identifier lambda lambda_parameters identifier binary_operator string string_start string_content string_end tuple identifier call identifier argument_list comparison_operator identifier identifier expression_statement call identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list tuple binary_operator string string_start string_content string_end identifier binary_operator string string_start string_content string_end attribute identifier identifier binary_operator string string_start string_content string_end attribute identifier identifier binary_operator string string_start string_content string_end identifier call identifier argument_list string string_start string_content string_end call identifier argument_list string string_start string_content string_end call identifier argument_list string string_start string_content string_end call identifier argument_list string string_start string_content string_end | Prints a job's ID, log file, remaining tries, and other properties. |
def set(self, key, val):
data = self.get_data(True)
if data is not None:
data[key] = val
else:
raise RuntimeError("No task is currently running") | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list true if_statement comparison_operator identifier none block expression_statement assignment subscript identifier identifier identifier else_clause block raise_statement call identifier argument_list string string_start string_content string_end | Set value stored for current running task. |
async def send_http_response(writer,
http_code: int,
headers: List[Tuple[str, str]],
content: bytes,
http_status: str= None
) -> None:
if not http_status:
http_status = STATUS_CODES.get(http_code, 'Unknown')
response: bytes = f'HTTP/1.1 {http_code} {http_status}\r\n'.encode()
for k, v in headers:
response += f'{k}: {v}\r\n'.encode()
response += b'\r\n'
response += content
writer.write(response)
await writer.drain() | module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type generic_type identifier type_parameter type generic_type identifier type_parameter type identifier type identifier typed_parameter identifier type identifier typed_default_parameter identifier type identifier none type none block if_statement not_operator identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier type identifier call attribute string string_start string_content interpolation identifier string_content interpolation identifier string_content escape_sequence escape_sequence string_end identifier argument_list for_statement pattern_list identifier identifier identifier block expression_statement augmented_assignment identifier call attribute string string_start interpolation identifier string_content interpolation identifier string_content escape_sequence escape_sequence string_end identifier argument_list expression_statement augmented_assignment identifier string string_start string_content escape_sequence escape_sequence string_end expression_statement augmented_assignment identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement await call attribute identifier identifier argument_list | generate http response payload and send to writer |
def calculate_y_ticks(self, plot_height):
calibrated_data_min = self.calibrated_data_min
calibrated_data_max = self.calibrated_data_max
calibrated_data_range = calibrated_data_max - calibrated_data_min
ticker = self.y_ticker
y_ticks = list()
for tick_value, tick_label in zip(ticker.values, ticker.labels):
if calibrated_data_range != 0.0:
y_tick = plot_height - plot_height * (tick_value - calibrated_data_min) / calibrated_data_range
else:
y_tick = plot_height - plot_height * 0.5
if y_tick >= 0 and y_tick <= plot_height:
y_ticks.append((y_tick, tick_label))
return y_ticks | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier binary_operator identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier attribute identifier identifier block if_statement comparison_operator identifier float block expression_statement assignment identifier binary_operator identifier binary_operator binary_operator identifier parenthesized_expression binary_operator identifier identifier identifier else_clause block expression_statement assignment identifier binary_operator identifier binary_operator identifier float if_statement boolean_operator comparison_operator identifier integer comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list tuple identifier identifier return_statement identifier | Calculate the y-axis items dependent on the plot height. |
def performAction(self, action):
gs = [g for g in self.case.online_generators if g.bus.type !=REFERENCE]
assert len(action) == len(gs)
logger.info("Action: %s" % list(action))
for i, g in enumerate(gs):
g.p = action[i]
NewtonPF(self.case, verbose=False).solve()
self._Pg[:, self._step] = [g.p for g in self.case.online_generators]
if self._step != len(self.profile) - 1:
pq_buses = [b for b in self.case.buses if b.type == PQ]
for i, b in enumerate(pq_buses):
b.p_demand = self._Pd0[i] * self.profile[self._step + 1]
self._step += 1
logger.info("Entering step %d." % self._step) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list_comprehension identifier for_in_clause identifier attribute attribute identifier identifier identifier if_clause comparison_operator attribute attribute identifier identifier identifier identifier assert_statement comparison_operator call identifier argument_list identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement assignment attribute identifier identifier subscript identifier identifier expression_statement call attribute call identifier argument_list attribute identifier identifier keyword_argument identifier false identifier argument_list expression_statement assignment subscript attribute identifier identifier slice attribute identifier identifier list_comprehension attribute identifier identifier for_in_clause identifier attribute attribute identifier identifier identifier if_statement comparison_operator attribute identifier identifier binary_operator call identifier argument_list attribute identifier identifier integer block expression_statement assignment identifier list_comprehension identifier for_in_clause identifier attribute attribute identifier identifier identifier if_clause comparison_operator attribute identifier identifier identifier for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement assignment attribute identifier identifier binary_operator subscript attribute identifier identifier identifier subscript attribute identifier identifier binary_operator attribute identifier identifier integer expression_statement augmented_assignment attribute identifier identifier integer expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier | Perform an action on the world that changes it's internal state. |
def add_jardiff_optgroup(parser):
og = parser.add_argument_group("JAR Checking Options")
og.add_argument("--ignore-jar-entry", action="append", default=[])
og.add_argument("--ignore-jar-signature",
action="store_true", default=False,
help="Ignore JAR signing changes")
og.add_argument("--ignore-manifest",
action="store_true", default=False,
help="Ignore changes to manifests")
og.add_argument("--ignore-manifest-subsections",
action="store_true", default=False,
help="Ignore changes to manifest subsections")
og.add_argument("--ignore-manifest-key",
action="append", default=[],
help="case-insensitive manifest keys to ignore") | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier list 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 keyword_argument identifier false keyword_argument identifier string string_start string_content string_end 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 keyword_argument identifier false keyword_argument identifier string string_start string_content string_end 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 keyword_argument identifier false keyword_argument identifier string string_start string_content string_end 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 keyword_argument identifier list keyword_argument identifier string string_start string_content string_end | option group specific to the tests in jardiff |
def _get_pool(name=None, session=None):
if session is None:
session = _get_session()
pools = session.xenapi.pool.get_all()
for pool in pools:
pool_record = session.xenapi.pool.get_record(pool)
if name in pool_record.get('name_label'):
return pool
return None | module function_definition identifier parameters default_parameter identifier none default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list for_statement identifier identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier if_statement comparison_operator identifier call attribute identifier identifier argument_list string string_start string_content string_end block return_statement identifier return_statement none | Get XEN resource pool object reference |
def localize_field(self, value):
if self.default is not None:
if value is None or value == '':
value = self.default
return value or '' | module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier none block if_statement boolean_operator comparison_operator identifier none comparison_operator identifier string string_start string_end block expression_statement assignment identifier attribute identifier identifier return_statement boolean_operator identifier string string_start string_end | Method that must transform the value from object to localized string |
def add_warning (self, s, tag=None):
item = (tag, s)
if item not in self.warnings and \
tag not in self.aggregate.config["ignorewarnings"]:
self.warnings.append(item) | module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier tuple identifier identifier if_statement boolean_operator comparison_operator identifier attribute identifier identifier line_continuation comparison_operator identifier subscript attribute attribute identifier identifier identifier string string_start string_content string_end block expression_statement call attribute attribute identifier identifier identifier argument_list identifier | Add a warning string. |
def combine_reports(original, new):
if original is None:
return new
report = {}
report['name'] = original['name']
report['source_digest'] = original['source_digest']
coverage = []
for original_num, new_num in zip(original['coverage'], new['coverage']):
if original_num is None:
coverage.append(new_num)
elif new_num is None:
coverage.append(original_num)
else:
coverage.append(original_num + new_num)
report['coverage'] = coverage
return report | module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier none block return_statement identifier expression_statement assignment identifier dictionary expression_statement assignment subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement assignment identifier list for_statement pattern_list identifier identifier call identifier argument_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end block if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list identifier elif_clause comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list binary_operator identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier return_statement identifier | Combines two gcov reports for a file into one by adding the number of hits on each line |
def add_to_collection(self, request, pk=None):
entity = self.get_object()
if 'ids' not in request.data:
return Response({"error": "`ids` parameter is required"}, status=status.HTTP_400_BAD_REQUEST)
for collection_id in request.data['ids']:
self._get_collection_for_user(collection_id, request.user)
for collection_id in request.data['ids']:
entity.collections.add(collection_id)
collection = Collection.objects.get(pk=collection_id)
for data in entity.data.all():
collection.data.add(data)
return Response() | module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block return_statement call identifier argument_list dictionary pair string string_start string_content string_end string string_start string_content string_end keyword_argument identifier attribute identifier identifier for_statement identifier subscript attribute identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier for_statement identifier subscript attribute identifier identifier string string_start string_content string_end block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier for_statement identifier call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement call identifier argument_list | Add Entity to a collection. |
def create_superuser(self, email, password, **extra_fields):
extra_fields.setdefault('is_staff', True)
extra_fields.setdefault('is_superuser', True)
if extra_fields.get('is_staff') is not True:
raise ValueError('Superuser must have is_staff=True.')
if extra_fields.get('is_superuser') is not True:
raise ValueError('Superuser must have is_superuser=True.')
return self._create_user(email, password, **extra_fields) | module function_definition identifier parameters identifier identifier identifier dictionary_splat_pattern identifier block 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 true if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end true block raise_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end true block raise_statement call identifier argument_list string string_start string_content string_end return_statement call attribute identifier identifier argument_list identifier identifier dictionary_splat identifier | Save new User with is_staff and is_superuser set to True |
def use_any_status_composition_view(self):
self._operable_views['composition'] = ANY_STATUS
for session in self._get_provider_sessions():
try:
session.use_any_status_composition_view()
except AttributeError:
pass | module function_definition identifier parameters identifier block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end identifier for_statement identifier call attribute identifier identifier argument_list block try_statement block expression_statement call attribute identifier identifier argument_list except_clause identifier block pass_statement | Pass through to provider CompositionLookupSession.use_any_status_composition_view |
def fill_fw_dict_from_db(self, fw_data):
rule_dict = fw_data.get('rules').get('rules')
fw_dict = {'fw_id': fw_data.get('fw_id'),
'fw_name': fw_data.get('name'),
'firewall_policy_id': fw_data.get('firewall_policy_id'),
'fw_type': fw_data.get('fw_type'),
'router_id': fw_data.get('router_id'), 'rules': {}}
for rule in rule_dict:
fw_dict['rules'][rule] = rule_dict.get(rule)
return fw_dict | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier argument_list string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end pair string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end pair string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end pair string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end pair string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end pair string string_start string_content string_end dictionary for_statement identifier identifier block expression_statement assignment subscript subscript identifier string string_start string_content string_end identifier call attribute identifier identifier argument_list identifier return_statement identifier | This routine is called to create a local fw_dict with data from DB. |
def day_start(self):
day_start_minutes = self.get("day_start_minutes")
hours, minutes = divmod(day_start_minutes, 60)
return dt.time(hours, minutes) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier integer return_statement call attribute identifier identifier argument_list identifier identifier | Start of the hamster day. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.