code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def detach_session(self): if self._session is not None: self._session.unsubscribe(self) self._session = None
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier none
Allow the session to be discarded and don't get change notifications from it anymore
def _marshal(self, obj): logger.debug("Checking if %s needs to be marshalled", obj) if isinstance(obj, ManagedObject): logger.debug("obj is a psphere object, converting to MOR") return obj._mo_ref if isinstance(obj, list): logger.debug("obj is a list, recursing it") new_list = [] for item in obj: new_list.append(self._marshal(item)) return new_list if not isinstance(obj, suds.sudsobject.Object): logger.debug("%s is not a sudsobject subclass, skipping", obj) return obj if hasattr(obj, '__iter__'): logger.debug("obj is iterable, recursing it") for (name, value) in obj: setattr(obj, name, self._marshal(value)) return obj logger.debug("obj doesn't need to be marshalled") return obj
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement attribute identifier identifier if_statement call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier list for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier return_statement identifier if_statement not_operator call identifier argument_list identifier attribute attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement identifier if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end for_statement tuple_pattern identifier identifier identifier block expression_statement call identifier argument_list identifier identifier call attribute identifier identifier argument_list identifier return_statement identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier
Walks an object and marshals any psphere object into MORs.
def _ensure_field(self, key): if self._has_field: self._size += 2 self._has_field = True self._size += len(key) + 4
module function_definition identifier parameters identifier identifier block if_statement attribute identifier identifier block expression_statement augmented_assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier true expression_statement augmented_assignment attribute identifier identifier binary_operator call identifier argument_list identifier integer
Ensure a non-array field
def read_comment(self, start: int, line: int, col: int, prev: Token) -> Token: body = self.source.body body_length = len(body) position = start while True: position += 1 if position > body_length: break char = body[position] if char < " " and char != "\t": break return Token( TokenKind.COMMENT, start, position, line, col, prev, body[start + 1 : position], )
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier type identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier identifier while_statement true block expression_statement augmented_assignment identifier integer if_statement comparison_operator identifier identifier block break_statement expression_statement assignment identifier subscript identifier identifier if_statement boolean_operator comparison_operator identifier string string_start string_content string_end comparison_operator identifier string string_start string_content escape_sequence string_end block break_statement return_statement call identifier argument_list attribute identifier identifier identifier identifier identifier identifier identifier subscript identifier slice binary_operator identifier integer identifier
Read a comment token from the source file.
def _get_areas(self): if self.areas is None: self.areas = [] for surf in self.surfaces: self.areas.append(surf.get_area()) self.areas = numpy.array(self.areas) return self.areas
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier list for_statement identifier attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier return_statement attribute identifier identifier
Return surface elements area values in a numpy array.
def on_select_task(self, task): logger.info('select %(project)s:%(taskid)s %(url)s', task) project_info = self.projects.get(task['project']) assert project_info, 'no such project' task['type'] = self.TASK_PACK task['group'] = project_info.group task['project_md5sum'] = project_info.md5sum task['project_updatetime'] = project_info.updatetime if getattr(project_info, 'crawl_config', None): task = BaseHandler.task_join_crawl_config(task, project_info.crawl_config) project_info.active_tasks.appendleft((time.time(), task)) self.send_task(task) return task
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list subscript identifier string string_start string_content string_end assert_statement identifier string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier if_statement call identifier argument_list identifier string string_start string_content string_end none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list tuple call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Called when a task is selected to fetch & process
def _set_windows(self, ticks, bars): self.tick_window = ticks self.bar_window = bars
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier
be aware of default windows
def remove_blank_dirs(self): if self.is_blank(): try: os.rmdir(self.path) except OSError as e: print(e) else: remove_empty_dir(self.path)
module function_definition identifier parameters identifier block if_statement call attribute identifier identifier argument_list block try_statement block expression_statement call attribute identifier identifier argument_list attribute identifier identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call identifier argument_list identifier else_clause block expression_statement call identifier argument_list attribute identifier identifier
Remove blank dir and all blank subdirectories
def _remove_from_index(index, obj): try: index.value_map[indexed_value(index, obj)].remove(obj.id) except KeyError: pass
module function_definition identifier parameters identifier identifier block try_statement block expression_statement call attribute subscript attribute identifier identifier call identifier argument_list identifier identifier identifier argument_list attribute identifier identifier except_clause identifier block pass_statement
Removes object ``obj`` from the ``index``.
def timex_starts(self): if not self.is_tagged(TIMEXES): self.tag_timexes() return self.starts(TIMEXES)
module function_definition identifier parameters identifier block if_statement not_operator call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list return_statement call attribute identifier identifier argument_list identifier
The list of start positions of ``timexes`` layer elements.
def ServerLoggingStartupInit(): global LOGGER if local_log: logging.debug("Using local LogInit from %s", local_log) local_log.LogInit() logging.debug("Using local AppLogInit from %s", local_log) LOGGER = local_log.AppLogInit() else: LogInit() LOGGER = AppLogInit()
module function_definition identifier parameters block global_statement identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list else_clause block expression_statement call identifier argument_list expression_statement assignment identifier call identifier argument_list
Initialize the server logging configuration.
def find_if_x_retbool_else_retbool(node): return ( isinstance(node, ast.If) and isinstance(node.body[0], ast.Return) and h.is_boolean(node.body[0].value) and h.has_else(node) and isinstance(node.orelse[0], ast.Return) and h.is_boolean(node.orelse[0].value) )
module function_definition identifier parameters identifier block return_statement parenthesized_expression boolean_operator boolean_operator boolean_operator boolean_operator boolean_operator call identifier argument_list identifier attribute identifier identifier call identifier argument_list subscript attribute identifier identifier integer attribute identifier identifier call attribute identifier identifier argument_list attribute subscript attribute identifier identifier integer identifier call attribute identifier identifier argument_list identifier call identifier argument_list subscript attribute identifier identifier integer attribute identifier identifier call attribute identifier identifier argument_list attribute subscript attribute identifier identifier integer identifier
Finds simplifiable if condition
def _collect_gpu_info(run_info): gpu_info = {} local_device_protos = device_lib.list_local_devices() gpu_info["count"] = len([d for d in local_device_protos if d.device_type == "GPU"]) for d in local_device_protos: if d.device_type == "GPU": gpu_info["model"] = _parse_gpu_model(d.physical_device_desc) break run_info["machine_config"]["gpu_info"] = gpu_info
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list list_comprehension identifier for_in_clause identifier identifier if_clause comparison_operator attribute identifier identifier string string_start string_content string_end for_statement identifier identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list attribute identifier identifier break_statement expression_statement assignment subscript subscript identifier string string_start string_content string_end string string_start string_content string_end identifier
Collect local GPU information by TF device library.
def cwd(self, new_path): old_cwd = self._cwd self._cwd = new_path return old_cwd
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment attribute identifier identifier identifier return_statement identifier
Sets the cwd during reads and writes
def apply(self, snapshot): for name in snapshot: setattr(self, name, snapshot[name])
module function_definition identifier parameters identifier identifier block for_statement identifier identifier block expression_statement call identifier argument_list identifier identifier subscript identifier identifier
Set the current context from a given snapshot dictionary
def gausspars(data): N, mean, d = len(data), 0., 0. if N < 1: return "", "" if N == 1: return data[0], 0 for j in range(N): mean += old_div(data[j], float(N)) for j in range(N): d += (data[j] - mean)**2 stdev = np.sqrt(d * (1./(float(N - 1)))) return mean, stdev
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier identifier expression_list call identifier argument_list identifier float float if_statement comparison_operator identifier integer block return_statement expression_list string string_start string_end string string_start string_end if_statement comparison_operator identifier integer block return_statement expression_list subscript identifier integer integer for_statement identifier call identifier argument_list identifier block expression_statement augmented_assignment identifier call identifier argument_list subscript identifier identifier call identifier argument_list identifier for_statement identifier call identifier argument_list identifier block expression_statement augmented_assignment identifier binary_operator parenthesized_expression binary_operator subscript identifier identifier identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator identifier parenthesized_expression binary_operator float parenthesized_expression call identifier argument_list binary_operator identifier integer return_statement expression_list identifier identifier
calculates gaussian statistics for data
def reset(self): self._count = 0 self._exception_count = 0 self._stat_start_time = None self._time_sum = float(0) self._time_min = float('inf') self._time_max = float(0) self._server_time_sum = float(0) self._server_time_min = float('inf') self._server_time_max = float(0) self._server_time_stored = False self._request_len_sum = float(0) self._request_len_min = float('inf') self._request_len_max = float(0) self._reply_len_sum = float(0) self._reply_len_min = float('inf') self._reply_len_max = float(0)
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier call identifier argument_list integer expression_statement assignment attribute identifier identifier call identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier call identifier argument_list integer expression_statement assignment attribute identifier identifier call identifier argument_list integer expression_statement assignment attribute identifier identifier call identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier call identifier argument_list integer expression_statement assignment attribute identifier identifier false expression_statement assignment attribute identifier identifier call identifier argument_list integer expression_statement assignment attribute identifier identifier call identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier call identifier argument_list integer expression_statement assignment attribute identifier identifier call identifier argument_list integer expression_statement assignment attribute identifier identifier call identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier call identifier argument_list integer
Reset the statistics data for this object.
def _meta_get_resource_sync(md_uuid): isogeo.resource(id_resource=md_uuid) elapsed = default_timer() - START_TIME time_completed_at = "{:5.2f}s".format(elapsed) print("{0:<30} {1:>20}".format(md_uuid, time_completed_at)) return
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier expression_statement assignment identifier binary_operator call identifier argument_list identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier return_statement
Just a meta func to get execution time
def generic_insert_with_folder(folder_name, file_name, template_name, args): if not os.path.isdir( os.path.join( args['django_application_folder'], folder_name ) ): os.mkdir(os.path.join(args['django_application_folder'], folder_name)) codecs.open( os.path.join( args['django_application_folder'], folder_name, '__init__.py' ), 'w+' ) view_file = create_or_open( os.path.join( folder_name, '{}.py'.format(file_name) ), '', args ) render_template_with_args_in_file( view_file, os.path.join( BASE_TEMPLATES_DIR, template_name ), model_name=args['model_name'], model_prefix=args['model_prefix'], model_name_lower=args['model_name'].lower(), application_name=args['django_application_folder'].split("/")[-1] ) view_file.close()
module function_definition identifier parameters identifier identifier identifier identifier block if_statement not_operator call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list subscript identifier string string_start string_content string_end identifier block expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list subscript identifier string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list subscript identifier string string_start string_content string_end identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier call attribute string string_start string_content string_end identifier argument_list identifier string string_start string_end identifier expression_statement call identifier argument_list identifier call attribute attribute identifier identifier identifier argument_list identifier identifier keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list keyword_argument identifier subscript call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end unary_operator integer expression_statement call attribute identifier identifier argument_list
In general if we need to put a file on a folder, we use this method
def run_until(self, endtime, timeunit='minutes', save=True): integrator = self.case.solver.Integrator integrator.rununtil(endtime, timeunit) if save is True: self.case.save()
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end default_parameter identifier true block expression_statement assignment identifier attribute attribute attribute identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier if_statement comparison_operator identifier true block expression_statement call attribute attribute identifier identifier identifier argument_list
Run a case untile the specifiend endtime
def to_file(file, array): try: array.tofile(file) except (TypeError, IOError, UnsupportedOperation): file.write(array.tostring())
module function_definition identifier parameters identifier identifier block try_statement block expression_statement call attribute identifier identifier argument_list identifier except_clause tuple identifier identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list
Wrapper around ndarray.tofile to support any file-like object
def default(self): output = ensure_unicode(self.git.log( '-1', '-p', '--no-color', '--format=%s', ).stdout) lines = output.splitlines() return u'\n'.join( itertools.chain( lines[:1], itertools.islice( itertools.dropwhile( lambda x: not x.startswith('+++'), lines[1:], ), 1, None, ), ) )
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list attribute call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list return_statement call attribute string string_start string_content escape_sequence string_end identifier argument_list call attribute identifier identifier argument_list subscript identifier slice integer call attribute identifier identifier argument_list call attribute identifier identifier argument_list lambda lambda_parameters identifier not_operator call attribute identifier identifier argument_list string string_start string_content string_end subscript identifier slice integer integer none
Return last changes in truncated unified diff format
def clean(): run('rm -rf build/') run('rm -rf dist/') run('rm -rf puzzle.egg-info') run('find . -name __pycache__ -delete') run('find . -name *.pyc -delete') run('find . -name *.pyo -delete') run('find . -name *~ -delete') log.info('cleaned up')
module function_definition identifier parameters block expression_statement call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end
clean - remove build artifacts.
def to_binary_string(self): if self.priority not in self.PRIORITIES: raise NotificationInvalidPriorityError() try: token = binascii.unhexlify(self.token) except TypeError as error: raise NotificationTokenUnhexlifyError(error) try: payload = json.dumps(self.payload) except TypeError: raise NotificationPayloadNotSerializableError() fmt = ">BIBH{0}sBH{1}sBHIBHIBHB".format(len(token), len(payload)) expire = (0 if self.expire == self.EXPIRE_IMMEDIATELY else datetime_to_timestamp(self.expire)) length = 3*5 + len(token) + len(payload) + 4 + 4 + 1 message = struct.pack(fmt, self.COMMAND, length, self.TOKEN, len(token), token, self.PAYLOAD, len(payload), payload, self.NOTIFICATION_ID, 4, self.iden, self.EXPIRE, 4, expire, self.PRIORITY, 1, self.priority) return message
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block raise_statement call identifier argument_list try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier except_clause as_pattern identifier as_pattern_target identifier block raise_statement call identifier argument_list identifier try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier except_clause identifier block raise_statement call identifier argument_list expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier call identifier argument_list identifier expression_statement assignment identifier parenthesized_expression conditional_expression integer comparison_operator attribute identifier identifier attribute identifier identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator integer integer call identifier argument_list identifier call identifier argument_list identifier integer integer integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier identifier attribute identifier identifier call identifier argument_list identifier identifier attribute identifier identifier call identifier argument_list identifier identifier attribute identifier identifier integer attribute identifier identifier attribute identifier identifier integer identifier attribute identifier identifier integer attribute identifier identifier return_statement identifier
Pack the notification to binary form and return it as string.
def _parse_attributes(self, value): from zigpy.zcl import foundation as f attributes = {} attribute_names = { 1: BATTERY_VOLTAGE_MV, 3: TEMPERATURE, 4: XIAOMI_ATTR_4, 5: XIAOMI_ATTR_5, 6: XIAOMI_ATTR_6, 10: PATH } result = {} while value: skey = int(value[0]) svalue, value = f.TypeValue.deserialize(value[1:]) result[skey] = svalue.value for item, value in result.items(): key = attribute_names[item] \ if item in attribute_names else "0xff01-" + str(item) attributes[key] = value if BATTERY_VOLTAGE_MV in attributes: attributes[BATTERY_LEVEL] = int( self._calculate_remaining_battery_percentage( attributes[BATTERY_VOLTAGE_MV] ) ) return attributes
module function_definition identifier parameters identifier identifier block import_from_statement dotted_name identifier identifier aliased_import dotted_name identifier identifier expression_statement assignment identifier dictionary expression_statement assignment identifier dictionary pair integer identifier pair integer identifier pair integer identifier pair integer identifier pair integer identifier pair integer identifier expression_statement assignment identifier dictionary while_statement identifier block expression_statement assignment identifier call identifier argument_list subscript identifier integer expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list subscript identifier slice integer expression_statement assignment subscript identifier identifier attribute identifier identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment identifier conditional_expression subscript identifier identifier line_continuation comparison_operator identifier identifier binary_operator string string_start string_content string_end call identifier argument_list identifier expression_statement assignment subscript identifier identifier identifier if_statement comparison_operator identifier identifier block expression_statement assignment subscript identifier identifier call identifier argument_list call attribute identifier identifier argument_list subscript identifier identifier return_statement identifier
Parse non standard atrributes.
def serialize_on_parent( self, parent, value, state ): if not value and self.required: state.raise_error(MissingValue, 'Missing required array: "{}"'.format( self.alias)) if not value and self.omit_empty: return if self._nested is not None: array_parent = _element_get_or_add_from_parent(parent, self._nested) else: array_parent = parent self._serialize(array_parent, value, state)
module function_definition identifier parameters identifier identifier identifier identifier block if_statement boolean_operator not_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier if_statement boolean_operator not_operator identifier attribute identifier identifier block return_statement if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier call identifier argument_list identifier attribute identifier identifier else_clause block expression_statement assignment identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier identifier
Serialize the value and append it to the parent element.
def validate_data_files(problem, data_files, min_size): data_dir = os.path.split(data_files[0])[0] out_filepaths = problem.out_filepaths(data_dir) missing_filepaths = set(out_filepaths) - set(data_files) if missing_filepaths: tf.logging.error("Missing %d data files", len(missing_filepaths)) too_small = [] for data_file in data_files: length = get_length(data_file) if length < min_size: too_small.append(data_file) if too_small: tf.logging.error("%d files too small", len(too_small)) bad_files = too_small + list(missing_filepaths) return bad_files
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier subscript call attribute attribute identifier identifier identifier argument_list subscript identifier integer integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator call identifier argument_list identifier call identifier argument_list identifier if_statement identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end call identifier argument_list identifier expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end call identifier argument_list identifier expression_statement assignment identifier binary_operator identifier call identifier argument_list identifier return_statement identifier
Validate presence and minimum size of files.
def self_signed(self, value): self._self_signed = bool(value) if self._self_signed: self._issuer = None
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list identifier if_statement attribute identifier identifier block expression_statement assignment attribute identifier identifier none
A bool - if the certificate should be self-signed.
def _create_netmap_config(self): netmap_path = os.path.join(self.working_dir, "NETMAP") try: with open(netmap_path, "w", encoding="utf-8") as f: for bay in range(0, 16): for unit in range(0, 4): f.write("{ubridge_id}:{bay}/{unit}{iou_id:>5d}:{bay}/{unit}\n".format(ubridge_id=str(self.application_id + 512), bay=bay, unit=unit, iou_id=self.application_id)) log.info("IOU {name} [id={id}]: NETMAP file created".format(name=self._name, id=self._id)) except OSError as e: raise IOUError("Could not create {}: {}".format(netmap_path, e))
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier string string_start string_content string_end try_statement block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end as_pattern_target identifier block for_statement identifier call identifier argument_list integer integer block for_statement identifier call identifier argument_list integer integer block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list keyword_argument identifier call identifier argument_list binary_operator attribute identifier identifier integer keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier except_clause as_pattern identifier as_pattern_target identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier
Creates the NETMAP file.
def make_summary_funcs(rows, ids): return { 'len': len, 'list': lambda *x: filter(None, list(x)), 'max': max, 'min': min, 'rows': partial(summary_rows, rows, ids), 'sum': sum, 'trace': print_trace }
module function_definition identifier parameters identifier identifier block return_statement dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end lambda lambda_parameters list_splat_pattern identifier call identifier argument_list none call identifier argument_list 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 call identifier argument_list identifier identifier identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier
Functions available for listing summary fields.
def add_subsegment(self, subsegment): self._check_ended() subsegment.parent_id = self.id self.subsegments.append(subsegment)
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Add input subsegment as a child subsegment.
def __init(self): params = { "f" : "json" } json_dict = self._get(url=self._currentURL, param_dict=params, securityHandler=self._securityHandler, proxy_url=self._proxy_url, proxy_port=self._proxy_port) self._json = json.dumps(json_dict) self._json_dict = json_dict attributes = [attr for attr in dir(self) if not attr.startswith('__') and \ not attr.startswith('_')] for k,v in json_dict.items(): if k.lower() == "extensions": self._extensions = [] for ext in v: self._extensions.append(Extension.fromJSON(ext)) del ext elif k in attributes: setattr(self, "_"+ k, json_dict[k]) else: print( k, " - attribute not implemented in manageags.AGSService.") del k del v
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment identifier list_comprehension identifier for_in_clause identifier call identifier argument_list identifier if_clause boolean_operator not_operator call attribute identifier identifier argument_list string string_start string_content string_end line_continuation not_operator call attribute identifier identifier argument_list string string_start string_content string_end for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment attribute identifier identifier list for_statement identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier delete_statement identifier elif_clause comparison_operator identifier identifier block expression_statement call identifier argument_list identifier binary_operator string string_start string_content string_end identifier subscript identifier identifier else_clause block expression_statement call identifier argument_list identifier string string_start string_content string_end delete_statement identifier delete_statement identifier
populates server admin information
def main(): trig, echo, speed, samples = get_args() print('trig pin = gpio {}'.format(trig)) print('echo pin = gpio {}'.format(echo)) print('speed = {}'.format(speed)) print('samples = {}'.format(samples)) print('') value = sensor.Measurement(trig, echo) raw_distance = value.raw_distance(sample_size=samples, sample_wait=speed) imperial_distance = value.distance_imperial(raw_distance) metric_distance = value.distance_metric(raw_distance) print('The imperial distance is {} inches.'.format(imperial_distance)) print('The metric distance is {} centimetres.'.format(metric_distance))
module function_definition identifier parameters block expression_statement assignment pattern_list identifier identifier identifier identifier call identifier argument_list expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call identifier argument_list string string_start string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier 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 identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier
Main function to run the sensor with passed arguments
def out_shape_from_meshgrid(mesh): if len(mesh) == 1: return (len(mesh[0]),) else: return np.broadcast(*mesh).shape
module function_definition identifier parameters identifier block if_statement comparison_operator call identifier argument_list identifier integer block return_statement tuple call identifier argument_list subscript identifier integer else_clause block return_statement attribute call attribute identifier identifier argument_list list_splat identifier identifier
Get the broadcast output shape from a `meshgrid`.
def _delete_percolator(spec, search_pattern): if spec: for index in current_search.mappings.keys(): percolator_doc_type = _get_percolator_doc_type(index) _create_percolator_mapping(index, percolator_doc_type) current_search_client.delete( index=index, doc_type=percolator_doc_type, id='oaiset-{}'.format(spec), ignore=[404] )
module function_definition identifier parameters identifier identifier block if_statement identifier block for_statement identifier call attribute attribute identifier identifier identifier argument_list block expression_statement assignment identifier call identifier argument_list identifier expression_statement call identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier call attribute string string_start string_content string_end identifier argument_list identifier keyword_argument identifier list integer
Delete percolator associated with the new oaiset.
def copy(self, **replacements): cls = type(self) kwargs = self._asdict() for key, val in replacements.items(): if key == 'excludes': val = JarDependency._prepare_excludes(val) kwargs[key] = val org = kwargs.pop('org') base_name = kwargs.pop('base_name') return cls(org, base_name, **kwargs)
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment subscript identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement call identifier argument_list identifier identifier dictionary_splat identifier
Returns a clone of this JarDependency with the given replacements kwargs overlaid.
def _client(self, id, secret): url = self.api_url + self.auth_token_url auth_string = '%s:%s' % (id, secret) authorization = base64.b64encode(auth_string.encode()).decode() headers = { 'Authorization': "Basic " + authorization, 'Content-Type': "application/x-www-form-urlencoded" } params = { 'grant_type': 'client_credentials', 'response_type': 'token' } return self.session.post(url, params=params, headers=headers)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier binary_operator attribute identifier identifier attribute identifier identifier expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier argument_list expression_statement assignment identifier dictionary pair string string_start string_content string_end binary_operator string string_start string_content string_end identifier pair string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end return_statement call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier
Performs client login with the provided credentials
def center_important_part(self, crop_box): if not self.important_box: return crop_box ib = self.important_box cl, ct, cr, cb = crop_box iw, ih = self.image.size move_horiz = (ib[0] + ib[2]) // 2 - (cl + cr) // 2 move_verti = (ib[1] + ib[3]) // 2 - (ct + cb) // 2 if move_horiz > 0: move_horiz = min(iw - cr, move_horiz) else: move_horiz = max(-cl, move_horiz) if move_verti > 0: move_verti = min(ih - cb, move_verti) else: move_verti = max(-ct, move_verti) return (cl + move_horiz, ct + move_verti, cr + move_horiz, cb + move_verti)
module function_definition identifier parameters identifier identifier block if_statement not_operator attribute identifier identifier block return_statement identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment pattern_list identifier identifier identifier identifier identifier expression_statement assignment pattern_list identifier identifier attribute attribute identifier identifier identifier expression_statement assignment identifier binary_operator binary_operator parenthesized_expression binary_operator subscript identifier integer subscript identifier integer integer binary_operator parenthesized_expression binary_operator identifier identifier integer expression_statement assignment identifier binary_operator binary_operator parenthesized_expression binary_operator subscript identifier integer subscript identifier integer integer binary_operator parenthesized_expression binary_operator identifier identifier integer if_statement comparison_operator identifier integer block expression_statement assignment identifier call identifier argument_list binary_operator identifier identifier identifier else_clause block expression_statement assignment identifier call identifier argument_list unary_operator identifier identifier if_statement comparison_operator identifier integer block expression_statement assignment identifier call identifier argument_list binary_operator identifier identifier identifier else_clause block expression_statement assignment identifier call identifier argument_list unary_operator identifier identifier return_statement tuple binary_operator identifier identifier binary_operator identifier identifier binary_operator identifier identifier binary_operator identifier identifier
If important_box was specified, make sure it lies inside the crop box.
def count_changes(change): if isinstance(change, ChangeSet): result = 0 for child in change.changes: result += count_changes(child) return result return 1
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier integer for_statement identifier attribute identifier identifier block expression_statement augmented_assignment identifier call identifier argument_list identifier return_statement identifier return_statement integer
Counts the number of basic changes a `Change` will make
def create(cls, ip_version, datacenter, bandwidth, vm=None, vlan=None, ip=None, background=False): return Iface.create(ip_version, datacenter, bandwidth, vlan, vm, ip, background)
module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier false block return_statement call attribute identifier identifier argument_list identifier identifier identifier identifier identifier identifier identifier
Create a public ip and attach it if vm is given.
def _deshuffle_field(self, *args): ip = self._invpermutation fields = [] for arg in args: fields.append( arg[ip] ) if len(fields) == 1: return fields[0] else: return fields
module function_definition identifier parameters identifier list_splat_pattern identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier list for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list subscript identifier identifier if_statement comparison_operator call identifier argument_list identifier integer block return_statement subscript identifier integer else_clause block return_statement identifier
Return to original ordering
def max_spline_jumps(self, convert_to_muC_per_cm2=True, all_in_polar=True): tot = self.get_same_branch_polarization_data( convert_to_muC_per_cm2=convert_to_muC_per_cm2, all_in_polar=all_in_polar) sps = self.same_branch_splines(convert_to_muC_per_cm2=convert_to_muC_per_cm2, all_in_polar=all_in_polar) max_jumps = [None, None, None] for i, sp in enumerate(sps): if sp != None: max_jumps[i] = max(tot[:, i].ravel() - sp(range(len(tot[:, i].ravel())))) return max_jumps
module function_definition identifier parameters identifier default_parameter identifier true default_parameter identifier true block expression_statement assignment identifier call attribute 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 keyword_argument identifier identifier expression_statement assignment identifier list none none none for_statement pattern_list identifier identifier call identifier argument_list identifier block if_statement comparison_operator identifier none block expression_statement assignment subscript identifier identifier call identifier argument_list binary_operator call attribute subscript identifier slice identifier identifier argument_list call identifier argument_list call identifier argument_list call identifier argument_list call attribute subscript identifier slice identifier identifier argument_list return_statement identifier
Get maximum difference between spline and same branch polarization data.
def max_knob_end_distance(self): return max([distance(self.knob_end, h) for h in self.hole])
module function_definition identifier parameters identifier block return_statement call identifier argument_list list_comprehension call identifier argument_list attribute identifier identifier identifier for_in_clause identifier attribute identifier identifier
Maximum distance between knob_end and each of the hole side-chain centres.
def renamed_tree(self, source, dest): dirname = osp.abspath(to_text_string(source)) tofile = to_text_string(dest) for fname in self.get_filenames(): if osp.abspath(fname).startswith(dirname): new_filename = fname.replace(dirname, tofile) self.renamed(source=fname, dest=new_filename)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier for_statement identifier call attribute identifier identifier argument_list block if_statement call attribute call attribute identifier identifier argument_list identifier identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier
Directory was renamed in file explorer or in project explorer.
def notify_update(self, update, urgent=False): if not isinstance(update, list): update = [update] self.update_queue.extend(update) containers = self.config["py3_config"][".module_groups"] containers_to_update = set() for item in update: if item in containers: containers_to_update.update(set(containers[item])) for container in containers_to_update: container_module = self.output_modules.get(container) if container_module: if urgent and container_module.get("urgent_function"): container_module["urgent_function"](update) if container_module.get("content_function"): if set(update) & container_module["content_function"](): container_module["module"].force_update() else: container_module["module"].force_update() if self.update_queue: self.update_request.set()
module function_definition identifier parameters identifier identifier default_parameter identifier false block if_statement not_operator call identifier argument_list identifier identifier block expression_statement assignment identifier list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call identifier argument_list for_statement identifier identifier block if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list subscript identifier identifier for_statement identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement identifier block if_statement boolean_operator identifier call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement call subscript identifier string string_start string_content string_end argument_list identifier if_statement call attribute identifier identifier argument_list string string_start string_content string_end block if_statement binary_operator call identifier argument_list identifier call subscript identifier string string_start string_content string_end argument_list block expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list else_clause block expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list
Name or list of names of modules that have updated.
def need_to_create_symlink(directory, checksums, filetype, symlink_path): if symlink_path is None: return False pattern = NgdConfig.get_fileending(filetype) filename, _ = get_name_and_checksum(checksums, pattern) full_filename = os.path.join(directory, filename) symlink_name = os.path.join(symlink_path, filename) if os.path.islink(symlink_name): existing_link = os.readlink(symlink_name) if full_filename == existing_link: return False return True
module function_definition identifier parameters identifier identifier identifier identifier block if_statement comparison_operator identifier none block return_statement false expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier identifier block return_statement false return_statement true
Check if we need to create a symlink for an existing file.
def _get_policy_set(self, policy_set_id): uri = self._get_policy_set_uri(guid=policy_set_id) return self.service._get(uri)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier
Get a specific policy set by id.
def _ctl_cmd(cmd, name, conf_file, bin_env): ret = [_get_supervisorctl_bin(bin_env)] if conf_file is not None: ret += ['-c', conf_file] ret.append(cmd) if name: ret.append(name) return ret
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier list call identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement augmented_assignment identifier list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Return the command list to use
def shell(self, command, *args, environment=None): command += ' ' + ' '.join(args) command = command.strip() self.debug(self.yellow_style('$ %s' % command)) env = self.env.copy() env.update(environment or {}) return subprocess.call(command, shell=True, env=env)
module function_definition identifier parameters identifier identifier list_splat_pattern identifier default_parameter identifier none 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 identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list boolean_operator identifier dictionary return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier true keyword_argument identifier identifier
Runs a shell command
def load_installed_plugins(): providers = {} checkers = {} for entry_point in pkg_resources.iter_entry_points(group='archan'): obj = entry_point.load() if issubclass(obj, Provider): providers[entry_point.name] = obj elif issubclass(obj, Checker): checkers[entry_point.name] = obj return collections.namedtuple( 'Plugins', 'providers checkers')( providers=providers, checkers=checkers)
module function_definition identifier parameters block expression_statement assignment identifier dictionary expression_statement assignment identifier dictionary for_statement identifier call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement call identifier argument_list identifier identifier block expression_statement assignment subscript identifier attribute identifier identifier identifier elif_clause call identifier argument_list identifier identifier block expression_statement assignment subscript identifier attribute identifier identifier identifier return_statement call call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end argument_list keyword_argument identifier identifier keyword_argument identifier identifier
Search and load every installed plugin through entry points.
def _iname2qname(self, iname: InstanceName) -> QualName: p, s, loc = iname.partition(":") return (loc, p) if s else (p, self.ns)
module function_definition identifier parameters identifier typed_parameter identifier type identifier type identifier block expression_statement assignment pattern_list identifier identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement conditional_expression tuple identifier identifier identifier tuple identifier attribute identifier identifier
Translate instance name to qualified name in the receiver's context.
def read_template_source(filename): from django.conf import settings if not settings.configured: settings.configure() with open(filename, "rb") as f: text = f.read().decode(settings.FILE_CHARSET) return text
module function_definition identifier parameters identifier block import_from_statement dotted_name identifier identifier dotted_name identifier if_statement not_operator attribute identifier identifier block expression_statement call attribute identifier identifier argument_list 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 call attribute identifier identifier argument_list identifier argument_list attribute identifier identifier return_statement identifier
Read the source of a Django template, returning the Unicode text.
def sleep_if_necessary(cls, user, token, endpoint='search', msg=''): my_kw = {'auth': (user, token)} if user else {} info = requests.get('https://api.github.com/rate_limit', **my_kw) info_dict = info.json() remaining = info_dict['resources'][endpoint]['remaining'] logging.debug('Search remaining on github is at %s', remaining) if remaining <= 5: sleep_time = 120 else: sleep_time = 0 if sleep_time: logging.warning('Sleep %i since github requests remaining = %i%s', sleep_time, remaining, msg) time.sleep(sleep_time) return True return False
module function_definition identifier parameters identifier identifier identifier default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_end block expression_statement assignment identifier conditional_expression dictionary pair string string_start string_content string_end tuple identifier identifier identifier dictionary expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end dictionary_splat identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier subscript subscript subscript identifier string string_start string_content string_end identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement comparison_operator identifier integer block expression_statement assignment identifier integer else_clause block expression_statement assignment identifier integer if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement true return_statement false
Sleep a little if hit github recently to honor rate limit.
def printrdf(wflow, ctx, style): rdf = gather(wflow, ctx).serialize(format=style, encoding='utf-8') if not rdf: return u"" return rdf.decode('utf-8')
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute call identifier argument_list identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end if_statement not_operator identifier block return_statement string string_start string_end return_statement call attribute identifier identifier argument_list string string_start string_content string_end
Serialize the CWL document into a string, ready for printing.
def _create_event(instance, action): user = None user_repr = repr(user) if CUSER: user = CuserMiddleware.get_user() user_repr = repr(user) if user is not None and user.is_anonymous: user = None return TrackingEvent.objects.create( action=action, object=instance, object_repr=repr(instance), user=user, user_repr=user_repr, )
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier none expression_statement assignment identifier call identifier argument_list identifier if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier if_statement boolean_operator comparison_operator identifier none attribute identifier identifier block expression_statement assignment identifier none return_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier
Create a new event, getting the use if django-cuser is available.
def filterVerticalLines(arr, min_line_length=4): gy = arr.shape[0] gx = arr.shape[1] mn = min_line_length-1 for i in range(gy): for j in range(gx): if arr[i,j]: for d in range(min_line_length): if not arr[i+d,j]: break if d == mn: d = 0 while True: if not arr[i+d,j]: break arr[i+d,j] = 0 d +=1
module function_definition identifier parameters identifier default_parameter identifier integer block expression_statement assignment identifier subscript attribute identifier identifier integer expression_statement assignment identifier subscript attribute identifier identifier integer expression_statement assignment identifier binary_operator identifier integer for_statement identifier call identifier argument_list identifier block for_statement identifier call identifier argument_list identifier block if_statement subscript identifier identifier identifier block for_statement identifier call identifier argument_list identifier block if_statement not_operator subscript identifier binary_operator identifier identifier identifier block break_statement if_statement comparison_operator identifier identifier block expression_statement assignment identifier integer while_statement true block if_statement not_operator subscript identifier binary_operator identifier identifier identifier block break_statement expression_statement assignment subscript identifier binary_operator identifier identifier identifier integer expression_statement augmented_assignment identifier integer
Remove vertical lines in boolean array if linelength >=min_line_length
def addAnalyses(self, analyses): actions_pool = ActionHandlerPool.get_instance() actions_pool.queue_pool() for analysis in analyses: self.addAnalysis(api.get_object(analysis)) actions_pool.resume()
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list
Adds a collection of analyses to the Worksheet at once
def finish(self, result, array_id = None): new_status = 'success' if result == 0 else 'failure' new_result = result finished = True if array_id is not None: for array_job in self.array: if array_job.id == array_id: array_job.status = new_status array_job.result = result array_job.finish_time = datetime.now() if array_job.status not in ('success', 'failure'): finished = False elif new_result == 0: new_result = array_job.result if finished: self.status = 'success' if new_result == 0 else 'failure' self.result = new_result self.finish_time = datetime.now() for job in self.get_jobs_waiting_for_us(): if job.status == 'waiting': job.queue()
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier conditional_expression string string_start string_content string_end comparison_operator identifier integer string string_start string_content string_end expression_statement assignment identifier identifier expression_statement assignment identifier true if_statement comparison_operator identifier none block for_statement identifier attribute identifier identifier block if_statement comparison_operator attribute identifier identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list if_statement comparison_operator attribute identifier identifier tuple string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier false elif_clause comparison_operator identifier integer block expression_statement assignment identifier attribute identifier identifier if_statement identifier block expression_statement assignment attribute identifier identifier conditional_expression string string_start string_content string_end comparison_operator identifier integer string string_start string_content string_end expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list for_statement identifier call attribute identifier identifier argument_list block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list
Sets the status of this job to 'success' or 'failure'.
def end_output (self, **kwargs): self.stats.downloaded_bytes = kwargs.get("downloaded_bytes") self.stats.num_urls = kwargs.get("num_urls") if self.has_part('stats'): self.write_stats() if self.has_part('outro'): self.write_outro(interrupt=kwargs.get("interrupt")) self.close_fileoutput()
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment attribute attribute identifier identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute attribute identifier identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list
Write end of output info, and flush all output buffers.
def plot_iv_curve(a, hold_v, i, *plt_args, **plt_kwargs): grid = plt_kwargs.pop('grid',True) same_fig = plt_kwargs.pop('same_fig',False) if not len(plt_args): plt_args = ('ko-',) if 'label' not in plt_kwargs: plt_kwargs['label'] = 'Current' if not same_fig: make_iv_curve_fig(a, grid=grid) if type(i) is dict: i = [i[v] for v in hold_v] plt.plot([v*1e3 for v in hold_v], [ii*1e12 for ii in i], *plt_args, **plt_kwargs) plt.legend(loc=2)
module function_definition identifier parameters identifier identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end true expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end false if_statement not_operator call identifier argument_list identifier block expression_statement assignment identifier tuple string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end if_statement not_operator identifier block expression_statement call identifier argument_list identifier keyword_argument identifier identifier if_statement comparison_operator call identifier argument_list identifier identifier block expression_statement assignment identifier list_comprehension subscript identifier identifier for_in_clause identifier identifier expression_statement call attribute identifier identifier argument_list list_comprehension binary_operator identifier float for_in_clause identifier identifier list_comprehension binary_operator identifier float for_in_clause identifier identifier list_splat identifier dictionary_splat identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier integer
A single IV curve
def asDict(self): return { 'isError': self.isError, 'message': self.message, 'values': self.values, 'value': self.value, }
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
Returns a serializable object
def fileids(self): return [os.path.join(self.path,i) for i in os.listdir(self.path)]
module function_definition identifier parameters identifier block return_statement list_comprehension call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier for_in_clause identifier call attribute identifier identifier argument_list attribute identifier identifier
Returns files from SemEval2007 Coarse-grain All-words WSD task.
def parse_consumer_offsets(cls, json_file): with open(json_file, 'r') as consumer_offsets_json: try: parsed_offsets = {} parsed_offsets_data = json.load(consumer_offsets_json) parsed_offsets['groupid'] = parsed_offsets_data['groupid'] parsed_offsets['offsets'] = {} for topic, topic_data in six.iteritems(parsed_offsets_data['offsets']): parsed_offsets['offsets'][topic] = {} for partition, offset in six.iteritems(topic_data): parsed_offsets['offsets'][topic][int(partition)] = offset return parsed_offsets except ValueError: print( "Error: Given consumer-data json data-file {file} could not be " "parsed".format(file=json_file), file=sys.stderr, ) raise
module function_definition identifier parameters identifier 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 try_statement block expression_statement assignment identifier dictionary expression_statement assignment identifier call attribute identifier identifier argument_list identifier 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 for_statement pattern_list identifier identifier call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end block expression_statement assignment subscript subscript identifier string string_start string_content string_end identifier dictionary for_statement pattern_list identifier identifier call attribute identifier identifier argument_list identifier block expression_statement assignment subscript subscript subscript identifier string string_start string_content string_end identifier call identifier argument_list identifier identifier return_statement identifier except_clause identifier block expression_statement call identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier raise_statement
Parse current offsets from json-file.
def build(id=None, name=None, revision=None, temporary_build=False, timestamp_alignment=False, no_build_dependencies=False, keep_pod_on_failure=False, force_rebuild=False, rebuild_mode=common.REBUILD_MODES_DEFAULT): data = build_raw(id, name, revision, temporary_build, timestamp_alignment, no_build_dependencies, keep_pod_on_failure, force_rebuild, rebuild_mode) if data: return utils.format_json(data)
module function_definition identifier parameters default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier false default_parameter identifier false default_parameter identifier false default_parameter identifier false default_parameter identifier false default_parameter identifier attribute identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier identifier identifier identifier identifier identifier identifier identifier if_statement identifier block return_statement call attribute identifier identifier argument_list identifier
Trigger a BuildConfiguration by name or ID
def _stringify_val(val): if isinstance(val, list): return " ".join([str(i) for i in val]) else: return str(val)
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block return_statement call attribute string string_start string_content string_end identifier argument_list list_comprehension call identifier argument_list identifier for_in_clause identifier identifier else_clause block return_statement call identifier argument_list identifier
Convert the given value to string.
def setblocking(self, blocking): for sock in self.socket(): sock.setblocking(blocking) self._blocking = blocking
module function_definition identifier parameters identifier identifier block for_statement identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier
Set whether or not this message is blocking
def _get_current_label(self): if len(self._last) == 0: raise StopIteration return self._last[:self._last.find(":")]
module function_definition identifier parameters identifier block if_statement comparison_operator call identifier argument_list attribute identifier identifier integer block raise_statement identifier return_statement subscript attribute identifier identifier slice call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end
Get the label from the last line read
def remove_rule(self, tag): resp = requests.delete(url=self.REQUEST_URL.format(**self._params), json={'tag': tag}) return resp.json()
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier call attribute attribute identifier identifier identifier argument_list dictionary_splat attribute identifier identifier keyword_argument identifier dictionary pair string string_start string_content string_end identifier return_statement call attribute identifier identifier argument_list
Remove a rule by tag
def print_file_details_as_csv(self, fname, col_headers): line = '' qu = '"' d = ',' for fld in col_headers: if fld == "fullfilename": line = line + qu + fname + qu + d if fld == "name": line = line + qu + os.path.basename(fname) + qu + d if fld == "date": line = line + qu + self.GetDateAsString(fname) + qu + d if fld == "size": line = line + qu + self.get_size_as_string(fname) + qu + d if fld == "path": try: line = line + qu + os.path.dirname(fname) + qu + d except IOError: line = line + qu + 'ERROR_PATH' + qu + d return line
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier string string_start string_end expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end for_statement identifier identifier block if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier binary_operator binary_operator binary_operator binary_operator identifier identifier identifier identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier binary_operator binary_operator binary_operator binary_operator identifier identifier call attribute attribute identifier identifier identifier argument_list identifier identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier binary_operator binary_operator binary_operator binary_operator identifier identifier call attribute identifier identifier argument_list identifier identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier binary_operator binary_operator binary_operator binary_operator identifier identifier call attribute identifier identifier argument_list identifier identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block try_statement block expression_statement assignment identifier binary_operator binary_operator binary_operator binary_operator identifier identifier call attribute attribute identifier identifier identifier argument_list identifier identifier identifier except_clause identifier block expression_statement assignment identifier binary_operator binary_operator binary_operator binary_operator identifier identifier string string_start string_content string_end identifier identifier return_statement identifier
saves as csv format
def insert(self, events): if not len(events): return keys = sorted(events[0].keys()) ss = ','.join(['%s' for _ in keys]) query = 'INSERT INTO %s (%s) VALUES ' % (self.table, ','.join(keys)) data = [] for event in events: query += '(%s),' % ss data += [event[k] for k in keys] query = query[:-1] + ';' LOG.info("%s (data: %s)", query, data) conn = self.conn.conn cursor = conn.cursor() cursor.execute(query, data) conn.commit()
module function_definition identifier parameters identifier identifier block if_statement not_operator call identifier argument_list identifier block return_statement expression_statement assignment identifier call identifier argument_list call attribute subscript identifier integer identifier argument_list expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list list_comprehension string string_start string_content string_end for_in_clause identifier identifier expression_statement assignment identifier binary_operator string string_start string_content string_end tuple attribute identifier identifier call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier list for_statement identifier identifier block expression_statement augmented_assignment identifier binary_operator string string_start string_content string_end identifier expression_statement augmented_assignment identifier list_comprehension subscript identifier identifier for_in_clause identifier identifier expression_statement assignment identifier binary_operator subscript identifier slice unary_operator integer string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list
Constructs and executes a MySQL insert for the given events.
def target_to_ipv6_cidr(target): splitted = target.split('/') if len(splitted) != 2: return None try: start_packed = inet_pton(socket.AF_INET6, splitted[0]) block = int(splitted[1]) except (socket.error, ValueError): return None if block <= 0 or block > 126: return None start_value = int(binascii.hexlify(start_packed), 16) >> (128 - block) start_value = (start_value << (128 - block)) + 1 end_value = (start_value | (int('ff' * 16, 16) >> block)) - 1 high = start_value >> 64 low = start_value & ((1 << 64) - 1) start_packed = struct.pack('!QQ', high, low) high = end_value >> 64 low = end_value & ((1 << 64) - 1) end_packed = struct.pack('!QQ', high, low) return ipv6_range_to_list(start_packed, end_packed)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator call identifier argument_list identifier integer block return_statement none try_statement block expression_statement assignment identifier call identifier argument_list attribute identifier identifier subscript identifier integer expression_statement assignment identifier call identifier argument_list subscript identifier integer except_clause tuple attribute identifier identifier identifier block return_statement none if_statement boolean_operator comparison_operator identifier integer comparison_operator identifier integer block return_statement none expression_statement assignment identifier binary_operator call identifier argument_list call attribute identifier identifier argument_list identifier integer parenthesized_expression binary_operator integer identifier expression_statement assignment identifier binary_operator parenthesized_expression binary_operator identifier parenthesized_expression binary_operator integer identifier integer expression_statement assignment identifier binary_operator parenthesized_expression binary_operator identifier parenthesized_expression binary_operator call identifier argument_list binary_operator string string_start string_content string_end integer integer identifier integer expression_statement assignment identifier binary_operator identifier integer expression_statement assignment identifier binary_operator identifier parenthesized_expression binary_operator parenthesized_expression binary_operator integer integer integer expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier expression_statement assignment identifier binary_operator identifier integer expression_statement assignment identifier binary_operator identifier parenthesized_expression binary_operator parenthesized_expression binary_operator integer integer integer expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier return_statement call identifier argument_list identifier identifier
Attempt to return a IPv6 CIDR list from a target string.
def engines(opts, functions, runners, utils, proxy=None): pack = {'__salt__': functions, '__runners__': runners, '__proxy__': proxy, '__utils__': utils} return LazyLoader( _module_dirs(opts, 'engines'), opts, tag='engines', pack=pack, )
module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier none block expression_statement assignment identifier 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 return_statement call identifier argument_list call identifier argument_list identifier string string_start string_content string_end identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier
Return the master services plugins
def close(self): for plugin in self.plugins: if hasattr(plugin, 'close'): plugin.close() self.stopped = True
module function_definition identifier parameters identifier block for_statement identifier attribute identifier identifier block if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier true
Close the application and all installed plugins.
def run(self): _LOGGER.info("Started") while True: self._maybe_reconnect() line = '' try: t = self._telnet if t is not None: line = t.read_until(b"\n") except EOFError: try: self._lock.acquire() self._disconnect_locked() continue finally: self._lock.release() self._recv_cb(line.decode('ascii').rstrip())
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end while_statement true block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier string string_start string_end try_statement block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end except_clause identifier block try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list continue_statement finally_clause block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list call attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier argument_list
Main thread function to maintain connection and receive remote status.
def ref_file_from_bam(bam_file, data): new_ref = os.path.join(utils.safe_makedir(os.path.join(dd.get_work_dir(data), "inputs", "ref")), "%s-subset.fa" % dd.get_genome_build(data)) if not utils.file_exists(new_ref): with file_transaction(data, new_ref) as tx_out_file: contig_file = "%s-contigs.txt" % utils.splitext_plus(new_ref)[0] with open(contig_file, "w") as out_handle: for contig in [x.contig for x in idxstats(bam_file, data) if x.contig != "*"]: out_handle.write("%s\n" % contig) cmd = "seqtk subseq -l 100 %s %s > %s" % (dd.get_ref_file(data), contig_file, tx_out_file) do.run(cmd, "Subset %s to BAM file contigs" % dd.get_genome_build(data)) ref.fasta_idx(new_ref, data["config"]) runner = broad.runner_from_path("picard", data["config"]) runner.run_fn("picard_index_ref", new_ref) return {"base": new_ref}
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end binary_operator string string_start string_content string_end call attribute identifier identifier argument_list identifier if_statement not_operator call attribute identifier identifier argument_list identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier identifier as_pattern_target identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end subscript call attribute identifier identifier argument_list identifier integer 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 for_statement identifier list_comprehension attribute identifier identifier for_in_clause identifier call identifier argument_list identifier identifier if_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end identifier expression_statement assignment identifier binary_operator string string_start string_content string_end tuple call attribute identifier identifier argument_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier binary_operator string string_start string_content string_end call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement dictionary pair string string_start string_content string_end identifier
Subset a fasta input file to only a fraction of input contigs.
def unserialize(self, data): if "author" not in data["object"]: data["object"]["author"] = data["actor"] for key in ["to", "cc", "bto", "bcc"]: if key not in data["object"] and key in data: data["object"][key] = data[key] Mapper(pypump=self._pump).parse_map(self, data=data) self._add_links(data) return self
module function_definition identifier parameters identifier identifier block if_statement comparison_operator string string_start string_content string_end subscript identifier string string_start string_content string_end block expression_statement assignment subscript subscript identifier string string_start string_content string_end string string_start string_content string_end subscript identifier string string_start string_content string_end for_statement identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block if_statement boolean_operator comparison_operator identifier subscript identifier string string_start string_content string_end comparison_operator identifier identifier block expression_statement assignment subscript subscript identifier string string_start string_content string_end identifier subscript identifier identifier expression_statement call attribute call identifier argument_list keyword_argument identifier attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
From JSON -> Activity object
def _handle_wikilink(self, token): title = None self._push() while self._tokens: token = self._tokens.pop() if isinstance(token, tokens.WikilinkSeparator): title = self._pop() self._push() elif isinstance(token, tokens.WikilinkClose): if title is not None: return Wikilink(title, self._pop()) return Wikilink(self._pop()) else: self._write(self._handle_token(token)) raise ParserError("_handle_wikilink() missed a close token")
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier none expression_statement call attribute identifier identifier argument_list while_statement attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list if_statement call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list elif_clause call identifier argument_list identifier attribute identifier identifier block if_statement comparison_operator identifier none block return_statement call identifier argument_list identifier call attribute identifier identifier argument_list return_statement call identifier argument_list call attribute identifier identifier argument_list else_clause block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier raise_statement call identifier argument_list string string_start string_content string_end
Handle a case where a wikilink is at the head of the tokens.
def findExtname(fimg, extname, extver=None): i = 0 extnum = None for chip in fimg: hdr = chip.header if 'EXTNAME' in hdr: if hdr['EXTNAME'].strip() == extname.upper(): if extver is None or hdr['EXTVER'] == extver: extnum = i break i += 1 return extnum
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier integer expression_statement assignment identifier none for_statement identifier identifier block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator string string_start string_content string_end identifier block if_statement comparison_operator call attribute subscript identifier string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list block if_statement boolean_operator comparison_operator identifier none comparison_operator subscript identifier string string_start string_content string_end identifier block expression_statement assignment identifier identifier break_statement expression_statement augmented_assignment identifier integer return_statement identifier
Returns the list number of the extension corresponding to EXTNAME given.
def do_hotswap(self, msg): try: self.app.widget.showTooltip("Hot swapping...", now=True) except: pass self.save_changed_files(msg) hotswap = self.hotswap app = self.app try: print("Attempting hotswap....") with hotswap.active(): hotswap.update(app.view) except: app.send_event(Command.ERROR, traceback.format_exc())
module function_definition identifier parameters identifier identifier block try_statement block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier true except_clause block pass_statement expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier try_statement block expression_statement call identifier argument_list string string_start string_content string_end with_statement with_clause with_item call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list attribute identifier identifier except_clause block expression_statement call attribute identifier identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list
Attempt to hotswap the code
async def is_bot(self): if self._bot is None: self._bot = (await self.get_me()).bot return self._bot
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier attribute parenthesized_expression await call attribute identifier identifier argument_list identifier return_statement attribute identifier identifier
Return ``True`` if the signed-in user is a bot, ``False`` otherwise.
def unpack_bytes(self, obj_bytes, encoding=None): assert self.bytes_to_dict or self.string_to_dict encoding = encoding or self.default_encoding LOGGER.debug('%r decoding %d bytes with encoding of %s', self, len(obj_bytes), encoding) if self.bytes_to_dict: return escape.recursive_unicode(self.bytes_to_dict(obj_bytes)) return self.string_to_dict(obj_bytes.decode(encoding))
module function_definition identifier parameters identifier identifier default_parameter identifier none block assert_statement boolean_operator attribute identifier identifier attribute identifier identifier expression_statement assignment identifier boolean_operator identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier call identifier argument_list identifier identifier if_statement attribute identifier identifier block return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier
Unpack a byte stream into a dictionary.
def get(cls, uni_char): uni_char = unicod(uni_char) code_point = ord(uni_char) if Block._RANGE_KEYS is None: Block._RANGE_KEYS = sorted(Block._RANGES.keys()) idx = bisect.bisect_left(Block._RANGE_KEYS, code_point) if (idx > 0 and code_point >= Block._RANGES[Block._RANGE_KEYS[idx - 1]].start and code_point <= Block._RANGES[Block._RANGE_KEYS[idx - 1]].end): return Block._RANGES[Block._RANGE_KEYS[idx - 1]] elif (idx < len(Block._RANGES) and code_point >= Block._RANGES[Block._RANGE_KEYS[idx]].start and code_point <= Block._RANGES[Block._RANGE_KEYS[idx]].end): return Block._RANGES[Block._RANGE_KEYS[idx]] else: return Block.UNKNOWN
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier identifier if_statement parenthesized_expression boolean_operator boolean_operator comparison_operator identifier integer comparison_operator identifier attribute subscript attribute identifier identifier subscript attribute identifier identifier binary_operator identifier integer identifier comparison_operator identifier attribute subscript attribute identifier identifier subscript attribute identifier identifier binary_operator identifier integer identifier block return_statement subscript attribute identifier identifier subscript attribute identifier identifier binary_operator identifier integer elif_clause parenthesized_expression boolean_operator boolean_operator comparison_operator identifier call identifier argument_list attribute identifier identifier comparison_operator identifier attribute subscript attribute identifier identifier subscript attribute identifier identifier identifier identifier comparison_operator identifier attribute subscript attribute identifier identifier subscript attribute identifier identifier identifier identifier block return_statement subscript attribute identifier identifier subscript attribute identifier identifier identifier else_clause block return_statement attribute identifier identifier
Return the Unicode block of the given Unicode character
def _write_history(self): if self.data['history_file'] is None: return contents = '\n'.join(self.data['history_lines']) history = self.data['history_file'] open(history, 'w').write(contents) logger.info("History file %s updated.", history)
module function_definition identifier parameters identifier block if_statement comparison_operator subscript attribute identifier identifier string string_start string_content string_end none block return_statement expression_statement assignment identifier call attribute string string_start string_content escape_sequence string_end identifier argument_list subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement call attribute call identifier argument_list identifier string string_start string_content string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier
Write previously-calculated history lines back to the file
def _certificate_required(cls, hostname, port=XCLI_DEFAULT_PORT, ca_certs=None, validate=None): if not ca_certs: return False xlog.debug("CONNECT SSL %s:%s, cert_file=%s", hostname, port, ca_certs) certificate = ssl.get_server_certificate((hostname, port), ca_certs=None) if validate: return not validate(certificate) return True
module function_definition identifier parameters identifier identifier default_parameter identifier identifier default_parameter identifier none default_parameter identifier none block if_statement not_operator identifier block return_statement false expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list tuple identifier identifier keyword_argument identifier none if_statement identifier block return_statement not_operator call identifier argument_list identifier return_statement true
returns true if connection should verify certificate
def clear(board, term, height): for y in xrange(height): print term.move(y, 0) + term.clear_eol,
module function_definition identifier parameters identifier identifier identifier block for_statement identifier call identifier argument_list identifier block print_statement binary_operator call attribute identifier identifier argument_list identifier integer attribute identifier identifier
Clear the droppings of the given board.
def Indentation( logical_line, previous_logical, indent_level, previous_indent_level ): comment = '' if logical_line else ' (comment)' if indent_level % 2: code = 'YCM111' if logical_line else 'YCM114' message = ' indentation is not a multiple of two spaces' + comment yield 0, code + message if ( previous_logical.endswith( ':' ) and ( indent_level - previous_indent_level != 2 ) ): code = 'YCM112' if logical_line else 'YCM115' message = ' expected an indented block of {} spaces{}'.format( previous_indent_level + 2, comment ) yield 0, code + message
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier conditional_expression string string_start string_end identifier string string_start string_content string_end if_statement binary_operator identifier integer block expression_statement assignment identifier conditional_expression string string_start string_content string_end identifier string string_start string_content string_end expression_statement assignment identifier binary_operator string string_start string_content string_end identifier expression_statement yield expression_list integer binary_operator identifier identifier if_statement parenthesized_expression boolean_operator call attribute identifier identifier argument_list string string_start string_content string_end parenthesized_expression comparison_operator binary_operator identifier identifier integer block expression_statement assignment identifier conditional_expression string string_start string_content string_end identifier string string_start string_content string_end expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list binary_operator identifier integer identifier expression_statement yield expression_list integer binary_operator identifier identifier
Use two spaces per indentation level.
def _reduce_input(self, inputs, reducer, final=NotImplemented): for key, values in groupby(inputs, key=lambda x: self.internal_serialize(x[0])): for output in reducer(self.deserialize(key), (v[1] for v in values)): yield output if final != NotImplemented: for output in final(): yield output self._flush_batch_incr_counter()
module function_definition identifier parameters identifier identifier identifier default_parameter identifier identifier block for_statement pattern_list identifier identifier call identifier argument_list identifier keyword_argument identifier lambda lambda_parameters identifier call attribute identifier identifier argument_list subscript identifier integer block for_statement identifier call identifier argument_list call attribute identifier identifier argument_list identifier generator_expression subscript identifier integer for_in_clause identifier identifier block expression_statement yield identifier if_statement comparison_operator identifier identifier block for_statement identifier call identifier argument_list block expression_statement yield identifier expression_statement call attribute identifier identifier argument_list
Iterate over input, collect values with the same key, and call the reducer for each unique key.
def ProcessFlow(self, flow_processing_request): client_id = flow_processing_request.client_id flow_id = flow_processing_request.flow_id data_store.REL_DB.AckFlowProcessingRequests([flow_processing_request]) try: rdf_flow = data_store.REL_DB.LeaseFlowForProcessing( client_id, flow_id, processing_time=rdfvalue.Duration("6h")) except db.ParentHuntIsNotRunningError: flow_base.TerminateFlow(client_id, flow_id, "Parent hunt stopped.") return logging.info("Processing Flow %s/%s (%s).", client_id, flow_id, rdf_flow.flow_class_name) flow_cls = registry.FlowRegistry.FlowClassByName(rdf_flow.flow_class_name) flow_obj = flow_cls(rdf_flow) if not flow_obj.IsRunning(): raise ValueError( "Received a request to process flow %s on client %s that is not " "running." % (flow_id, client_id)) processed = flow_obj.ProcessAllReadyRequests() if processed == 0: raise ValueError( "Unable to process any requests for flow %s on client %s." % (flow_id, client_id)) while not self._ReleaseProcessedFlow(flow_obj): processed = flow_obj.ProcessAllReadyRequests() if processed == 0: raise ValueError( "%s/%s: ReleaseProcessedFlow returned false but no " "request could be processed (next req: %d)." % (client_id, flow_id, flow_obj.rdf_flow.next_request_to_process))
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list list identifier try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier keyword_argument identifier call attribute identifier identifier argument_list string string_start string_content string_end except_clause attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier string string_start string_content string_end return_statement expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier if_statement not_operator call attribute identifier identifier argument_list block raise_statement call identifier argument_list binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end tuple identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier integer block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier while_statement not_operator call attribute identifier identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier integer block raise_statement call identifier argument_list binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end tuple identifier identifier attribute attribute identifier identifier identifier
The callback for the flow processing queue.
def process_relation_class(self, relation_class, context, assert_declared=False): relation_class.database = self.database relation_class._connection = self.connection relation_class._heading = Heading() instance = relation_class() is_declared = instance.is_declared if not is_declared: if not self.create_tables or assert_declared: raise DataJointError('Table not declared %s' % instance.table_name) else: instance.declare(context) is_declared = is_declared or instance.is_declared if isinstance(instance, Lookup) and hasattr(instance, 'contents') and is_declared: contents = list(instance.contents) if len(contents) > len(instance): if instance.heading.has_autoincrement: warnings.warn( 'Contents has changed but cannot be inserted because {table} has autoincrement.'.format( table=instance.__class__.__name__)) else: instance.insert(contents, skip_duplicates=True)
module function_definition identifier parameters identifier identifier identifier default_parameter identifier false block 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 identifier argument_list expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier attribute identifier identifier if_statement not_operator identifier block if_statement boolean_operator not_operator attribute identifier identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier boolean_operator identifier attribute identifier identifier if_statement boolean_operator boolean_operator call identifier argument_list identifier identifier call identifier argument_list identifier string string_start string_content string_end identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier if_statement comparison_operator call identifier argument_list identifier call identifier argument_list identifier block if_statement attribute attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier attribute attribute identifier identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier true
assign schema properties to the relation class and declare the table
def download_files(files): for (url, file) in files: print("Downloading %s as %s" % (url, file)) data = download_url(url) if data is None: continue try: open(file, mode='wb').write(data) except Exception as e: print("Failed to save to %s : %s" % (file, e))
module function_definition identifier parameters identifier block for_statement tuple_pattern identifier identifier identifier block expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier none block continue_statement try_statement block expression_statement call attribute call identifier argument_list identifier keyword_argument identifier string string_start string_content string_end identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier
download an array of files
def __registerSeqStr(): _SeqStr = lambda self: (self and "[%s]" % (", ".join(map(repr, self)))) or "[]" _SeqRepr = lambda self: (self and "[%s]" % (", ".join(map(repr, self)))) or "[]" seqs = (StdStringVector, StdLongVector, CommandInfoList, AttributeInfoList, AttributeInfoListEx, PipeInfoList, DeviceDataHistoryList, GroupReplyList, GroupAttrReplyList, GroupCmdReplyList, DbData, DbDevInfos, DbDevExportInfos, DbDevImportInfos, DbHistoryList) for seq in seqs: seq.__str__ = _SeqStr seq.__repr__ = _SeqRepr
module function_definition identifier parameters block expression_statement assignment identifier lambda lambda_parameters identifier boolean_operator parenthesized_expression boolean_operator identifier binary_operator string string_start string_content string_end parenthesized_expression call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier identifier string string_start string_content string_end expression_statement assignment identifier lambda lambda_parameters identifier boolean_operator parenthesized_expression boolean_operator identifier binary_operator string string_start string_content string_end parenthesized_expression call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier identifier string string_start string_content string_end expression_statement assignment identifier tuple identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier for_statement identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier
helper function to make internal sequences printable
def removefromreadergroup(self, groupname): hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER) if 0 != hresult: raise EstablishContextException(hresult) try: hresult = SCardRemoveReaderFromGroup(hcontext, self.name, groupname) if 0 != hresult: raise RemoveReaderFromGroupException(hresult, self.name, groupname) finally: hresult = SCardReleaseContext(hcontext) if 0 != hresult: raise ReleaseContextException(hresult)
module function_definition identifier parameters identifier identifier block expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier if_statement comparison_operator integer identifier block raise_statement call identifier argument_list identifier try_statement block expression_statement assignment identifier call identifier argument_list identifier attribute identifier identifier identifier if_statement comparison_operator integer identifier block raise_statement call identifier argument_list identifier attribute identifier identifier identifier finally_clause block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator integer identifier block raise_statement call identifier argument_list identifier
Remove a reader from a reader group
def install_API_key(api_key, profile_name='default'): fname = API_profile_fname(profile_name) if not os.path.isdir(os.path.dirname(fname)): os.makedirs(os.path.dirname(fname)) with open(fname, 'w') as fh: fh.write(api_key)
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list identifier 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 with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier
Put the given API key into the given profile name.
def read(self, path, environ): try: inp = open(path, 'rb') except FileNotFoundError as error: if error.errno != 2: raise return None parsing = parse_vexrc(inp, environ) for heading, key, value in parsing: heading = self.default_heading if heading is None else heading if heading not in self.headings: self.headings[heading] = OrderedDict() self.headings[heading][key] = value parsing.close()
module function_definition identifier parameters identifier identifier identifier block try_statement block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end except_clause as_pattern identifier as_pattern_target identifier block if_statement comparison_operator attribute identifier identifier integer block raise_statement return_statement none expression_statement assignment identifier call identifier argument_list identifier identifier for_statement pattern_list identifier identifier identifier identifier block expression_statement assignment identifier conditional_expression attribute identifier identifier comparison_operator identifier none identifier if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier call identifier argument_list expression_statement assignment subscript subscript attribute identifier identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list
Read data from file into this vexrc instance.
def min_abs(self): if self.__len__() == 0: return ArgumentError('empty set has no minimum absolute value.') if self.contains(0): return 0 return numpy.min([numpy.abs(val) for val in [self.max_neg(), self.min_pos()] if val is not None])
module function_definition identifier parameters identifier block if_statement comparison_operator call attribute identifier identifier argument_list integer block return_statement call identifier argument_list string string_start string_content string_end if_statement call attribute identifier identifier argument_list integer block return_statement integer return_statement call attribute identifier identifier argument_list list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier list call attribute identifier identifier argument_list call attribute identifier identifier argument_list if_clause comparison_operator identifier none
Returns minimum absolute value.
def _get_tree_paths(tree, node_id, depth=0): if node_id == _tree.TREE_LEAF: raise ValueError("Invalid node_id %s" % _tree.TREE_LEAF) left_child = tree.children_left[node_id] right_child = tree.children_right[node_id] if left_child != _tree.TREE_LEAF: left_paths = _get_tree_paths(tree, left_child, depth=depth + 1) right_paths = _get_tree_paths(tree, right_child, depth=depth + 1) for path in left_paths: path.append(node_id) for path in right_paths: path.append(node_id) paths = left_paths + right_paths else: paths = [[node_id]] return paths
module function_definition identifier parameters identifier identifier default_parameter identifier integer block if_statement comparison_operator identifier attribute identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier subscript attribute identifier identifier identifier expression_statement assignment identifier subscript attribute identifier identifier identifier if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier keyword_argument identifier binary_operator identifier integer expression_statement assignment identifier call identifier argument_list identifier identifier keyword_argument identifier binary_operator identifier integer for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator identifier identifier else_clause block expression_statement assignment identifier list list identifier return_statement identifier
Returns all paths through the tree as list of node_ids
def variables(self): url = self.base_url + 'ts' headers = {'Authorization': 'Bearer {}'.format(self.auth())} r = requests.get(url, headers=headers) df = pd.read_json(r.content, orient='records') return pd.Series(df['variable'].unique(), name='variable')
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator attribute identifier identifier string string_start string_content string_end 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 call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier string string_start string_content string_end return_statement call attribute identifier identifier argument_list call attribute subscript identifier string string_start string_content string_end identifier argument_list keyword_argument identifier string string_start string_content string_end
All variables in the connected data source
def add_node(self, node): if _debug: Network._debug("add_node %r", node) self.nodes.append(node) node.lan = self if not node.name: node.name = '%s:%s' % (self.name, node.address)
module function_definition identifier parameters identifier identifier block if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier if_statement not_operator attribute identifier identifier block expression_statement assignment attribute identifier identifier binary_operator string string_start string_content string_end tuple attribute identifier identifier attribute identifier identifier
Add a node to this network, let the node know which network it's on.
def _load_options(self, container, **options): for opt in self.dict_options(): options.setdefault(opt, container) return anyconfig.utils.filter_options(self._load_opts, options)
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block for_statement identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier identifier return_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier
Select backend specific loading options.
def sponsor_tagged_image(sponsor, tag): if sponsor.files.filter(tag_name=tag).exists(): return sponsor.files.filter(tag_name=tag).first().tagged_file.item.url return ''
module function_definition identifier parameters identifier identifier block if_statement call attribute call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier identifier argument_list block return_statement attribute attribute attribute call attribute call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier identifier argument_list identifier identifier identifier return_statement string string_start string_end
returns the corresponding url from the tagged image list.