code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def form_valid(self, form): slotIds = form.cleaned_data['slotIds'] deleteSlot = form.cleaned_data.get('deleteSlot', False) these_slots = InstructorAvailabilitySlot.objects.filter(id__in=slotIds) if deleteSlot: these_slots.delete() else: for this_slot in these_slots: this_slot.location = form.cleaned_data['updateLocation'] this_slot.room = form.cleaned_data['updateRoom'] this_slot.status = form.cleaned_data['updateStatus'] this_slot.pricingTier = form.cleaned_data.get('updatePricing') this_slot.save() return JsonResponse({'valid': True})
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end false expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list else_clause block for_statement identifier identifier block expression_statement assignment attribute identifier identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list return_statement call identifier argument_list dictionary pair string string_start string_content string_end true
Modify or delete the availability slot as requested and return success message.
def form_valid(self, form): form_valid_from_parent = super(HostCreate, self).form_valid(form) messages.success(self.request, 'Host {} Successfully Created'.format(self.object)) return form_valid_from_parent
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute call identifier argument_list identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier return_statement identifier
First call the parent's form valid then let the user know it worked.
def percent_of_the_time(p): def decorator(fn): def wrapped(*args, **kwargs): if in_percentage(p): fn(*args, **kwargs) return wrapped return decorator
module function_definition identifier parameters identifier block function_definition identifier parameters identifier block function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block if_statement call identifier argument_list identifier block expression_statement call identifier argument_list list_splat identifier dictionary_splat identifier return_statement identifier return_statement identifier
Function has a X percentage chance of running
def _jstype(self, stype, sval): if stype == self.IS_LIST: return "array" if stype == self.IS_DICT: return "object" if isinstance(sval, Scalar): return sval.jstype v = sval._schema return self._jstype(self._whatis(v), v)
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block return_statement string string_start string_content string_end if_statement comparison_operator identifier attribute identifier identifier block return_statement string string_start string_content string_end if_statement call identifier argument_list identifier identifier block return_statement attribute identifier identifier expression_statement assignment identifier attribute identifier identifier return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier
Get JavaScript name for given data type, called by `_build_schema`.
def error_handler(task): @wraps(task) def wrapper(self, *args, **kwargs): try: return task(self, *args, **kwargs) except Exception as e: self.connected = False if not self.testing: exc_type, exc_obj, exc_tb = sys.exc_info() fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] error_message = ( "[" + str(datetime.now()) + "] Error in task \"" + task.__name__ + "\" (" + fname + "/" + str(exc_tb.tb_lineno) + ")" + e.message ) self.logger.error("%s: RPC instruction failed" % error_message) return wrapper
module function_definition identifier parameters identifier block decorated_definition decorator call identifier argument_list identifier function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block try_statement block return_statement call identifier argument_list identifier list_splat identifier dictionary_splat identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement assignment attribute identifier identifier false if_statement not_operator attribute identifier identifier block expression_statement assignment pattern_list identifier identifier identifier call attribute identifier identifier argument_list expression_statement assignment identifier subscript call attribute attribute identifier identifier identifier argument_list attribute attribute attribute identifier identifier identifier identifier integer expression_statement assignment identifier parenthesized_expression binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator string string_start string_content string_end call identifier argument_list call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end attribute identifier identifier string string_start string_content escape_sequence string_end identifier string string_start string_content string_end call identifier argument_list attribute identifier identifier string string_start string_content string_end attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end identifier return_statement identifier
Handle and log RPC errors.
def _check(self): if self._returncode: rarfile.check_returncode(self, '') if self._remain != 0: raise rarfile.BadRarFile("Failed the read enough data")
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier string string_start string_end if_statement comparison_operator attribute identifier identifier integer block raise_statement call attribute identifier identifier argument_list string string_start string_content string_end
Do not check final CRC.
def _add_products(self, tile, show_all=False): products = tile.products unique_id = tile.unique_id base_path = tile.output_folder for prod_path, prod_type in products.items(): if prod_path == 'tilebus_definitions' or prod_path == 'include_directories': continue if prod_type in self.IGNORED_PRODUCTS: continue prod_base = os.path.basename(prod_path) if prod_type not in self._product_map: self._product_map[prod_type] = {} prod_map = self._product_map[prod_type] if prod_base not in prod_map: prod_map[prod_base] = [] full_path = os.path.normpath(os.path.join(base_path, prod_path)) info = ProductInfo(prod_base, full_path, unique_id, not show_all and prod_base not in self._product_filter) prod_map[prod_base].append(info)
module function_definition identifier parameters identifier identifier default_parameter identifier false block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement boolean_operator comparison_operator identifier string string_start string_content string_end comparison_operator identifier string string_start string_content string_end block continue_statement if_statement comparison_operator identifier attribute identifier identifier block continue_statement expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier dictionary expression_statement assignment identifier subscript attribute identifier identifier identifier if_statement comparison_operator identifier identifier block expression_statement assignment subscript identifier identifier list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier boolean_operator not_operator identifier comparison_operator identifier attribute identifier identifier expression_statement call attribute subscript identifier identifier identifier argument_list identifier
Add all products from a tile into our product map.
def escape_keywords(arr): for i in arr: i = i if i not in kwlist else i + '_' i = i if '-' not in i else i.replace('-', '_') yield i
module function_definition identifier parameters identifier block for_statement identifier identifier block expression_statement assignment identifier conditional_expression identifier comparison_operator identifier identifier binary_operator identifier string string_start string_content string_end expression_statement assignment identifier conditional_expression identifier comparison_operator string string_start string_content string_end identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement yield identifier
append _ to all python keywords
def _check_list_minions(self, expr, greedy, ignore_missing=False): if isinstance(expr, six.string_types): expr = [m for m in expr.split(',') if m] minions = self._pki_minions() return {'minions': [x for x in expr if x in minions], 'missing': [] if ignore_missing else [x for x in expr if x not in minions]}
module function_definition identifier parameters identifier identifier identifier default_parameter identifier false block if_statement call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier list_comprehension identifier for_in_clause identifier call attribute identifier identifier argument_list string string_start string_content string_end if_clause identifier expression_statement assignment identifier call attribute identifier identifier argument_list return_statement dictionary pair string string_start string_content string_end list_comprehension identifier for_in_clause identifier identifier if_clause comparison_operator identifier identifier pair string string_start string_content string_end conditional_expression list identifier list_comprehension identifier for_in_clause identifier identifier if_clause comparison_operator identifier identifier
Return the minions found by looking via a list
def _remove(self, timer): assert timer.timer_heap == self del self.timers[timer] assert timer in self.heap self.heap.remove(timer) heapq.heapify(self.heap)
module function_definition identifier parameters identifier identifier block assert_statement comparison_operator attribute identifier identifier identifier delete_statement subscript attribute identifier identifier identifier assert_statement comparison_operator identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier
Remove timer from heap lock and presence are assumed
def build(site, tagdata): tagdata.sort() tagmax = 0 for tagname, tagcount in tagdata: if tagcount > tagmax: tagmax = tagcount steps = getsteps(site.tagcloud_levels, tagmax) tags = [] for tagname, tagcount in tagdata: weight = [twt[0] \ for twt in steps if twt[1] >= tagcount and twt[1] > 0][0]+1 tags.append({'tagname':tagname, 'count':tagcount, 'weight':weight}) return tags
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier integer for_statement pattern_list identifier identifier identifier block if_statement comparison_operator identifier identifier block expression_statement assignment identifier identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier identifier expression_statement assignment identifier list for_statement pattern_list identifier identifier identifier block expression_statement assignment identifier binary_operator subscript list_comprehension subscript identifier integer line_continuation for_in_clause identifier identifier if_clause boolean_operator comparison_operator subscript identifier integer identifier comparison_operator subscript identifier integer integer integer integer expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier return_statement identifier
Returns the tag cloud for a list of tags.
def clear(self) -> None: if self._cache_directory is not None: assert os.path.exists(self._cache_directory_index), "Attempt to clear a non-existent cache" self._load() for e in self._cache.values(): if os.path.exists(e.loc): os.remove(e.loc) self._cache.clear() self._update() self._cache = {}
module function_definition identifier parameters identifier type none block if_statement comparison_operator attribute identifier identifier none block assert_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list for_statement identifier call attribute attribute identifier identifier identifier argument_list block if_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier dictionary
Clear all cache entries for directory and, if it is a 'pure' directory, remove the directory itself
def prep_recal(data): if dd.get_recalibrate(data) in [True, "gatk"]: logger.info("Prepare BQSR tables with GATK: %s " % str(dd.get_sample_name(data))) dbsnp_file = tz.get_in(("genome_resources", "variation", "dbsnp"), data) if not dbsnp_file: logger.info("Skipping GATK BaseRecalibrator because no VCF file of known variants was found.") return data broad_runner = broad.runner_from_config(data["config"]) data["prep_recal"] = _gatk_base_recalibrator(broad_runner, dd.get_align_bam(data), dd.get_ref_file(data), dd.get_platform(data), dbsnp_file, dd.get_variant_regions(data) or dd.get_sample_callable(data), data) elif dd.get_recalibrate(data) == "sentieon": logger.info("Prepare BQSR tables with sentieon: %s " % str(dd.get_sample_name(data))) data["prep_recal"] = sentieon.bqsr_table(data) elif dd.get_recalibrate(data): raise NotImplementedError("Unsupported recalibration type: %s" % (dd.get_recalibrate(data))) return data
module function_definition identifier parameters identifier block if_statement comparison_operator call attribute identifier identifier argument_list identifier list true string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier if_statement not_operator identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list identifier call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier identifier boolean_operator call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier identifier elif_clause comparison_operator call attribute identifier identifier argument_list identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list call attribute identifier identifier argument_list identifier expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list identifier elif_clause call attribute identifier identifier argument_list identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end parenthesized_expression call attribute identifier identifier argument_list identifier return_statement identifier
Do pre-BQSR recalibration, calculation of recalibration tables.
def glr_path_static(): return os.path.abspath(os.path.join(os.path.dirname(__file__), '_static'))
module function_definition identifier parameters block return_statement call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end
Returns path to packaged static files
def add_listener(self, listener, message_type, data=None, one_shot=False): lst = self._one_shots if one_shot else self._listeners if message_type not in lst: lst[message_type] = [] lst[message_type].append(Listener(listener, data))
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none default_parameter identifier false block expression_statement assignment identifier conditional_expression attribute identifier identifier identifier attribute identifier identifier if_statement comparison_operator identifier identifier block expression_statement assignment subscript identifier identifier list expression_statement call attribute subscript identifier identifier identifier argument_list call identifier argument_list identifier identifier
Add a listener that will receice incoming messages.
def dinfFlowDirection(self, flow_dir_grid, slope_grid, pit_filled_elevation_grid=None): log("PROCESS: DinfFlowDirection") if pit_filled_elevation_grid: self.pit_filled_elevation_grid = pit_filled_elevation_grid cmd = [os.path.join(self.taudem_exe_path, 'dinfflowdir'), '-fel', self.pit_filled_elevation_grid, '-ang', flow_dir_grid, '-slp', slope_grid, ] self._run_mpi_cmd(cmd) self._add_prj_file(self.pit_filled_elevation_grid, flow_dir_grid) self._add_prj_file(self.pit_filled_elevation_grid, slope_grid)
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none block expression_statement call identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement assignment attribute identifier identifier identifier expression_statement assignment identifier list call attribute attribute identifier identifier identifier argument_list attribute identifier identifier string string_start string_content string_end string string_start string_content string_end attribute identifier identifier string string_start string_content string_end identifier string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier
Calculates flow direction with Dinf method
def add_delta_step(self, delta: float): if self.delta_last_experience_collection: self.delta_last_experience_collection += delta else: self.delta_last_experience_collection = delta
module function_definition identifier parameters identifier typed_parameter identifier type identifier block if_statement attribute identifier identifier block expression_statement augmented_assignment attribute identifier identifier identifier else_clause block expression_statement assignment attribute identifier identifier identifier
Inform Metrics class about time to step in environment.
def freqpoly_plot(data): rel_data = OrderedDict() for key, val in data.items(): tot = sum(val.values(), 0) rel_data[key] = {k: v / tot for k, v in val.items()} fplotconfig = { 'data_labels': [ {'name': 'Absolute', 'ylab': 'Frequency', 'xlab': 'Merged Read Length'}, {'name': 'Relative', 'ylab': 'Relative Frequency', 'xlab': 'Merged Read Length'} ], 'id': 'flash_freqpoly_plot', 'title': 'FLASh: Frequency of merged read lengths', 'colors': dict(zip(data.keys(), MultiqcModule.get_colors(len(data)))) } return linegraph.plot([data, rel_data], fplotconfig)
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list integer expression_statement assignment subscript identifier identifier dictionary_comprehension pair identifier binary_operator identifier identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list expression_statement assignment identifier dictionary pair string string_start string_content string_end list 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 pair string string_start string_content string_end string string_start string_content string_end 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 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 pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end call identifier argument_list call identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list call identifier argument_list identifier return_statement call attribute identifier identifier argument_list list identifier identifier identifier
make freqpoly plot of merged read lengths
def delete(self, resource, resource_id): service_def, resource_def, path = self._get_service_information( resource) delete_path = "{0}{1}/" . format(path, resource_id) return self.call(path=delete_path, method="delete")
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment pattern_list identifier identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier identifier return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end
A base function that performs a default delete DELETE request for a given object
def interface(self, context): self.context = context self.callback = self.context.get("callback")
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end
Implement the interface for the adapter object
def kernel(): print('================================') print(' WARNING: upgrading the kernel') print('================================') time.sleep(5) print('-[kernel]----------') cmd('rpi-update', True) print(' >> You MUST reboot to load the new kernel <<')
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 attribute identifier identifier argument_list integer 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 true expression_statement call identifier argument_list string string_start string_content string_end
Handle linux kernel update
def _get_token_create_url(config): role_name = config.get('role_name', None) auth_path = '/v1/auth/token/create' base_url = config['url'] return '/'.join(x.strip('/') for x in (base_url, auth_path, role_name) if x)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end none expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier string string_start string_content string_end return_statement call attribute string string_start string_content string_end identifier generator_expression call attribute identifier identifier argument_list string string_start string_content string_end for_in_clause identifier tuple identifier identifier identifier if_clause identifier
Create Vault url for token creation
def counter_style(self, val, style): if style == 'decimal-leading-zero': if val < 10: valstr = "0{}".format(val) else: valstr = str(val) elif style == 'lower-roman': valstr = _to_roman(val).lower() elif style == 'upper-roman': valstr = _to_roman(val) elif style == 'lower-latin' or style == 'lower-alpha': if 1 <= val <= 26: valstr = chr(val + 96) else: log(WARN, 'Counter out of range for latin (must be 1...26)') valstr = str(val) elif style == 'upper-latin' or style == 'upper-alpha': if 1 <= val <= 26: valstr = chr(val + 64) else: log(WARN, 'Counter out of range for latin (must be 1...26)') valstr = str(val) elif style == 'decimal': valstr = str(val) else: log(WARN, u"ERROR: Counter numbering not supported for" u" list type {}. Using decimal.".format( style).encode('utf-8')) valstr = str(val) return valstr
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator identifier string string_start string_content string_end block if_statement comparison_operator identifier integer block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier else_clause block expression_statement assignment identifier call identifier argument_list identifier elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call attribute call identifier argument_list identifier identifier argument_list elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list identifier elif_clause boolean_operator comparison_operator identifier string string_start string_content string_end comparison_operator identifier string string_start string_content string_end block if_statement comparison_operator integer identifier integer block expression_statement assignment identifier call identifier argument_list binary_operator identifier integer else_clause block expression_statement call identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier elif_clause boolean_operator comparison_operator identifier string string_start string_content string_end comparison_operator identifier string string_start string_content string_end block if_statement comparison_operator integer identifier integer block expression_statement assignment identifier call identifier argument_list binary_operator identifier integer else_clause block expression_statement call identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list identifier else_clause block expression_statement call identifier argument_list identifier call attribute call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier return_statement identifier
Return counter value in given style.
def sendall(self, *args, **kwargs): return self._safe_call( False, super(SSLFileobjectMixin, self).sendall, *args, **kwargs )
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block return_statement call attribute identifier identifier argument_list false attribute call identifier argument_list identifier identifier identifier list_splat identifier dictionary_splat identifier
Send whole message to the socket.
def class_type_changed(self): if self.source_path.text(): self.reset_avaliable(self.source_path.text())
module function_definition identifier parameters identifier block if_statement call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list
Forces a reset if the class type is changed from instruments to scripts or vice versa
def register(self, password): if len(password) < 8: raise ValueError("Password must be at least 8 characters.") params = {"name": self.nick, "password": password} resp = self.conn.make_api_call("register", params) if "error" in resp: raise RuntimeError(f"{resp['error'].get('message') or resp['error']}") self.conn.make_call("useSession", resp["session"]) self.conn.cookies.update({"session": resp["session"]}) self.logged_in = True
module function_definition identifier parameters identifier identifier block if_statement comparison_operator call identifier argument_list identifier integer block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier if_statement comparison_operator string string_start string_content string_end identifier block raise_statement call identifier argument_list string string_start interpolation boolean_operator call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end subscript identifier string string_start string_content string_end string_end expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list dictionary pair string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier true
Registers the current user with the given password.
def atlas_node_add_callback(atlas_state, callback_name, callback): if callback_name == 'store_zonefile': atlas_state['zonefile_crawler'].set_store_zonefile_callback(callback) else: raise ValueError("Unrecognized callback {}".format(callback_name))
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator identifier string string_start string_content string_end block expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list identifier else_clause block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier
Add a callback to the initialized atlas state
def on_reset_button(self, _): for graph in self.visible_graphs.values(): graph.reset() for graph in self.graphs.values(): try: graph.source.reset() except NotImplementedError: pass self.clock_view.set_text(ZERO_TIME) self.update_displayed_information()
module function_definition identifier parameters identifier identifier block for_statement identifier call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list for_statement identifier call attribute attribute identifier identifier identifier argument_list block try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list except_clause identifier block pass_statement expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list
Reset graph data and display empty graph
def index(self, values=None, only_index=None): assert self.indexable, "Field not indexable" assert not only_index or self.has_index(only_index), "Invalid index" if only_index: only_index = only_index if isclass(only_index) else only_index.__class__ if values is None: values = self.proxy_get() for value in values: if value is not None: needs_to_check_uniqueness = bool(self.unique) for index in self._indexes: if only_index and not isinstance(index, only_index): continue index.add(value, check_uniqueness=needs_to_check_uniqueness and index.handle_uniqueness) if needs_to_check_uniqueness and index.handle_uniqueness: needs_to_check_uniqueness = False
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block assert_statement attribute identifier identifier string string_start string_content string_end assert_statement boolean_operator not_operator identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end if_statement identifier block expression_statement assignment identifier conditional_expression identifier call identifier argument_list identifier attribute identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier identifier block if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list attribute identifier identifier for_statement identifier attribute identifier identifier block if_statement boolean_operator identifier not_operator call identifier argument_list identifier identifier block continue_statement expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier boolean_operator identifier attribute identifier identifier if_statement boolean_operator identifier attribute identifier identifier block expression_statement assignment identifier false
Index all values stored in the field, or only given ones if any.
def visit_binop(self, node): left = self._precedence_parens(node, node.left) right = self._precedence_parens(node, node.right, is_left=False) if node.op == "**": return "%s%s%s" % (left, node.op, right) return "%s %s %s" % (left, node.op, right)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier keyword_argument identifier false if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block return_statement binary_operator string string_start string_content string_end tuple identifier attribute identifier identifier identifier return_statement binary_operator string string_start string_content string_end tuple identifier attribute identifier identifier identifier
return an astroid.BinOp node as string
def os_details(): bits, linkage = platform.architecture() results = { "platform.arch.bits": bits, "platform.arch.linkage": linkage, "platform.machine": platform.machine(), "platform.process": platform.processor(), "sys.byteorder": sys.byteorder, "os.name": os.name, "host.name": socket.gethostname(), "sys.platform": sys.platform, "platform.system": platform.system(), "platform.release": platform.release(), "platform.version": platform.version(), "encoding.filesystem": sys.getfilesystemencoding(), } for name in "sep", "altsep", "pathsep", "linesep": results["os.{0}".format(name)] = getattr(os, name, None) try: results["os.cpu_count"] = os.cpu_count() except AttributeError: results["os.cpu_count"] = None try: results["sys.dlopenflags"] = sys.getdlopenflags() except AttributeError: results["sys.dlopenflags"] = None return results
module function_definition identifier parameters block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list 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 call attribute identifier identifier argument_list pair string string_start string_content string_end call attribute identifier identifier argument_list 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 call attribute identifier identifier argument_list pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end call attribute identifier identifier argument_list pair string string_start string_content string_end call attribute identifier identifier argument_list pair string string_start string_content string_end call attribute identifier identifier argument_list pair string string_start string_content string_end call attribute identifier identifier argument_list for_statement identifier expression_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 expression_statement assignment subscript identifier call attribute string string_start string_content string_end identifier argument_list identifier call identifier argument_list identifier identifier none try_statement block expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list except_clause identifier block expression_statement assignment subscript identifier string string_start string_content string_end none try_statement block expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list except_clause identifier block expression_statement assignment subscript identifier string string_start string_content string_end none return_statement identifier
Returns a dictionary containing details about the operating system
def request(self, method, url, params=None, **kwargs): params_key = tuple(params.items()) if params else () if method.upper() == "GET": if (url, params_key) in self.get_cache: print("Returning cached response for:", method, url, params) return self.get_cache[(url, params_key)] result = super().request(method, url, params, **kwargs) if method.upper() == "GET": self.get_cache[(url, params_key)] = result print("Adding entry to the cache:", method, url, params) return result
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none dictionary_splat_pattern identifier block expression_statement assignment identifier conditional_expression call identifier argument_list call attribute identifier identifier argument_list identifier tuple if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end block if_statement comparison_operator tuple identifier identifier attribute identifier identifier block expression_statement call identifier argument_list string string_start string_content string_end identifier identifier identifier return_statement subscript attribute identifier identifier tuple identifier identifier expression_statement assignment identifier call attribute call identifier argument_list identifier argument_list identifier identifier identifier dictionary_splat identifier if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment subscript attribute identifier identifier tuple identifier identifier identifier expression_statement call identifier argument_list string string_start string_content string_end identifier identifier identifier return_statement identifier
Perform a request, or return a cached response if available.
def chdir(self, directory_path, make=False): if os.sep in directory_path: for directory in directory_path.split(os.sep): if make and not self.directory_exists(directory): try: self.session.mkd(directory) except ftplib.error_perm: pass self.session.cwd(directory) else: self.session.cwd(directory_path)
module function_definition identifier parameters identifier identifier default_parameter identifier false block if_statement comparison_operator attribute identifier identifier identifier block for_statement identifier call attribute identifier identifier argument_list attribute identifier identifier block if_statement boolean_operator identifier not_operator call attribute identifier identifier argument_list identifier block try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list identifier except_clause attribute identifier identifier block pass_statement expression_statement call attribute attribute identifier identifier identifier argument_list identifier else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Change directories and optionally make the directory if it doesn't exist.
def build_requirements(docs_path, package_name="yacms"): mezz_string = "yacms==" project_path = os.path.join(docs_path, "..") requirements_file = os.path.join(project_path, package_name, "project_template", "requirements.txt") with open(requirements_file, "r") as f: requirements = f.readlines() with open(requirements_file, "w") as f: f.write("yacms==%s\n" % __version__) for requirement in requirements: if requirement.strip() and not requirement.startswith(mezz_string): f.write(requirement)
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier string string_start string_content string_end string string_start string_content string_end with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier 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 call attribute identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end identifier for_statement identifier identifier block if_statement boolean_operator call attribute identifier identifier argument_list not_operator call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier
Updates the requirements file with yacms's version number.
def _create_gitlab_prometheus_instance(self, instance, init_config): allowed_metrics = init_config.get('allowed_metrics') if allowed_metrics is None: raise CheckException("At least one metric must be whitelisted in `allowed_metrics`.") gitlab_instance = deepcopy(instance) gitlab_instance['prometheus_url'] = instance.get('prometheus_endpoint') gitlab_instance.update( { 'namespace': 'gitlab', 'metrics': allowed_metrics, 'send_monotonic_counter': instance.get('send_monotonic_counter', False), 'health_service_check': instance.get('health_service_check', False), } ) return gitlab_instance
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier none block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end identifier pair string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end false pair string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end false return_statement identifier
Set up the gitlab instance so it can be used in OpenMetricsBaseCheck
def display_terminal_carbon(mol): for i, a in mol.atoms_iter(): if mol.neighbor_count(i) == 1: a.visible = True
module function_definition identifier parameters identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement comparison_operator call attribute identifier identifier argument_list identifier integer block expression_statement assignment attribute identifier identifier true
Set visible=True to the terminal carbon atoms.
def getApplicationLaunchArguments(self, unHandle, pchArgs, unArgs): fn = self.function_table.getApplicationLaunchArguments result = fn(unHandle, pchArgs, unArgs) return result
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier return_statement identifier
Get the args list from an app launch that had the process already running, you call this when you get a VREvent_ApplicationMimeTypeLoad
def _get_title(self,directory,filename): fullfile=os.path.join(directory,filename+'.title') try: logger.debug('trying to open [%s]'%(fullfile)) _title=(open(fullfile).readline().strip()) logger.debug("_updatemeta: %s - title is '%s'",filename,_title) except: _title='' return _title
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier binary_operator identifier string string_start string_content string_end try_statement block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end parenthesized_expression identifier expression_statement assignment identifier parenthesized_expression call attribute call attribute call identifier argument_list identifier identifier argument_list identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier except_clause block expression_statement assignment identifier string string_start string_end return_statement identifier
Loads image title if any
def _scale_back_response(bqm, response, scalar, ignored_interactions, ignored_variables, ignore_offset): if len(ignored_interactions) + len( ignored_variables) + ignore_offset == 0: response.record.energy = np.divide(response.record.energy, scalar) else: response.record.energy = bqm.energies((response.record.sample, response.variables)) return response
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block if_statement comparison_operator binary_operator binary_operator call identifier argument_list identifier call identifier argument_list identifier identifier integer block expression_statement assignment attribute attribute identifier identifier identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier identifier else_clause block expression_statement assignment attribute attribute identifier identifier identifier call attribute identifier identifier argument_list tuple attribute attribute identifier identifier identifier attribute identifier identifier return_statement identifier
Helper function to scale back the response of sample method
def init_not_msvc(self): paths = os.environ.get('LD_LIBRARY_PATH', '').split(':') for gomp in ('libgomp.so', 'libgomp.dylib'): if cxx is None: continue cmd = [cxx, '-print-file-name=' + gomp] try: path = os.path.dirname(check_output(cmd).strip()) if path: paths.append(path) except OSError: pass libgomp_path = find_library("gomp") for path in paths: if libgomp_path: break path = path.strip() if os.path.isdir(path): libgomp_path = find_library(os.path.join(str(path), "libgomp")) if not libgomp_path: raise ImportError("I can't find a shared library for libgomp," " you may need to install it or adjust the " "LD_LIBRARY_PATH environment variable.") else: self.libomp = ctypes.CDLL(libgomp_path) self.version = 45
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_end identifier argument_list string string_start string_content string_end for_statement identifier tuple string string_start string_content string_end string string_start string_content string_end block if_statement comparison_operator identifier none block continue_statement expression_statement assignment identifier list identifier binary_operator string string_start string_content string_end identifier try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute call identifier argument_list identifier identifier argument_list if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier except_clause identifier block pass_statement expression_statement assignment identifier call identifier argument_list string string_start string_content string_end for_statement identifier identifier block if_statement identifier block break_statement expression_statement assignment identifier call attribute identifier identifier argument_list if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier string string_start string_content string_end if_statement not_operator identifier block raise_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end else_clause block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier integer
Find OpenMP library and try to load if using ctype interface.
def removePeer(self, url): q = models.Peer.delete().where( models.Peer.url == url) q.execute()
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list comparison_operator attribute attribute identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list
Remove peers by URL.
def extract(self, pbf, output): logging.info("Extracting POI nodes from {0} to {1}".format(pbf, output)) with open(output, 'w') as f: def nodes_callback(nodes): for node in nodes: node_id, tags, coordinates = node if any([t in tags for t in POI_TAGS]): f.write(json.dumps(dict(tags=tags, coordinates=coordinates))) f.write('\n') parser = OSMParser(concurrency=4, nodes_callback=nodes_callback) parser.parse(pbf) return output
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier 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 function_definition identifier parameters identifier block for_statement identifier identifier block expression_statement assignment pattern_list identifier identifier identifier identifier if_statement call identifier argument_list list_comprehension comparison_operator identifier identifier for_in_clause identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end expression_statement assignment identifier call identifier argument_list keyword_argument identifier integer keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
extract POI nodes from osm pbf extract
def _handle_template_param(self): if self._context & contexts.TEMPLATE_NAME: if not self._context & (contexts.HAS_TEXT | contexts.HAS_TEMPLATE): self._fail_route() self._context ^= contexts.TEMPLATE_NAME elif self._context & contexts.TEMPLATE_PARAM_VALUE: self._context ^= contexts.TEMPLATE_PARAM_VALUE else: self._emit_all(self._pop()) self._context |= contexts.TEMPLATE_PARAM_KEY self._emit(tokens.TemplateParamSeparator()) self._push(self._context)
module function_definition identifier parameters identifier block if_statement binary_operator attribute identifier identifier attribute identifier identifier block if_statement not_operator binary_operator attribute identifier identifier parenthesized_expression binary_operator attribute identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement augmented_assignment attribute identifier identifier attribute identifier identifier elif_clause binary_operator attribute identifier identifier attribute identifier identifier block expression_statement augmented_assignment attribute identifier identifier attribute identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement augmented_assignment attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list attribute identifier identifier
Handle a template parameter at the head of the string.
def run(self): try: for index, port in enumerate(self.possible_ports): try: self.httpd = self._create_server(port) except socket.error as e: if (index + 1 < len(self.possible_ports) and e.error == errno.EADDRINUSE): continue else: raise else: self.port = port break self.is_ready.set() self.httpd.serve_forever() except Exception as e: self.error = e self.is_ready.set()
module function_definition identifier parameters identifier block try_statement block for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block try_statement block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier except_clause as_pattern attribute identifier identifier as_pattern_target identifier block if_statement parenthesized_expression boolean_operator comparison_operator binary_operator identifier integer call identifier argument_list attribute identifier identifier comparison_operator attribute identifier identifier attribute identifier identifier block continue_statement else_clause block raise_statement else_clause block expression_statement assignment attribute identifier identifier identifier break_statement expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list except_clause as_pattern identifier as_pattern_target identifier block expression_statement assignment attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list
Sets up live server, and then loops over handling http requests.
def module_del(self, key): if key in self._module_event_map: del self._module_event_map[key] if key in self._watch_modules.names: self._watch_modules.remove(key)
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block delete_statement subscript attribute identifier identifier identifier if_statement comparison_operator identifier attribute attribute identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Deregister from python module change events.
def nacl_bindings_pick_scrypt_params(opslimit, memlimit): if opslimit < 32768: opslimit = 32768 r = 8 if opslimit < (memlimit // 32): p = 1 maxn = opslimit // (4 * r) for n_log2 in range(1, 63): if (2 ** n_log2) > (maxn // 2): break else: maxn = memlimit // (r * 128) for n_log2 in range(1, 63): if (2 ** n_log2) > maxn // 2: break maxrp = (opslimit // 4) // (2 ** n_log2) if maxrp > 0x3fffffff: maxrp = 0x3fffffff p = maxrp // r return n_log2, r, p
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier integer block expression_statement assignment identifier integer expression_statement assignment identifier integer if_statement comparison_operator identifier parenthesized_expression binary_operator identifier integer block expression_statement assignment identifier integer expression_statement assignment identifier binary_operator identifier parenthesized_expression binary_operator integer identifier for_statement identifier call identifier argument_list integer integer block if_statement comparison_operator parenthesized_expression binary_operator integer identifier parenthesized_expression binary_operator identifier integer block break_statement else_clause block expression_statement assignment identifier binary_operator identifier parenthesized_expression binary_operator identifier integer for_statement identifier call identifier argument_list integer integer block if_statement comparison_operator parenthesized_expression binary_operator integer identifier binary_operator identifier integer block break_statement expression_statement assignment identifier binary_operator parenthesized_expression binary_operator identifier integer parenthesized_expression binary_operator integer identifier if_statement comparison_operator identifier integer block expression_statement assignment identifier integer expression_statement assignment identifier binary_operator identifier identifier return_statement expression_list identifier identifier identifier
Python implementation of libsodium's pickparams
def record(self, tags, measurement_map, timestamp, attachments=None): assert all(vv >= 0 for vv in measurement_map.values()) for measure, value in measurement_map.items(): if measure != self._registered_measures.get(measure.name): return view_datas = [] for measure_name, view_data_list \ in self._measure_to_view_data_list_map.items(): if measure_name == measure.name: view_datas.extend(view_data_list) for view_data in view_datas: view_data.record( context=tags, value=value, timestamp=timestamp, attachments=attachments) self.export(view_datas)
module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier none block assert_statement call identifier generator_expression comparison_operator identifier integer for_in_clause 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 call attribute attribute identifier identifier identifier argument_list attribute identifier identifier block return_statement expression_statement assignment identifier list for_statement pattern_list identifier identifier line_continuation call attribute attribute identifier identifier identifier argument_list block if_statement comparison_operator identifier attribute 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 keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier
records stats with a set of tags
def as_bel(self) -> str: return '{}(fus({}:{}, "{}", {}:{}, "{}"))'.format( self._func, self.partner_5p.namespace, self.partner_5p._priority_id, self.range_5p.as_bel(), self.partner_3p.namespace, self.partner_3p._priority_id, self.range_3p.as_bel(), )
module function_definition identifier parameters identifier type identifier block return_statement call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier call attribute attribute identifier identifier identifier argument_list
Return this fusion as a BEL string.
def register(self, prefix, viewset, base_name=None, router_class=None): if base_name is None: base_name = self.get_default_base_name(viewset) if router_class is not None: kwargs = {'trailing_slash': bool(self.trailing_slash)} single_object_router_classes = ( AuthenticationRouter, SingleObjectRouter) if issubclass(router_class, single_object_router_classes): router = router_class(**kwargs) router.register(prefix, viewset, base_name=base_name) self._single_object_registry.append(router) else: self.registry.append((prefix, viewset, base_name))
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement assignment identifier dictionary pair string string_start string_content string_end call identifier argument_list attribute identifier identifier expression_statement assignment identifier tuple identifier identifier if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list dictionary_splat identifier expression_statement call attribute identifier identifier argument_list identifier identifier keyword_argument identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list tuple identifier identifier identifier
Append the given viewset to the proper registry.
def change_response(x, prob, index): N = (x==index).sum() x[x==index] = dist.sample(N)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute parenthesized_expression comparison_operator identifier identifier identifier argument_list expression_statement assignment subscript identifier comparison_operator identifier identifier call attribute identifier identifier argument_list identifier
change every response in x that matches 'index' by randomly sampling from prob
def write_slide_list(self, logname, slides): with open('%s/%s' % (self.cache, logname), 'w') as logfile: for slide in slides: heading = slide['heading']['text'] filename = self.get_image_name(heading) print('%s,%d' % (filename, slide.get('time', 0)), file=logfile)
module function_definition identifier parameters identifier identifier identifier block with_statement with_clause with_item as_pattern call identifier argument_list binary_operator string string_start string_content string_end tuple attribute identifier identifier identifier string string_start string_content string_end as_pattern_target identifier block for_statement identifier identifier block expression_statement assignment identifier subscript subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier call attribute identifier identifier argument_list string string_start string_content string_end integer keyword_argument identifier identifier
Write list of slides to logfile
def update(self): from ambry.orm.exc import NotFoundError from requests.exceptions import ConnectionError, HTTPError from boto.exception import S3ResponseError d = {} try: for k, v in self.list(full=True): if not v: continue d[v['vid']] = { 'vid': v['vid'], 'vname': v.get('vname'), 'id': v.get('id'), 'name': v.get('name') } self.data['list'] = d except (NotFoundError, ConnectionError, S3ResponseError, HTTPError) as e: raise RemoteAccessError("Failed to update {}: {}".format(self.short_name, e))
module function_definition identifier parameters identifier block import_from_statement dotted_name identifier identifier identifier dotted_name identifier import_from_statement dotted_name identifier identifier dotted_name identifier dotted_name identifier import_from_statement dotted_name identifier identifier dotted_name identifier expression_statement assignment identifier dictionary try_statement block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list keyword_argument identifier true block if_statement not_operator identifier block continue_statement expression_statement assignment subscript identifier subscript identifier string string_start string_content string_end dictionary pair string string_start string_content string_end subscript identifier string string_start string_content string_end pair string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end pair string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end pair string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end identifier except_clause as_pattern tuple identifier identifier identifier identifier as_pattern_target identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier identifier
Cache the list into the data section of the record
def merge_sims(oldsims, newsims, clip=None): if oldsims is None: result = newsims or [] elif newsims is None: result = oldsims else: result = sorted(oldsims + newsims, key=lambda item: -item[1]) if clip is not None: result = result[:clip] return result
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier boolean_operator identifier list elif_clause comparison_operator identifier none block expression_statement assignment identifier identifier else_clause block expression_statement assignment identifier call identifier argument_list binary_operator identifier identifier keyword_argument identifier lambda lambda_parameters identifier unary_operator subscript identifier integer if_statement comparison_operator identifier none block expression_statement assignment identifier subscript identifier slice identifier return_statement identifier
Merge two precomputed similarity lists, truncating the result to `clip` most similar items.
def _check_file_field(self, field): is_field = field in self.field_names is_file = self.__meta_metadata(field, 'field_type') == 'file' if not (is_field and is_file): msg = "'%s' is not a field or not a 'file' field" % field raise ValueError(msg) else: return True
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier comparison_operator identifier attribute identifier identifier expression_statement assignment identifier comparison_operator call attribute identifier identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end if_statement not_operator parenthesized_expression boolean_operator identifier identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end identifier raise_statement call identifier argument_list identifier else_clause block return_statement true
Check that field exists and is a file field
def virtual_interface_list(self, name): nt_ks = self.compute_conn nets = nt_ks.virtual_interfaces.list(self._server_uuid_from_name(name)) return [network.__dict__ for network in nets]
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier return_statement list_comprehension attribute identifier identifier for_in_clause identifier identifier
Get virtual interfaces on slice
def on_train_begin(self, **kwargs: Any) -> None: "Prepare file with metric names." self.path.parent.mkdir(parents=True, exist_ok=True) self.file = self.path.open('a') if self.append else self.path.open('w') self.file.write(','.join(self.learn.recorder.names[:(None if self.add_time else -1)]) + '\n')
module function_definition identifier parameters identifier typed_parameter dictionary_splat_pattern identifier type identifier type none block expression_statement string string_start string_content string_end expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list keyword_argument identifier true keyword_argument identifier true expression_statement assignment attribute identifier identifier conditional_expression call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end attribute identifier identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator call attribute string string_start string_content string_end identifier argument_list subscript attribute attribute attribute identifier identifier identifier identifier slice parenthesized_expression conditional_expression none attribute identifier identifier unary_operator integer string string_start string_content escape_sequence string_end
Prepare file with metric names.
def remove_cv(type_): nake_type = remove_alias(type_) if not is_const(nake_type) and not is_volatile(nake_type): return type_ result = nake_type if is_const(result): result = remove_const(result) if is_volatile(result): result = remove_volatile(result) if is_const(result): result = remove_const(result) return result
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement boolean_operator not_operator call identifier argument_list identifier not_operator call identifier argument_list identifier block return_statement identifier expression_statement assignment identifier identifier if_statement call identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement call identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement call identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list identifier return_statement identifier
removes const and volatile from the type definition
def item_enclosure_url(self, item): try: url = item.image.url except (AttributeError, ValueError): img = BeautifulSoup(item.html_content, 'html.parser').find('img') url = img.get('src') if img else None self.cached_enclosure_url = url if url: url = urljoin(self.site_url, url) if self.feed_format == 'rss': url = url.replace('https://', 'http://') return url
module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment identifier attribute attribute identifier identifier identifier except_clause tuple identifier identifier block expression_statement assignment identifier call attribute call identifier argument_list attribute identifier identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end expression_statement assignment identifier conditional_expression call attribute identifier identifier argument_list string string_start string_content string_end identifier none expression_statement assignment attribute identifier identifier identifier if_statement identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier identifier if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end return_statement identifier
Return an image for enclosure.
def flush (self, overlap=0): self.buf += self.empty.join(self.tmpbuf) self.tmpbuf = [] if overlap and overlap < self.pos: data = self.buf[:-overlap] self.buf = self.buf[-overlap:] else: data = self.buf self.buf = self.empty return data
module function_definition identifier parameters identifier default_parameter identifier integer block expression_statement augmented_assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier list if_statement boolean_operator identifier comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier slice unary_operator identifier expression_statement assignment attribute identifier identifier subscript attribute identifier identifier slice unary_operator identifier else_clause block expression_statement assignment identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier return_statement identifier
Flush buffered data and return it.
def identify_names(filename): node, _ = parse_source_file(filename) if node is None: return {} finder = NameFinder() finder.visit(node) names = list(finder.get_mapping()) names += extract_object_names_from_docs(filename) example_code_obj = collections.OrderedDict() for name, full_name in names: if name in example_code_obj: continue splitted = full_name.rsplit('.', 1) if len(splitted) == 1: continue module, attribute = splitted module_short = get_short_module_name(module, attribute) cobj = {'name': attribute, 'module': module, 'module_short': module_short} example_code_obj[name] = cobj return example_code_obj
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier if_statement comparison_operator identifier none block return_statement dictionary expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list expression_statement augmented_assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list for_statement pattern_list identifier identifier identifier block if_statement comparison_operator identifier identifier block continue_statement expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end integer if_statement comparison_operator call identifier argument_list identifier integer block continue_statement expression_statement assignment pattern_list identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier 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 expression_statement assignment subscript identifier identifier identifier return_statement identifier
Builds a codeobj summary by identifying and resolving used names.
def _mean_square_error(y, y_pred, w): return np.average(((y_pred - y) ** 2), weights=w)
module function_definition identifier parameters identifier identifier identifier block return_statement call attribute identifier identifier argument_list parenthesized_expression binary_operator parenthesized_expression binary_operator identifier identifier integer keyword_argument identifier identifier
Calculate the mean square error.
def subtract(self, route): for address in self.raw_maps.pop(route, NullHardwareMap()).iterkeys(): self.pop(address, NullHardwareNode())
module function_definition identifier parameters identifier identifier block for_statement identifier call attribute call attribute attribute identifier identifier identifier argument_list identifier call identifier argument_list identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier call identifier argument_list
Remove the route entirely.
def make_replacement_visitor(find_expression, replace_expression): def visitor_fn(expression): if expression == find_expression: return replace_expression else: return expression return visitor_fn
module function_definition identifier parameters identifier identifier block function_definition identifier parameters identifier block if_statement comparison_operator identifier identifier block return_statement identifier else_clause block return_statement identifier return_statement identifier
Return a visitor function that replaces every instance of one expression with another one.
def remake_display(self, *args): Builder.load_string(self.kv) if hasattr(self, '_kv_layout'): self.remove_widget(self._kv_layout) del self._kv_layout self._kv_layout = KvLayout() self.add_widget(self._kv_layout)
module function_definition identifier parameters identifier list_splat_pattern identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list attribute identifier identifier delete_statement attribute identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list attribute identifier identifier
Remake any affected widgets after a change in my ``kv``.
async def join(self, ctx): perms = discord.Permissions.none() perms.read_messages = True perms.send_messages = True perms.manage_messages = True perms.embed_links = True perms.read_message_history = True perms.attach_files = True perms.add_reactions = True await self.bot.send_message(ctx.message.author, discord.utils.oauth_url(self.bot.client_id, perms))
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier true expression_statement assignment attribute identifier identifier true expression_statement assignment attribute identifier identifier true expression_statement assignment attribute identifier identifier true expression_statement assignment attribute identifier identifier true expression_statement assignment attribute identifier identifier true expression_statement assignment attribute identifier identifier true expression_statement await call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier identifier
Sends you the bot invite link.
def _parse_myinfo(client, command, actor, args): _, server, version, usermodes, channelmodes = args.split(None, 5)[:5] s = client.server s.host = server s.version = version s.user_modes = set(usermodes) s.channel_modes = set(channelmodes)
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment pattern_list identifier identifier identifier identifier identifier subscript call attribute identifier identifier argument_list none integer slice integer expression_statement assignment identifier attribute identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list identifier expression_statement assignment attribute identifier identifier call identifier argument_list identifier
Parse MYINFO and update the Host object.
def _render_context(self, template, block, **context): return u''.join(block(template.new_context(context)))
module function_definition identifier parameters identifier identifier identifier dictionary_splat_pattern identifier block return_statement call attribute string string_start string_end identifier argument_list call identifier argument_list call attribute identifier identifier argument_list identifier
Render a block to a string with its context
def _ha_gen_method(func): def wrapped(self, *args, **kw): self._reset_retries() while(True): try: results = func(self, *args, **kw) while(True): yield results.next() except RequestError as e: self.__handle_request_error(e) except socket.error as e: self.__handle_socket_error(e) return wrapped
module function_definition identifier parameters identifier block function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement call attribute identifier identifier argument_list while_statement parenthesized_expression true block try_statement block expression_statement assignment identifier call identifier argument_list identifier list_splat identifier dictionary_splat identifier while_statement parenthesized_expression true block expression_statement yield call attribute identifier identifier argument_list except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier except_clause as_pattern attribute identifier identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Method decorator for 'generator type' methods
def parse_limits(self): if 'limits' in self._model: if not isinstance(self._model['limits'], list): raise ParseError('Expected limits to be a list') for limit in parse_limits_list( self._context, self._model['limits']): yield limit
module function_definition identifier parameters identifier block if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block if_statement not_operator call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end identifier block raise_statement call identifier argument_list string string_start string_content string_end for_statement identifier call identifier argument_list attribute identifier identifier subscript attribute identifier identifier string string_start string_content string_end block expression_statement yield identifier
Yield tuples of reaction ID, lower, and upper bound flux limits
def all_server_links(server_id, rel_to=None): return [ server_link(rel, server_id, self_rel=(rel == rel_to)) for rel in ('delete-server', 'get-server-info', 'server-command') ]
module function_definition identifier parameters identifier default_parameter identifier none block return_statement list_comprehension call identifier argument_list identifier identifier keyword_argument identifier parenthesized_expression comparison_operator identifier identifier for_in_clause identifier tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end
Get a list of all links to be included with Servers.
def execute_sql(self, sql): cursor = self.get_cursor() cursor.execute(sql) return cursor
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Executes SQL and returns cursor for it
def _cnn_filter(in_file, vrn_files, data): tensor_type = "read_tensor" score_file = _cnn_score_variants(in_file, tensor_type, data) return _cnn_tranch_filtering(score_file, vrn_files, tensor_type, data)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier identifier identifier return_statement call identifier argument_list identifier identifier identifier identifier
Perform CNN filtering on input VCF using pre-trained models.
def keys(self): " Returns the keys of all the elements." if self.ndims == 1: return [k[0] for k in self.data.keys()] else: return list(self.data.keys())
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end if_statement comparison_operator attribute identifier identifier integer block return_statement list_comprehension subscript identifier integer for_in_clause identifier call attribute attribute identifier identifier identifier argument_list else_clause block return_statement call identifier argument_list call attribute attribute identifier identifier identifier argument_list
Returns the keys of all the elements.
def in6_getifaddr(): ifaddrs = [] ip6s = get_ips(v6=True) for iface in ip6s: ips = ip6s[iface] for ip in ips: scope = in6_getscope(ip) ifaddrs.append((ip, scope, iface)) if conf.use_npcap and scapy.consts.LOOPBACK_INTERFACE: ifaddrs.append(("::1", 0, scapy.consts.LOOPBACK_INTERFACE)) return ifaddrs
module function_definition identifier parameters block expression_statement assignment identifier list expression_statement assignment identifier call identifier argument_list keyword_argument identifier true for_statement identifier identifier block expression_statement assignment identifier subscript identifier identifier for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list tuple identifier identifier identifier if_statement boolean_operator attribute identifier identifier attribute attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list tuple string string_start string_content string_end integer attribute attribute identifier identifier identifier return_statement identifier
Returns all IPv6 addresses found on the computer
def GetClientVersion(client_id, token=None): if data_store.RelationalDBEnabled(): sinfo = data_store.REL_DB.ReadClientStartupInfo(client_id=client_id) if sinfo is not None: return sinfo.client_info.client_version else: return config.CONFIG["Source.version_numeric"] else: with aff4.FACTORY.Open(client_id, token=token) as client: cinfo = client.Get(client.Schema.CLIENT_INFO) if cinfo is not None: return cinfo.client_version else: return config.CONFIG["Source.version_numeric"]
module function_definition identifier parameters identifier default_parameter identifier none block if_statement call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier if_statement comparison_operator identifier none block return_statement attribute attribute identifier identifier identifier else_clause block return_statement subscript attribute identifier identifier string string_start string_content string_end else_clause block with_statement with_clause with_item as_pattern call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier if_statement comparison_operator identifier none block return_statement attribute identifier identifier else_clause block return_statement subscript attribute identifier identifier string string_start string_content string_end
Returns last known GRR version that the client used.
def to_ufo_blue_values(self, ufo, master): alignment_zones = master.alignmentZones blue_values = [] other_blues = [] for zone in sorted(alignment_zones): pos = zone.position size = zone.size val_list = blue_values if pos == 0 or size >= 0 else other_blues val_list.extend(sorted((pos, pos + size))) ufo.info.postscriptBlueValues = blue_values ufo.info.postscriptOtherBlues = other_blues
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier list expression_statement assignment identifier list for_statement identifier call identifier argument_list identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier conditional_expression identifier boolean_operator comparison_operator identifier integer comparison_operator identifier integer identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list tuple identifier binary_operator identifier identifier expression_statement assignment attribute attribute identifier identifier identifier identifier expression_statement assignment attribute attribute identifier identifier identifier identifier
Set postscript blue values from Glyphs alignment zones.
def end_policy_update(self): if self.time_policy_update_start: self.delta_policy_update = time() - self.time_policy_update_start else: self.delta_policy_update = 0 delta_train_start = time() - self.time_training_start LOGGER.debug(" Policy Update Training Metrics for {}: " "\n\t\tTime to update Policy: {:0.3f} s \n" "\t\tTime elapsed since training: {:0.3f} s \n" "\t\tTime for experience collection: {:0.3f} s \n" "\t\tBuffer Length: {} \n" "\t\tReturns : {:0.3f}\n" .format(self.brain_name, self.delta_policy_update, delta_train_start, self.delta_last_experience_collection, self.last_buffer_length, self.last_mean_return)) self._add_row(delta_train_start)
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement assignment attribute identifier identifier binary_operator call identifier argument_list attribute identifier identifier else_clause block expression_statement assignment attribute identifier identifier integer expression_statement assignment identifier binary_operator call identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content escape_sequence escape_sequence escape_sequence escape_sequence string_end string string_start string_content escape_sequence escape_sequence escape_sequence string_end string string_start string_content escape_sequence escape_sequence escape_sequence string_end string string_start string_content escape_sequence escape_sequence escape_sequence string_end string string_start string_content escape_sequence escape_sequence escape_sequence string_end identifier argument_list attribute identifier identifier attribute identifier identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier
Inform Metrics class that policy update has started.
def allowed(self, method, _dict, allow): for key in _dict.keys(): if key not in allow: raise LunrError("'%s' is not an argument for method '%s'" % (key, method))
module function_definition identifier parameters identifier identifier identifier identifier block for_statement identifier call attribute identifier identifier argument_list block if_statement comparison_operator identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier
Only these items are allowed in the dictionary
def readerWalker(self): ret = libxml2mod.xmlReaderWalker(self._o) if ret is None:raise treeError('xmlReaderWalker() failed') __tmp = xmlTextReader(_obj=ret) return __tmp
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier if_statement comparison_operator identifier none block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier return_statement identifier
Create an xmltextReader for a preparsed document.
def _get_space(self): title = '%s._space_id' % self.__class__.__name__ list_kwargs = { 'q': "'%s' in parents" % self.drive_space, 'spaces': self.drive_space, 'fields': 'files(name, parents)', 'pageSize': 1 } try: response = self.drive.list(**list_kwargs).execute() except: raise DriveConnectionError(title) for file in response.get('files',[]): self.space_id = file.get('parents')[0] break return self.space_id
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end attribute attribute identifier identifier identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end binary_operator 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 string string_start string_content string_end pair string string_start string_content string_end integer try_statement block expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list dictionary_splat identifier identifier argument_list except_clause block raise_statement call identifier argument_list identifier for_statement identifier call attribute identifier identifier argument_list string string_start string_content string_end list block expression_statement assignment attribute identifier identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end integer break_statement return_statement attribute identifier identifier
a helper method to retrieve id of drive space
def crop_to_extents(img1, img2, padding): beg_coords1, end_coords1 = crop_coords(img1, padding) beg_coords2, end_coords2 = crop_coords(img2, padding) beg_coords = np.fmin(beg_coords1, beg_coords2) end_coords = np.fmax(end_coords1, end_coords2) img1 = crop_3dimage(img1, beg_coords, end_coords) img2 = crop_3dimage(img2, beg_coords, end_coords) return img1, img2
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier identifier expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier return_statement expression_list identifier identifier
Crop the images to ensure both fit within the bounding box
def _bsecurate_cli_print_component_file(args): data = fileio.read_json_basis(args.file) return printing.component_basis_str(data, elements=args.elements)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier
Handles the print-component-file subcommand
def decompress(self, data): decompressed = "" pos = 0 while pos < len(data): currentChar = data[pos] if currentChar != self.referencePrefix: decompressed += currentChar pos += 1 else: nextChar = data[pos + 1] if nextChar != self.referencePrefix: distance = self.__decodeReferenceInt(data[pos + 1 : pos + 3], 2) length = self.__decodeReferenceLength(data[pos + 3]) start = len(decompressed) - distance - length end = start + length decompressed += decompressed[start : end] pos += self.minStringLength - 1 else: decompressed += self.referencePrefix pos += 2 return decompressed
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier string string_start string_end expression_statement assignment identifier integer while_statement comparison_operator identifier call identifier argument_list identifier block expression_statement assignment identifier subscript identifier identifier if_statement comparison_operator identifier attribute identifier identifier block expression_statement augmented_assignment identifier identifier expression_statement augmented_assignment identifier integer else_clause block expression_statement assignment identifier subscript identifier binary_operator identifier integer if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier slice binary_operator identifier integer binary_operator identifier integer integer expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier binary_operator identifier integer expression_statement assignment identifier binary_operator binary_operator call identifier argument_list identifier identifier identifier expression_statement assignment identifier binary_operator identifier identifier expression_statement augmented_assignment identifier subscript identifier slice identifier identifier expression_statement augmented_assignment identifier binary_operator attribute identifier identifier integer else_clause block expression_statement augmented_assignment identifier attribute identifier identifier expression_statement augmented_assignment identifier integer return_statement identifier
Decompresses LZ77 compressed text data
def token_list_to_text(tokenlist): ZeroWidthEscape = Token.ZeroWidthEscape return ''.join(item[1] for item in tokenlist if item[0] != ZeroWidthEscape)
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier return_statement call attribute string string_start string_end identifier generator_expression subscript identifier integer for_in_clause identifier identifier if_clause comparison_operator subscript identifier integer identifier
Concatenate all the text parts again.
def which(program): " Check program is exists. " head, _ = op.split(program) if head: if is_exe(program): return program else: for path in environ["PATH"].split(pathsep): exe_file = op.join(path, program) if is_exe(exe_file): return exe_file return None
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier if_statement identifier block if_statement call identifier argument_list identifier block return_statement identifier else_clause block for_statement identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement call identifier argument_list identifier block return_statement identifier return_statement none
Check program is exists.
def add_style(self, name, fg=None, bg=None, options=None): style = Style(name) if fg is not None: style.fg(fg) if bg is not None: style.bg(bg) if options is not None: if "bold" in options: style.bold() if "underline" in options: style.underlined() self._io.output.formatter.add_style(style) self._io.error_output.formatter.add_style(style)
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block if_statement comparison_operator string string_start string_content string_end identifier block expression_statement call attribute identifier identifier argument_list if_statement comparison_operator string string_start string_content string_end identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute attribute attribute attribute identifier identifier identifier identifier identifier argument_list identifier expression_statement call attribute attribute attribute attribute identifier identifier identifier identifier identifier argument_list identifier
Adds a new style
def clone_from(self, other): for other_finfo in other.data: self.clone_editor_from(other_finfo, set_current=True) self.set_stack_index(other.get_stack_index())
module function_definition identifier parameters identifier identifier block for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier true expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list
Clone EditorStack from other instance
def items(self): if type(self.transaction['items']['item']) == list: return self.transaction['items']['item'] else: return [self.transaction['items']['item'],]
module function_definition identifier parameters identifier block if_statement comparison_operator call identifier argument_list subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end identifier block return_statement subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end else_clause block return_statement list subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end
Lista dos items do pagamento
def _get_field_error_dict(self, field): return { 'name': field.html_name, 'id': 'id_{}'.format(field.html_name), 'errors': field.errors, }
module function_definition identifier parameters identifier identifier block return_statement dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier
Returns the dict containing the field errors information
def remove(self, row_or_row_indices): if not row_or_row_indices: return if isinstance(row_or_row_indices, int): rows_remove = [row_or_row_indices] else: rows_remove = row_or_row_indices for col in self._columns: self._columns[col] = [elem for i, elem in enumerate(self[col]) if i not in rows_remove] return self
module function_definition identifier parameters identifier identifier block if_statement not_operator identifier block return_statement if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier list identifier else_clause block expression_statement assignment identifier identifier for_statement identifier attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier list_comprehension identifier for_in_clause pattern_list identifier identifier call identifier argument_list subscript identifier identifier if_clause comparison_operator identifier identifier return_statement identifier
Removes a row or multiple rows of a table in place.
def getTimeOfClassesRemaining(self,numClasses=0): occurrences = EventOccurrence.objects.filter( cancelled=False, event__in=[x.event for x in self.temporaryeventregistration_set.filter(event__series__isnull=False)], ).order_by('-endTime') if occurrences.count() > numClasses: return occurrences[numClasses].endTime else: return occurrences.last().startTime
module function_definition identifier parameters identifier default_parameter identifier integer block expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list keyword_argument identifier false keyword_argument identifier list_comprehension attribute identifier identifier for_in_clause identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier false identifier argument_list string string_start string_content string_end if_statement comparison_operator call attribute identifier identifier argument_list identifier block return_statement attribute subscript identifier identifier identifier else_clause block return_statement attribute call attribute identifier identifier argument_list identifier
For checking things like prerequisites, it's useful to check if a requirement is 'almost' met
def assertpathsandfiles(self): assert os.path.isdir(self.miseqpath), u'MiSeqPath is not a valid directory {0!r:s}'.format(self.miseqpath) if not self.miseqfolder: miseqfolders = glob('{}*/'.format(self.miseqpath)) self.miseqfolder = sorted(miseqfolders)[-1] self.miseqfoldername = self.miseqfolder.split("/")[-2] else: self.miseqfoldername = self.miseqfolder self.miseqfolder = self.miseqpath + self.miseqfolder + "/" assert os.path.isdir(self.miseqfolder), u'MiSeqFolder is not a valid directory {0!r:s}'\ .format(self.miseqfolder) if self.customsamplesheet: self.samplesheet = self.customsamplesheet assert os.path.isfile(self.customsamplesheet), u'Could not find CustomSampleSheet as entered: {0!r:s}'\ .format(self.customsamplesheet) else: self.samplesheet = self.miseqfolder + "SampleSheet.csv"
module function_definition identifier parameters identifier block assert_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier if_statement not_operator attribute identifier identifier block expression_statement assignment identifier call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier subscript call identifier argument_list identifier unary_operator integer expression_statement assignment attribute identifier identifier subscript call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end unary_operator integer else_clause block expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier binary_operator binary_operator attribute identifier identifier attribute identifier identifier string string_start string_content string_end assert_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier call attribute string string_start string_content string_end line_continuation identifier argument_list attribute identifier identifier if_statement attribute identifier identifier block expression_statement assignment attribute identifier identifier attribute identifier identifier assert_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier call attribute string string_start string_content string_end line_continuation identifier argument_list attribute identifier identifier else_clause block expression_statement assignment attribute identifier identifier binary_operator attribute identifier identifier string string_start string_content string_end
Assertions to make sure that arguments are at least mostly valid
def callback_checkbox(attr, old, new): import numpy for i in range(len(lines)): lines[i].visible = i in param_checkbox.active scats[i].visible = i in param_checkbox.active return None
module function_definition identifier parameters identifier identifier identifier block import_statement dotted_name identifier for_statement identifier call identifier argument_list call identifier argument_list identifier block expression_statement assignment attribute subscript identifier identifier identifier comparison_operator identifier attribute identifier identifier expression_statement assignment attribute subscript identifier identifier identifier comparison_operator identifier attribute identifier identifier return_statement none
Update visible data from parameters selectin in the CheckboxSelect
def value(self): value = getattr(self.instrument, self.probe_name) self.buffer.append(value) return value
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement identifier
reads the value from the instrument
def local_regon_checksum(digits): weights_for_check_digit = [2, 4, 8, 5, 0, 9, 7, 3, 6, 1, 2, 4, 8] check_digit = 0 for i in range(0, 13): check_digit += weights_for_check_digit[i] * digits[i] check_digit %= 11 if check_digit == 10: check_digit = 0 return check_digit
module function_definition identifier parameters identifier block expression_statement assignment identifier list integer integer integer integer integer integer integer integer integer integer integer integer integer expression_statement assignment identifier integer for_statement identifier call identifier argument_list integer integer block expression_statement augmented_assignment identifier binary_operator subscript identifier identifier subscript identifier identifier expression_statement augmented_assignment identifier integer if_statement comparison_operator identifier integer block expression_statement assignment identifier integer return_statement identifier
Calculates and returns a control digit for given list of digits basing on local REGON standard.
def protoFast(): r, x = blind(m) y,kw,tTilde = eval(w,t,x,msk,s) z = deblind(r, y)
module function_definition identifier parameters block expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier expression_statement assignment pattern_list identifier identifier identifier call identifier argument_list identifier identifier identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier
Runs the protocol but omits proof generation and verification.
def _rule2path(cls, rule): typeless = re.sub(r'<\w+?:', '<', rule) return typeless.replace('<', '{').replace('>', '}')
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier return_statement call attribute call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier argument_list string string_start string_content string_end string string_start string_content string_end
Convert relative Flask rule to absolute OpenAPI path.
def umi_below_threshold(umi_quals, quality_encoding, quality_filter_threshold): below_threshold = get_below_threshold( umi_quals, quality_encoding, quality_filter_threshold) return any(below_threshold)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier identifier return_statement call identifier argument_list identifier
return true if any of the umi quals is below the threshold
def __create_safari_driver(self): if not os.getenv(self.__SELENIUM_SERVER_JAR_ENV): try: selenium_server_path = self._config_reader.get( self.SELENIUM_SERVER_LOCATION) self._env_vars[ self.__SELENIUM_SERVER_JAR_ENV] = selenium_server_path except KeyError: raise RuntimeError(u("Missing selenium server path config {0}.").format( self.SELENIUM_SERVER_LOCATION)) return webdriver.Safari()
module function_definition identifier parameters identifier block if_statement not_operator call attribute identifier identifier argument_list attribute identifier identifier block try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment subscript attribute identifier identifier attribute identifier identifier identifier except_clause identifier block raise_statement call identifier argument_list call attribute call identifier argument_list string string_start string_content string_end identifier argument_list attribute identifier identifier return_statement call attribute identifier identifier argument_list
Creates an instance of Safari webdriver.
def read_aldb(self, mem_addr=0x0000, num_recs=0): if self._aldb.version == ALDBVersion.Null: _LOGGER.info('Device %s does not contain an All-Link Database', self._address.human) else: _LOGGER.info('Reading All-Link Database for device %s', self._address.human) asyncio.ensure_future(self._aldb.load(mem_addr, num_recs), loop=self._plm.loop) self._aldb.add_loaded_callback(self._aldb_loaded_callback)
module function_definition identifier parameters identifier default_parameter identifier integer default_parameter identifier integer block if_statement comparison_operator attribute attribute identifier identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute attribute identifier identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier
Read the device All-Link Database.