code stringlengths 51 2.34k | sequence stringlengths 186 3.94k | docstring stringlengths 11 171 |
|---|---|---|
def sort_depth(vals, reverse=False):
lst = [[float(price), quantity] for price, quantity in vals.items()]
lst = sorted(lst, key=itemgetter(0), reverse=reverse)
return lst | module function_definition identifier parameters identifier default_parameter identifier false block expression_statement assignment identifier list_comprehension list call identifier argument_list identifier identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier call identifier argument_list integer keyword_argument identifier identifier return_statement identifier | Sort bids or asks by price |
def metrics_for_mode(self, mode):
if mode not in self._values:
logging.info("Mode %s not found", mode)
return []
return sorted(list(self._values[mode].keys())) | module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement list return_statement call identifier argument_list call identifier argument_list call attribute subscript attribute identifier identifier identifier identifier argument_list | Metrics available for a given mode. |
def add_network_to_bgp_speaker(self, speaker_id, body=None):
return self.put((self.bgp_speaker_path % speaker_id) +
"/add_gateway_network", body=body) | module function_definition identifier parameters identifier identifier default_parameter identifier none block return_statement call attribute identifier identifier argument_list binary_operator parenthesized_expression binary_operator attribute identifier identifier identifier string string_start string_content string_end keyword_argument identifier identifier | Adds a network to BGP speaker. |
def pypirc_temp(index_url):
pypirc_file = tempfile.NamedTemporaryFile(suffix='.pypirc', delete=False)
print(pypirc_file.name)
with open(pypirc_file.name, 'w') as fh:
fh.write(PYPIRC_TEMPLATE.format(index_name=PYPIRC_TEMP_INDEX_NAME, index_url=index_url))
return pypirc_file.name | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier false expression_statement call identifier argument_list attribute identifier identifier with_statement with_clause with_item as_pattern call identifier argument_list attribute identifier identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier return_statement attribute identifier identifier | Create a temporary pypirc file for interaction with twine |
def create_signature(secret, value, digestmod='sha256', encoding='utf-8'):
if isinstance(secret, str):
secret = secret.encode(encoding)
if isinstance(value, str):
value = value.encode(encoding)
if isinstance(digestmod, str):
digestmod = getattr(hashlib, digestmod, hashlib.sha1)
hm = hmac.new(secret, digestmod=digestmod)
hm.update(value)
return hm.hexdigest() | module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_content string_end block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list | Create HMAC Signature from secret for value. |
def send_confirmation_email(self):
form = self._get_form('SECURITY_SEND_CONFIRMATION_FORM')
if form.validate_on_submit():
self.security_service.send_email_confirmation_instructions(form.user)
self.flash(_('flask_unchained.bundles.security:flash.confirmation_request',
email=form.user.email), category='info')
if request.is_json:
return '', HTTPStatus.NO_CONTENT
elif form.errors and request.is_json:
return self.errors(form.errors)
return self.render('send_confirmation_email',
send_confirmation_form=form,
**self.security.run_ctx_processor('send_confirmation_email')) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement call attribute identifier identifier argument_list block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list string string_start string_content string_end keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier string string_start string_content string_end if_statement attribute identifier identifier block return_statement expression_list string string_start string_end attribute identifier identifier elif_clause boolean_operator attribute identifier identifier attribute identifier identifier block return_statement call attribute identifier identifier argument_list attribute identifier identifier return_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier dictionary_splat call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end | View function which sends confirmation token and instructions to a user. |
def _stub_tag(constructor, node):
seen = getattr(constructor, "_stub_seen", None)
if seen is None:
seen = constructor._stub_seen = set()
if node.tag not in seen:
print("YAML tag {} is not supported".format(node.tag))
seen.add(node.tag)
return {} | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end none if_statement comparison_operator identifier none block expression_statement assignment identifier assignment attribute identifier identifier call identifier argument_list if_statement comparison_operator attribute identifier identifier identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier return_statement dictionary | Stub a constructor with a dictionary. |
def build_absolute_uri(self, uri):
request = self.context.get('request', None)
return (
request.build_absolute_uri(uri) if request is not None else uri
) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end none return_statement parenthesized_expression conditional_expression call attribute identifier identifier argument_list identifier comparison_operator identifier none identifier | Return a fully qualified absolute url for the given uri. |
def read_index(self):
if not isinstance(self.tree, dict):
self.tree = dict()
self.tree.clear()
for path, metadata in self.read_index_iter():
self.tree[path] = metadata | module function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list attribute identifier identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment subscript attribute identifier identifier identifier identifier | Reads the index and populates the directory tree |
def insort_no_dup(lst, item):
import bisect
ix = bisect.bisect_left(lst, item)
if lst[ix] != item:
lst[ix:ix] = [item] | module function_definition identifier parameters identifier identifier block import_statement dotted_name identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement comparison_operator subscript identifier identifier identifier block expression_statement assignment subscript identifier slice identifier identifier list identifier | If item is not in lst, add item to list at its sorted position |
def RedirectDemo(handler, t):
t.redirect(SIP_PHONE)
json = t.RenderJson()
logging.info ("RedirectDemo json: %s" % json)
handler.response.out.write(json) | module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier | Demonstration of redirecting to another number. |
def resolve_indices(self, index, start_val):
channels = self.vertices[index].meta['channels']
base_channel = start_val
rot_ind = -np.ones(3, dtype=int)
pos_ind = -np.ones(3, dtype=int)
for i in range(len(channels)):
if channels[i]== 'Xrotation':
rot_ind[0] = base_channel + i
elif channels[i]=='Yrotation':
rot_ind[1] = base_channel + i
elif channels[i]=='Zrotation':
rot_ind[2] = base_channel + i
elif channels[i]=='Xposition':
pos_ind[0] = base_channel + i
elif channels[i]=='Yposition':
pos_ind[1] = base_channel + i
elif channels[i]=='Zposition':
pos_ind[2] = base_channel + i
self.vertices[index].meta['rot_ind'] = list(rot_ind)
self.vertices[index].meta['pos_ind'] = list(pos_ind) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier subscript attribute subscript attribute identifier identifier identifier identifier string string_start string_content string_end expression_statement assignment identifier identifier expression_statement assignment identifier unary_operator call attribute identifier identifier argument_list integer keyword_argument identifier identifier expression_statement assignment identifier unary_operator call attribute identifier identifier argument_list integer keyword_argument identifier identifier for_statement identifier call identifier argument_list call identifier argument_list identifier block if_statement comparison_operator subscript identifier identifier string string_start string_content string_end block expression_statement assignment subscript identifier integer binary_operator identifier identifier elif_clause comparison_operator subscript identifier identifier string string_start string_content string_end block expression_statement assignment subscript identifier integer binary_operator identifier identifier elif_clause comparison_operator subscript identifier identifier string string_start string_content string_end block expression_statement assignment subscript identifier integer binary_operator identifier identifier elif_clause comparison_operator subscript identifier identifier string string_start string_content string_end block expression_statement assignment subscript identifier integer binary_operator identifier identifier elif_clause comparison_operator subscript identifier identifier string string_start string_content string_end block expression_statement assignment subscript identifier integer binary_operator identifier identifier elif_clause comparison_operator subscript identifier identifier string string_start string_content string_end block expression_statement assignment subscript identifier integer binary_operator identifier identifier expression_statement assignment subscript attribute subscript attribute identifier identifier identifier identifier string string_start string_content string_end call identifier argument_list identifier expression_statement assignment subscript attribute subscript attribute identifier identifier identifier identifier string string_start string_content string_end call identifier argument_list identifier | Get indices for the skeleton from the channels when loading in channel data. |
def _init_action_list(self, action_filename):
self.actions = list()
self.hiid_to_action_index = dict()
f = codecs.open(action_filename, 'r', encoding='latin-1')
first_line = True
for line in f:
line = line.rstrip()
if first_line:
first_line = False
else:
self.actions.append(GenewaysAction(line))
latestInd = len(self.actions)-1
hiid = self.actions[latestInd].hiid
if hiid in self.hiid_to_action_index:
raise Exception('action hiid not unique: %d' % hiid)
self.hiid_to_action_index[hiid] = latestInd | module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list expression_statement assignment attribute identifier identifier call identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier true for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement identifier block expression_statement assignment identifier false else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier expression_statement assignment identifier binary_operator call identifier argument_list attribute identifier identifier integer expression_statement assignment identifier attribute subscript attribute identifier identifier identifier identifier if_statement comparison_operator identifier attribute identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment subscript attribute identifier identifier identifier identifier | Parses the file and populates the data. |
def bytes_array(self):
assert len(self.dimensions) == 2, \
'{}: cannot get value as bytes array!'.format(self.name)
l, n = self.dimensions
return [self.bytes[i*l:(i+1)*l] for i in range(n)] | module function_definition identifier parameters identifier block assert_statement comparison_operator call identifier argument_list attribute identifier identifier integer call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement assignment pattern_list identifier identifier attribute identifier identifier return_statement list_comprehension subscript attribute identifier identifier slice binary_operator identifier identifier binary_operator parenthesized_expression binary_operator identifier integer identifier for_in_clause identifier call identifier argument_list identifier | Get the param as an array of raw byte strings. |
def _timeseries_component(self, series):
return lambda: np.interp(self.time(), series.index, series.values) | module function_definition identifier parameters identifier identifier block return_statement lambda call attribute identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier | Internal function for creating a timeseries model element |
def _wrap_data(data: Union[str, bytes]):
MsgType = TextMessage if isinstance(data, str) else BytesMessage
return MsgType(data=data, frame_finished=True, message_finished=True) | module function_definition identifier parameters typed_parameter identifier type generic_type identifier type_parameter type identifier type identifier block expression_statement assignment identifier conditional_expression identifier call identifier argument_list identifier identifier identifier return_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier true keyword_argument identifier true | Wraps data into the right event. |
def _dump_date(d, delim):
if d is None:
d = gmtime()
elif isinstance(d, datetime):
d = d.utctimetuple()
elif isinstance(d, (integer_types, float)):
d = gmtime(d)
return "%s, %02d%s%s%s%s %02d:%02d:%02d GMT" % (
("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun")[d.tm_wday],
d.tm_mday,
delim,
(
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec",
)[d.tm_mon - 1],
delim,
str(d.tm_year),
d.tm_hour,
d.tm_min,
d.tm_sec,
) | module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list elif_clause call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list elif_clause call identifier argument_list identifier tuple identifier identifier block expression_statement assignment identifier call identifier argument_list identifier return_statement binary_operator string string_start string_content string_end tuple subscript 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 string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end attribute identifier identifier attribute identifier identifier identifier subscript 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 string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end binary_operator attribute identifier identifier integer identifier call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier | Used for `http_date` and `cookie_date`. |
def _read_stderr(self):
f = open(self.stderr_file, 'rb')
try:
stderr_text = f.read()
if not stderr_text:
return ''
encoding = get_coding(stderr_text)
stderr_text = to_text_string(stderr_text, encoding)
return stderr_text
finally:
f.close() | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier string string_start string_content string_end try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement not_operator identifier block return_statement string string_start string_end expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier identifier return_statement identifier finally_clause block expression_statement call attribute identifier identifier argument_list | Read the stderr file of the kernel. |
def _get_future_expected_model(self, core_element):
for model in self.expected_future_models:
if model.core_element is core_element:
self.expected_future_models.remove(model)
return model
return None | module function_definition identifier parameters identifier identifier block for_statement identifier attribute identifier identifier block if_statement comparison_operator attribute identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement identifier return_statement none | Hand model for an core element from expected model list and remove the model from this list |
def _init_logs_table():
_logs_table = sqlalchemy.Table(
'logs', _METADATA,
sqlalchemy.Column(
'job_id', sqlalchemy.ForeignKey("jobs.job_id", ondelete="CASCADE"),
nullable=False),
sqlalchemy.Column('timestamp', sqlalchemy.DateTime),
sqlalchemy.Column('message', sqlalchemy.UnicodeText),
sqlalchemy.Column('level', sqlalchemy.UnicodeText),
sqlalchemy.Column('module', sqlalchemy.UnicodeText),
sqlalchemy.Column('funcName', sqlalchemy.UnicodeText),
sqlalchemy.Column('lineno', sqlalchemy.Integer)
)
return _logs_table | module function_definition identifier parameters block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier 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 keyword_argument identifier string string_start string_content string_end keyword_argument identifier false call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier return_statement identifier | Initialise the "logs" table in the db. |
def unregister_dependent_on(self, tree):
if tree in self.dependent_on:
self.dependent_on.remove(tree) | module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier | unregistering tree that we are dependent on |
def GroupEncoder(field_number, is_repeated, is_packed):
start_tag = TagBytes(field_number, wire_format.WIRETYPE_START_GROUP)
end_tag = TagBytes(field_number, wire_format.WIRETYPE_END_GROUP)
assert not is_packed
if is_repeated:
def EncodeRepeatedField(write, value):
for element in value:
write(start_tag)
element._InternalSerialize(write)
write(end_tag)
return EncodeRepeatedField
else:
def EncodeField(write, value):
write(start_tag)
value._InternalSerialize(write)
return write(end_tag)
return EncodeField | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier attribute identifier identifier assert_statement not_operator identifier if_statement identifier block function_definition identifier parameters identifier identifier block for_statement identifier identifier block expression_statement call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list identifier return_statement identifier else_clause block function_definition identifier parameters identifier identifier block expression_statement call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier return_statement call identifier argument_list identifier return_statement identifier | Returns an encoder for a group field. |
def upload_collection_configs(self, collection, fs_path):
coll_path = fs_path
if not os.path.isdir(coll_path):
raise ValueError("{} Doesn't Exist".format(coll_path))
self._upload_dir(coll_path, '/configs/{}'.format(collection)) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier identifier if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier call attribute string string_start string_content string_end identifier argument_list identifier | Uploads collection configurations from a specified directory to zookeeper. |
def OnCellTextRotation(self, event):
with undo.group(_("Rotation")):
self.grid.actions.toggle_attr("angle")
self.grid.ForceRefresh()
self.grid.update_attribute_toolbar()
if is_gtk():
try:
wx.Yield()
except:
pass
event.Skip() | module function_definition identifier parameters identifier identifier block with_statement with_clause with_item call attribute identifier identifier argument_list call identifier argument_list string string_start string_content string_end block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list if_statement call identifier argument_list block try_statement block expression_statement call attribute identifier identifier argument_list except_clause block pass_statement expression_statement call attribute identifier identifier argument_list | Cell text rotation event handler |
def action(self, relationship):
action_obj = FileAction(self._indicator_data.get('xid'), relationship)
self._file_actions.append(action_obj)
return action_obj | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement identifier | Add a File Action. |
def relabel_squeeze(data):
palette, index = np.unique(data, return_inverse=True)
data = index.reshape(data.shape)
return data | module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier keyword_argument identifier true expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier return_statement identifier | Makes relabeling of data if there are unused values. |
def _load_physical_network_mappings(self, phys_net_vswitch_mappings):
for mapping in phys_net_vswitch_mappings:
parts = mapping.split(':')
if len(parts) != 2:
LOG.debug('Invalid physical network mapping: %s', mapping)
else:
pattern = re.escape(parts[0].strip()).replace('\\*', '.*')
pattern = pattern + '$'
vswitch = parts[1].strip()
self._physical_network_mappings[pattern] = vswitch | module function_definition identifier parameters identifier identifier block for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator call identifier argument_list identifier integer block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier else_clause block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list call attribute subscript identifier integer identifier argument_list identifier argument_list string string_start string_content escape_sequence string_end string string_start string_content string_end expression_statement assignment identifier binary_operator identifier string string_start string_content string_end expression_statement assignment identifier call attribute subscript identifier integer identifier argument_list expression_statement assignment subscript attribute identifier identifier identifier identifier | Load all the information regarding the physical network. |
def do_directives(self, line):
for name, cmd in self.adapter.directives.items():
with colorize('blue'):
print('bot %s:' % name)
if cmd.__doc__:
for line in cmd.__doc__.split('\n'):
print(' %s' % line)
else:
print() | module function_definition identifier parameters identifier identifier block for_statement pattern_list identifier identifier call attribute attribute attribute identifier identifier identifier identifier argument_list block with_statement with_clause with_item call identifier argument_list string string_start string_content string_end block expression_statement call identifier argument_list binary_operator string string_start string_content string_end identifier if_statement attribute identifier identifier block for_statement identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content escape_sequence string_end block expression_statement call identifier argument_list binary_operator string string_start string_content string_end identifier else_clause block expression_statement call identifier argument_list | List all directives supported by the bot |
def list(self):
queue = self._pebble.get_endpoint_queue(DataLogging)
self._pebble.send_packet(DataLogging(data=DataLoggingReportOpenSessions(sessions=[])))
sessions = []
while True:
try:
result = queue.get(timeout=2).data
except TimeoutError:
break
if isinstance(result, DataLoggingDespoolOpenSession):
self._pebble.send_packet(DataLogging(data=DataLoggingACK(
session_id=result.session_id)))
sessions.append(result.__dict__)
queue.close()
return sessions | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list keyword_argument identifier call identifier argument_list keyword_argument identifier list expression_statement assignment identifier list while_statement true block try_statement block expression_statement assignment identifier attribute call attribute identifier identifier argument_list keyword_argument identifier integer identifier except_clause identifier block break_statement if_statement call identifier argument_list identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list keyword_argument identifier call identifier argument_list keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list return_statement identifier | List all available data logging sessions |
def _add_implied_commands(self):
if len(self.get_added_columns()) and not self._creating():
self._commands.insert(0, self._create_command("add"))
if len(self.get_changed_columns()) and not self._creating():
self._commands.insert(0, self._create_command("change"))
return self._add_fluent_indexes() | module function_definition identifier parameters identifier block if_statement boolean_operator call identifier argument_list call attribute identifier identifier argument_list not_operator call attribute identifier identifier argument_list block expression_statement call attribute attribute identifier identifier identifier argument_list integer call attribute identifier identifier argument_list string string_start string_content string_end if_statement boolean_operator call identifier argument_list call attribute identifier identifier argument_list not_operator call attribute identifier identifier argument_list block expression_statement call attribute attribute identifier identifier identifier argument_list integer call attribute identifier identifier argument_list string string_start string_content string_end return_statement call attribute identifier identifier argument_list | Add the commands that are implied by the blueprint. |
def main():
log_level = os.environ.get('LOG_LEVEL', 'INFO')
logging.basicConfig(level=getattr(logging, log_level),
format='%(asctime)s %(name)s[%(levelname)s] %(message)s',
datefmt='%Y-%m-%d %H:%M:%S')
current_path = os.path.abspath('.')
if current_path not in sys.path:
sys.path.insert(0, current_path)
argcomplete.autocomplete(ARG_PARSER)
args = ARG_PARSER.parse_args()
args.func(args) | module function_definition identifier parameters block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list keyword_argument identifier call identifier argument_list identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list integer identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier | Entry point of rw cli |
def _validate_mandatory_keys(mandatory, validated, data, to_validate):
errors = []
for key, sub_schema in mandatory.items():
if key not in data:
errors.append('missing key: %r' % (key,))
continue
try:
validated[key] = sub_schema(data[key])
except NotValid as ex:
errors.extend(['%r: %s' % (key, arg) for arg in ex.args])
to_validate.remove(key)
return errors | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier continue_statement try_statement block expression_statement assignment subscript identifier identifier call identifier argument_list subscript identifier identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list list_comprehension binary_operator string string_start string_content string_end tuple identifier identifier for_in_clause identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | Validate the manditory keys. |
def sub_description(self):
gd = self.geo_description
td = self.time_description
if gd and td:
return '{}, {}. {} Rows.'.format(gd, td, self._p.count)
elif gd:
return '{}. {} Rows.'.format(gd, self._p.count)
elif td:
return '{}. {} Rows.'.format(td, self._p.count)
else:
return '{} Rows.'.format(self._p.count) | module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier if_statement boolean_operator identifier identifier block return_statement call attribute string string_start string_content string_end identifier argument_list identifier identifier attribute attribute identifier identifier identifier elif_clause identifier block return_statement call attribute string string_start string_content string_end identifier argument_list identifier attribute attribute identifier identifier identifier elif_clause identifier block return_statement call attribute string string_start string_content string_end identifier argument_list identifier attribute attribute identifier identifier identifier else_clause block return_statement call attribute string string_start string_content string_end identifier argument_list attribute attribute identifier identifier identifier | Time and space dscription |
def runGetExpressionLevel(self, id_):
compoundId = datamodel.ExpressionLevelCompoundId.parse(id_)
dataset = self.getDataRepository().getDataset(compoundId.dataset_id)
rnaQuantificationSet = dataset.getRnaQuantificationSet(
compoundId.rna_quantification_set_id)
rnaQuantification = rnaQuantificationSet.getRnaQuantification(
compoundId.rna_quantification_id)
expressionLevel = rnaQuantification.getExpressionLevel(compoundId)
return self.runGetRequest(expressionLevel) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier | Runs a getExpressionLevel request for the specified ID. |
def clear_cache():
fsb_cachedir = os.path.join(__opts__['cachedir'], 'svnfs')
list_cachedir = os.path.join(__opts__['cachedir'], 'file_lists/svnfs')
errors = []
for rdir in (fsb_cachedir, list_cachedir):
if os.path.exists(rdir):
try:
shutil.rmtree(rdir)
except OSError as exc:
errors.append('Unable to delete {0}: {1}'.format(rdir, exc))
return errors | module function_definition identifier parameters block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier list for_statement identifier tuple identifier identifier block if_statement call attribute attribute identifier identifier identifier argument_list identifier block try_statement block expression_statement call attribute identifier identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier return_statement identifier | Completely clear svnfs cache |
def field_uuid(self, attr, options):
options['validators'].append(validators.UUIDValidator(attr.entity))
return wtf_fields.StringField, options | module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier return_statement expression_list attribute identifier identifier identifier | Creates a form element for the UUID type. |
def interpret(code, in_vars):
try:
result = eval(code, in_vars)
except SyntaxError:
pass
else:
if result is not None:
print(ascii(result))
return
exec_func(code, in_vars) | module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment identifier call identifier argument_list identifier identifier except_clause identifier block pass_statement else_clause block if_statement comparison_operator identifier none block expression_statement call identifier argument_list call identifier argument_list identifier return_statement expression_statement call identifier argument_list identifier identifier | Try to evaluate the given code, otherwise execute it. |
def optwrap(self, text):
if not self.body_width:
return text
assert wrap, "Requires Python 2.3."
result = ''
newlines = 0
for para in text.split("\n"):
if len(para) > 0:
if not skipwrap(para):
result += "\n".join(wrap(para, self.body_width))
if para.endswith(' '):
result += " \n"
newlines = 1
else:
result += "\n\n"
newlines = 2
else:
if not onlywhite(para):
result += para + "\n"
newlines = 1
else:
if newlines < 2:
result += "\n"
newlines += 1
return result | module function_definition identifier parameters identifier identifier block if_statement not_operator attribute identifier identifier block return_statement identifier assert_statement identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_end expression_statement assignment identifier integer for_statement identifier call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end block if_statement comparison_operator call identifier argument_list identifier integer block if_statement not_operator call identifier argument_list identifier block expression_statement augmented_assignment identifier call attribute string string_start string_content escape_sequence string_end identifier argument_list call identifier argument_list identifier attribute identifier identifier if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement augmented_assignment identifier string string_start string_content escape_sequence string_end expression_statement assignment identifier integer else_clause block expression_statement augmented_assignment identifier string string_start string_content escape_sequence escape_sequence string_end expression_statement assignment identifier integer else_clause block if_statement not_operator call identifier argument_list identifier block expression_statement augmented_assignment identifier binary_operator identifier string string_start string_content escape_sequence string_end expression_statement assignment identifier integer else_clause block if_statement comparison_operator identifier integer block expression_statement augmented_assignment identifier string string_start string_content escape_sequence string_end expression_statement augmented_assignment identifier integer return_statement identifier | Wrap all paragraphs in the provided text. |
def add_action(self, name, parent, action):
if iskeyword(name):
name = '_' + name
self._actions[name] = parent.new_action(**action)
setattr(self, name, self._actions[name].execute) | module function_definition identifier parameters identifier identifier identifier identifier block if_statement call identifier argument_list identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end identifier expression_statement assignment subscript attribute identifier identifier identifier call attribute identifier identifier argument_list dictionary_splat identifier expression_statement call identifier argument_list identifier identifier attribute subscript attribute identifier identifier identifier identifier | Add a single Action to the APIObject. |
def _processDML(self, dataset_name, cols, reader):
sql_template = self._generateInsertStatement(dataset_name, cols)
c = self.conn.cursor()
c.executemany(sql_template, reader)
self.conn.commit() | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list | Overridden version of create DML for SQLLite |
def apply_texture(self, image):
self.image = image.convert_alpha()
self.untransformed_image = self.image.copy()
self.source.x = 0
self.source.y = 0
self.source.width = self.image.get_width()
self.source.height = self.image.get_height()
center = Vector2(self.source.width / 2.0,
self.source.height / 2.0)
self.set_origin(center) | module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute attribute identifier identifier identifier integer expression_statement assignment attribute attribute identifier identifier identifier integer expression_statement assignment attribute attribute identifier identifier identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute attribute identifier identifier identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call identifier argument_list binary_operator attribute attribute identifier identifier identifier float binary_operator attribute attribute identifier identifier identifier float expression_statement call attribute identifier identifier argument_list identifier | Place a preexisting texture as the sprite's texture. |
def box_iter(self):
for i in utils.range_(self.order):
for j in utils.range_(self.order):
yield self.box(i * 3, j * 3) | module function_definition identifier parameters identifier block for_statement identifier call attribute identifier identifier argument_list attribute identifier identifier block for_statement identifier call attribute identifier identifier argument_list attribute identifier identifier block expression_statement yield call attribute identifier identifier argument_list binary_operator identifier integer binary_operator identifier integer | Get an iterator over all boxes in the Sudoku |
def _run(self):
self.set_state(self.STATE_INITIALIZING)
self.ioloop = ioloop.IOLoop.current()
self.consumer_lock = locks.Lock()
self.sentry_client = self.setup_sentry(
self._kwargs['config'], self.consumer_name)
try:
self.setup()
except (AttributeError, ImportError):
return self.on_startup_error(
'Failed to import the Python module for {}'.format(
self.consumer_name))
if not self.is_stopped:
try:
self.ioloop.start()
except KeyboardInterrupt:
LOGGER.warning('CTRL-C while waiting for clean shutdown') | module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier try_statement block expression_statement call attribute identifier identifier argument_list except_clause tuple identifier identifier block return_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier if_statement not_operator attribute identifier identifier block try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list except_clause identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end | Run method that can be profiled |
def mkdirs(filename, mode=0o777):
dirname = os.path.dirname(filename)
if not dirname:
return
_compat.makedirs(dirname, mode=mode, exist_ok=True) | module function_definition identifier parameters identifier default_parameter identifier integer block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement not_operator identifier block return_statement expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier true | Recursively create directories up to the path of ``filename`` as needed. |
def _smooth(values: List[float], beta: float) -> List[float]:
avg_value = 0.
smoothed = []
for i, value in enumerate(values):
avg_value = beta * avg_value + (1 - beta) * value
smoothed.append(avg_value / (1 - beta ** (i + 1)))
return smoothed | module function_definition identifier parameters typed_parameter identifier type generic_type identifier type_parameter type identifier typed_parameter identifier type identifier type generic_type identifier type_parameter type identifier block expression_statement assignment identifier float expression_statement assignment identifier list for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement assignment identifier binary_operator binary_operator identifier identifier binary_operator parenthesized_expression binary_operator integer identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator identifier parenthesized_expression binary_operator integer binary_operator identifier parenthesized_expression binary_operator identifier integer return_statement identifier | Exponential smoothing of values |
def quil_to_program(quil: str) -> Program:
pyquil_instructions = pyquil.parser.parse(quil)
return pyquil_to_program(pyquil_instructions) | module function_definition identifier parameters typed_parameter identifier type identifier type identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier return_statement call identifier argument_list identifier | Parse a quil program and return a Program object |
def collection_options(self, **kwargs):
methods = self._get_handled_methods(self._collection_actions)
return self._set_options_headers(methods) | module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier return_statement call attribute identifier identifier argument_list identifier | Handle collection item OPTIONS request. |
def open_current_in_browser(self):
if self.impact_path is None:
html = self.page().mainFrame().toHtml()
html_to_file(html, open_browser=True)
else:
if self.action_show_report.isEnabled():
open_in_browser(self.log_path)
else:
open_in_browser(self.report_path) | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier call attribute call attribute call attribute identifier identifier argument_list identifier argument_list identifier argument_list expression_statement call identifier argument_list identifier keyword_argument identifier true else_clause block if_statement call attribute attribute identifier identifier identifier argument_list block expression_statement call identifier argument_list attribute identifier identifier else_clause block expression_statement call identifier argument_list attribute identifier identifier | Open current selected impact report in browser. |
def filter_fh_by_metadata(self, filehandlers):
for filehandler in filehandlers:
filehandler.metadata['start_time'] = filehandler.start_time
filehandler.metadata['end_time'] = filehandler.end_time
if self.metadata_matches(filehandler.metadata, filehandler):
yield filehandler | module function_definition identifier parameters identifier identifier block for_statement identifier identifier block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier if_statement call attribute identifier identifier argument_list attribute identifier identifier identifier block expression_statement yield identifier | Filter out filehandlers using provide filter parameters. |
def connection_lost(self, reason):
LOG.info(
'Connection to peer %s lost, reason: %s Resetting '
'retry connect loop: %s' %
(self._neigh_conf.ip_address, reason,
self._connect_retry_event.is_set()),
extra={
'resource_name': self._neigh_conf.name,
'resource_id': self._neigh_conf.id
}
)
self.state.bgp_state = const.BGP_FSM_IDLE
if self._protocol:
self._protocol.stop()
self._protocol = None
self._init_rtc_nlri_path = []
self._sent_init_non_rtc_update = False
self.clear_outgoing_msg_list()
self._unschedule_sending_init_updates()
self.version_num += 1
self._peer_manager.on_peer_down(self)
if self._neigh_conf.enabled:
if not self._connect_retry_event.is_set():
self._connect_retry_event.set() | module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end tuple attribute attribute identifier identifier identifier identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier dictionary pair string string_start string_content string_end attribute attribute identifier identifier identifier pair string string_start string_content string_end attribute attribute identifier identifier identifier expression_statement assignment attribute attribute identifier identifier identifier attribute identifier identifier if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier list expression_statement assignment attribute identifier identifier false expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement augmented_assignment attribute identifier identifier integer expression_statement call attribute attribute identifier identifier identifier argument_list identifier if_statement attribute attribute identifier identifier identifier block if_statement not_operator call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute attribute identifier identifier identifier argument_list | Protocols connection lost handler. |
def getinfo(ee_obj, n=4):
output = None
for i in range(1, n):
try:
output = ee_obj.getInfo()
except ee.ee_exception.EEException as e:
if 'Earth Engine memory capacity exceeded' in str(e):
logging.info(' Resending query ({}/10)'.format(i))
logging.debug(' {}'.format(e))
sleep(i ** 2)
else:
raise e
if output:
break
return output | module function_definition identifier parameters identifier default_parameter identifier integer block expression_statement assignment identifier none for_statement identifier call identifier argument_list integer identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list except_clause as_pattern attribute attribute identifier identifier identifier as_pattern_target identifier block if_statement comparison_operator string string_start string_content string_end call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call identifier argument_list binary_operator identifier integer else_clause block raise_statement identifier if_statement identifier block break_statement return_statement identifier | Make an exponential back off getInfo call on an Earth Engine object |
def _handle_type(self, other):
if isinstance(other, Int):
return Int
elif isinstance(other, Float):
return Float
else:
raise TypeError(
f"Unsuported operation between `{type(self)}` and `{type(other)}`."
) | module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier identifier block return_statement identifier elif_clause call identifier argument_list identifier identifier block return_statement identifier else_clause block raise_statement call identifier argument_list string string_start string_content interpolation call identifier argument_list identifier string_content interpolation call identifier argument_list identifier string_content string_end | Helper to handle the return type. |
def _graphql_request_count_per_sliding_window(self, query_hash: str) -> int:
if self.is_logged_in:
max_reqs = {'1cb6ec562846122743b61e492c85999f': 20, '33ba35852cb50da46f5b5e889df7d159': 20}
else:
max_reqs = {'1cb6ec562846122743b61e492c85999f': 200, '33ba35852cb50da46f5b5e889df7d159': 200}
return max_reqs.get(query_hash) or min(max_reqs.values()) | module function_definition identifier parameters identifier typed_parameter identifier type identifier type identifier block if_statement attribute identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end integer pair string string_start string_content string_end integer else_clause block expression_statement assignment identifier dictionary pair string string_start string_content string_end integer pair string string_start string_content string_end integer return_statement boolean_operator call attribute identifier identifier argument_list identifier call identifier argument_list call attribute identifier identifier argument_list | Return how many GraphQL requests can be done within the sliding window. |
def dot(v1, v2):
x1, y1, z1 = v1
x2, y2, z2 = v2
return x1 * x2 + y1 * y2 + z1 * z2 | module function_definition identifier parameters identifier identifier block expression_statement assignment pattern_list identifier identifier identifier identifier expression_statement assignment pattern_list identifier identifier identifier identifier return_statement binary_operator binary_operator binary_operator identifier identifier binary_operator identifier identifier binary_operator identifier identifier | Computes the dot product of two vectors. |
def connect(self):
try:
for group in ('inlets', 'receivers', 'outlets', 'senders'):
self._connect_subgroup(group)
except BaseException:
objecttools.augment_excmessage(
'While trying to build the node connection of the `%s` '
'sequences of the model handled by element `%s`'
% (group[:-1], objecttools.devicename(self))) | module function_definition identifier parameters identifier block try_statement block for_statement identifier 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 block expression_statement call attribute identifier identifier argument_list identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end tuple subscript identifier slice unary_operator integer call attribute identifier identifier argument_list identifier | Connect the link sequences of the actual model. |
def _get_loss_fn(self):
criteria = self.criteria.to(self.config["device"])
loss_fn = lambda X, Y: sum(
criteria(Y_tp, Y_t) for Y_tp, Y_t in zip(self.forward(X), Y)
)
return loss_fn | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier lambda lambda_parameters identifier identifier call identifier generator_expression call identifier argument_list identifier identifier for_in_clause pattern_list identifier identifier call identifier argument_list call attribute identifier identifier argument_list identifier identifier return_statement identifier | Returns the loss function to use in the train_model routine |
def unwrap(self):
return [v.unwrap() if hasattr(v, 'unwrap') and not hasattr(v, 'no_unwrap') else v for v in self] | module function_definition identifier parameters identifier block return_statement list_comprehension conditional_expression call attribute identifier identifier argument_list boolean_operator call identifier argument_list identifier string string_start string_content string_end not_operator call identifier argument_list identifier string string_start string_content string_end identifier for_in_clause identifier identifier | Return a deep copy of myself as a list, and unwrap any wrapper objects in me. |
def handle_action(self, channel, nick, msg):
"Core message parser and dispatcher"
messages = ()
for handler in Handler.find_matching(msg, channel):
exception_handler = functools.partial(
self._handle_exception,
handler=handler,
)
rest = handler.process(msg)
client = connection = event = None
match = rest
f = handler.attach(locals())
results = pmxbot.itertools.generate_results(f)
clean_results = pmxbot.itertools.trap_exceptions(results, exception_handler)
messages = itertools.chain(messages, clean_results)
if not handler.allow_chain:
break
self._handle_output(channel, messages) | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier tuple for_statement identifier call attribute identifier identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier assignment identifier assignment identifier none expression_statement assignment identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement not_operator attribute identifier identifier block break_statement expression_statement call attribute identifier identifier argument_list identifier identifier | Core message parser and dispatcher |
def fetch(cls, id, incident=None, endpoint=None, *args, **kwargs):
if incident is None and endpoint is None:
raise InvalidArguments(incident, endpoint)
if endpoint is None:
iid = incident['id'] if isinstance(incident, Entity) else incident
endpoint = 'incidents/{0}/alerts'.format(iid)
return getattr(Entity, 'fetch').__func__(cls, id, endpoint=endpoint,
*args, **kwargs) | module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none list_splat_pattern identifier dictionary_splat_pattern identifier block if_statement boolean_operator comparison_operator identifier none comparison_operator identifier none block raise_statement call identifier argument_list identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier conditional_expression subscript identifier string string_start string_content string_end call identifier argument_list identifier identifier identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier return_statement call attribute call identifier argument_list identifier string string_start string_content string_end identifier argument_list identifier identifier keyword_argument identifier identifier list_splat identifier dictionary_splat identifier | Customize fetch because this is a nested resource. |
def _update_submodules(repo_dir):
subprocess.check_call("git submodule init", cwd=repo_dir, shell=True)
subprocess.check_call(
"git submodule update --recursive", cwd=repo_dir, shell=True) | module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier true expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier true | update submodules in a repo |
def _bp_static_url(blueprint):
u = six.u('%s%s' % (blueprint.url_prefix or '', blueprint.static_url_path or ''))
return u | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple boolean_operator attribute identifier identifier string string_start string_end boolean_operator attribute identifier identifier string string_start string_end return_statement identifier | builds the absolute url path for a blueprint's static folder |
def save(self, commit=True):
if getattr(self.instance,'instructor',None):
self.instance.instructor.availableForPrivates = self.cleaned_data.pop('availableForPrivates',self.instance.instructor.availableForPrivates)
self.instance.instructor.save(update_fields=['availableForPrivates',])
super(StaffMemberBioChangeForm,self).save(commit=True) | module function_definition identifier parameters identifier default_parameter identifier true block if_statement call identifier argument_list attribute identifier identifier string string_start string_content string_end none block expression_statement assignment attribute attribute attribute identifier identifier identifier identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end attribute attribute attribute identifier identifier identifier identifier expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list keyword_argument identifier list string string_start string_content string_end expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list keyword_argument identifier true | If the staff member is an instructor, also update the availableForPrivates field on the Instructor record. |
def _create_field_mapping_action(self):
icon = resources_path('img', 'icons', 'show-mapping-tool.svg')
self.action_field_mapping = QAction(
QIcon(icon),
self.tr('InaSAFE Field Mapping Tool'),
self.iface.mainWindow())
self.action_field_mapping.setStatusTip(self.tr(
'Assign field mapping to layer.'))
self.action_field_mapping.setWhatsThis(self.tr(
'Use this tool to assign field mapping in layer.'))
self.action_field_mapping.setEnabled(False)
self.action_field_mapping.triggered.connect(self.show_field_mapping)
self.add_action(
self.action_field_mapping, add_to_toolbar=self.full_toolbar) | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement assignment attribute identifier identifier call identifier argument_list call identifier argument_list identifier call attribute identifier identifier argument_list string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list false expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier attribute identifier identifier | Create action for showing field mapping dialog. |
def _find_devices_win(self):
self._find_xinput()
self._detect_gamepads()
self._count_devices()
if self._raw_device_counts['keyboards'] > 0:
self.keyboards.append(Keyboard(
self,
"/dev/input/by-id/usb-A_Nice_Keyboard-event-kbd"))
if self._raw_device_counts['mice'] > 0:
self.mice.append(Mouse(
self,
"/dev/input/by-id/usb-A_Nice_Mouse_called_Arthur-event-mouse")) | module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list if_statement comparison_operator subscript attribute identifier identifier string string_start string_content string_end integer block expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier string string_start string_content string_end if_statement comparison_operator subscript attribute identifier identifier string string_start string_content string_end integer block expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier string string_start string_content string_end | Find devices on Windows. |
def document_endpoint(endpoint):
descr = clean_description(py_doc_trim(endpoint.__doc__))
docs = {
'name': endpoint._route_name,
'http_method': endpoint._http_method,
'uri': endpoint._uri,
'description': descr,
'arguments': extract_endpoint_arguments(endpoint),
'returns': format_endpoint_returns_doc(endpoint),
}
if hasattr(endpoint, "_success"):
docs["success"] = endpoint._success
if hasattr(endpoint, "_requires_permission"):
docs["requires_permission"] = endpoint._requires_permission
return docs | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list call identifier argument_list attribute identifier identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end call identifier argument_list identifier pair string string_start string_content string_end call identifier argument_list identifier if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier return_statement identifier | Extract the full documentation dictionary from the endpoint. |
def enabled_flags(self):
if not self.value:
yield self.__flags_members__[0]
return
val = self.value
while val:
lowest_bit = val & -val
val ^= lowest_bit
yield self.__flags_members__[lowest_bit] | module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block expression_statement yield subscript attribute identifier identifier integer return_statement expression_statement assignment identifier attribute identifier identifier while_statement identifier block expression_statement assignment identifier binary_operator identifier unary_operator identifier expression_statement augmented_assignment identifier identifier expression_statement yield subscript attribute identifier identifier identifier | Return the objects for each individual set flag. |
def _apply_validator_chain(chain, value, handler):
if hasattr(chain, 'validate'):
chain = [chain, ]
for validator in chain:
if hasattr(validator, 'validate'):
value = validator.validate(value, handler)
else:
raise web.HTTPError(500)
return value | module function_definition identifier parameters identifier identifier identifier block if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier list identifier for_statement identifier identifier block if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier else_clause block raise_statement call attribute identifier identifier argument_list integer return_statement identifier | Apply validators in sequence to a value. |
def _fusion_legacy_handler(_, __, tokens):
if RANGE_5P not in tokens:
tokens[RANGE_5P] = {FUSION_MISSING: '?'}
if RANGE_3P not in tokens:
tokens[RANGE_3P] = {FUSION_MISSING: '?'}
return tokens | module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator identifier identifier block expression_statement assignment subscript identifier identifier dictionary pair identifier string string_start string_content string_end if_statement comparison_operator identifier identifier block expression_statement assignment subscript identifier identifier dictionary pair identifier string string_start string_content string_end return_statement identifier | Handle a legacy fusion. |
def check_help():
know = set(('-h', '--help', '-v', '--version'))
args = set(sys.argv[1:])
return len(know.intersection(args)) > 0 | module function_definition identifier parameters block expression_statement assignment identifier call 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 expression_statement assignment identifier call identifier argument_list subscript attribute identifier identifier slice integer return_statement comparison_operator call identifier argument_list call attribute identifier identifier argument_list identifier integer | check know args in argv. |
def add_janitor(self, janitor):
if not self.owner and not self.admin:
raise RuntimeError("Not enough street creed to do this")
janitor = janitor.strip().lower()
if not janitor:
raise ValueError("Empty strings cannot be janitors")
if janitor in self.config.janitors:
return
self.config.janitors.append(janitor)
self.__set_config_value("janitors", self.config.janitors) | module function_definition identifier parameters identifier identifier block if_statement boolean_operator not_operator attribute identifier identifier not_operator attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list if_statement not_operator identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier attribute attribute identifier identifier identifier block return_statement expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute attribute identifier identifier identifier | Add janitor to the room |
def _clear(self):
self._finished = False
self._measurement = None
self._message = None
self._message_body = None | module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier false expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier none | Resets all assigned data for the current message. |
def parse_for(self):
lineno = self.stream.expect('name:for').lineno
target = self.parse_assign_target(extra_end_rules=('name:in',))
self.stream.expect('name:in')
iter = self.parse_tuple(with_condexpr=False,
extra_end_rules=('name:recursive',))
test = None
if self.stream.skip_if('name:if'):
test = self.parse_expression()
recursive = self.stream.skip_if('name:recursive')
body = self.parse_statements(('name:endfor', 'name:else'))
if next(self.stream).value == 'endfor':
else_ = []
else:
else_ = self.parse_statements(('name:endfor',), drop_needle=True)
return nodes.For(target, iter, body, else_, test,
recursive, lineno=lineno) | module function_definition identifier parameters identifier block expression_statement assignment identifier attribute call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier tuple string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier false keyword_argument identifier tuple string string_start string_content string_end expression_statement assignment identifier none if_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list tuple string string_start string_content string_end string string_start string_content string_end if_statement comparison_operator attribute call identifier argument_list attribute identifier identifier identifier string string_start string_content string_end block expression_statement assignment identifier list else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list tuple string string_start string_content string_end keyword_argument identifier true return_statement call attribute identifier identifier argument_list identifier identifier identifier identifier identifier identifier keyword_argument identifier identifier | Parse a for loop. |
def to_header(self):
if self.star_tag:
return "*"
return ", ".join(
['"%s"' % x for x in self._strong] + ['W/"%s"' % x for x in self._weak]
) | module function_definition identifier parameters identifier block if_statement attribute identifier identifier block return_statement string string_start string_content string_end return_statement call attribute string string_start string_content string_end identifier argument_list binary_operator list_comprehension binary_operator string string_start string_content string_end identifier for_in_clause identifier attribute identifier identifier list_comprehension binary_operator string string_start string_content string_end identifier for_in_clause identifier attribute identifier identifier | Convert the etags set into a HTTP header string. |
def view(input_file, plane, backend):
if backend == 'matplotlib':
from neurom.viewer import draw
kwargs = {
'mode': '3d' if plane == '3d' else '2d',
}
if plane != '3d':
kwargs['plane'] = plane
draw(load_neuron(input_file), **kwargs)
else:
from neurom.view.plotly import draw
draw(load_neuron(input_file), plane=plane)
if backend == 'matplotlib':
import matplotlib.pyplot as plt
plt.show() | module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator identifier string string_start string_content string_end block import_from_statement dotted_name identifier identifier dotted_name identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end conditional_expression string string_start string_content string_end comparison_operator identifier string string_start string_content string_end string string_start string_content string_end if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement call identifier argument_list call identifier argument_list identifier dictionary_splat identifier else_clause block import_from_statement dotted_name identifier identifier identifier dotted_name identifier expression_statement call identifier argument_list call identifier argument_list identifier keyword_argument identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block import_statement aliased_import dotted_name identifier identifier identifier expression_statement call attribute identifier identifier argument_list | A simple neuron viewer |
def wait_all_tasks_done(self, timeout=None, delay=0.5, interval=0.1):
timeout = self._timeout if timeout is None else timeout
timeout = timeout or float("inf")
start_time = time.time()
time.sleep(delay)
while 1:
if not self.todo_tasks:
return self.all_tasks
if time.time() - start_time > timeout:
return self.done_tasks
time.sleep(interval) | module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier float default_parameter identifier float block expression_statement assignment identifier conditional_expression attribute identifier identifier comparison_operator identifier none identifier expression_statement assignment identifier boolean_operator identifier call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier while_statement integer block if_statement not_operator attribute identifier identifier block return_statement attribute identifier identifier if_statement comparison_operator binary_operator call attribute identifier identifier argument_list identifier identifier block return_statement attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier | Block, only be used while loop running in a single non-main thread. |
def _get_orig_items(data):
if isinstance(data, dict):
if dd.get_align_bam(data) and tz.get_in(["metadata", "batch"], data) and "group_orig" in data:
return vmulti.get_orig_items(data)
else:
return [data]
else:
return data | module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block if_statement boolean_operator boolean_operator call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list list string string_start string_content string_end string string_start string_content string_end identifier comparison_operator string string_start string_content string_end identifier block return_statement call attribute identifier identifier argument_list identifier else_clause block return_statement list identifier else_clause block return_statement identifier | Retrieve original items in a batch, handling CWL and standard cases. |
def options(self, url: StrOrURL, *, allow_redirects: bool=True,
**kwargs: Any) -> '_RequestContextManager':
return _RequestContextManager(
self._request(hdrs.METH_OPTIONS, url,
allow_redirects=allow_redirects,
**kwargs)) | module function_definition identifier parameters identifier typed_parameter identifier type identifier keyword_separator typed_default_parameter identifier type identifier true typed_parameter dictionary_splat_pattern identifier type identifier type string string_start string_content string_end block return_statement call identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier identifier keyword_argument identifier identifier dictionary_splat identifier | Perform HTTP OPTIONS request. |
def download_file_job(entry, directory, checksums, filetype='genbank', symlink_path=None):
pattern = NgdConfig.get_fileending(filetype)
filename, expected_checksum = get_name_and_checksum(checksums, pattern)
base_url = convert_ftp_url(entry['ftp_path'])
full_url = '{}/{}'.format(base_url, filename)
local_file = os.path.join(directory, filename)
full_symlink = None
if symlink_path is not None:
full_symlink = os.path.join(symlink_path, filename)
mtable = metadata.get()
mtable.add(entry, local_file)
return DownloadJob(full_url, local_file, expected_checksum, full_symlink) | module function_definition identifier parameters identifier identifier identifier default_parameter identifier string string_start string_content string_end default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement assignment identifier none if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier identifier return_statement call identifier argument_list identifier identifier identifier identifier | Generate a DownloadJob that actually triggers a file download. |
def _Execute(self, options):
whitelist = dict(
name=options["name"],
description=options.get("description", "<empty>"))
return self._agent.client.compute.security_groups.create(**whitelist) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end return_statement call attribute attribute attribute attribute attribute identifier identifier identifier identifier identifier identifier argument_list dictionary_splat identifier | Handles security groups operations. |
def play(self):
self.t = 1
while self.t <= self.T:
for i in range(self.N):
for j in range(self.N):
live = self.live_neighbours(i, j)
if (self.old_grid[i][j] == 1 and live < 2):
self.new_grid[i][j] = 0
elif (self.old_grid[i][j] == 1 and (live == 2 or live == 3)):
self.new_grid[i][j] = 1
elif (self.old_grid[i][j] == 1 and live > 3):
self.new_grid[i][j] = 0
elif (self.old_grid[i][j] == 0 and live == 3):
self.new_grid[i][j] = 1
self.old_grid = self.new_grid.copy()
self.draw_board()
self.t += 1 | module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier integer while_statement comparison_operator attribute identifier identifier attribute identifier identifier block for_statement identifier call identifier argument_list attribute identifier identifier block for_statement identifier call identifier argument_list attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement parenthesized_expression boolean_operator comparison_operator subscript subscript attribute identifier identifier identifier identifier integer comparison_operator identifier integer block expression_statement assignment subscript subscript attribute identifier identifier identifier identifier integer elif_clause parenthesized_expression boolean_operator comparison_operator subscript subscript attribute identifier identifier identifier identifier integer parenthesized_expression boolean_operator comparison_operator identifier integer comparison_operator identifier integer block expression_statement assignment subscript subscript attribute identifier identifier identifier identifier integer elif_clause parenthesized_expression boolean_operator comparison_operator subscript subscript attribute identifier identifier identifier identifier integer comparison_operator identifier integer block expression_statement assignment subscript subscript attribute identifier identifier identifier identifier integer elif_clause parenthesized_expression boolean_operator comparison_operator subscript subscript attribute identifier identifier identifier identifier integer comparison_operator identifier integer block expression_statement assignment subscript subscript attribute identifier identifier identifier identifier integer expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement augmented_assignment attribute identifier identifier integer | Play Conway's Game of Life. |
def do_workers(self, args):
workers = self.task_master.workers(alive=not args.all)
for k in sorted(workers.iterkeys()):
self.stdout.write('{0} ({1})\n'.format(k, workers[k]))
if args.details:
heartbeat = self.task_master.get_heartbeat(k)
for hk, hv in heartbeat.iteritems():
self.stdout.write(' {0}: {1}\n'.format(hk, hv)) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier not_operator attribute identifier identifier for_statement identifier call identifier argument_list call attribute identifier identifier argument_list block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier subscript identifier identifier if_statement attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier identifier | list all known workers |
def _delete(self, c, context, hm):
pools = hm.get("pools", [])
for pool in pools:
pool_id = pool.get("pool_id")
self._dissociate(c, context, hm, pool_id)
self._delete_unused(c, context, hm) | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end list for_statement identifier 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 identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier identifier | Delete a healthmonitor and ALL its pool associations |
def monitor(self, name, ip, port, quorum):
fut = self.execute(b'MONITOR', name, ip, port, quorum)
return wait_ok(fut) | module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier identifier identifier return_statement call identifier argument_list identifier | Add a new master to Sentinel to be monitored. |
def add_uniform_precip_event(self, intensity, duration):
self.project_manager.setCard('PRECIP_UNIF', '')
self.project_manager.setCard('RAIN_INTENSITY', str(intensity))
self.project_manager.setCard('RAIN_DURATION', str(duration.total_seconds()/60.0)) | module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_end expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end call identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end call identifier argument_list binary_operator call attribute identifier identifier argument_list float | Add a uniform precip event |
def _index_resized(self, col, old_width, new_width):
self.table_index.setColumnWidth(col, new_width)
self._update_layout() | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list | Resize the corresponding column of the index section selected. |
def _parse_lobby_chat(self, messages, source, timestamp):
for message in messages:
if message.message_length == 0:
continue
chat = ChatMessage(message.message, timestamp, self._players(), source=source)
self._parse_chat(chat) | module function_definition identifier parameters identifier identifier identifier identifier block for_statement identifier identifier block if_statement comparison_operator attribute identifier identifier integer block continue_statement expression_statement assignment identifier call identifier argument_list attribute identifier identifier identifier call attribute identifier identifier argument_list keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier | Parse a lobby chat message. |
def DrawIconAndLabel(self, dc, node, x, y, w, h, depth):
if w-2 < self._em_size_//2 or h-2 < self._em_size_ //2:
return
dc.SetClippingRegion(x+1, y+1, w-2, h-2)
try:
icon = self.adapter.icon(node, node==self.selectedNode)
if icon and h >= icon.GetHeight() and w >= icon.GetWidth():
iconWidth = icon.GetWidth() + 2
dc.DrawIcon(icon, x+2, y+2)
else:
iconWidth = 0
if self.labels and h >= dc.GetTextExtent('ABC')[1]:
dc.SetTextForeground(self.TextForegroundForNode(node, depth))
dc.DrawText(self.adapter.label(node), x + iconWidth + 2, y+2)
finally:
dc.DestroyClippingRegion() | module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier identifier block if_statement boolean_operator comparison_operator binary_operator identifier integer binary_operator attribute identifier identifier integer comparison_operator binary_operator identifier integer binary_operator attribute identifier identifier integer block return_statement expression_statement call attribute identifier identifier argument_list binary_operator identifier integer binary_operator identifier integer binary_operator identifier integer binary_operator identifier integer try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier comparison_operator identifier attribute identifier identifier if_statement boolean_operator boolean_operator identifier comparison_operator identifier call attribute identifier identifier argument_list comparison_operator identifier call attribute identifier identifier argument_list block expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list identifier binary_operator identifier integer binary_operator identifier integer else_clause block expression_statement assignment identifier integer if_statement boolean_operator attribute identifier identifier comparison_operator identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end integer block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier binary_operator binary_operator identifier identifier integer binary_operator identifier integer finally_clause block expression_statement call attribute identifier identifier argument_list | Draw the icon, if any, and the label, if any, of the node. |
def assign_routes(self, app):
for grp in self.filters:
for f in self.filters[grp]:
if f.route_func:
f.register_route(app)
for c in self.charts:
if c.route_func:
c.register_route(app) | module function_definition identifier parameters identifier identifier block for_statement identifier attribute identifier identifier block for_statement identifier subscript attribute identifier identifier identifier block if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier for_statement identifier attribute identifier identifier block if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier | Register routes with the app. |
def update_gol(self):
updated_grid = [[self.update_cell(row, col) \
for col in range(self.get_grid_width())] \
for row in range(self.get_grid_height())]
self.replace_grid(updated_grid) | module function_definition identifier parameters identifier block expression_statement assignment identifier list_comprehension list_comprehension call attribute identifier identifier argument_list identifier identifier line_continuation for_in_clause identifier call identifier argument_list call attribute identifier identifier argument_list line_continuation for_in_clause identifier call identifier argument_list call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier | Function that performs one step of the Game of Life |
def info(cabdir, header=False):
pfile = "{}/parameters.json".format(cabdir)
if not os.path.exists(pfile):
raise RuntimeError("Cab could not be found at : {}".format(cabdir))
cab_definition = cab.CabDefinition(parameter_file=pfile)
cab_definition.display(header) | module function_definition identifier parameters identifier default_parameter identifier false block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier | prints out help information about a cab |
def memoize_methodcalls(func, pickle=False, dumps=pickle.dumps):
cache = func._memoize_cache = {}
@functools.wraps(func)
def memoizer(self, *args, **kwargs):
if pickle:
key = dumps((args, kwargs))
else:
key = args
if key not in cache:
cache[key] = func(self, *args, **kwargs)
return cache[key]
return memoizer | module function_definition identifier parameters identifier default_parameter identifier false default_parameter identifier attribute identifier identifier block expression_statement assignment identifier assignment attribute identifier identifier dictionary decorated_definition decorator call attribute identifier identifier argument_list identifier function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block if_statement identifier block expression_statement assignment identifier call identifier argument_list tuple identifier identifier else_clause block expression_statement assignment identifier identifier if_statement comparison_operator identifier identifier block expression_statement assignment subscript identifier identifier call identifier argument_list identifier list_splat identifier dictionary_splat identifier return_statement subscript identifier identifier return_statement identifier | Cache the results of the function for each input it gets called with. |
def _get_pooling_layers(self, start_node_id, end_node_id):
layer_list = []
node_list = [start_node_id]
assert self._depth_first_search(end_node_id, layer_list, node_list)
ret = []
for layer_id in layer_list:
layer = self.layer_list[layer_id]
if is_layer(layer, "Pooling"):
ret.append(layer)
elif is_layer(layer, "Conv") and layer.stride != 1:
ret.append(layer)
return ret | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier list expression_statement assignment identifier list identifier assert_statement call attribute identifier identifier argument_list identifier identifier identifier expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier identifier if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier elif_clause boolean_operator call identifier argument_list identifier string string_start string_content string_end comparison_operator attribute identifier identifier integer block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | Given two node IDs, return all the pooling layers between them. |
def reader(f):
return unicodecsv.reader(f, encoding='utf-8', delimiter=b',', quotechar=b'"') | module function_definition identifier parameters identifier block return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end | CSV Reader factory for CADA format |
def patch(self, path, data, **options):
data, options = self._update_request(data, options)
return self.request('patch', path, data=data, **options) | module function_definition identifier parameters identifier identifier identifier dictionary_splat_pattern identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier identifier return_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier keyword_argument identifier identifier dictionary_splat identifier | Parses PATCH request options and dispatches a request |
def distance(self, other):
return math.acos(self._pos3d.dot(other.vector)) | module function_definition identifier parameters identifier identifier block return_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list attribute identifier identifier | Distance to another point on the sphere |
def validate_obj(keys, obj):
msg = ''
for k in keys:
if isinstance(k, str):
if k not in obj or (not isinstance(obj[k], list) and not obj[k]):
if msg:
msg = "%s," % msg
msg = "%s%s" % (msg, k)
elif isinstance(k, list):
found = False
for k_a in k:
if k_a in obj:
found = True
if not found:
if msg:
msg = "%s," % msg
msg = "%s(%s" % (msg, ','.join(k))
if msg:
msg = "%s missing" % msg
return msg | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier string string_start string_end for_statement identifier identifier block if_statement call identifier argument_list identifier identifier block if_statement boolean_operator comparison_operator identifier identifier parenthesized_expression boolean_operator not_operator call identifier argument_list subscript identifier identifier identifier not_operator subscript identifier identifier block if_statement identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end identifier expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier identifier elif_clause call identifier argument_list identifier identifier block expression_statement assignment identifier false for_statement identifier identifier block if_statement comparison_operator identifier identifier block expression_statement assignment identifier true if_statement not_operator identifier block if_statement identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end identifier expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier call attribute string string_start string_content string_end identifier argument_list identifier if_statement identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end identifier return_statement identifier | Super simple "object" validation. |
def save(self, *args, **kwargs):
if not self.status:
self.status == Event.RegStatus.hidden
super(PrivateLessonEvent,self).save(*args,**kwargs) | module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block if_statement not_operator attribute identifier identifier block expression_statement comparison_operator attribute identifier identifier attribute attribute identifier identifier identifier expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list list_splat identifier dictionary_splat identifier | Set registration status to hidden if it is not specified otherwise |
def visit_const(self, node, parent):
return nodes.Const(
node.value,
getattr(node, "lineno", None),
getattr(node, "col_offset", None),
parent,
) | module function_definition identifier parameters identifier identifier identifier block return_statement call attribute identifier identifier argument_list attribute identifier identifier call identifier argument_list identifier string string_start string_content string_end none call identifier argument_list identifier string string_start string_content string_end none identifier | visit a Const node by returning a fresh instance of it |
def morrison_and_stephenson_2004_table():
import pandas as pd
f = load.open('http://eclipse.gsfc.nasa.gov/SEcat5/deltat.html')
tables = pd.read_html(f.read())
df = tables[0]
return pd.DataFrame({'year': df[0], 'delta_t': df[1]}) | module function_definition identifier parameters block import_statement aliased_import dotted_name identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement assignment identifier subscript identifier integer return_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end subscript identifier integer pair string string_start string_content string_end subscript identifier integer | Table of smoothed Delta T values from Morrison and Stephenson, 2004. |
def init_debug(self):
import signal
def debug_trace(sig, frame):
self.log('Trace signal received')
self.log(''.join(traceback.format_stack(frame)))
signal.signal(signal.SIGUSR2, debug_trace) | module function_definition identifier parameters identifier block import_statement dotted_name identifier function_definition identifier parameters 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 call attribute string string_start string_end identifier argument_list call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier | Initialize debugging features, such as a handler for USR2 to print a trace |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.