code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def family_coff(self): if not self._ptr: raise BfdException("BFD not initialized") return _bfd.get_bfd_attribute(self._ptr, BfdAttributes.FAMILY_COFF)
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end return_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier
Return the family_coff attribute of the BFD file being processed.
def folders(self): for directory in self.directory: for path in os.listdir(directory): full_path = os.path.join(directory, path) if os.path.isdir(full_path): if not path.startswith('.'): self.filepaths.append(full_path) return self._get_filepaths()
module function_definition identifier parameters identifier block for_statement identifier attribute identifier identifier block for_statement identifier call attribute identifier identifier argument_list identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier if_statement call attribute attribute identifier identifier identifier argument_list identifier block if_statement not_operator call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list
Return list of folders in root directory
def build_message(self): if self.params is None: inline_params = "" else: inline_params = "" if type(self.params) is list: for x in self.params: if x != self.params[0]: inline_params += ", " if type(x) is int: inline_params += str(x) else: inline_params += '"{}"'.format(x) else: inline_params += '"{}"'.format(self.params) self.message = self.COMMAND_BODY.format(str(self.command_id), self.method, inline_params)
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier string string_start string_end else_clause block expression_statement assignment identifier string string_start string_end if_statement comparison_operator call identifier argument_list attribute identifier identifier identifier block for_statement identifier attribute identifier identifier block if_statement comparison_operator identifier subscript attribute identifier identifier integer block expression_statement augmented_assignment identifier string string_start string_content string_end if_statement comparison_operator call identifier argument_list identifier identifier block expression_statement augmented_assignment identifier call identifier argument_list identifier else_clause block expression_statement augmented_assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier else_clause block expression_statement augmented_assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list call identifier argument_list attribute identifier identifier attribute identifier identifier identifier
Make the one string message sent to the bulb
def reMutualReceptions(self, idA, idB): mr = self.mutualReceptions(idA, idB) filter_ = ['ruler', 'exalt'] return [(a,b) for (a,b) in mr if (a in filter_ and b in filter_)]
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end return_statement list_comprehension tuple identifier identifier for_in_clause tuple_pattern identifier identifier identifier if_clause parenthesized_expression boolean_operator comparison_operator identifier identifier comparison_operator identifier identifier
Returns ruler and exaltation mutual receptions.
def bands(self, telescope): q = self._seen_bands.get(telescope) if q is None: return [] return list(q)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator identifier none block return_statement list return_statement call identifier argument_list identifier
Return a list of bands associated with the specified telescope.
def _cursorLeft(self): if self.cursorPos > 0: self.cursorPos -= 1 sys.stdout.write(console.CURSOR_LEFT) sys.stdout.flush()
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier integer block expression_statement augmented_assignment attribute identifier identifier integer expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list
Handles "cursor left" events
def _weighted_pearson(y, y_pred, w): with np.errstate(divide='ignore', invalid='ignore'): y_pred_demean = y_pred - np.average(y_pred, weights=w) y_demean = y - np.average(y, weights=w) corr = ((np.sum(w * y_pred_demean * y_demean) / np.sum(w)) / np.sqrt((np.sum(w * y_pred_demean ** 2) * np.sum(w * y_demean ** 2)) / (np.sum(w) ** 2))) if np.isfinite(corr): return np.abs(corr) return 0.
module function_definition identifier parameters identifier identifier identifier block with_statement with_clause with_item call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end block expression_statement assignment identifier binary_operator identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier expression_statement assignment identifier binary_operator identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier expression_statement assignment identifier parenthesized_expression binary_operator parenthesized_expression binary_operator call attribute identifier identifier argument_list binary_operator binary_operator identifier identifier identifier call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list binary_operator parenthesized_expression binary_operator call attribute identifier identifier argument_list binary_operator identifier binary_operator identifier integer call attribute identifier identifier argument_list binary_operator identifier binary_operator identifier integer parenthesized_expression binary_operator call attribute identifier identifier argument_list identifier integer if_statement call attribute identifier identifier argument_list identifier block return_statement call attribute identifier identifier argument_list identifier return_statement float
Calculate the weighted Pearson correlation coefficient.
def _safe_issue_checkout(repo, issue=None): branch_name = str(issue) if issue else 'master' if branch_name not in repo.heads: branch = repo.create_head(branch_name) else: branch = repo.heads[branch_name] branch.checkout()
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier conditional_expression call identifier argument_list identifier identifier string string_start string_content string_end if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment identifier subscript attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list
Safely checkout branch for the issue.
def _save_potentials(self, directory): print('saving potentials') digits = int(np.ceil(np.log10(self.configs.configs.shape[0]))) for i in range(0, self.configs.configs.shape[0]): pot_data = self.get_potential(i) filename_raw = 'pot{0:0' + '{0}'.format(digits) + '}.dat' filename = directory + os.sep + filename_raw.format(i + 1) nodes = self.grid.nodes['sorted'][:, 1:3] all_data = np.hstack(( nodes, pot_data[0][:, np.newaxis], pot_data[1][:, np.newaxis], )) with open(filename, 'wb') as fid: np.savetxt(fid, all_data)
module function_definition identifier parameters identifier identifier block expression_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list subscript attribute attribute attribute identifier identifier identifier identifier integer for_statement identifier call identifier argument_list integer subscript attribute attribute attribute identifier identifier identifier identifier integer block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator binary_operator string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier binary_operator binary_operator identifier attribute identifier identifier call attribute identifier identifier argument_list binary_operator identifier integer expression_statement assignment identifier subscript subscript attribute attribute identifier identifier identifier string string_start string_content string_end slice slice integer integer expression_statement assignment identifier call attribute identifier identifier argument_list tuple identifier subscript subscript identifier integer slice attribute identifier identifier subscript subscript identifier integer slice attribute 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 expression_statement call attribute identifier identifier argument_list identifier identifier
save potentials to a directory
def dnld_gaf(species_txt, prt=sys.stdout, loading_bar=True): return dnld_gafs([species_txt], prt, loading_bar)[0]
module function_definition identifier parameters identifier default_parameter identifier attribute identifier identifier default_parameter identifier true block return_statement subscript call identifier argument_list list identifier identifier identifier integer
Download GAF file if necessary.
def DefaultSelector(sock): "Return the best selector for the platform" global _DEFAULT_SELECTOR if _DEFAULT_SELECTOR is None: if has_selector('poll'): _DEFAULT_SELECTOR = PollSelector elif hasattr(select, 'select'): _DEFAULT_SELECTOR = SelectSelector else: raise RedisError('Platform does not support any selectors') return _DEFAULT_SELECTOR(sock)
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end global_statement identifier if_statement comparison_operator identifier none block if_statement call identifier argument_list string string_start string_content string_end block expression_statement assignment identifier identifier elif_clause call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier identifier else_clause block raise_statement call identifier argument_list string string_start string_content string_end return_statement call identifier argument_list identifier
Return the best selector for the platform
async def publish(self, message): try: self.write('data: {}\n\n'.format(message)) await self.flush() except StreamClosedError: self.finished = True
module function_definition identifier parameters identifier identifier block try_statement block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content escape_sequence escape_sequence string_end identifier argument_list identifier expression_statement await call attribute identifier identifier argument_list except_clause identifier block expression_statement assignment attribute identifier identifier true
Pushes data to a listener.
def _generate_struct_properties(self, fields): for field in fields: doc = self.process_doc(field.doc, self._docf) if field.doc else undocumented self.emit_wrapped_text( self.process_doc(doc, self._docf), prefix=comment_prefix) self.emit(fmt_property(field=field)) self.emit()
module function_definition identifier parameters identifier identifier block for_statement identifier identifier block expression_statement assignment identifier conditional_expression call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier attribute identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list
Emits struct instance properties from the given fields.
def _get_schema_for_field(self, obj, field): mapping = self._get_default_mapping(obj) if hasattr(field, '_jsonschema_type_mapping'): schema = field._jsonschema_type_mapping() elif '_jsonschema_type_mapping' in field.metadata: schema = field.metadata['_jsonschema_type_mapping'] elif field.__class__ in mapping: pytype = mapping[field.__class__] if isinstance(pytype, basestring): schema = getattr(self, pytype)(obj, field) else: schema = self._from_python_type( obj, field, pytype ) else: raise ValueError('unsupported field type %s' % field) for validator in field.validators: if validator.__class__ in FIELD_VALIDATORS: schema = FIELD_VALIDATORS[validator.__class__]( schema, field, validator, obj ) return schema
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list elif_clause comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end elif_clause comparison_operator attribute identifier identifier identifier block expression_statement assignment identifier subscript identifier attribute identifier identifier if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call call identifier argument_list identifier identifier argument_list identifier identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier else_clause block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier for_statement identifier attribute identifier identifier block if_statement comparison_operator attribute identifier identifier identifier block expression_statement assignment identifier call subscript identifier attribute identifier identifier argument_list identifier identifier identifier identifier return_statement identifier
Get schema and validators for field.
def generate_identity(self): identity = struct.pack('!BI', 0, self._base_identity) self._base_identity += 1 if self._base_identity >= 2 ** 32: self._base_identity = 0 return identity
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end integer attribute identifier identifier expression_statement augmented_assignment attribute identifier identifier integer if_statement comparison_operator attribute identifier identifier binary_operator integer integer block expression_statement assignment attribute identifier identifier integer return_statement identifier
Generate a unique but random identity.
def pull_byte(self, stack_pointer): addr = stack_pointer.value byte = self.memory.read_byte(addr) stack_pointer.increment(1) return byte
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 identifier expression_statement call attribute identifier identifier argument_list integer return_statement identifier
pulled a byte from stack
def unwrap(self): pixels = [[[int(c) for c in p] for p in l] for l in self.pixels_array] return self.GLFWimage(self.width, self.height, pixels)
module function_definition identifier parameters identifier block expression_statement assignment identifier list_comprehension list_comprehension list_comprehension call identifier argument_list identifier for_in_clause identifier identifier for_in_clause identifier identifier for_in_clause identifier attribute identifier identifier return_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier identifier
Returns a GLFWimage object.
def start_tag(self, indent): return u"%s<%s%s/>" % (indent, self.tagName, u"".join(u" %s=\"%s\"" % keyvalue for keyvalue in self.attributes.items()))
module function_definition identifier parameters identifier identifier block return_statement binary_operator string string_start string_content string_end tuple identifier attribute identifier identifier call attribute string string_start string_end identifier generator_expression binary_operator string string_start string_content escape_sequence escape_sequence string_end identifier for_in_clause identifier call attribute attribute identifier identifier identifier argument_list
Generate the string for the element's start tag.
def needs_distribute_ready(self): alive = [c for c in self.connections() if c.alive()] if any(c.ready <= (c.last_ready_sent * 0.25) for c in alive): return True
module function_definition identifier parameters identifier block expression_statement assignment identifier list_comprehension identifier for_in_clause identifier call attribute identifier identifier argument_list if_clause call attribute identifier identifier argument_list if_statement call identifier generator_expression comparison_operator attribute identifier identifier parenthesized_expression binary_operator attribute identifier identifier float for_in_clause identifier identifier block return_statement true
Determine whether or not we need to redistribute the ready state
def cluster_get_keys_in_slots(self, slot, count, *, encoding): return self.execute(b'CLUSTER', b'GETKEYSINSLOT', slot, count, encoding=encoding)
module function_definition identifier parameters identifier identifier identifier keyword_separator identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier identifier keyword_argument identifier identifier
Return local key names in the specified hash slot.
def logger(self, logger): if logger is None or not isinstance(logger, Logger): raise ValueError("Logger can not be set to None, and must be of type logging.Logger") self._logger = logger
module function_definition identifier parameters identifier identifier block if_statement boolean_operator comparison_operator identifier none not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier identifier
Set the logger if is not None, and it is of type Logger.
def send(self, text): if text: self.send_buffer += text.replace('\n', '\r\n') self.send_pending = True
module function_definition identifier parameters identifier identifier block if_statement identifier block expression_statement augmented_assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end string string_start string_content escape_sequence escape_sequence string_end expression_statement assignment attribute identifier identifier true
Send raw text to the distant end.
def load_df_from_file(file_path, sep=",", header=0): with tf.gfile.Open(file_path) as infile: df = pd.read_csv(infile, sep=sep, header=header) return df
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end default_parameter identifier integer block with_statement with_clause with_item as_pattern call attribute attribute identifier identifier identifier argument_list identifier as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier return_statement identifier
Wrapper around pandas' read_csv.
def join_cols(cols): return ", ".join([i for i in cols]) if isinstance(cols, (list, tuple, set)) else cols
module function_definition identifier parameters identifier block return_statement conditional_expression call attribute string string_start string_content string_end identifier argument_list list_comprehension identifier for_in_clause identifier identifier call identifier argument_list identifier tuple identifier identifier identifier identifier
Join list of columns into a string for a SQL query
def broadcast(cls, message): clients = cls.get_clients() for id, client in clients.iteritems(): client.send_message(message)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier
broadcast message to all connected clients
def run(self, evals, feed_dict=None, breakpoints=None, break_immediately=False): if not isinstance(evals,list): evals=[evals] if feed_dict is None: feed_dict={} if breakpoints is None: breakpoints=[] self.state=RUNNING self._original_evals=evals self._original_feed_dict=feed_dict self._exe_order=op_store.compute_exe_order(evals) self._init_evals_bps(evals, breakpoints) for k,v in feed_dict.items(): if not isinstance(k,str): k=k.name self._cache[k]=v op_store.register_dbsession(self) if break_immediately: return self._break() else: return self.c()
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier false block if_statement not_operator call identifier argument_list identifier identifier block expression_statement assignment identifier list identifier if_statement comparison_operator identifier none block expression_statement assignment identifier dictionary if_statement comparison_operator identifier none block expression_statement assignment identifier list expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement not_operator call identifier argument_list identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier if_statement identifier block return_statement call attribute identifier identifier argument_list else_clause block return_statement call attribute identifier identifier argument_list
starts the debug session
def crop_image(img, padding=5): "Crops an image or slice to its extents" if padding < 1: return img beg_coords, end_coords = crop_coords(img, padding) if len(img.shape) == 3: img = crop_3dimage(img, beg_coords, end_coords) elif len(img.shape) == 2: img = crop_2dimage(img, beg_coords, end_coords) else: raise ValueError('Can only crop 2D or 3D images!') return img
module function_definition identifier parameters identifier default_parameter identifier integer block expression_statement string string_start string_content string_end if_statement comparison_operator identifier integer block return_statement identifier expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier identifier if_statement comparison_operator call identifier argument_list attribute identifier identifier integer block expression_statement assignment identifier call identifier argument_list identifier identifier identifier elif_clause comparison_operator call identifier argument_list attribute identifier identifier integer block expression_statement assignment identifier call identifier argument_list identifier identifier identifier else_clause block raise_statement call identifier argument_list string string_start string_content string_end return_statement identifier
Crops an image or slice to its extents
def _get_fido_dollar(self, account_number, number): data = json.dumps({"fidoDollarBalanceFormList": [{"phoneNumber": number, "accountNumber": account_number}]}) headers_json = self._headers.copy() headers_json["Content-Type"] = "application/json;charset=UTF-8" try: raw_res = yield from self._session.post(FIDO_DOLLAR_URL, data=data, headers=headers_json, timeout=self._timeout) except OSError: raise PyFidoError("Can not get fido dollar") try: json_content = yield from raw_res.json() fido_dollar_str = json_content\ .get("fidoDollarBalanceInfoList", [{}])[0]\ .get("fidoDollarBalance") except (OSError, ValueError): raise PyFidoError("Can not get fido dollar as json") if fido_dollar_str is None: raise PyFidoError("Can not get fido dollar") try: fido_dollar = float(fido_dollar_str) except ValueError: raise PyFidoError("Can not get fido dollar") return fido_dollar
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end list dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end try_statement block expression_statement assignment identifier yield call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier except_clause identifier block raise_statement call identifier argument_list string string_start string_content string_end try_statement block expression_statement assignment identifier yield call attribute identifier identifier argument_list expression_statement assignment identifier call attribute subscript call attribute identifier line_continuation identifier argument_list string string_start string_content string_end list dictionary integer line_continuation identifier argument_list string string_start string_content string_end except_clause tuple identifier identifier block raise_statement call 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 try_statement block expression_statement assignment identifier call identifier argument_list identifier except_clause identifier block raise_statement call identifier argument_list string string_start string_content string_end return_statement identifier
Get current Fido dollar balance.
def denormalize_bboxes(bboxes, rows, cols): return [denormalize_bbox(bbox, rows, cols) for bbox in bboxes]
module function_definition identifier parameters identifier identifier identifier block return_statement list_comprehension call identifier argument_list identifier identifier identifier for_in_clause identifier identifier
Denormalize a list of bounding boxes.
def key_pair_from_ed25519_key(hex_private_key): priv_key = crypto.Ed25519SigningKey(bytes.fromhex(hex_private_key)[:32], encoding='bytes') public_key = priv_key.get_verifying_key() return CryptoKeypair(private_key=priv_key.encode(encoding='base58').decode('utf-8'), public_key=public_key.encode(encoding='base58').decode('utf-8'))
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list subscript call attribute identifier identifier argument_list identifier slice integer keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list return_statement call identifier argument_list keyword_argument identifier call attribute call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end keyword_argument identifier call attribute call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end
Generate base58 encode public-private key pair from a hex encoded private key
def request_update_of_all_params(self): for group in self.toc.toc: for name in self.toc.toc[group]: complete_name = '%s.%s' % (group, name) self.request_param_update(complete_name)
module function_definition identifier parameters identifier block for_statement identifier attribute attribute identifier identifier identifier block for_statement identifier subscript attribute attribute identifier identifier identifier identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier identifier expression_statement call attribute identifier identifier argument_list identifier
Request an update of all the parameters in the TOC
def load(self): from os import path if path.isfile(self.dbpath): import json with open(self.dbpath) as f: jdb = json.load(f) self.entities = jdb["entities"] self.uuids = jdb["uuids"]
module function_definition identifier parameters identifier block import_from_statement dotted_name identifier dotted_name identifier if_statement call attribute identifier identifier argument_list attribute identifier identifier block import_statement dotted_name identifier with_statement with_clause with_item as_pattern call identifier argument_list attribute identifier identifier as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end
Deserializes the database from disk.
def save(self, *args, **kwargs): old_instance = None if self.pk: old_instance = self.__class__._default_manager.get(pk=self.pk) self.slug = slugify(force_text(self.name), allow_unicode=True) super().save(*args, **kwargs) if old_instance and old_instance.parent != self.parent: self.update_trackers() signals.forum_moved.send(sender=self, previous_parent=old_instance.parent)
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier none if_statement attribute identifier identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list call identifier argument_list attribute identifier identifier keyword_argument identifier true expression_statement call attribute call identifier argument_list identifier argument_list list_splat identifier dictionary_splat identifier if_statement boolean_operator identifier comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier
Saves the forum instance.
def list_repos(owner=None, **kwargs): client = get_repos_api() api_kwargs = {} api_kwargs.update(utils.get_page_kwargs(**kwargs)) repos_list = client.repos_list_with_http_info if owner is not None: api_kwargs["owner"] = owner if hasattr(client, "repos_list0_with_http_info"): repos_list = client.repos_list0_with_http_info else: if hasattr(client, "repos_all_list_with_http_info"): repos_list = client.repos_all_list_with_http_info with catch_raise_api_exception(): res, _, headers = repos_list(**api_kwargs) ratelimits.maybe_rate_limit(client, headers) page_info = PageInfo.from_headers(headers) return [x.to_dict() for x in res], page_info
module function_definition identifier parameters default_parameter identifier none dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier dictionary expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list dictionary_splat identifier expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier none block expression_statement assignment subscript identifier string string_start string_content string_end identifier if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier attribute identifier identifier else_clause block if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier attribute identifier identifier with_statement with_clause with_item call identifier argument_list block expression_statement assignment pattern_list identifier identifier identifier call identifier argument_list dictionary_splat identifier expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement expression_list list_comprehension call attribute identifier identifier argument_list for_in_clause identifier identifier identifier
List repositories in a namespace.
def time_title_header_element(feature, parent): _ = feature, parent header = time_title_header['string_format'] return header.capitalize()
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier expression_list identifier identifier expression_statement assignment identifier subscript identifier string string_start string_content string_end return_statement call attribute identifier identifier argument_list
Retrieve time title header string from definitions.
def _check_constant_value_data(self, data): arrayval = data.flat[0] if np.all(data == arrayval): return arrayval return None
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier integer if_statement call attribute identifier identifier argument_list comparison_operator identifier identifier block return_statement identifier return_statement none
Verify that the HDU's data is a constant value array.
def from_soup(self,soup): if soup is None or soup is '': return None else: author_name = soup.find('em').contents[0].strip() if soup.find('em') else '' author_image = soup.find('img').get('src') if soup.find('img') else '' author_contact = Contact.from_soup(self,soup) return Author(author_name,author_image,author_contact)
module function_definition identifier parameters identifier identifier block if_statement boolean_operator comparison_operator identifier none comparison_operator identifier string string_start string_end block return_statement none else_clause block expression_statement assignment identifier conditional_expression call attribute subscript attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier integer identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end expression_statement assignment identifier conditional_expression call attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier return_statement call identifier argument_list identifier identifier identifier
Factory Pattern. Fetches author data from given soup and builds the object
def root_frame(self, trim_stem=True): root_frame = None frame_stack = [] for frame_tuple in self.frame_records: identifier_stack = frame_tuple[0] time = frame_tuple[1] for stack_depth, frame_identifier in enumerate(identifier_stack): if stack_depth < len(frame_stack): if frame_identifier != frame_stack[stack_depth].identifier: del frame_stack[stack_depth:] if stack_depth >= len(frame_stack): frame = Frame(frame_identifier) frame_stack.append(frame) if stack_depth == 0: assert root_frame is None, ASSERTION_MESSAGE root_frame = frame else: parent = frame_stack[stack_depth-1] parent.add_child(frame) del frame_stack[stack_depth+1:] frame_stack[-1].add_child(SelfTimeFrame(self_time=time)) if root_frame is None: return None if trim_stem: root_frame = self._trim_stem(root_frame) return root_frame
module function_definition identifier parameters identifier default_parameter identifier true block expression_statement assignment identifier none expression_statement assignment identifier list for_statement identifier attribute identifier identifier block expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier subscript identifier integer for_statement pattern_list identifier identifier call identifier argument_list identifier block if_statement comparison_operator identifier call identifier argument_list identifier block if_statement comparison_operator identifier attribute subscript identifier identifier identifier block delete_statement subscript identifier slice identifier if_statement comparison_operator identifier call identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier integer block assert_statement comparison_operator identifier none identifier expression_statement assignment identifier identifier else_clause block expression_statement assignment identifier subscript identifier binary_operator identifier integer expression_statement call attribute identifier identifier argument_list identifier delete_statement subscript identifier slice binary_operator identifier integer expression_statement call attribute subscript identifier unary_operator integer identifier argument_list call identifier argument_list keyword_argument identifier identifier if_statement comparison_operator identifier none block return_statement none if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement identifier
Parses the internal frame records and returns a tree of Frame objects
def match_val_type(vals, vals_bounds, vals_types): vals_new = [] for i, _ in enumerate(vals_types): if vals_types[i] == "discrete_int": vals_new.append(min(vals_bounds[i], key=lambda x: abs(x - vals[i]))) elif vals_types[i] == "range_int": vals_new.append(math.floor(vals[i])) elif vals_types[i] == "range_continuous": vals_new.append(vals[i]) else: return None return vals_new
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier list for_statement pattern_list identifier identifier call identifier argument_list identifier block if_statement comparison_operator subscript identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list call identifier argument_list subscript identifier identifier keyword_argument identifier lambda lambda_parameters identifier call identifier argument_list binary_operator identifier subscript identifier identifier elif_clause comparison_operator subscript identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list subscript identifier identifier elif_clause comparison_operator subscript identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list subscript identifier identifier else_clause block return_statement none return_statement identifier
Update values in the array, to match their corresponding type
def sipprverse_method(self): logging.info('Beginning sipprverse method database downloads') if self.overwrite or not os.path.isdir(os.path.join(self.databasepath, 'genesippr')): self.sipprverse_targets(databasepath=self.databasepath) if self.overwrite or not os.path.isdir(os.path.join(self.databasepath, 'ConFindr')): self.confindr_targets() if self.overwrite or not os.path.isdir(os.path.join(self.databasepath, 'mash')): self.mash(databasepath=self.databasepath)
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end if_statement boolean_operator attribute identifier identifier not_operator call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list attribute identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier if_statement boolean_operator attribute identifier identifier not_operator call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list attribute identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list if_statement boolean_operator attribute identifier identifier not_operator call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list attribute identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier
Reduced subset again. Only sipprverse, MASH, and confindr targets are required
def update(tournament, match, attachment, **params): api.fetch( "PUT", "tournaments/%s/matches/%s/attachments/%s" % (tournament, match, attachment), "match_attachment", **params)
module function_definition identifier parameters identifier identifier identifier dictionary_splat_pattern identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end binary_operator string string_start string_content string_end tuple identifier identifier identifier string string_start string_content string_end dictionary_splat identifier
Update the attributes of a match attachment.
def update_search_letters(self, text): self.letters = text names = [shortcut.name for shortcut in self.shortcuts] results = get_search_scores(text, names, template='<b>{0}</b>') self.normal_text, self.rich_text, self.scores = zip(*results) self.reset()
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement assignment identifier list_comprehension attribute identifier identifier for_in_clause identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier keyword_argument identifier string string_start string_content string_end expression_statement assignment pattern_list attribute identifier identifier attribute identifier identifier attribute identifier identifier call identifier argument_list list_splat identifier expression_statement call attribute identifier identifier argument_list
Update search letters with text input in search box.
def open(self): try: self.device.open() except ConnectTimeoutError as cte: raise ConnectionException(cte.message) self.device.timeout = self.timeout self.device._conn._session.transport.set_keepalive(self.keepalive) if hasattr(self.device, "cu"): del self.device.cu self.device.bind(cu=Config) if self.config_lock: self._lock()
module function_definition identifier parameters identifier block try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list except_clause as_pattern identifier as_pattern_target identifier block raise_statement call identifier argument_list attribute identifier identifier expression_statement assignment attribute attribute identifier identifier identifier attribute identifier identifier expression_statement call attribute attribute attribute attribute attribute identifier identifier identifier identifier identifier identifier argument_list attribute identifier identifier if_statement call identifier argument_list attribute identifier identifier string string_start string_content string_end block delete_statement attribute attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list
Open the connection wit the device.
def ensure_repo_exists(self): if not os.path.isdir(self.cwd): os.makedirs(self.cwd) if not os.path.isdir(os.path.join(self.cwd, ".git")): self.git.init() self.git.config("user.email", "you@example.com") self.git.config("user.name", "Your Name")
module function_definition identifier parameters identifier block if_statement not_operator call attribute attribute identifier identifier identifier argument_list attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier if_statement not_operator call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list attribute identifier identifier string string_start string_content string_end block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end
Create git repo if one does not exist yet
def listPhysicsGroups(self, physics_group_name=""): if not isinstance(physics_group_name, basestring): dbsExceptionHandler('dbsException-invalid-input', 'physics group name given is not valid : %s' % physics_group_name) else: try: physics_group_name = str(physics_group_name) except: dbsExceptionHandler('dbsException-invalid-input', 'physics group name given is not valid : %s' % physics_group_name) conn = self.dbi.connection() try: result = self.pglist.execute(conn, physics_group_name) return result finally: if conn: conn.close()
module function_definition identifier parameters identifier default_parameter identifier string string_start string_end block if_statement not_operator call identifier argument_list identifier identifier block expression_statement call identifier argument_list string string_start string_content string_end binary_operator string string_start string_content string_end identifier else_clause block try_statement block expression_statement assignment identifier call identifier argument_list identifier except_clause block expression_statement call identifier argument_list string string_start string_content string_end binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier return_statement identifier finally_clause block if_statement identifier block expression_statement call attribute identifier identifier argument_list
Returns all physics groups if physics group names are not passed.
def _weighted_spearman(y, y_pred, w): y_pred_ranked = np.apply_along_axis(rankdata, 0, y_pred) y_ranked = np.apply_along_axis(rankdata, 0, y) return _weighted_pearson(y_pred_ranked, y_ranked, w)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier integer identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier integer identifier return_statement call identifier argument_list identifier identifier identifier
Calculate the weighted Spearman correlation coefficient.
def do(to_install): for solver in to_install: print('preparing {0}'.format(solver)) download_archive(sources[solver]) extract_archive(sources[solver][-1], solver) adapt_files(solver) patch_solver(solver) compile_solver(solver)
module function_definition identifier parameters identifier block for_statement identifier identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call identifier argument_list subscript identifier identifier expression_statement call identifier argument_list subscript subscript identifier identifier unary_operator integer identifier expression_statement call identifier argument_list identifier expression_statement call identifier argument_list identifier expression_statement call identifier argument_list identifier
Prepare all solvers specified in the command line.
def _is_missing_tags_strict(self): val = self.missing_tags if val == MissingTags.strict: return True elif val == MissingTags.ignore: return False raise Exception("Unsupported 'missing_tags' value: %s" % repr(val))
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier attribute identifier identifier block return_statement true elif_clause comparison_operator identifier attribute identifier identifier block return_statement false raise_statement call identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier
Return whether missing_tags is set to strict.
def category_names(self): if hasattr(self, '_category_names'): return self._category_names with open(os.path.join(os.path.dirname(__file__), 'category_names.txt'), 'r') as fd: self._category_names = fd.read().splitlines() return self._category_names
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier string string_start string_content string_end block return_statement attribute identifier identifier with_statement with_clause with_item as_pattern call 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 string string_start string_content string_end as_pattern_target identifier block expression_statement assignment attribute identifier identifier call attribute call attribute identifier identifier argument_list identifier argument_list return_statement attribute identifier identifier
Returns category names of 1000 ImageNet classes.
def local_targets(self): for node in self.node: if (node.repo, node.path) == (self.target.repo, self.target.path): yield node
module function_definition identifier parameters identifier block for_statement identifier attribute identifier identifier block if_statement comparison_operator tuple attribute identifier identifier attribute identifier identifier tuple attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier block expression_statement yield identifier
Iterator over the targets defined in this build file.
def WriteRow(stream, values): "Writes one row of comma-separated values to stream." stream.write(','.join([EncodeForCSV(val) for val in values])) stream.write('\n')
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list list_comprehension call identifier argument_list identifier for_in_clause identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end
Writes one row of comma-separated values to stream.
def handle(): try: cli = ZappaCLI() sys.exit(cli.handle()) except SystemExit as e: cli.on_exit() sys.exit(e.code) except KeyboardInterrupt: cli.on_exit() sys.exit(130) except Exception as e: cli.on_exit() click.echo("Oh no! An " + click.style("error occurred", fg='red', bold=True) + "! :(") click.echo("\n==============\n") import traceback traceback.print_exc() click.echo("\n==============\n") shamelessly_promote() sys.exit(-1)
module function_definition identifier parameters block try_statement block expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list attribute identifier identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list integer except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list binary_operator binary_operator string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier true string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence escape_sequence string_end import_statement dotted_name identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence escape_sequence string_end expression_statement call identifier argument_list expression_statement call attribute identifier identifier argument_list unary_operator integer
Main program execution handler.
def fetch(self, R, pk, depth=1): "Request object from API" d, e = self._fetcher.fetch(R, pk, depth) if e: raise e return d
module function_definition identifier parameters identifier identifier identifier default_parameter identifier integer block expression_statement string string_start string_content string_end expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier identifier identifier if_statement identifier block raise_statement identifier return_statement identifier
Request object from API
def process_module(self, yam): for ann in yam.search(("ietf-yang-metadata", "annotation")): self.process_annotation(ann) for ch in yam.i_children[:]: if ch.keyword == "rpc": self.process_rpc(ch) elif ch.keyword == "notification": self.process_notification(ch) else: continue yam.i_children.remove(ch) self.process_children(yam, "//nc:*", 1)
module function_definition identifier parameters identifier identifier block for_statement identifier call attribute identifier identifier argument_list tuple string string_start string_content string_end string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier for_statement identifier subscript attribute identifier identifier slice block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier else_clause block continue_statement expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier string string_start string_content string_end integer
Process data nodes, RPCs and notifications in a single module.
def GetTypeManager(self): dynTypeMgr = None if self.hostSystem: try: dynTypeMgr = self.hostSystem.RetrieveDynamicTypeManager() except vmodl.fault.MethodNotFound as err: pass if not dynTypeMgr: cmdlineTypesMoId = "ha-dynamic-type-manager" dynTypeMgr = vmodl.reflect.DynamicTypeManager(cmdlineTypesMoId, self.stub) return dynTypeMgr
module function_definition identifier parameters identifier block expression_statement assignment identifier none if_statement attribute identifier identifier block try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list except_clause as_pattern attribute attribute identifier identifier identifier as_pattern_target identifier block pass_statement if_statement not_operator identifier 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 attribute identifier identifier return_statement identifier
Get dynamic type manager
def required_args(self): r_args = [] for arg in self.arguments: if not arg.default_value: r_args.append(arg) else: break return r_args
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier attribute identifier identifier block if_statement not_operator attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier else_clause block break_statement return_statement identifier
list of all required arguments
def setEditorData(self, editor, index): text = from_qvariant(index.model().data(index, Qt.DisplayRole), str) editor.setText(text)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list call attribute call attribute identifier identifier argument_list identifier argument_list identifier attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier
Set editor widget's data
def _latex_labels(self, labels): config = self._configuration.get("latex_labels", {}) return [config.get(label, label) for label in labels]
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end dictionary return_statement list_comprehension call attribute identifier identifier argument_list identifier identifier for_in_clause identifier identifier
LaTeX-ify labels based on information provided in the configuration.
def _run_events(self, tag, stage=None): self._run_event_methods(tag, stage) self._run_tests(tag, stage)
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier
Run tests marked with a particular tag and stage
def __update(self, row): expr = self.__table.update().values(row) for key in self.__update_keys: expr = expr.where(getattr(self.__table.c, key) == row[key]) if self.__autoincrement: expr = expr.returning(getattr(self.__table.c, self.__autoincrement)) res = expr.execute() if res.rowcount > 0: if self.__autoincrement: first = next(iter(res)) last_row_id = first[0] return last_row_id return 0 return None
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 identifier for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list comparison_operator call identifier argument_list attribute attribute identifier identifier identifier identifier subscript identifier identifier if_statement attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list attribute attribute identifier identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator attribute identifier identifier integer block if_statement attribute identifier identifier block expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier expression_statement assignment identifier subscript identifier integer return_statement identifier return_statement integer return_statement none
Update rows in table
def dispatch_command(self, command, params=None): try: if command in self.handlers: self.handlers[command](**params) else: logging.warning('Unsupported command: %s: %s', command, params) except Exception as e: logging.warning('Error during command execution', exc_info=sys.exc_info()) raise e
module function_definition identifier parameters identifier identifier default_parameter identifier none block try_statement block if_statement comparison_operator identifier attribute identifier identifier block expression_statement call subscript attribute identifier identifier identifier argument_list dictionary_splat identifier else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier call attribute identifier identifier argument_list raise_statement identifier
Dispatch device commands to the appropriate handler.
def topological(nodes): order, enter, state = deque(), set(nodes), {} def dfs(node): state[node] = GRAY for parent in nodes.get(node, ()): color = state.get(parent, None) if color == GRAY: raise ValueError('cycle') if color == BLACK: continue enter.discard(parent) dfs(parent) order.appendleft(node) state[node] = BLACK while enter: dfs(enter.pop()) return order
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier identifier expression_list call identifier argument_list call identifier argument_list identifier dictionary function_definition identifier parameters identifier block expression_statement assignment subscript identifier identifier identifier for_statement identifier call attribute identifier identifier argument_list identifier tuple block expression_statement assignment identifier call attribute identifier identifier argument_list identifier none if_statement comparison_operator identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier identifier block continue_statement expression_statement call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment subscript identifier identifier identifier while_statement identifier block expression_statement call identifier argument_list call attribute identifier identifier argument_list return_statement identifier
Return nodes in a topological order.
def unmount(self, client): getattr(client, self.unmount_fun)(mount_point=self.path)
module function_definition identifier parameters identifier identifier block expression_statement call call identifier argument_list identifier attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier
Unmounts a backend within Vault
def _to_binpoly(x): if x <= 0: return "0" b = 1 c = [] i = 0 while x > 0: b = (1 << i) if x & b : c.append(i) x ^= b i = i+1 return " + ".join(["x^%i" % y for y in c[::-1]])
module function_definition identifier parameters identifier block if_statement comparison_operator identifier integer block return_statement string string_start string_content string_end expression_statement assignment identifier integer expression_statement assignment identifier list expression_statement assignment identifier integer while_statement comparison_operator identifier integer block expression_statement assignment identifier parenthesized_expression binary_operator integer identifier if_statement binary_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement augmented_assignment identifier identifier expression_statement assignment identifier binary_operator identifier integer return_statement call attribute string string_start string_content string_end identifier argument_list list_comprehension binary_operator string string_start string_content string_end identifier for_in_clause identifier subscript identifier slice unary_operator integer
Convert a Galois Field's number into a nice polynomial
def _apply_xheaders(self, headers: httputil.HTTPHeaders) -> None: ip = headers.get("X-Forwarded-For", self.remote_ip) for ip in (cand.strip() for cand in reversed(ip.split(","))): if ip not in self.trusted_downstream: break ip = headers.get("X-Real-Ip", ip) if netutil.is_valid_ip(ip): self.remote_ip = ip proto_header = headers.get( "X-Scheme", headers.get("X-Forwarded-Proto", self.protocol) ) if proto_header: proto_header = proto_header.split(",")[-1].strip() if proto_header in ("http", "https"): self.protocol = proto_header
module function_definition identifier parameters identifier typed_parameter identifier type attribute identifier identifier type none block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier for_statement identifier generator_expression call attribute identifier identifier argument_list for_in_clause identifier call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end block if_statement comparison_operator identifier attribute identifier identifier block break_statement expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement call attribute identifier identifier argument_list identifier block expression_statement assignment attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier if_statement identifier block expression_statement assignment identifier call attribute subscript call attribute identifier identifier argument_list string string_start string_content string_end unary_operator integer identifier argument_list if_statement comparison_operator identifier tuple string string_start string_content string_end string string_start string_content string_end block expression_statement assignment attribute identifier identifier identifier
Rewrite the ``remote_ip`` and ``protocol`` fields.
def write(self): mask = 0 for pin in self.pins: if pin.mode == OUTPUT: if pin.value == 1: pin_nr = pin.pin_number - self.port_number * 8 mask |= 1 << int(pin_nr) msg = bytearray([DIGITAL_MESSAGE + self.port_number, mask % 128, mask >> 7]) self.board.sp.write(msg)
module function_definition identifier parameters identifier block expression_statement assignment identifier integer for_statement identifier attribute identifier identifier block if_statement comparison_operator attribute identifier identifier identifier block if_statement comparison_operator attribute identifier identifier integer block expression_statement assignment identifier binary_operator attribute identifier identifier binary_operator attribute identifier identifier integer expression_statement augmented_assignment identifier binary_operator integer call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list list binary_operator identifier attribute identifier identifier binary_operator identifier integer binary_operator identifier integer expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier
Set the output pins of the port to the correct state.
def add_data_attribute(self, data_attr): if data_attr.header.attr_type_id is not AttrTypes.DATA: raise DataStreamError("Invalid attribute. A Datastream deals only with DATA attributes") if data_attr.header.attr_name != self.name: raise DataStreamError(f"Data from a different stream '{data_attr.header.attr_name}' cannot be add to this stream") if data_attr.header.non_resident: nonr_header = data_attr.header if self._data_runs is None: self._data_runs = [] if nonr_header.end_vcn > self.cluster_count: self.cluster_count = nonr_header.end_vcn if not nonr_header.start_vcn: self.size = nonr_header.curr_sstream self.alloc_size = nonr_header.alloc_sstream self._data_runs.append((nonr_header.start_vcn, nonr_header.data_runs)) self._data_runs_sorted = False else: self.size = self.alloc_size = data_attr.header.content_len self._pending_processing = None self._content = data_attr.content.content
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute attribute identifier identifier identifier attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator attribute attribute identifier identifier identifier attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content interpolation attribute attribute identifier identifier identifier string_content string_end if_statement attribute attribute identifier identifier identifier block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier list if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier attribute identifier identifier if_statement not_operator attribute identifier identifier block expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list tuple attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier false else_clause block expression_statement assignment attribute identifier identifier assignment attribute identifier identifier attribute attribute identifier identifier identifier expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier attribute attribute identifier identifier identifier
Interprets a DATA attribute and add it to the datastream.
def read_packet(self, timeout=3.0): try: return self.queue.get(timeout=timeout) except Empty: raise InternalTimeoutError("Timeout waiting for packet in AsyncPacketBuffer")
module function_definition identifier parameters identifier default_parameter identifier float block try_statement block return_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier except_clause identifier block raise_statement call identifier argument_list string string_start string_content string_end
read one packet, timeout if one packet is not available in the timeout period
def make_iv(self, pkt): if self.xpn_en: tmp_pn = (self.pn & 0xFFFFFFFF00000000) | (pkt[MACsec].pn & 0xFFFFFFFF) tmp_iv = self.ssci + struct.pack('!Q', tmp_pn) return bytes(bytearray([a ^ b for a, b in zip(bytearray(tmp_iv), bytearray(self.salt))])) else: return self.sci + struct.pack('!I', pkt[MACsec].pn)
module function_definition identifier parameters identifier identifier block if_statement attribute identifier identifier block expression_statement assignment identifier binary_operator parenthesized_expression binary_operator attribute identifier identifier integer parenthesized_expression binary_operator attribute subscript identifier identifier identifier integer expression_statement assignment identifier binary_operator attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement call identifier argument_list call identifier argument_list list_comprehension binary_operator identifier identifier for_in_clause pattern_list identifier identifier call identifier argument_list call identifier argument_list identifier call identifier argument_list attribute identifier identifier else_clause block return_statement binary_operator attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end attribute subscript identifier identifier identifier
generate an IV for the packet
def _ensure_programmer_executable(): updater_executable = shutil.which('lpc21isp', mode=os.F_OK) os.chmod(updater_executable, 0o777)
module function_definition identifier parameters block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier integer
Find the lpc21isp executable and ensure it is executable
def comment_urlview(self): data = self.get_selected_item() comment = data.get('body') or data.get('text') or data.get('url_full') if comment: self.term.open_urlview(comment) else: self.term.flash()
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier boolean_operator boolean_operator call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list
Open the selected comment with the URL viewer
async def pop_log(self): self._check_receive_loop() res = self.log_queue.get() self._check_error(res) return res
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Get one log from the log queue.
def save_account(changes: Changeset, table: LdapObjectClass, database: Database) -> Changeset: d = {} settings = database.settings uid_number = changes.get_value_as_single('uidNumber') if uid_number is None: scheme = settings['NUMBER_SCHEME'] first = settings.get('UID_FIRST', 10000) d['uidNumber'] = Counters.get_and_increment( scheme, "uidNumber", first, lambda n: not _check_exists(database, table, 'uidNumber', n) ) changes = changes.merge(d) return changes
module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier type identifier block expression_statement assignment identifier dictionary expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier none block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end integer expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list identifier string string_start string_content string_end identifier lambda lambda_parameters identifier not_operator call identifier argument_list identifier identifier string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement identifier
Modify a changes to add an automatically generated uidNumber.
def _validate_model(model): if not hasattr(model, "as_search_document"): raise ImproperlyConfigured("'%s' must implement `as_search_document`." % model) if not hasattr(model.objects, "get_search_queryset"): raise ImproperlyConfigured( "'%s.objects must implement `get_search_queryset`." % model )
module function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list identifier string string_start string_content string_end block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier if_statement not_operator call identifier argument_list attribute identifier identifier string string_start string_content string_end block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier
Check that a model configured for an index subclasses the required classes.
def literalize(self): expr = self.demorgan() if isinstance(expr, self.__class__): return expr return expr.literalize()
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement call identifier argument_list identifier attribute identifier identifier block return_statement identifier return_statement call attribute identifier identifier argument_list
Return an expression where NOTs are only occurring as literals.
def reset_default_props(**kwargs): global _DEFAULT_PROPS pcycle = plt.rcParams['axes.prop_cycle'] _DEFAULT_PROPS = { 'color': itertools.cycle(_get_standard_colors(**kwargs)) if len(kwargs) > 0 else itertools.cycle([x['color'] for x in pcycle]), 'marker': itertools.cycle(['o', 'x', '.', '+', '*']), 'linestyle': itertools.cycle(['-', '--', '-.', ':']), }
module function_definition identifier parameters dictionary_splat_pattern identifier block global_statement identifier expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end conditional_expression call attribute identifier identifier argument_list call identifier argument_list dictionary_splat identifier comparison_operator call identifier argument_list identifier integer call attribute identifier identifier argument_list list_comprehension subscript identifier string string_start string_content string_end for_in_clause identifier identifier pair string string_start string_content string_end call attribute identifier identifier argument_list list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end call attribute identifier identifier argument_list list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end
Reset properties to initial cycle point
def timestamp(self, name="<block>"): func = lambda x: x func.__module__ = "" func.__name__ = name self.add_function(func) timestamps = [] self.functions[func].append(timestamps) return _TimeStamperCM(timestamps)
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier lambda lambda_parameters identifier identifier expression_statement assignment attribute identifier identifier string string_start string_end expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier list expression_statement call attribute subscript attribute identifier identifier identifier identifier argument_list identifier return_statement call identifier argument_list identifier
Returns a context manager for timestamping a block of code.
def shutdown_kernel(self): kernel_id = self.get_kernel_id() if kernel_id: delete_url = self.add_token(url_path_join(self.server_url, 'api/kernels/', kernel_id)) delete_req = requests.delete(delete_url) if delete_req.status_code != 204: QMessageBox.warning( self, _("Server error"), _("The Jupyter Notebook server " "failed to shutdown the kernel " "associated with this notebook. " "If you want to shut it down, " "you'll have to close Spyder."))
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list attribute identifier identifier string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator attribute identifier identifier integer block expression_statement call attribute identifier identifier argument_list identifier call identifier argument_list string string_start string_content string_end 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 string string_start string_content string_end string string_start string_content string_end
Shutdown the kernel of the client.
def send_msg(self, chat_id, msg_type, **kwargs): return self.send(chat_id, msg_type, **kwargs)
module function_definition identifier parameters identifier identifier identifier dictionary_splat_pattern identifier block return_statement call attribute identifier identifier argument_list identifier identifier dictionary_splat identifier
deprecated, use `send` instead
def append(self, data): if os.path.exists(self.file_path): return self.write(data, method='a') else: return self.write(data, method='w')
module function_definition identifier parameters identifier identifier block if_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier block return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end else_clause block return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end
Append rows to an existing CSV file.
def nagiosCommandHelp(**kwargs): with open(os.path.join(DIRECTORY, 'document.html')) as document: return document.read()
module function_definition identifier parameters dictionary_splat_pattern identifier block with_statement with_clause with_item as_pattern call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block return_statement call attribute identifier identifier argument_list
Returns command help document when no command is specified
def _setGroupNames(classes, classRename): groups = {} for groupName, glyphList in classes.items(): groupName = classRename.get(groupName, groupName) if len(glyphList) == 1: continue groups[groupName] = glyphList return groups
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement comparison_operator call identifier argument_list identifier integer block continue_statement expression_statement assignment subscript identifier identifier identifier return_statement identifier
Set the final names into the groups.
def parse_from_parent( self, parent, state ): item_iter = parent.findall(self._item_path) return self._parse(item_iter, state)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier return_statement call attribute identifier identifier argument_list identifier identifier
Parse the array data from the provided parent XML element.
def GetInput(self): "Build the INPUT structure for the action" actions = 1 if self.up and self.down: actions = 2 inputs = (INPUT * actions)() vk, scan, flags = self._get_key_info() for inp in inputs: inp.type = INPUT_KEYBOARD inp._.ki.wVk = vk inp._.ki.wScan = scan inp._.ki.dwFlags |= flags if self.up: inputs[-1]._.ki.dwFlags |= KEYEVENTF_KEYUP return inputs
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier integer if_statement boolean_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier integer expression_statement assignment identifier call parenthesized_expression binary_operator identifier identifier argument_list expression_statement assignment pattern_list identifier identifier identifier call attribute identifier identifier argument_list for_statement identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute attribute attribute identifier identifier identifier identifier identifier expression_statement assignment attribute attribute attribute identifier identifier identifier identifier identifier expression_statement augmented_assignment attribute attribute attribute identifier identifier identifier identifier identifier if_statement attribute identifier identifier block expression_statement augmented_assignment attribute attribute attribute subscript identifier unary_operator integer identifier identifier identifier identifier return_statement identifier
Build the INPUT structure for the action
def ctcp(self, target, ctcp_verb, argument=None): atoms = [ctcp_verb] if argument is not None: atoms.append(argument) X_DELIM = '\x01' self.msg(target, X_DELIM + ' '.join(atoms) + X_DELIM, formatted=False)
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none block expression_statement assignment identifier list identifier if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier string string_start string_content escape_sequence string_end expression_statement call attribute identifier identifier argument_list identifier binary_operator binary_operator identifier call attribute string string_start string_content string_end identifier argument_list identifier identifier keyword_argument identifier false
Send a CTCP request to the given target.
def serialize_hdr(self): return struct.pack(self._PACK_HDR_STR, self.auth_type, self.auth_len)
module function_definition identifier parameters identifier block return_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier
Serialization function for common part of authentication section.
def _add_and_commit(self, doc_filepath, author, commit_msg): try: git(self.gitdir, self.gitwd, "add", doc_filepath) git(self.gitdir, self.gitwd, "commit", author=author, message=commit_msg) except Exception as e: if "nothing to commit" in e.message: _LOG.debug('"nothing to commit" found in error response') else: _LOG.exception('"git commit" failed') self.reset_hard() raise
module function_definition identifier parameters identifier identifier identifier identifier block try_statement block expression_statement call identifier argument_list attribute identifier identifier attribute identifier identifier string string_start string_content string_end identifier expression_statement call identifier argument_list attribute identifier identifier attribute identifier identifier string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier except_clause as_pattern identifier as_pattern_target identifier block if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list raise_statement
Low level function used internally when you have an absolute filepath to add and commit
def drag_rectangle_on_map_canvas(self): self.hide() self.rectangle_map_tool.reset() self.canvas.unsetMapTool(self.pan_tool) self.canvas.setMapTool(self.rectangle_map_tool)
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier
Hide the dialog and allow the user to draw a rectangle.
def controller_creatr(filename): if not check(): click.echo(Fore.RED + 'ERROR: Ensure you are in a bast app to run the create:controller command') return path = os.path.abspath('.') + '/controller' if not os.path.exists(path): os.makedirs(path) file_name = str(filename + '.py') if os.path.isfile(path+"/" + file_name): click.echo(Fore.WHITE + Back.RED + "ERROR: Controller file exists") return controller_file = open(os.path.abspath('.') + '/controller/' + file_name, 'w+') compose = "from bast import Controller\n\nclass " + filename + "(Controller):\n pass" controller_file.write(compose) controller_file.close() click.echo(Fore.GREEN + "Controller " + filename + " created successfully")
module function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list block expression_statement call attribute identifier identifier argument_list binary_operator attribute identifier identifier string string_start string_content string_end return_statement expression_statement assignment identifier binary_operator call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list binary_operator identifier string string_start string_content string_end if_statement call attribute attribute identifier identifier identifier argument_list binary_operator binary_operator identifier string string_start string_content string_end identifier block expression_statement call attribute identifier identifier argument_list binary_operator binary_operator attribute identifier identifier attribute identifier identifier string string_start string_content string_end return_statement expression_statement assignment identifier call identifier argument_list binary_operator binary_operator call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier string string_start string_content string_end expression_statement assignment identifier binary_operator binary_operator string string_start string_content escape_sequence escape_sequence string_end identifier string string_start string_content escape_sequence string_end expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list binary_operator binary_operator binary_operator attribute identifier identifier string string_start string_content string_end identifier string string_start string_content string_end
Name of the controller file to be created
def update_fw_local_result(self, os_result=None, dcnm_result=None, dev_result=None): self.update_fw_local_result_str(os_result=os_result, dcnm_result=dcnm_result, dev_result=dev_result)
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none block expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
Retrieve and update the FW result in the dict.
def message(self): template_name = self.template_name() if \ callable(self.template_name) \ else self.template_name return loader.render_to_string( template_name, self.get_context(), request=self.request )
module function_definition identifier parameters identifier block expression_statement assignment identifier conditional_expression call attribute identifier identifier argument_list line_continuation call identifier argument_list attribute identifier identifier line_continuation attribute identifier identifier return_statement call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier
Render the body of the message to a string.
def _patch_distribution_metadata(): for attr in ('write_pkg_file', 'read_pkg_file', 'get_metadata_version'): new_val = getattr(setuptools.dist, attr) setattr(distutils.dist.DistributionMetadata, attr, new_val)
module function_definition identifier parameters block for_statement identifier tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list attribute identifier identifier identifier expression_statement call identifier argument_list attribute attribute identifier identifier identifier identifier identifier
Patch write_pkg_file and read_pkg_file for higher metadata standards
def intel_extractor(url, response): for rintel in rintels: res = re.sub(r'<(script).*?</\1>(?s)', '', response) res = re.sub(r'<[^<]+?>', '', res) matches = rintel[0].findall(res) if matches: for match in matches: verb('Intel', match) bad_intel.add((match, rintel[1], url))
module function_definition identifier parameters identifier identifier block for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end identifier expression_statement assignment identifier call attribute subscript identifier integer identifier argument_list identifier if_statement identifier block for_statement identifier identifier block expression_statement call identifier argument_list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list tuple identifier subscript identifier integer identifier
Extract intel from the response body.
def raise_error( self, exception_type, message ): error_message = '{} at {}'.format(message, repr(self)) raise exception_type(error_message)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier call identifier argument_list identifier raise_statement call identifier argument_list identifier
Raise an exception with the current parser state information and error message.
def decode_aes256_cbc_base64(data, encryption_key): if not data: return b'' else: return decode_aes256( 'cbc', decode_base64(data[1:25]), decode_base64(data[26:]), encryption_key)
module function_definition identifier parameters identifier identifier block if_statement not_operator identifier block return_statement string string_start string_end else_clause block return_statement call identifier argument_list string string_start string_content string_end call identifier argument_list subscript identifier slice integer integer call identifier argument_list subscript identifier slice integer identifier
Decrypts base64 encoded AES-256 CBC bytes.
def add_special(self, name): self.undeclared.discard(name) self.declared.add(name)
module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Register a special name like `loop`.
def walk(self, node): "Walk a parse tree, calling visit for each node." node = self.visit(node) if node is None: return None if isinstance(node, parso.tree.BaseNode): walked = map(self.walk, node.children) node.children = [child for child in walked if child is not None] return node
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block return_statement none if_statement call identifier argument_list identifier attribute attribute identifier identifier identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier list_comprehension identifier for_in_clause identifier identifier if_clause comparison_operator identifier none return_statement identifier
Walk a parse tree, calling visit for each node.
def staff_member_required(request): "Lookup decorator to require the user is a staff member." user = getattr(request, 'user', None) if user is None or not user.is_authenticated: return HttpResponse(status=401) elif not user.is_staff: return HttpResponseForbidden()
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end none if_statement boolean_operator comparison_operator identifier none not_operator attribute identifier identifier block return_statement call identifier argument_list keyword_argument identifier integer elif_clause not_operator attribute identifier identifier block return_statement call identifier argument_list
Lookup decorator to require the user is a staff member.
def getObjectList(IDs, date, pos): objList = [getObject(ID, date, pos) for ID in IDs] return ObjectList(objList)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier list_comprehension call identifier argument_list identifier identifier identifier for_in_clause identifier identifier return_statement call identifier argument_list identifier
Returns a list of objects.
def in_system_path(filename): fn = sdk_normalize(os.path.realpath(filename)) if fn.startswith('/usr/local/'): return False elif fn.startswith('/System/') or fn.startswith('/usr/'): return True else: return False
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier if_statement call attribute identifier identifier argument_list string string_start string_content string_end block return_statement false elif_clause boolean_operator call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end block return_statement true else_clause block return_statement false
Return True if the file is in a system path