code stringlengths 51 2.34k | sequence stringlengths 186 3.94k | docstring stringlengths 11 171 |
|---|---|---|
def initStats(self):
url = "%s://%s:%d/%s?auto" % (self._proto, self._host, self._port,
self._statuspath)
response = util.get_url(url, self._user, self._password)
self._statusDict = {}
for line in response.splitlines():
mobj = re.match('(\S.*\S)\s*:\s*(\S+)\s*$', line)
if mobj:
self._statusDict[mobj.group(1)] = util.parse_value(mobj.group(2))
if self._statusDict.has_key('Scoreboard'):
self._statusDict['MaxWorkers'] = len(self._statusDict['Scoreboard']) | module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier dictionary for_statement identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement identifier block expression_statement assignment subscript attribute identifier identifier call attribute identifier identifier argument_list integer call attribute identifier identifier argument_list call attribute identifier identifier argument_list integer if_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end | Query and parse Apache Web Server Status Page. |
def oindex(a, selection):
selection = replace_ellipsis(selection, a.shape)
drop_axes = tuple([i for i, s in enumerate(selection) if is_integer(s)])
selection = ix_(selection, a.shape)
result = a[selection]
if drop_axes:
result = result.squeeze(axis=drop_axes)
return result | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list list_comprehension identifier for_in_clause pattern_list identifier identifier call identifier argument_list identifier if_clause call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier attribute identifier identifier expression_statement assignment identifier subscript identifier identifier if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier return_statement identifier | Implementation of orthogonal indexing with slices and ints. |
def prepare_cached_fields(self, flist):
cls_name = self.__class__
if flist:
Packet.class_default_fields[cls_name] = dict()
Packet.class_default_fields_ref[cls_name] = list()
Packet.class_fieldtype[cls_name] = dict()
Packet.class_packetfields[cls_name] = list()
for f in flist:
if isinstance(f, MultipleTypeField):
del Packet.class_default_fields[cls_name]
del Packet.class_default_fields_ref[cls_name]
del Packet.class_fieldtype[cls_name]
del Packet.class_packetfields[cls_name]
self.class_dont_cache[cls_name] = True
self.do_init_fields(self.fields_desc)
break
tmp_copy = copy.deepcopy(f.default)
Packet.class_default_fields[cls_name][f.name] = tmp_copy
Packet.class_fieldtype[cls_name][f.name] = f
if f.holds_packets:
Packet.class_packetfields[cls_name].append(f)
if isinstance(f.default, (list, dict, set, RandField, Packet)):
Packet.class_default_fields_ref[cls_name].append(f.name) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier if_statement identifier block expression_statement assignment subscript attribute identifier identifier identifier call identifier argument_list expression_statement assignment subscript attribute identifier identifier identifier call identifier argument_list expression_statement assignment subscript attribute identifier identifier identifier call identifier argument_list expression_statement assignment subscript attribute identifier identifier identifier call identifier argument_list for_statement identifier identifier block if_statement call identifier argument_list identifier identifier block delete_statement subscript attribute identifier identifier identifier delete_statement subscript attribute identifier identifier identifier delete_statement subscript attribute identifier identifier identifier delete_statement subscript attribute identifier identifier identifier expression_statement assignment subscript attribute identifier identifier identifier true expression_statement call attribute identifier identifier argument_list attribute identifier identifier break_statement expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment subscript subscript attribute identifier identifier identifier attribute identifier identifier identifier expression_statement assignment subscript subscript attribute identifier identifier identifier attribute identifier identifier identifier if_statement attribute identifier identifier block expression_statement call attribute subscript attribute identifier identifier identifier identifier argument_list identifier if_statement call identifier argument_list attribute identifier identifier tuple identifier identifier identifier identifier identifier block expression_statement call attribute subscript attribute identifier identifier identifier identifier argument_list attribute identifier identifier | Prepare the cached fields of the fields_desc dict |
def _get_stats(self, task, start_date):
stats = []
stats_dir = self._sdir(task.base_dir)
date = start_date
end_date = datetime.date.today()
delta = datetime.timedelta(days=1)
while date <= end_date:
date_str = date.strftime('%Y%m%d')
filename = os.path.join(stats_dir, '{0}.json'.format(date_str))
if os.path.exists(filename):
try:
with open(filename, 'r') as file_:
data = json.loads(file_.read())
stats.append((date, sorted(data.iteritems(),
key=lambda x: x[1],
reverse=True)))
except (json.JSONDecodeError, OSError):
pass
date += delta
return stats | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier list expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier integer while_statement comparison_operator identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier call attribute string string_start string_content string_end identifier argument_list identifier if_statement call attribute attribute identifier identifier identifier argument_list identifier block try_statement block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list tuple identifier call identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier lambda lambda_parameters identifier subscript identifier integer keyword_argument identifier true except_clause tuple attribute identifier identifier identifier block pass_statement expression_statement augmented_assignment identifier identifier return_statement identifier | Fetches statistic information for given task and start range. |
def return_opml_response(self, context, **response_kwargs):
self.template_name = 'fiction_outlines/outline.opml'
response = super().render_to_response(context, content_type='text/xml', **response_kwargs)
response['Content-Disposition'] = 'attachment; filename="{}.opml"'.format(slugify(self.object.title))
return response | module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block expression_statement assignment attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute call identifier argument_list identifier argument_list identifier keyword_argument identifier string string_start string_content string_end dictionary_splat identifier expression_statement assignment subscript identifier string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list call identifier argument_list attribute attribute identifier identifier identifier return_statement identifier | Returns export data as an opml file. |
def __pickleable(tree):
def removeDeviceReference(view):
view.device = None
treeCopy = tree
ViewClient.__traverse(treeCopy[0], transform=removeDeviceReference)
return treeCopy | module function_definition identifier parameters identifier block function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier none expression_statement assignment identifier identifier expression_statement call attribute identifier identifier argument_list subscript identifier integer keyword_argument identifier identifier return_statement identifier | Makes the tree pickleable. |
def labeled_mechanisms(self):
label = self.subsystem.node_labels.indices2labels
return tuple(list(label(mechanism)) for mechanism in self.mechanisms) | module function_definition identifier parameters identifier block expression_statement assignment identifier attribute attribute attribute identifier identifier identifier identifier return_statement call identifier generator_expression call identifier argument_list call identifier argument_list identifier for_in_clause identifier attribute identifier identifier | The labeled mechanism of each concept. |
def slots(self, inherited=False):
data = clips.data.DataObject(self._env)
lib.EnvClassSlots(self._env, self._cls, data.byref, int(inherited))
return (ClassSlot(self._env, self._cls, n.encode()) for n in data.value) | module function_definition identifier parameters identifier default_parameter identifier false block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier call identifier argument_list identifier return_statement generator_expression call identifier argument_list attribute identifier identifier attribute identifier identifier call attribute identifier identifier argument_list for_in_clause identifier attribute identifier identifier | Iterate over the Slots of the class. |
def add_term(self, t):
if t not in self.terms:
if t.parent_term_lc == 'root':
self.terms.append(t)
self.doc.add_term(t, add_section=False)
t.set_ownership()
else:
raise GenerateError("Can only add or move root-level terms. Term '{}' parent is '{}' "
.format(t, t.parent_term_lc))
assert t.section or t.join_lc == 'root.root', t | module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier false expression_statement call attribute identifier identifier argument_list else_clause block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier attribute identifier identifier assert_statement boolean_operator attribute identifier identifier comparison_operator attribute identifier identifier string string_start string_content string_end identifier | Add a term to this section and set it's ownership. Should only be used on root level terms |
def shorten_text(text: str):
if len(text) <= 40:
text = text
else:
text = text[:17] + ' ... ' + text[-17:]
return repr(text) | module function_definition identifier parameters typed_parameter identifier type identifier block if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier identifier else_clause block expression_statement assignment identifier binary_operator binary_operator subscript identifier slice integer string string_start string_content string_end subscript identifier slice unary_operator integer return_statement call identifier argument_list identifier | Return a short repr of text if it is longer than 40 |
def upload(self):
if not self._converter:
raise RuntimeError(
'Must set _converter on subclass or via set_converter before calling '
'upload.')
if not self.credentials:
raise RuntimeError('Must provide credentials to use upload callback.')
def upload_callback(test_record_obj):
proto = self._convert(test_record_obj)
self.upload_result = send_mfg_inspector_data(
proto, self.credentials, self.destination_url)
return upload_callback | module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block raise_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end if_statement not_operator attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier call identifier argument_list identifier attribute identifier identifier attribute identifier identifier return_statement identifier | Returns a callback to convert a test record to a proto and upload. |
def _handle_dbproc_call(self, parts, parameters_metadata):
for part in parts:
if part.kind == part_kinds.ROWSAFFECTED:
self.rowcount = part.values[0]
elif part.kind == part_kinds.TRANSACTIONFLAGS:
pass
elif part.kind == part_kinds.STATEMENTCONTEXT:
pass
elif part.kind == part_kinds.OUTPUTPARAMETERS:
self._buffer = part.unpack_rows(parameters_metadata, self.connection)
self._received_last_resultset_part = True
self._executed = True
elif part.kind == part_kinds.RESULTSETMETADATA:
self.description, self._column_types = self._handle_result_metadata(part)
elif part.kind == part_kinds.RESULTSETID:
self._resultset_id = part.value
elif part.kind == part_kinds.RESULTSET:
self._buffer = part.unpack_rows(self._column_types, self.connection)
self._received_last_resultset_part = part.attribute & 1
self._executed = True
else:
raise InterfaceError("Stored procedure call, unexpected part kind %d." % part.kind)
self._executed = True | module function_definition identifier parameters identifier identifier identifier block for_statement identifier identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier subscript attribute identifier identifier integer elif_clause comparison_operator attribute identifier identifier attribute identifier identifier block pass_statement elif_clause comparison_operator attribute identifier identifier attribute identifier identifier block pass_statement elif_clause comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier attribute identifier identifier expression_statement assignment attribute identifier identifier true expression_statement assignment attribute identifier identifier true elif_clause comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment pattern_list attribute identifier identifier attribute identifier identifier call attribute identifier identifier argument_list identifier elif_clause comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier attribute identifier identifier elif_clause comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier binary_operator attribute identifier identifier integer expression_statement assignment attribute identifier identifier true else_clause block raise_statement call identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier expression_statement assignment attribute identifier identifier true | Handle reply messages from STORED PROCEDURE statements |
def scalars_route(self, request):
tag = request.args.get('tag')
run = request.args.get('run')
experiment = request.args.get('experiment')
output_format = request.args.get('format')
(body, mime_type) = self.scalars_impl(tag, run, experiment, output_format)
return http_util.Respond(request, body, mime_type) | 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 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 attribute identifier identifier identifier argument_list 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 expression_statement assignment tuple_pattern identifier identifier call attribute identifier identifier argument_list identifier identifier identifier identifier return_statement call attribute identifier identifier argument_list identifier identifier identifier | Given a tag and single run, return array of ScalarEvents. |
def _choose_model_from_target_emotions(self):
model_indices = [self.emotion_index_map[emotion] for emotion in self.target_emotions]
sorted_indices = [str(idx) for idx in sorted(model_indices)]
model_suffix = ''.join(sorted_indices)
model_file = 'models/conv_model_%s.hdf5' % model_suffix
emotion_map_file = 'models/conv_emotion_map_%s.json' % model_suffix
emotion_map = json.loads(open(resource_filename('EmoPy', emotion_map_file)).read())
return load_model(resource_filename('EmoPy', model_file)), emotion_map | module function_definition identifier parameters identifier block expression_statement assignment identifier list_comprehension subscript attribute identifier identifier identifier for_in_clause identifier attribute identifier identifier expression_statement assignment identifier list_comprehension call identifier argument_list identifier for_in_clause identifier call identifier argument_list identifier expression_statement assignment identifier call attribute string string_start string_end identifier argument_list identifier 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 identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute call identifier argument_list call identifier argument_list string string_start string_content string_end identifier identifier argument_list return_statement expression_list call identifier argument_list call identifier argument_list string string_start string_content string_end identifier identifier | Initializes pre-trained deep learning model for the set of target emotions supplied by user. |
def vary_radius(dt):
global time
time += dt
disc.inner_radius = disc.outer_radius = 2.5 + math.sin(time / 2.0) * 1.5 | module function_definition identifier parameters identifier block global_statement identifier expression_statement augmented_assignment identifier identifier expression_statement assignment attribute identifier identifier assignment attribute identifier identifier binary_operator float binary_operator call attribute identifier identifier argument_list binary_operator identifier float float | Vary the disc radius over time |
def project_transfer_config_path(cls, project, transfer_config):
return google.api_core.path_template.expand(
"projects/{project}/transferConfigs/{transfer_config}",
project=project,
transfer_config=transfer_config,
) | module function_definition identifier parameters identifier identifier identifier block return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier | Return a fully-qualified project_transfer_config string. |
def list(request, content_type, id):
app_label, model = content_type.split('-')
ctype = ContentType.objects.get(app_label=app_label, model=model)
obj = ctype.get_object_for_this_type(id=id)
t = Template("{% load comments %}{% render_comment_list for object %}")
context = RequestContext(request)
context.update({'object': obj})
result = t.render(context)
return HttpResponse(result) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier expression_statement assignment identifier call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement call identifier argument_list identifier | Wrapper exposing comment's render_comment_list tag as a view. |
def write(self, ontol, **args):
s = self.render(ontol, **args)
if self.outfile is None:
print(s)
else:
f = open(self.outfile, 'w')
f.write(s)
f.close() | module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier dictionary_splat identifier if_statement comparison_operator attribute identifier identifier none block expression_statement call identifier argument_list identifier else_clause block expression_statement assignment identifier call identifier argument_list attribute identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list | Write a `ontology` object |
def import_dashboard_config(modules):
config = collections.defaultdict(dict)
for module in modules:
for submodule in import_submodules(module).values():
if hasattr(submodule, 'DASHBOARD'):
dashboard = submodule.DASHBOARD
config[dashboard].update(submodule.__dict__)
elif (hasattr(submodule, 'PANEL') or
hasattr(submodule, 'PANEL_GROUP') or
hasattr(submodule, 'FEATURE')):
name = submodule.__name__.rsplit('.', 1)[1]
config[name] = submodule.__dict__
else:
logging.warning("Skipping %s because it doesn't have DASHBOARD"
", PANEL, PANEL_GROUP, or FEATURE defined.",
submodule.__name__)
return sorted(config.items(),
key=lambda c: c[1]['__name__'].rsplit('.', 1)[1]) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement identifier identifier block for_statement identifier call attribute call identifier argument_list identifier identifier argument_list block if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier attribute identifier identifier expression_statement call attribute subscript identifier identifier identifier argument_list attribute identifier identifier elif_clause parenthesized_expression boolean_operator boolean_operator call identifier argument_list identifier string string_start string_content string_end call identifier argument_list identifier string string_start string_content string_end call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier subscript call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end integer integer expression_statement assignment subscript identifier identifier attribute identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end attribute identifier identifier return_statement call identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier lambda lambda_parameters identifier subscript call attribute subscript subscript identifier integer string string_start string_content string_end identifier argument_list string string_start string_content string_end integer integer | Imports configuration from all the modules and merges it. |
def Start(self):
if not self.started:
self.started = True
for _ in range(self.min_threads):
self._AddWorker() | module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block expression_statement assignment attribute identifier identifier true for_statement identifier call identifier argument_list attribute identifier identifier block expression_statement call attribute identifier identifier argument_list | This starts the worker threads. |
def FormatAsHexString(num, width=None, prefix="0x"):
hex_str = hex(num)[2:]
hex_str = hex_str.replace("L", "")
if width:
hex_str = hex_str.rjust(width, "0")
return "%s%s" % (prefix, hex_str) | module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier subscript call identifier argument_list identifier slice integer expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end return_statement binary_operator string string_start string_content string_end tuple identifier identifier | Takes an int and returns the number formatted as a hex string. |
def fetch_trades_since(self, since: int) -> List[Trade]:
return self._fetch_since('trades', self.market.code)(self._trades_since)(since) | module function_definition identifier parameters identifier typed_parameter identifier type identifier type generic_type identifier type_parameter type identifier block return_statement call call call attribute identifier identifier argument_list string string_start string_content string_end attribute attribute identifier identifier identifier argument_list attribute identifier identifier argument_list identifier | Fetch trades since given timestamp. |
def clear_weights(self):
self.weighted = False
for layer in self.layer_list:
layer.weights = None | module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier false for_statement identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier none | clear weights of the graph |
def recenter(positions):
(x0, y0, z0), (x1, y1, z1) = bounding_box(positions)
dx = x1 - (x1 - x0) / 2.0
dy = y1 - (y1 - y0) / 2.0
dz = z1 - (z1 - z0) / 2.0
result = []
for x, y, z in positions:
result.append((x - dx, y - dy, z - dz))
return result | module function_definition identifier parameters identifier block expression_statement assignment pattern_list tuple_pattern identifier identifier identifier tuple_pattern identifier identifier identifier call identifier argument_list identifier expression_statement assignment identifier binary_operator identifier binary_operator parenthesized_expression binary_operator identifier identifier float expression_statement assignment identifier binary_operator identifier binary_operator parenthesized_expression binary_operator identifier identifier float expression_statement assignment identifier binary_operator identifier binary_operator parenthesized_expression binary_operator identifier identifier float expression_statement assignment identifier list for_statement pattern_list identifier identifier identifier identifier block expression_statement call attribute identifier identifier argument_list tuple binary_operator identifier identifier binary_operator identifier identifier binary_operator identifier identifier return_statement identifier | Returns a list of new positions centered around the origin. |
def _has_example(self, label):
if label in self._raw_examples:
return True
else:
for field in self.all_fields:
dt, _ = unwrap_nullable(field.data_type)
if not is_user_defined_type(dt) and not is_void_type(dt):
continue
if label == field.name:
return True
else:
return False | module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block return_statement true else_clause block for_statement identifier attribute identifier identifier block expression_statement assignment pattern_list identifier identifier call identifier argument_list attribute identifier identifier if_statement boolean_operator not_operator call identifier argument_list identifier not_operator call identifier argument_list identifier block continue_statement if_statement comparison_operator identifier attribute identifier identifier block return_statement true else_clause block return_statement false | Whether this data type has an example with the given ``label``. |
def __check_to_permit(self, entry_type, entry_filename):
rules = self.__filter_rules[entry_type]
for pattern in rules[fss.constants.FILTER_INCLUDE]:
if fnmatch.fnmatch(entry_filename, pattern):
_LOGGER_FILTER.debug("Entry explicitly INCLUDED: [%s] [%s] "
"[%s]",
entry_type, pattern, entry_filename)
return True
for pattern in rules[fss.constants.FILTER_EXCLUDE]:
if fnmatch.fnmatch(entry_filename, pattern):
_LOGGER_FILTER.debug("Entry explicitly EXCLUDED: [%s] [%s] "
"[%s]",
entry_type, pattern, entry_filename)
return False
_LOGGER_FILTER.debug("Entry IMPLICITLY included: [%s] [%s]",
entry_type, entry_filename)
return True | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier identifier for_statement identifier subscript identifier attribute attribute identifier identifier identifier block if_statement call attribute identifier identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end identifier identifier identifier return_statement true for_statement identifier subscript identifier attribute attribute identifier identifier identifier block if_statement call attribute identifier identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end identifier identifier identifier return_statement false expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier return_statement true | Applying the filter rules. |
def create_menu(self):
menu = QtWidgets.QMenu(self.editor)
menu.setTitle(_('Select'))
menu.menuAction().setIcon(QtGui.QIcon.fromTheme('edit-select'))
menu.addAction(self.action_select_word)
menu.addAction(self.action_select_extended_word)
menu.addAction(self.action_select_matched)
menu.addAction(self.action_select_line)
menu.addSeparator()
menu.addAction(self.editor.action_select_all)
icon = QtGui.QIcon.fromTheme(
'edit-select-all', QtGui.QIcon(
':/pyqode-icons/rc/edit-select-all.png'))
self.editor.action_select_all.setIcon(icon)
return menu | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute 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 expression_statement call attribute call attribute identifier identifier argument_list identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier return_statement identifier | Creates the extended selection menu. |
def _get_block_transaction_data(db: BaseDB, transaction_root: Hash32) -> Iterable[Hash32]:
transaction_db = HexaryTrie(db, root_hash=transaction_root)
for transaction_idx in itertools.count():
transaction_key = rlp.encode(transaction_idx)
if transaction_key in transaction_db:
yield transaction_db[transaction_key]
else:
break | module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type identifier type generic_type identifier type_parameter type identifier block expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier for_statement identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier identifier block expression_statement yield subscript identifier identifier else_clause block break_statement | Returns iterable of the encoded transactions for the given block header |
def multi_agent_example():
env = holodeck.make("UrbanCity")
cmd0 = np.array([0, 0, -2, 10])
cmd1 = np.array([0, 0, 5, 10])
for i in range(10):
env.reset()
sensors = [Sensors.PIXEL_CAMERA, Sensors.LOCATION_SENSOR, Sensors.VELOCITY_SENSOR]
agent = AgentDefinition("uav1", agents.UavAgent, sensors)
env.spawn_agent(agent, [1, 1, 5])
env.set_control_scheme("uav0", ControlSchemes.UAV_ROLL_PITCH_YAW_RATE_ALT)
env.set_control_scheme("uav1", ControlSchemes.UAV_ROLL_PITCH_YAW_RATE_ALT)
env.tick()
env.act("uav0", cmd0)
env.act("uav1", cmd1)
for _ in range(1000):
states = env.tick()
uav0_terminal = states["uav0"][Sensors.TERMINAL]
uav1_reward = states["uav1"][Sensors.REWARD] | module function_definition identifier parameters block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list list integer integer unary_operator integer integer expression_statement assignment identifier call attribute identifier identifier argument_list list integer integer integer integer for_statement identifier call identifier argument_list integer block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier list attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list string string_start string_content string_end attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier list integer integer integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier for_statement identifier call identifier argument_list integer block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier subscript subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier subscript subscript identifier string string_start string_content string_end attribute identifier identifier | A basic example of using multiple agents |
def shutdown(self):
try:
while True:
self._executor._work_queue.get(block=False)
except queue.Empty:
pass
self._executor.shutdown() | module function_definition identifier parameters identifier block try_statement block while_statement true block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list keyword_argument identifier false except_clause attribute identifier identifier block pass_statement expression_statement call attribute attribute identifier identifier identifier argument_list | Shuts down the scheduler and immediately end all pending callbacks. |
def partition(pred, iterable):
trues = []
falses = []
for item in iterable:
if pred(item):
trues.append(item)
else:
falses.append(item)
return trues, falses | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list expression_statement assignment identifier list for_statement identifier identifier block if_statement call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier return_statement expression_list identifier identifier | split the results of an iterable based on a predicate |
def date_to_timestamp(date):
date_tuple = date.timetuple()
timestamp = calendar.timegm(date_tuple) * 1000
return timestamp | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list identifier integer return_statement identifier | date to unix timestamp in milliseconds |
def printcolour(text, sameline=False, colour=get_colour("ENDC")):
if sameline:
sep = ''
else:
sep = '\n'
sys.stdout.write(get_colour(colour) + text + bcolours["ENDC"] + sep) | module function_definition identifier parameters identifier default_parameter identifier false default_parameter identifier call identifier argument_list string string_start string_content string_end block if_statement identifier block expression_statement assignment identifier string string_start string_end else_clause block expression_statement assignment identifier string string_start string_content escape_sequence string_end expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator binary_operator binary_operator call identifier argument_list identifier identifier subscript identifier string string_start string_content string_end identifier | Print color text using escape codes |
def do_node_set(self, element, decl, pseudo):
target = serialize(decl.value).strip()
step = self.state[self.state['current_step']]
elem = self.current_target().tree
_, valstep = self.lookup('pending', target)
if not valstep:
step['pending'][target] = [('nodeset', elem)]
else:
self.state[valstep]['pending'][target] = [('nodeset', elem)] | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute call identifier argument_list attribute identifier identifier identifier argument_list expression_statement assignment identifier subscript attribute identifier identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier attribute call attribute identifier identifier argument_list identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement not_operator identifier block expression_statement assignment subscript subscript identifier string string_start string_content string_end identifier list tuple string string_start string_content string_end identifier else_clause block expression_statement assignment subscript subscript subscript attribute identifier identifier identifier string string_start string_content string_end identifier list tuple string string_start string_content string_end identifier | Implement node-set declaration. |
def _check_success(self):
t, d, cos = self._compute_orientation()
return d < 0.06 and t >= -0.12 and t <= 0.14 and cos > 0.95 | module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier identifier call attribute identifier identifier argument_list return_statement boolean_operator boolean_operator boolean_operator comparison_operator identifier float comparison_operator identifier unary_operator float comparison_operator identifier float comparison_operator identifier float | Returns True if task is successfully completed. |
def find_parent_scope(block):
original = block
if not TextBlockHelper.is_fold_trigger(block):
while block.text().strip() == '' and block.isValid():
block = block.next()
ref_lvl = TextBlockHelper.get_fold_lvl(block) - 1
block = original
while (block.blockNumber() and
(not TextBlockHelper.is_fold_trigger(block) or
TextBlockHelper.get_fold_lvl(block) > ref_lvl)):
block = block.previous()
return block | module function_definition identifier parameters identifier block expression_statement assignment identifier identifier if_statement not_operator call attribute identifier identifier argument_list identifier block while_statement boolean_operator comparison_operator call attribute call attribute identifier identifier argument_list identifier argument_list string string_start string_end call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list identifier integer expression_statement assignment identifier identifier while_statement parenthesized_expression boolean_operator call attribute identifier identifier argument_list parenthesized_expression boolean_operator not_operator call attribute identifier identifier argument_list identifier comparison_operator call attribute identifier identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list return_statement identifier | Find parent scope, if the block is not a fold trigger. |
def async_set_ac_state_property(
self, uid, name, value, ac_state=None, assumed_state=False):
if ac_state is None:
ac_state = yield from self.async_get_ac_states(uid)
ac_state = ac_state[0]['acState']
data = {
'currentAcState': ac_state,
'newValue': value
}
if assumed_state:
data['reason'] = "StateCorrectionByUser"
resp = yield from self._session.patch(
_SERVER + '/pods/{}/acStates/{}'.format(uid, name),
data=json.dumps(data),
params=self._params,
timeout=self._timeout)
try:
return (yield from resp.json())['result']
except aiohttp.client_exceptions.ContentTypeError:
pass
raise SensiboError((yield from resp.text())) | module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier none default_parameter identifier false block if_statement comparison_operator identifier none block expression_statement assignment identifier yield call attribute identifier identifier argument_list identifier expression_statement assignment identifier subscript subscript identifier integer string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier yield call attribute attribute identifier identifier identifier argument_list binary_operator identifier call attribute string string_start string_content string_end identifier argument_list identifier identifier keyword_argument identifier call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier try_statement block return_statement subscript parenthesized_expression yield call attribute identifier identifier argument_list string string_start string_content string_end except_clause attribute attribute identifier identifier identifier block pass_statement raise_statement call identifier argument_list parenthesized_expression yield call attribute identifier identifier argument_list | Set a specific device property. |
def translate_item(self, item_dict):
if not item_dict.get('title'):
return None
if item_dict.get('{wp}post_type', None) == 'attachment':
return None
ret_dict = {}
ret_dict['slug']= item_dict.get('{wp}post_name') or re.sub(item_dict['title'],' ','-')
ret_dict['ID']= item_dict['guid']
ret_dict['title']= item_dict['title']
ret_dict['description']= item_dict['description']
ret_dict['content']= item_dict['{content}encoded']
ret_dict['author']= {'username':item_dict['{dc}creator'],
'first_name':'',
'last_name':''}
ret_dict['terms']= item_dict.get('terms')
ret_dict['date']= self.convert_date(
item_dict['pubDate'],
fallback=item_dict.get('{wp}post_date','')
)
return ret_dict | module function_definition identifier parameters identifier identifier block if_statement not_operator call attribute identifier identifier argument_list string string_start string_content string_end block return_statement none if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end none string string_start string_content string_end block return_statement none expression_statement assignment identifier dictionary expression_statement assignment subscript identifier string string_start string_content string_end boolean_operator call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end dictionary pair string string_start string_content string_end subscript identifier string string_start string_content string_end pair string string_start string_content string_end string string_start string_end pair string string_start string_content string_end string string_start string_end expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end keyword_argument identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end return_statement identifier | cleanup item keys to match API json format |
def _aix_get_machine_id():
grains = {}
cmd = salt.utils.path.which('lsattr')
if cmd:
data = __salt__['cmd.run']('{0} -El sys0'.format(cmd)) + os.linesep
uuid_regexes = [re.compile(r'(?im)^\s*os_uuid\s+(\S+)\s+(.*)')]
for regex in uuid_regexes:
res = regex.search(data)
if res and len(res.groups()) >= 1:
grains['machine_id'] = res.group(1).strip()
break
else:
log.error('The \'lsattr\' binary was not found in $PATH.')
return grains | module function_definition identifier parameters block expression_statement assignment identifier dictionary expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement assignment identifier binary_operator call subscript identifier string string_start string_content string_end argument_list call attribute string string_start string_content string_end identifier argument_list identifier attribute identifier identifier expression_statement assignment identifier list call attribute identifier identifier argument_list string string_start string_content string_end for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement boolean_operator identifier comparison_operator call identifier argument_list call attribute identifier identifier argument_list integer block expression_statement assignment subscript identifier string string_start string_content string_end call attribute call attribute identifier identifier argument_list integer identifier argument_list break_statement else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence escape_sequence string_end return_statement identifier | Parse the output of lsattr -El sys0 for os_uuid |
def invert_delete_row2(self, key, value):
self.rows = filter(lambda x: x.get(key) == x.get(value), self.rows) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list lambda lambda_parameters identifier comparison_operator call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier attribute identifier identifier | Invert of type two where there are two columns given |
def load_model(self, config):
for package_name in getattr(config.app, 'modules', []):
module = __import__(package_name, fromlist=['model'])
if hasattr(module, 'model'):
return module.model
return None | module function_definition identifier parameters identifier identifier block for_statement identifier call identifier argument_list attribute identifier identifier string string_start string_content string_end list block expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier list string string_start string_content string_end if_statement call identifier argument_list identifier string string_start string_content string_end block return_statement attribute identifier identifier return_statement none | Load the model extension module |
def calcMD5(path):
if os.path.exists(path) is False:
yield False
else:
command = ['md5sum', path]
p = Popen(command, stdout = PIPE)
for line in p.communicate()[0].splitlines():
yield line.decode('ascii').strip().split()[0]
p.wait()
yield False | module function_definition identifier parameters identifier block if_statement comparison_operator call attribute attribute identifier identifier identifier argument_list identifier false block expression_statement yield false else_clause block expression_statement assignment identifier list string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier for_statement identifier call attribute subscript call attribute identifier identifier argument_list integer identifier argument_list block expression_statement yield subscript call attribute call attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier argument_list identifier argument_list integer expression_statement call attribute identifier identifier argument_list expression_statement yield false | calc MD5 based on path |
def undo(scm, verbose, fake, hard):
scm.fake = fake
scm.verbose = fake or verbose
scm.repo_check()
status_log(scm.undo, 'Last commit removed from history.', hard) | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier boolean_operator identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement call identifier argument_list attribute identifier identifier string string_start string_content string_end identifier | Removes the last commit from history. |
async def create(
cls, boot_source, os, release, *,
arches=None, subarches=None, labels=None):
if not isinstance(boot_source, BootSource):
raise TypeError(
"boot_source must be a BootSource, not %s"
% type(boot_source).__name__)
if arches is None:
arches = ['*']
if subarches is None:
subarches = ['*']
if labels is None:
labels = ['*']
data = await cls._handler.create(
boot_source_id=boot_source.id,
os=os, release=release, arches=arches, subarches=subarches,
labels=labels)
return cls._object(data, {"boot_source_id": boot_source.id}) | module function_definition identifier parameters identifier identifier identifier identifier keyword_separator default_parameter identifier none default_parameter identifier none default_parameter identifier none block if_statement not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end attribute call identifier argument_list identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier list string string_start string_content string_end if_statement comparison_operator identifier none block expression_statement assignment identifier list string string_start string_content string_end if_statement comparison_operator identifier none block expression_statement assignment identifier list string string_start string_content string_end expression_statement assignment identifier await call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier return_statement call attribute identifier identifier argument_list identifier dictionary pair string string_start string_content string_end attribute identifier identifier | Create a new `BootSourceSelection`. |
def send(self, data: bytes = b""):
self.input.extend(data)
self._process() | module function_definition identifier parameters identifier typed_default_parameter identifier type identifier string string_start string_end block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list | send data for parsing |
def _hn2db(self, hn):
db = self.hn_db
hn_found = False
for k,v in db.items():
if v == hn:
ret_hn = k
hn_found = True
if hn_found:
return ret_hn
else:
self.hostname_count += 1
o_domain = self.root_domain
for od,d in self.dn_db.items():
if d in hn:
o_domain = od
new_hn = "host%s.%s" % (self.hostname_count, o_domain)
self.hn_db[new_hn] = hn
return new_hn | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier false for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement comparison_operator identifier identifier block expression_statement assignment identifier identifier expression_statement assignment identifier true if_statement identifier block return_statement identifier else_clause block expression_statement augmented_assignment attribute identifier identifier integer expression_statement assignment identifier attribute identifier identifier for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block if_statement comparison_operator identifier identifier block expression_statement assignment identifier identifier expression_statement assignment identifier binary_operator string string_start string_content string_end tuple attribute identifier identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier return_statement identifier | This will add a hostname for a hostname for an included domain or return an existing entry |
def patch(self, request):
attrs = ('edx_video_id', 'status')
missing = [attr for attr in attrs if attr not in request.data]
if missing:
return Response(
status=status.HTTP_400_BAD_REQUEST,
data={'message': u'"{missing}" params must be specified.'.format(missing=' and '.join(missing))}
)
edx_video_id = request.data['edx_video_id']
video_status = request.data['status']
if video_status not in VALID_VIDEO_STATUSES:
return Response(
status=status.HTTP_400_BAD_REQUEST,
data={'message': u'"{status}" is not a valid Video status.'.format(status=video_status)}
)
try:
video = Video.objects.get(edx_video_id=edx_video_id)
video.status = video_status
video.save()
response_status = status.HTTP_200_OK
response_payload = {}
except Video.DoesNotExist:
response_status = status.HTTP_400_BAD_REQUEST
response_payload = {
'message': u'Video is not found for specified edx_video_id: {edx_video_id}'.format(
edx_video_id=edx_video_id
)
}
return Response(status=response_status, data=response_payload) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier tuple string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier list_comprehension identifier for_in_clause identifier identifier if_clause comparison_operator identifier attribute identifier identifier if_statement identifier block return_statement call identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier dictionary pair string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end if_statement comparison_operator identifier identifier block return_statement call identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier dictionary pair string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier dictionary except_clause attribute identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier return_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier | Update the status of a video. |
def r_sa_check(template, tag_type, is_standalone):
if is_standalone and tag_type not in ['variable', 'no escape']:
on_newline = template.split('\n', 1)
if on_newline[0].isspace() or not on_newline[0]:
return True
else:
return False
else:
return False | module function_definition identifier parameters identifier identifier identifier block if_statement boolean_operator identifier comparison_operator identifier list string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end integer if_statement boolean_operator call attribute subscript identifier integer identifier argument_list not_operator subscript identifier integer block return_statement true else_clause block return_statement false else_clause block return_statement false | Do a final checkto see if a tag could be a standalone |
def configure(self):
dlg = GCPluginConfigDialog(self.__where)
if dlg.exec_() == QDialog.Accepted:
newWhere = dlg.getCheckedOption()
if newWhere != self.__where:
self.__where = newWhere
self.__saveConfiguredWhere() | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier if_statement comparison_operator call attribute identifier identifier argument_list attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list | Configures the garbage collector plugin |
def _get_next_path(headers):
links = headers.get('Link', '')
matches = re.match('<([^>]+)>; rel="next"', links)
if matches:
parsed = urlparse(matches.group(1))
return "?".join([parsed.path, parsed.query]) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement identifier block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list integer return_statement call attribute string string_start string_content string_end identifier argument_list list attribute identifier identifier attribute identifier identifier | Given timeline response headers, returns the path to the next batch |
def filepath(self, filename):
return os.path.join(self.node.full_path, filename) | module function_definition identifier parameters identifier identifier block return_statement call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier identifier | The full path to a file |
def scan(self):
if self.implicit is not None:
return
self.implicit = []
self.implicit_set = set()
self._children_reset()
if not self.has_builder():
return
build_env = self.get_build_env()
executor = self.get_executor()
if implicit_cache and not implicit_deps_changed:
implicit = self.get_stored_implicit()
if implicit is not None:
for tgt in executor.get_all_targets():
tgt.add_to_implicit(implicit)
if implicit_deps_unchanged or self.is_up_to_date():
return
for tgt in executor.get_all_targets():
tgt.implicit = []
tgt.implicit_set = set()
executor.scan_sources(self.builder.source_scanner)
scanner = self.get_target_scanner()
if scanner:
executor.scan_targets(scanner) | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block return_statement expression_statement assignment attribute identifier identifier list expression_statement assignment attribute identifier identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list if_statement not_operator call attribute identifier identifier argument_list block return_statement expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list if_statement boolean_operator identifier not_operator identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier none block for_statement identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier if_statement boolean_operator identifier call attribute identifier identifier argument_list block return_statement for_statement identifier call attribute identifier identifier argument_list block expression_statement assignment attribute identifier identifier list expression_statement assignment attribute identifier identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier | Scan this node's dependents for implicit dependencies. |
def _delete_horizontal_space(text, pos):
while pos > 0 and text[pos - 1].isspace():
pos -= 1
end_pos = pos
while end_pos < len(text) and text[end_pos].isspace():
end_pos += 1
return text[:pos] + text[end_pos:], pos | module function_definition identifier parameters identifier identifier block while_statement boolean_operator comparison_operator identifier integer call attribute subscript identifier binary_operator identifier integer identifier argument_list block expression_statement augmented_assignment identifier integer expression_statement assignment identifier identifier while_statement boolean_operator comparison_operator identifier call identifier argument_list identifier call attribute subscript identifier identifier identifier argument_list block expression_statement augmented_assignment identifier integer return_statement expression_list binary_operator subscript identifier slice identifier subscript identifier slice identifier identifier | Delete all spaces and tabs around pos. |
def detectors(regex=None, sep='\t', temporary=False):
db = DBManager(temporary=temporary)
dt = db.detectors
if regex is not None:
try:
re.compile(regex)
except re.error:
log.error("Invalid regex!")
return
dt = dt[dt['OID'].str.contains(regex) | dt['CITY'].str.contains(regex)]
dt.to_csv(sys.stdout, sep=sep) | module function_definition identifier parameters default_parameter identifier none default_parameter identifier string string_start string_content escape_sequence string_end default_parameter identifier false block expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier none block try_statement block expression_statement call attribute identifier identifier argument_list identifier except_clause attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement expression_statement assignment identifier subscript identifier binary_operator call attribute attribute subscript identifier string string_start string_content string_end identifier identifier argument_list identifier call attribute attribute subscript identifier string string_start string_content string_end identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier identifier | Print the detectors table |
def lineage(self, h):
lineage = [ ]
predecessors = list(self._graph.predecessors(h))
while len(predecessors):
lineage.append(predecessors[0])
predecessors = list(self._graph.predecessors(predecessors[0]))
lineage.reverse()
return lineage | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier while_statement call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list subscript identifier integer expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list subscript identifier integer expression_statement call attribute identifier identifier argument_list return_statement identifier | Returns the lineage of histories leading up to `h`. |
def create_attr_obj(self, protocol_interface, phy_interface):
self.intf_attr[protocol_interface] = TopoIntfAttr(
protocol_interface, phy_interface)
self.store_obj(protocol_interface, self.intf_attr[protocol_interface]) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier call identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier subscript attribute identifier identifier identifier | Creates the local interface attribute object and stores it. |
def add_writable_file_volume(self,
runtime,
volume,
host_outdir_tgt,
tmpdir_prefix
):
if self.inplace_update:
self.append_volume(runtime, volume.resolved, volume.target,
writable=True)
else:
if host_outdir_tgt:
if not os.path.exists(os.path.dirname(host_outdir_tgt)):
os.makedirs(os.path.dirname(host_outdir_tgt))
shutil.copy(volume.resolved, host_outdir_tgt)
else:
tmp_dir, tmp_prefix = os.path.split(tmpdir_prefix)
tmpdir = tempfile.mkdtemp(prefix=tmp_prefix, dir=tmp_dir)
file_copy = os.path.join(
tmpdir, os.path.basename(volume.resolved))
shutil.copy(volume.resolved, file_copy)
self.append_volume(runtime, file_copy, volume.target,
writable=True)
ensure_writable(host_outdir_tgt or file_copy) | module function_definition identifier parameters identifier identifier identifier identifier identifier block if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier attribute identifier identifier keyword_argument identifier true else_clause block if_statement identifier block if_statement not_operator call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier else_clause block expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier attribute identifier identifier keyword_argument identifier true expression_statement call identifier argument_list boolean_operator identifier identifier | Append a writable file mapping to the runtime option list. |
def _create_minimum_needs_options_action(self):
icon = resources_path('img', 'icons', 'show-global-minimum-needs.svg')
self.action_minimum_needs_config = QAction(
QIcon(icon),
self.tr('Minimum Needs Configuration'),
self.iface.mainWindow())
self.action_minimum_needs_config.setStatusTip(self.tr(
'Open InaSAFE minimum needs configuration'))
self.action_minimum_needs_config.setWhatsThis(self.tr(
'Open InaSAFE minimum needs configuration'))
self.action_minimum_needs_config.triggered.connect(
self.show_minimum_needs_configuration)
self.add_action(
self.action_minimum_needs_config, 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 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 global minimum needs dialog. |
def from_jd(jd):
jd = trunc(jd) + 0.5
depoch = jd - to_jd(475, 1, 1)
cycle = trunc(depoch / 1029983)
cyear = (depoch % 1029983)
if cyear == 1029982:
ycycle = 2820
else:
aux1 = trunc(cyear / 366)
aux2 = cyear % 366
ycycle = trunc(((2134 * aux1) + (2816 * aux2) + 2815) / 1028522) + aux1 + 1
year = ycycle + (2820 * cycle) + 474
if (year <= 0):
year -= 1
yday = (jd - to_jd(year, 1, 1)) + 1
if yday <= 186:
month = ceil(yday / 31)
else:
month = ceil((yday - 6) / 30)
day = int(jd - to_jd(year, month, 1)) + 1
return (year, month, day) | module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator call identifier argument_list identifier float expression_statement assignment identifier binary_operator identifier call identifier argument_list integer integer integer expression_statement assignment identifier call identifier argument_list binary_operator identifier integer expression_statement assignment identifier parenthesized_expression binary_operator identifier integer if_statement comparison_operator identifier integer block expression_statement assignment identifier integer else_clause block expression_statement assignment identifier call identifier argument_list binary_operator identifier integer expression_statement assignment identifier binary_operator identifier integer expression_statement assignment identifier binary_operator binary_operator call identifier argument_list binary_operator parenthesized_expression binary_operator binary_operator parenthesized_expression binary_operator integer identifier parenthesized_expression binary_operator integer identifier integer integer identifier integer expression_statement assignment identifier binary_operator binary_operator identifier parenthesized_expression binary_operator integer identifier integer if_statement parenthesized_expression comparison_operator identifier integer block expression_statement augmented_assignment identifier integer expression_statement assignment identifier binary_operator parenthesized_expression binary_operator identifier call identifier argument_list identifier integer integer integer if_statement comparison_operator identifier integer block expression_statement assignment identifier call identifier argument_list binary_operator identifier integer else_clause block expression_statement assignment identifier call identifier argument_list binary_operator parenthesized_expression binary_operator identifier integer integer expression_statement assignment identifier binary_operator call identifier argument_list binary_operator identifier call identifier argument_list identifier identifier integer integer return_statement tuple identifier identifier identifier | Calculate Persian date from Julian day |
def _prep_cnv_file(cns_file, svcaller, work_dir, data):
in_file = cns_file
out_file = os.path.join(work_dir, "%s-%s-prep.csv" % (utils.splitext_plus(os.path.basename(in_file))[0],
svcaller))
if not utils.file_uptodate(out_file, in_file):
with file_transaction(data, out_file) as tx_out_file:
with open(in_file) as in_handle:
with open(tx_out_file, "w") as out_handle:
reader = csv.reader(in_handle, dialect="excel-tab")
writer = csv.writer(out_handle)
writer.writerow(["chrom", "start", "end", "num.mark", "seg.mean"])
header = next(reader)
for line in reader:
cur = dict(zip(header, line))
if chromhacks.is_autosomal(cur["chromosome"]):
writer.writerow([_to_ucsc_style(cur["chromosome"]), cur["start"],
cur["end"], cur["probes"], cur["log2"]])
return out_file | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier binary_operator string string_start string_content string_end tuple subscript call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier integer identifier if_statement not_operator call attribute identifier identifier argument_list identifier identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier identifier as_pattern_target identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier as_pattern_target identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier identifier if_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list list call identifier argument_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end return_statement identifier | Create a CSV file of CNV calls with log2 and number of marks. |
def addUser(self, username, password,
firstname, lastname,
email, role):
self._invites.append({
"username":username,
"password":password,
"firstname":firstname,
"lastname":lastname,
"fullname":"%s %s" % (firstname, lastname),
"email":email,
"role":role
}) | module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end binary_operator string string_start string_content string_end tuple identifier identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier | adds a user to the invitation list |
def _shallow_clone(self, ref, git_cmd):
git_config = 'protocol.version=2'
git_cmd('-c', git_config, 'fetch', 'origin', ref, '--depth=1')
git_cmd('checkout', ref)
git_cmd(
'-c', git_config, 'submodule', 'update', '--init',
'--recursive', '--depth=1',
) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement call identifier argument_list string string_start string_content string_end identifier string string_start string_content string_end string string_start string_content string_end identifier string string_start string_content string_end expression_statement call identifier argument_list string string_start string_content string_end identifier expression_statement call identifier argument_list string string_start string_content string_end identifier 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 | Perform a shallow clone of a repository and its submodules |
def _create_response(self, datapath, port, req):
src = datapath.ports[port].hw_addr
res_ether = ethernet.ethernet(
slow.SLOW_PROTOCOL_MULTICAST, src, ether.ETH_TYPE_SLOW)
res_lacp = self._create_lacp(datapath, port, req)
res_pkt = packet.Packet()
res_pkt.add_protocol(res_ether)
res_pkt.add_protocol(res_lacp)
res_pkt.serialize()
return res_pkt | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier attribute subscript attribute identifier identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list return_statement identifier | create a packet including LACP. |
def log(self):
logserv = self.system.request_service('LogStoreService')
return logserv.lastlog(html=False) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end return_statement call attribute identifier identifier argument_list keyword_argument identifier false | Return recent log entries as a string. |
def rpc_get_completions(self, filename, source, offset):
results = self._call_backend("rpc_get_completions", [], filename,
get_source(source), offset)
results = list(dict((res['name'], res) for res in results)
.values())
results.sort(key=lambda cand: _pysymbol_key(cand["name"]))
return results | 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 identifier call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list call attribute call identifier generator_expression tuple subscript identifier string string_start string_content string_end identifier for_in_clause identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list keyword_argument identifier lambda lambda_parameters identifier call identifier argument_list subscript identifier string string_start string_content string_end return_statement identifier | Get a list of completion candidates for the symbol at offset. |
def _prepare_output_multi(self, model):
model_name = model.__name__
current_path = os.path.join(self._output_path, '{model}.{extension}'.format(
model=model_name,
extension=self.EXTENSION,
))
self._outfile = codecs.open(current_path, 'w', encoding='utf-8')
print('Dumping {model} to {file}'.format(model=model_name, file=current_path)) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier expression_statement assignment attribute identifier 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 call identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier | If printing to a different file per model, change the file for the current model |
def render_attrs(attrs):
if attrs is not None:
def parts():
for key, value in sorted(attrs.items()):
if value is None:
continue
if value is True:
yield '%s' % (key, )
continue
if key == 'class' and isinstance(value, dict):
if not value:
continue
value = render_class(value)
if key == 'style' and isinstance(value, dict):
if not value:
continue
value = render_style(value)
yield '%s="%s"' % (key, ('%s' % value).replace('"', '"'))
return mark_safe(' %s' % ' '.join(parts()))
return '' | module function_definition identifier parameters identifier block if_statement comparison_operator identifier none block function_definition identifier parameters block for_statement pattern_list identifier identifier call identifier argument_list call attribute identifier identifier argument_list block if_statement comparison_operator identifier none block continue_statement if_statement comparison_operator identifier true block expression_statement yield binary_operator string string_start string_content string_end tuple identifier continue_statement if_statement boolean_operator comparison_operator identifier string string_start string_content string_end call identifier argument_list identifier identifier block if_statement not_operator identifier block continue_statement expression_statement assignment identifier call identifier argument_list identifier if_statement boolean_operator comparison_operator identifier string string_start string_content string_end call identifier argument_list identifier identifier block if_statement not_operator identifier block continue_statement expression_statement assignment identifier call identifier argument_list identifier expression_statement yield binary_operator string string_start string_content string_end tuple identifier call attribute parenthesized_expression binary_operator string string_start string_content string_end identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end return_statement call identifier argument_list binary_operator string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list call identifier argument_list return_statement string string_start string_end | Render HTML attributes, or return '' if no attributes needs to be rendered. |
def monthrange(cls, year, month):
functions.check_valid_bs_range(NepDate(year, month, 1))
return values.NEPALI_MONTH_DAY_DATA[year][month - 1] | module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier identifier integer return_statement subscript subscript attribute identifier identifier identifier binary_operator identifier integer | Returns the number of days in a month |
def send_confirmation():
form_class = _security.send_confirmation_form
if request.is_json:
form = form_class(MultiDict(request.get_json()))
else:
form = form_class()
if form.validate_on_submit():
send_confirmation_instructions(form.user)
if not request.is_json:
do_flash(*get_message('CONFIRMATION_REQUEST',
email=form.user.email))
if request.is_json:
return _render_json(form)
return _security.render_template(
config_value('SEND_CONFIRMATION_TEMPLATE'),
send_confirmation_form=form,
**_ctx('send_confirmation')
) | module function_definition identifier parameters block expression_statement assignment identifier attribute identifier identifier if_statement attribute identifier identifier block expression_statement assignment identifier call identifier argument_list call identifier argument_list call attribute identifier identifier argument_list else_clause block expression_statement assignment identifier call identifier argument_list if_statement call attribute identifier identifier argument_list block expression_statement call identifier argument_list attribute identifier identifier if_statement not_operator attribute identifier identifier block expression_statement call identifier argument_list list_splat call identifier argument_list string string_start string_content string_end keyword_argument identifier attribute attribute identifier identifier identifier if_statement attribute identifier identifier block return_statement call identifier argument_list identifier return_statement call attribute identifier identifier argument_list call identifier argument_list string string_start string_content string_end keyword_argument identifier identifier dictionary_splat call identifier argument_list string string_start string_content string_end | View function which sends confirmation instructions. |
def search_mergedcell_value(xl_sheet, merged_range):
for search_row_idx in range(merged_range[0], merged_range[1]):
for search_col_idx in range(merged_range[2], merged_range[3]):
if xl_sheet.cell(search_row_idx, search_col_idx).value:
return xl_sheet.cell(search_row_idx, search_col_idx)
return False | module function_definition identifier parameters identifier identifier block for_statement identifier call identifier argument_list subscript identifier integer subscript identifier integer block for_statement identifier call identifier argument_list subscript identifier integer subscript identifier integer block if_statement attribute call attribute identifier identifier argument_list identifier identifier identifier block return_statement call attribute identifier identifier argument_list identifier identifier return_statement false | Search for a value in merged_range cells. |
def remove_context(self, name):
context = self.get_context(name)
contexts = self.get_contexts()
contexts.remove(context) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier 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 | Remove a context from kubeconfig. |
def reject_source(ident, comment):
source = get_source(ident)
source.validation.on = datetime.now()
source.validation.comment = comment
source.validation.state = VALIDATION_REFUSED
if current_user.is_authenticated:
source.validation.by = current_user._get_current_object()
source.save()
return source | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment attribute attribute identifier identifier identifier call attribute identifier identifier argument_list expression_statement assignment attribute attribute identifier identifier identifier identifier expression_statement assignment attribute attribute identifier identifier identifier identifier if_statement attribute identifier identifier block expression_statement assignment attribute attribute identifier identifier identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list return_statement identifier | Reject a source for automatic harvesting |
def equal_levels(self, other):
if self.nlevels != other.nlevels:
return False
for i in range(self.nlevels):
if not self.levels[i].equals(other.levels[i]):
return False
return True | module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block return_statement false for_statement identifier call identifier argument_list attribute identifier identifier block if_statement not_operator call attribute subscript attribute identifier identifier identifier identifier argument_list subscript attribute identifier identifier identifier block return_statement false return_statement true | Return True if the levels of both MultiIndex objects are the same |
def transform_dataframe(self, dataframe):
dataframe.columns.name = ""
for i in range(len(self.get_header_fields())):
dataframe = dataframe.unstack()
dataframe = dataframe.dropna(
axis=0, how='all'
).dropna(
axis=1, how='all'
)
return dataframe | module function_definition identifier parameters identifier identifier block expression_statement assignment attribute attribute identifier identifier identifier string string_start string_end for_statement identifier call identifier argument_list call identifier argument_list call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute call attribute identifier identifier argument_list keyword_argument identifier integer keyword_argument identifier string string_start string_content string_end identifier argument_list keyword_argument identifier integer keyword_argument identifier string string_start string_content string_end return_statement identifier | Unstack the dataframe so header fields are across the top. |
async def start(self):
await self.server.start()
self.port = self.server.port | module function_definition identifier parameters identifier block expression_statement await call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier attribute attribute identifier identifier identifier | Start the supervisor server. |
def record_to_fh(self, f):
fr = self.record
if fr.contents:
yaml.safe_dump(fr.unpacked_contents, f, default_flow_style=False, encoding='utf-8')
fr.source_hash = self.fs_hash
fr.modified = self.fs_modtime | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier keyword_argument identifier false keyword_argument identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier | Write the record, in filesystem format, to a file handle or file object |
def to_json(self):
return {
'dry_bulb_max': self.dry_bulb_max,
'dry_bulb_range': self.dry_bulb_range,
'modifier_type': self.modifier_type,
'modifier_schedule': self.modifier_schedule
} | module function_definition identifier parameters identifier block return_statement 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 attribute identifier identifier | Convert the Dry Bulb Condition to a dictionary. |
def _get_recursive_state(widget, store=None, drop_defaults=False):
if store is None:
store = dict()
state = widget._get_embed_state(drop_defaults=drop_defaults)
store[widget.model_id] = state
for ref in _find_widget_refs_by_state(widget, state['state']):
if ref.model_id not in store:
_get_recursive_state(ref, store, drop_defaults=drop_defaults)
return store | module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier false block if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier expression_statement assignment subscript identifier attribute identifier identifier identifier for_statement identifier call identifier argument_list identifier subscript identifier string string_start string_content string_end block if_statement comparison_operator attribute identifier identifier identifier block expression_statement call identifier argument_list identifier identifier keyword_argument identifier identifier return_statement identifier | Gets the embed state of a widget, and all other widgets it refers to as well |
def _sign_response(self, response):
if 'Authorization' not in request.headers:
return response
try:
mohawk_receiver = mohawk.Receiver(
credentials_map=self._client_key_loader_func,
request_header=request.headers['Authorization'],
url=request.url,
method=request.method,
content=request.get_data(),
content_type=request.mimetype,
accept_untrusted_content=current_app.config['HAWK_ACCEPT_UNTRUSTED_CONTENT'],
localtime_offset_in_seconds=current_app.config['HAWK_LOCALTIME_OFFSET_IN_SECONDS'],
timestamp_skew_in_seconds=current_app.config['HAWK_TIMESTAMP_SKEW_IN_SECONDS']
)
except mohawk.exc.HawkFail:
return response
response.headers['Server-Authorization'] = mohawk_receiver.respond(
content=response.data,
content_type=response.mimetype
)
return response | module function_definition identifier parameters identifier identifier block if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block return_statement identifier try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier subscript attribute identifier identifier string string_start string_content string_end keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier subscript attribute identifier identifier string string_start string_content string_end keyword_argument identifier subscript attribute identifier identifier string string_start string_content string_end keyword_argument identifier subscript attribute identifier identifier string string_start string_content string_end except_clause attribute attribute identifier identifier identifier block return_statement identifier expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier return_statement identifier | Signs a response if it's possible. |
def main():
p = argparse.ArgumentParser()
p.add_argument("--host", default="localhost")
p.add_argument("--port", type=int, default=3551)
p.add_argument("--strip-units", action="store_true", default=False)
args = p.parse_args()
status.print_status(
status.get(args.host, args.port),
strip_units=args.strip_units
) | module function_definition identifier parameters block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier false expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier | Get status from APC NIS and print output on stdout. |
def add_init_script(self, file, name):
f_path = os.path.join("/etc/init.d", name)
f = open(f_path, "w")
f.write(file)
f.close()
os.chmod(f_path, stat.S_IREAD| stat.S_IWRITE | stat.S_IEXEC)
self.run("/usr/sbin/update-rc.d %s defaults" % name) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier binary_operator binary_operator attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier | Add this file to the init.d directory |
def space_info(args):
r = fapi.get_workspace(args.project, args.workspace)
fapi._check_response_code(r, 200)
return r.text | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier integer return_statement attribute identifier identifier | Get metadata for a workspace. |
def map_tree(visitor, tree):
newn = [map_tree(visitor, node) for node in tree.nodes]
return visitor(tree, newn) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list_comprehension call identifier argument_list identifier identifier for_in_clause identifier attribute identifier identifier return_statement call identifier argument_list identifier identifier | Apply function to nodes |
def _get_sentinel_val(v):
out = workflow.get_base_id(v["id"])
if workflow.is_cwl_record(v):
out += ":%s" % ";".join([x["name"] for x in _get_record_fields(v)])
return out | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end if_statement call attribute identifier identifier argument_list identifier block expression_statement augmented_assignment identifier binary_operator string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list list_comprehension subscript identifier string string_start string_content string_end for_in_clause identifier call identifier argument_list identifier return_statement identifier | Retrieve expected sentinel value for an output, expanding records. |
def stash(self, payload):
succeeded = []
failed = []
for key in payload['keys']:
if self.queue.get(key) is not None:
if self.queue[key]['status'] == 'queued':
self.queue[key]['status'] = 'stashed'
succeeded.append(str(key))
else:
failed.append(str(key))
else:
failed.append(str(key))
message = ''
if len(succeeded) > 0:
message += 'Stashed entries: {}.'.format(', '.join(succeeded))
status = 'success'
if len(failed) > 0:
message += '\nNo queued entry for keys: {}'.format(', '.join(failed))
status = 'error'
answer = {'message': message.strip(), 'status': status}
return answer | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list expression_statement assignment identifier list for_statement identifier subscript identifier string string_start string_content string_end block if_statement comparison_operator call attribute attribute identifier identifier identifier argument_list identifier none block if_statement comparison_operator subscript subscript attribute identifier identifier identifier string string_start string_content string_end string string_start string_content string_end block expression_statement assignment subscript subscript attribute identifier identifier identifier string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier expression_statement assignment identifier string string_start string_end if_statement comparison_operator call identifier argument_list identifier integer block expression_statement augmented_assignment identifier call attribute string string_start string_content string_end identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier string string_start string_content string_end if_statement comparison_operator call identifier argument_list identifier integer block expression_statement augmented_assignment identifier call attribute string string_start string_content escape_sequence string_end identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end call attribute identifier identifier argument_list pair string string_start string_content string_end identifier return_statement identifier | Stash the specified processes. |
def close(self):
if getattr(self, '_connection', None):
logger.debug('Closing postgresql connection.')
self._connection.close()
self._connection = None
if getattr(self, '_engine', None):
self._engine.dispose() | module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier string string_start string_content string_end none block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier none if_statement call identifier argument_list identifier string string_start string_content string_end none block expression_statement call attribute attribute identifier identifier identifier argument_list | Closes connection to database. |
def amod(a, b):
modded = int(a % b)
return b if modded is 0 else modded | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list binary_operator identifier identifier return_statement conditional_expression identifier comparison_operator identifier integer identifier | Modulus function which returns numerator if modulus is zero |
def BNReLU(x, name=None):
x = BatchNorm('bn', x)
x = tf.nn.relu(x, name=name)
return x | module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier return_statement identifier | A shorthand of BatchNormalization + ReLU. |
def insert_injfilterrejector_option_group(parser):
injfilterrejector_group = \
parser.add_argument_group(_injfilterrejector_group_help)
curr_arg = "--injection-filter-rejector-chirp-time-window"
injfilterrejector_group.add_argument(curr_arg, type=float, default=None,
help=_injfilterer_cthresh_help)
curr_arg = "--injection-filter-rejector-match-threshold"
injfilterrejector_group.add_argument(curr_arg, type=float, default=None,
help=_injfilterer_mthresh_help)
curr_arg = "--injection-filter-rejector-coarsematch-deltaf"
injfilterrejector_group.add_argument(curr_arg, type=float, default=1.,
help=_injfilterer_deltaf_help)
curr_arg = "--injection-filter-rejector-coarsematch-fmax"
injfilterrejector_group.add_argument(curr_arg, type=float, default=256.,
help=_injfilterer_fmax_help)
curr_arg = "--injection-filter-rejector-seg-buffer"
injfilterrejector_group.add_argument(curr_arg, type=int, default=10,
help=_injfilterer_buffer_help)
curr_arg = "--injection-filter-rejector-f-lower"
injfilterrejector_group.add_argument(curr_arg, type=int, default=None,
help=_injfilterer_flower_help) | module function_definition identifier parameters identifier block expression_statement assignment identifier line_continuation call attribute identifier identifier argument_list identifier expression_statement assignment identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier none keyword_argument identifier identifier expression_statement assignment identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier none keyword_argument identifier identifier expression_statement assignment identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier float keyword_argument identifier identifier expression_statement assignment identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier float keyword_argument identifier identifier expression_statement assignment identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier integer keyword_argument identifier identifier expression_statement assignment identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier none keyword_argument identifier identifier | Add options for injfilterrejector to executable. |
def clean_value(self):
python_data = self.parent.python_data
if self.name in python_data:
return python_data[self.name]
return self.get_initial() | module function_definition identifier parameters identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier if_statement comparison_operator attribute identifier identifier identifier block return_statement subscript identifier attribute identifier identifier return_statement call attribute identifier identifier argument_list | Current field's converted value from form's python_data. |
def exchange_token(self, code):
url = '%s%s/oauth2/token' % (self.scheme, self.host)
options = {
'grant_type': 'authorization_code',
'redirect_uri': self._redirect_uri(),
'client_id': self.options.get('client_id'),
'client_secret': self.options.get('client_secret'),
'code': code,
}
options.update({
'verify_ssl': self.options.get('verify_ssl', True),
'proxies': self.options.get('proxies', None)
})
self.token = wrapped_resource(
make_request('post', url, options))
self.access_token = self.token.access_token
return self.token | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple attribute identifier identifier attribute identifier identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end call attribute identifier identifier argument_list pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end pair string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end true pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end none expression_statement assignment attribute identifier identifier call identifier argument_list call identifier argument_list string string_start string_content string_end identifier identifier expression_statement assignment attribute identifier identifier attribute attribute identifier identifier identifier return_statement attribute identifier identifier | Given the value of the code parameter, request an access token. |
def script(server_):
return salt.utils.cloud.os_script(
config.get_cloud_config_value('script', server_, __opts__),
server_,
__opts__,
salt.utils.cloud.salt_config_to_yaml(
salt.utils.cloud.minion_config(__opts__, server_)
)
) | module function_definition identifier parameters identifier block return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier identifier identifier call attribute attribute attribute identifier identifier identifier identifier argument_list call attribute attribute attribute identifier identifier identifier identifier argument_list identifier identifier | Return the script deployment object. |
def idPlayerResults(cfg, rawResult):
result = {}
knownPlayers = []
dictResult = {plyrRes.player_id : plyrRes.result for plyrRes in rawResult}
for p in cfg.players:
if p.playerID and p.playerID in dictResult:
knownPlayers.append(p)
result[p.name] = dictResult[p.playerID]
return result | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary expression_statement assignment identifier list expression_statement assignment identifier dictionary_comprehension pair attribute identifier identifier attribute identifier identifier for_in_clause identifier identifier for_statement identifier attribute identifier identifier block if_statement boolean_operator attribute identifier identifier comparison_operator attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment subscript identifier attribute identifier identifier subscript identifier attribute identifier identifier return_statement identifier | interpret standard rawResult for all players with known IDs |
def clean(self, value):
if not self.create:
return super(AgnocompleteModelMultipleField, self).clean(value)
value = self.clear_list_value(value)
pks = [v for v in value if v.isdigit()]
self._new_values = [v for v in value if not v.isdigit()]
qs = super(AgnocompleteModelMultipleField, self).clean(pks)
return qs | module function_definition identifier parameters identifier identifier block if_statement not_operator attribute identifier identifier block return_statement call attribute call identifier argument_list identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier list_comprehension identifier for_in_clause identifier identifier if_clause call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier list_comprehension identifier for_in_clause identifier identifier if_clause not_operator call attribute identifier identifier argument_list expression_statement assignment identifier call attribute call identifier argument_list identifier identifier identifier argument_list identifier return_statement identifier | Clean the field values. |
def on_epoch_end(self, epoch, smooth_loss, last_metrics, **kwargs):
"Logs training loss, validation loss and custom metrics & log prediction samples & save model"
if self.save_model:
current = self.get_monitor_value()
if current is not None and self.operator(current, self.best):
print(
f'Better model found at epoch {epoch} with {self.monitor} value: {current}.'
)
self.best = current
with self.model_path.open('wb') as model_file:
self.learn.save(model_file)
if self.show_results:
self.learn.show_results()
wandb.log({"Prediction Samples": plt}, commit=False)
logs = {
name: stat
for name, stat in list(
zip(self.learn.recorder.names, [epoch, smooth_loss] +
last_metrics))[1:]
}
wandb.log(logs)
if self.show_results:
plt.close('all') | module function_definition identifier parameters identifier identifier identifier identifier dictionary_splat_pattern identifier block expression_statement string string_start string_content string_end if_statement attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement boolean_operator comparison_operator identifier none call attribute identifier identifier argument_list identifier attribute identifier identifier block expression_statement call identifier argument_list string string_start string_content interpolation identifier string_content interpolation attribute identifier identifier string_content interpolation identifier string_content string_end expression_statement assignment attribute identifier identifier identifier with_statement with_clause with_item as_pattern call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end identifier keyword_argument identifier false expression_statement assignment identifier dictionary_comprehension pair identifier identifier for_in_clause pattern_list identifier identifier subscript call identifier argument_list call identifier argument_list attribute attribute attribute identifier identifier identifier identifier binary_operator list identifier identifier identifier slice integer expression_statement call attribute identifier identifier argument_list identifier if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end | Logs training loss, validation loss and custom metrics & log prediction samples & save model |
def use_comparative_sequence_rule_enabler_view(self):
self._object_views['sequence_rule_enabler'] = COMPARATIVE
for session in self._get_provider_sessions():
try:
session.use_comparative_sequence_rule_enabler_view()
except AttributeError:
pass | module function_definition identifier parameters identifier block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end identifier for_statement identifier call attribute identifier identifier argument_list block try_statement block expression_statement call attribute identifier identifier argument_list except_clause identifier block pass_statement | Pass through to provider SequenceRuleEnablerLookupSession.use_comparative_sequence_rule_enabler_view |
def compare_basis_against_file(basis_name,
src_filepath,
file_type=None,
version=None,
uncontract_general=False,
data_dir=None):
src_data = read_formatted_basis(src_filepath, file_type)
bse_data = get_basis(basis_name, version=version, data_dir=data_dir)
return basis_comparison_report(src_data, bse_data, uncontract_general=uncontract_general) | module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier false default_parameter identifier none block expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier return_statement call identifier argument_list identifier identifier keyword_argument identifier identifier | Compare a basis set in the BSE against a reference file |
def change_attributes(self, **kwargs):
new_track = Track(self.viewconf['type'])
new_track.position = self.position
new_track.tileset = self.tileset
new_track.viewconf = json.loads(json.dumps(self.viewconf))
new_track.viewconf = {**new_track.viewconf, **kwargs}
return new_track | module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier dictionary dictionary_splat attribute identifier identifier dictionary_splat identifier return_statement identifier | Change an attribute of this track and return a new copy. |
def _init_goterm_ref(self, rec_curr, name, lnum):
if rec_curr is None:
return GOTerm()
msg = "PREVIOUS {REC} WAS NOT TERMINATED AS EXPECTED".format(REC=name)
self._die(msg, lnum) | module function_definition identifier parameters identifier identifier identifier identifier block if_statement comparison_operator identifier none block return_statement call identifier argument_list expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier | Initialize new reference and perform checks. |
def survey_loader(sur_dir=SUR_DIR, sur_file=SUR_FILE):
survey_path = os.path.join(sur_dir, sur_file)
survey = None
with open(survey_path) as survey_file:
survey = Survey(survey_file.read())
return survey | module function_definition identifier parameters default_parameter identifier identifier default_parameter identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement assignment identifier none with_statement with_clause with_item as_pattern call identifier argument_list identifier as_pattern_target identifier block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list return_statement identifier | Loads up the given survey in the given dir. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.