code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def flush(self): if self._requests_middleware: self._requests_middleware.flush() if self._trace_log_handler: self._trace_log_handler.flush() if self._exception_telemetry_client: self._exception_telemetry_client.flush()
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list
Flushes the queued up telemetry to the service.
def JSON_NumpyArrayEncoder(obj): if isinstance(obj, np.ndarray): return {'numpyArray': obj.tolist(), 'dtype': obj.dtype.__str__()} elif isinstance(obj, np.generic): return np.asscalar(obj) else: print type(obj) raise TypeError(repr(obj) + " is not JSON serializable")
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier attribute identifier identifier block return_statement dictionary pair string string_start string_content string_end call attribute identifier identifier argument_list pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list elif_clause call identifier argument_list identifier attribute identifier identifier block return_statement call attribute identifier identifier argument_list identifier else_clause block print_statement call identifier argument_list identifier raise_statement call identifier argument_list binary_operator call identifier argument_list identifier string string_start string_content string_end
Define Specialize JSON encoder for numpy array
def count_rows(self, table_name): self.table_must_exist(table_name) query = "SELECT COUNT (*) FROM `%s`" % table_name.lower() self.own_cursor.execute(query) return int(self.own_cursor.fetchone()[0])
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator string string_start string_content string_end call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement call identifier argument_list subscript call attribute attribute identifier identifier identifier argument_list integer
Return the number of entries in a table by counting them.
def norm(x, encoding="latin1"): "Convertir acentos codificados en ISO 8859-1 u otro, a ASCII regular" if not isinstance(x, basestring): x = unicode(x) elif isinstance(x, str): x = x.decode(encoding, 'ignore') return unicodedata.normalize('NFKD', x).encode('ASCII', 'ignore')
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block expression_statement string string_start string_content string_end if_statement not_operator call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier elif_clause call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end return_statement call attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end
Convertir acentos codificados en ISO 8859-1 u otro, a ASCII regular
def patch_text(actions, tree): tree = etree.fromstring(tree) actions = patch.DiffParser().parse(actions) tree = patch_tree(actions, tree) return etree.tounicode(tree)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier identifier return_statement call attribute identifier identifier argument_list identifier
Takes a string with XML and a string with actions
def sh(self, *command, **kwargs): self.log.debug('shell: %s', ' '.join(command)) return subprocess.check_call(' '.join(command), stdout=sys.stdout, stderr=sys.stderr, stdin=sys.stdin, shell=True, **kwargs)
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list identifier return_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier true dictionary_splat identifier
Run a shell command with the given arguments.
def repeat_call(func, retries, *args, **kwargs): retries = max(0, int(retries)) try_num = 0 while True: if try_num == retries: return func(*args, **kwargs) else: try: return func(*args, **kwargs) except Exception as e: if isinstance(e, KeyboardInterrupt): raise e try_num += 1
module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list integer call identifier argument_list identifier expression_statement assignment identifier integer while_statement true block if_statement comparison_operator identifier identifier block return_statement call identifier argument_list list_splat identifier dictionary_splat identifier else_clause block try_statement block return_statement call identifier argument_list list_splat identifier dictionary_splat identifier except_clause as_pattern identifier as_pattern_target identifier block if_statement call identifier argument_list identifier identifier block raise_statement identifier expression_statement augmented_assignment identifier integer
Tries a total of 'retries' times to execute callable before failing.
def get(self, path_tuple): if path_tuple in self.contentcache: metadata = self.contentcache[path_tuple] else: LOGGER.warning('No metadata found for path_tuple ' + str(path_tuple)) metadata = dict( filepath=os.path.sep.join(path_tuple), title=os.path.sep.join(path_tuple) ) return metadata
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier keyword_argument identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier return_statement identifier
Returns metadata dict for path in `path_tuple`.
def _get_free_words(self, blockAllowed, isRead): if blockAllowed: send = self._size - 5 - 4 * self._write_count recv = self._size - 4 - 4 * self._read_count if isRead: return recv // 4 else: return send // 4 else: send = self._size - 3 - 1 * self._read_count - 5 * self._write_count recv = self._size - 3 - 4 * self._read_count if isRead: return min(send, recv // 4) else: return send // 5
module function_definition identifier parameters identifier identifier identifier block if_statement identifier block expression_statement assignment identifier binary_operator binary_operator attribute identifier identifier integer binary_operator integer attribute identifier identifier expression_statement assignment identifier binary_operator binary_operator attribute identifier identifier integer binary_operator integer attribute identifier identifier if_statement identifier block return_statement binary_operator identifier integer else_clause block return_statement binary_operator identifier integer else_clause block expression_statement assignment identifier binary_operator binary_operator binary_operator attribute identifier identifier integer binary_operator integer attribute identifier identifier binary_operator integer attribute identifier identifier expression_statement assignment identifier binary_operator binary_operator attribute identifier identifier integer binary_operator integer attribute identifier identifier if_statement identifier block return_statement call identifier argument_list identifier binary_operator identifier integer else_clause block return_statement binary_operator identifier integer
Return the number of words free in the transmit packet
def _read(self, size): if self.comptype == "tar": return self.__read(size) c = len(self.dbuf) while c < size: buf = self.__read(self.bufsize) if not buf: break try: buf = self.cmp.decompress(buf) except IOError: raise ReadError("invalid compressed data") self.dbuf += buf c += len(buf) buf = self.dbuf[:size] self.dbuf = self.dbuf[size:] return buf
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block return_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier while_statement comparison_operator identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier if_statement not_operator identifier block break_statement try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier except_clause identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement augmented_assignment attribute identifier identifier identifier expression_statement augmented_assignment identifier call identifier argument_list identifier expression_statement assignment identifier subscript attribute identifier identifier slice identifier expression_statement assignment attribute identifier identifier subscript attribute identifier identifier slice identifier return_statement identifier
Return size bytes from the stream.
def _parse_qualimap_globals_inregion(table): out = {} for row in table.find_all("tr"): col, val = [x.text for x in row.find_all("td")] if col == "Mapped reads": out.update(_parse_num_pct("%s (in regions)" % col, val)) return out
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary for_statement identifier call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment pattern_list identifier identifier list_comprehension attribute identifier identifier for_in_clause identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list call identifier argument_list binary_operator string string_start string_content string_end identifier identifier return_statement identifier
Retrieve metrics from the global targeted region table.
def security_warnings(request, PROXY_ALLOWED_HOSTS=()): warnings = [] PROXY_ALLOWED_HOSTS = PROXY_ALLOWED_HOSTS or getattr(settings, 'PROXY_ALLOWED_HOSTS', ()) if PROXY_ALLOWED_HOSTS and '*' in PROXY_ALLOWED_HOSTS: warnings.append(dict(title=_('Insecure setting detected.'), description=_('A wildcard is included in the PROXY_ALLOWED_HOSTS setting.'))) return dict(warnings=warnings)
module function_definition identifier parameters identifier default_parameter identifier tuple block expression_statement assignment identifier list expression_statement assignment identifier boolean_operator identifier call identifier argument_list identifier string string_start string_content string_end tuple if_statement boolean_operator identifier comparison_operator string string_start string_content string_end identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list keyword_argument identifier call identifier argument_list string string_start string_content string_end keyword_argument identifier call identifier argument_list string string_start string_content string_end return_statement call identifier argument_list keyword_argument identifier identifier
Detects insecure settings and reports them to the client-side context.
def _matches(o, pattern): if not len(o) == len(pattern): return False comps = zip(o,pattern) return all(isinstance(obj,kind) for obj,kind in comps)
module function_definition identifier parameters identifier identifier block if_statement not_operator comparison_operator call identifier argument_list identifier call identifier argument_list identifier block return_statement false expression_statement assignment identifier call identifier argument_list identifier identifier return_statement call identifier generator_expression call identifier argument_list identifier identifier for_in_clause pattern_list identifier identifier identifier
Match a pattern of types in a sequence.
def coneSearch(self, center, radius=3*u.arcmin, magnitudelimit=25): self.magnitudelimit = magnitudelimit self.speak('querying GALEX, centered on {} with radius {}'.format(center, radius, magnitudelimit)) coordinatetosearch = '{0.ra.deg} {0.dec.deg}'.format(center) table = astroquery.mast.Catalogs.query_region(coordinates=center, radius=radius, catalog='GALEX') epoch = 2005 self.coordinates = coord.SkyCoord( ra=table['ra'].data*u.deg, dec=table['dec'].data*u.deg, obstime=Time(epoch, format='decimalyear')) self.magnitudes = dict(NUV=table['nuv_mag'].data, FUV=table['fuv_mag'].data) self.magnitude = self.magnitudes['NUV']
module function_definition identifier parameters identifier identifier default_parameter identifier binary_operator integer attribute identifier identifier default_parameter identifier integer block expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier integer expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list keyword_argument identifier binary_operator attribute subscript identifier string string_start string_content string_end identifier attribute identifier identifier keyword_argument identifier binary_operator attribute subscript identifier string string_start string_content string_end identifier attribute identifier identifier keyword_argument identifier call identifier argument_list identifier keyword_argument identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier call identifier argument_list keyword_argument identifier attribute subscript identifier string string_start string_content string_end identifier keyword_argument identifier attribute subscript identifier string string_start string_content string_end identifier expression_statement assignment attribute identifier identifier subscript attribute identifier identifier string string_start string_content string_end
Run a cone search of the GALEX archive
def remove_role(role): def processor(action, argument): ActionRoles.query_by_action(action, argument=argument).filter( ActionRoles.role_id == role.id ).delete(synchronize_session=False) return processor
module function_definition identifier parameters identifier block function_definition identifier parameters identifier identifier block expression_statement call attribute call attribute call attribute identifier identifier argument_list identifier keyword_argument identifier identifier identifier argument_list comparison_operator attribute identifier identifier attribute identifier identifier identifier argument_list keyword_argument identifier false return_statement identifier
Remove a action for a role.
def extract_bad_ami(e): msg = e.response['Error']['Message'] error = e.response['Error']['Code'] e_ami_ids = None if error == 'InvalidAMIID.NotFound': e_ami_ids = [ e_ami_id.strip() for e_ami_id in msg[msg.find("'[") + 2:msg.rfind("]'")].split(',')] log.warning("Image not found %s" % e_ami_ids) elif error == 'InvalidAMIID.Malformed': e_ami_ids = [msg[msg.find('"') + 1:msg.rfind('"')]] log.warning("Image id malformed %s" % e_ami_ids) return e_ami_ids
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier none if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list for_in_clause identifier call attribute subscript identifier slice binary_operator call attribute identifier identifier argument_list string string_start string_content string_end integer call attribute identifier identifier argument_list string string_start string_content string_end identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier list subscript identifier slice binary_operator call attribute identifier identifier argument_list string string_start string_content string_end integer call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier return_statement identifier
Handle various client side errors when describing images
def _set_trainer(self, trainer): if self._stype != 'default' and self._trainer and trainer and self._trainer is not trainer: raise RuntimeError( "Failed to set the trainer for Parameter '%s' because it was already set. " \ "More than one trainers for a %s Parameter is not supported." \ %(self.name, self._stype)) self._trainer = trainer
module function_definition identifier parameters identifier identifier block if_statement boolean_operator boolean_operator boolean_operator comparison_operator attribute identifier identifier string string_start string_content string_end attribute identifier identifier identifier comparison_operator attribute identifier identifier identifier block raise_statement call identifier argument_list binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end line_continuation tuple attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier identifier
Set the trainer this parameter is associated with.
def conf_sets(self): with self._mutex: if not self._conf_sets: self._parse_configuration() return self._conf_sets
module function_definition identifier parameters identifier block with_statement with_clause with_item attribute identifier identifier block if_statement not_operator attribute identifier identifier block expression_statement call attribute identifier identifier argument_list return_statement attribute identifier identifier
The dictionary of configuration sets in this component, if any.
def _parse(self, stream, context, path): objs = [] while True: start = stream.tell() test = stream.read(len(self.find)) stream.seek(start) if test == self.find: break else: subobj = self.subcon._parse(stream, context, path) objs.append(subobj) return objs
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier list while_statement true block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier attribute identifier identifier block break_statement else_clause block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Parse until a given byte string is found.
def load_library_handle(libname, path): if path is None or path in ['None', 'none']: return None try: if os.name == "nt": opj_lib = ctypes.windll.LoadLibrary(path) else: opj_lib = ctypes.CDLL(path) except (TypeError, OSError): msg = 'The {libname} library at {path} could not be loaded.' msg = msg.format(path=path, libname=libname) warnings.warn(msg, UserWarning) opj_lib = None return opj_lib
module function_definition identifier parameters identifier identifier block if_statement boolean_operator comparison_operator identifier none comparison_operator identifier list string string_start string_content string_end string string_start string_content string_end block return_statement none try_statement block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause tuple identifier identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier none return_statement identifier
Load the library, return the ctypes handle.
def _cursor_down(self, value): self._cursor.clearSelection() if self._cursor.atEnd(): self._cursor.insertText('\n') else: self._cursor.movePosition(self._cursor.Down, self._cursor.MoveAnchor, value) self._last_cursor_pos = self._cursor.position()
module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list if_statement call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content escape_sequence string_end else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier identifier expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list
Moves the cursor down by ``value``.
def _unhash(hashed, alphabet): number = 0 len_alphabet = len(alphabet) for character in hashed: position = alphabet.index(character) number *= len_alphabet number += position return number
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier integer expression_statement assignment identifier call identifier argument_list identifier for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement augmented_assignment identifier identifier expression_statement augmented_assignment identifier identifier return_statement identifier
Restores a number tuple from hashed using the given `alphabet` index.
def run(self, command, options, pipe=False, get_stdout=False, memscale=None): cl = self.cl_picard(command, options, memscale=memscale) if pipe: subprocess.Popen(cl) elif get_stdout: p = subprocess.Popen(cl, stdout=subprocess.PIPE) stdout = p.stdout.read() p.wait() p.stdout.close() return stdout else: do.run(cl, "Picard {0}".format(command), None)
module function_definition identifier parameters identifier identifier identifier default_parameter identifier false default_parameter identifier false default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier keyword_argument identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier elif_clause identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list return_statement identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier call attribute string string_start string_content string_end identifier argument_list identifier none
Run a Picard command with the provided option pairs.
def _collect_monitor_metrics(self, conn, tags): for entry in conn.entries: dn = entry.entry_dn.lower() if dn.endswith(self.CONNECTIONS_METRICS_DN): self._handle_connections_entry(entry, tags) elif dn.endswith(self.OPERATIONS_METRICS_DN): self._handle_operations_entry(entry, tags) elif dn.endswith(self.STATISTICS_METRICS_DN): self._handle_statistics_entry(entry, tags) elif dn.endswith(self.THREADS_METRICS_DN): self._handle_threads_entry(entry, tags) elif dn.endswith(self.TIME_METRICS_DN): self._handle_time_entry(entry, tags) elif dn.endswith(self.WAITERS_METRICS_DN): self._handle_waiters_entry(entry, tags)
module function_definition identifier parameters identifier identifier identifier block for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list if_statement call attribute identifier identifier argument_list attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier elif_clause call attribute identifier identifier argument_list attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier elif_clause call attribute identifier identifier argument_list attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier elif_clause call attribute identifier identifier argument_list attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier elif_clause call attribute identifier identifier argument_list attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier elif_clause call attribute identifier identifier argument_list attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier
Collect metrics from the monitor backend
def _reset_timeout(self): if self._timeout: self._timeout.cancel() self._timeout = self.loop.call_later(self.client.timeout, self.transport.close)
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier
Reset timeout for date keep alive.
def level_to_action(level): try: return LEVEL_ACTION_MAP[level] except LookupError: raise d1_common.types.exceptions.InvalidRequest( 0, 'Unknown action level. level="{}"'.format(level) )
module function_definition identifier parameters identifier block try_statement block return_statement subscript identifier identifier except_clause identifier block raise_statement call attribute attribute attribute identifier identifier identifier identifier argument_list integer call attribute string string_start string_content string_end identifier argument_list identifier
Map action level to action name.
def _reset (self): self.entries = [] self.default_entry = None self.disallow_all = False self.allow_all = False self.last_checked = 0 self.sitemap_urls = []
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier list expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier false expression_statement assignment attribute identifier identifier false expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier list
Reset internal flags and entry lists.
def add_to_inventory(self): host = self.db_attrs.pop(A.database.HOST) self.stack.add_host( host, self.groups, self.db_attrs )
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier attribute identifier identifier attribute identifier identifier
Adds db host to stack inventory
def OnChar(self, event): key = event.GetKeyCode() if key < wx.WXK_SPACE or key == wx.WXK_DELETE or key > 255 or \ chr(key) in string.digits: event.Skip()
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement boolean_operator boolean_operator boolean_operator comparison_operator identifier attribute identifier identifier comparison_operator identifier attribute identifier identifier comparison_operator identifier integer line_continuation comparison_operator call identifier argument_list identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list
Eats event if key not in digits
def mark_seen(self): data = self.get_selected_item() if data['is_new']: with self.term.loader('Marking as read'): data['object'].mark_as_read() if not self.term.loader.exception: data['is_new'] = False else: with self.term.loader('Marking as unread'): data['object'].mark_as_unread() if not self.term.loader.exception: data['is_new'] = True
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement subscript identifier string string_start string_content string_end block with_statement with_clause with_item call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list if_statement not_operator attribute attribute attribute identifier identifier identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end false else_clause block with_statement with_clause with_item call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list if_statement not_operator attribute attribute attribute identifier identifier identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end true
Mark the selected message or comment as seen.
def split_diff(old, new): return map(lambda l: l.rstrip(), icdiff.ConsoleDiff(cols=COLUMNS).make_table(old.splitlines(), new.splitlines()))
module function_definition identifier parameters identifier identifier block return_statement call identifier argument_list lambda lambda_parameters identifier call attribute identifier identifier argument_list call attribute call attribute identifier identifier argument_list keyword_argument identifier identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list
Returns a generator yielding the side-by-side diff of `old` and `new`).
def _update_dictionary(self): self._total_words = sum(self._dictionary.values()) self._unique_words = len(self._dictionary.keys()) self._letters = set() for key in self._dictionary: self._letters.update(key)
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier call identifier argument_list for_statement identifier attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Update the word frequency object
def _is_field_serializable(self, field_name): return ( self._meta.get_field(field_name).get_internal_type() in self.SIMPLE_UPDATE_FIELD_TYPES )
module function_definition identifier parameters identifier identifier block return_statement parenthesized_expression comparison_operator call attribute call attribute attribute identifier identifier identifier argument_list identifier identifier argument_list attribute identifier identifier
Return True if the field can be serialized into a JSON doc.
def by_month(self, chamber, year=None, month=None): check_chamber(chamber) now = datetime.datetime.now() year = year or now.year month = month or now.month path = "{chamber}/votes/{year}/{month}.json".format( chamber=chamber, year=year, month=month) return self.fetch(path, parse=lambda r: r['results'])
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none block expression_statement call identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier boolean_operator identifier attribute identifier identifier expression_statement assignment identifier boolean_operator identifier attribute identifier identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier lambda lambda_parameters identifier subscript identifier string string_start string_content string_end
Return votes for a single month, defaulting to the current month.
def restriction(self, lam, mean_field): self.update_H(mean_field, lam) restric = np.array([self.expected(op) - n for op, n in zip(self.oper['Sz+1/2'], self.param['populations'])]) return restric
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list list_comprehension binary_operator call attribute identifier identifier argument_list identifier identifier for_in_clause pattern_list identifier identifier call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end return_statement identifier
Lagrange multiplier in lattice slave spin
def _set_default_resource_names(self): self.ip_config_name = ''.join([ self.running_instance_id, '-ip-config' ]) self.nic_name = ''.join([self.running_instance_id, '-nic']) self.public_ip_name = ''.join([self.running_instance_id, '-public-ip'])
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call attribute string string_start string_end identifier argument_list list attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute string string_start string_end identifier argument_list list attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute string string_start string_end identifier argument_list list attribute identifier identifier string string_start string_content string_end
Generate names for resources based on the running_instance_id.
def _ConvertToCanonicalSqlDict(self, schema, raw_dict, prefix=""): flattened_dict = {} for k, v in iteritems(raw_dict): if isinstance(v, dict): flattened_dict.update( self._ConvertToCanonicalSqlDict( schema, v, prefix="%s%s." % (prefix, k))) else: field_name = prefix + k flattened_dict[field_name] = schema[field_name].convert_fn(v) return flattened_dict
module function_definition identifier parameters identifier identifier identifier default_parameter identifier string string_start string_end block expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier call identifier argument_list identifier block if_statement call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier keyword_argument identifier binary_operator string string_start string_content string_end tuple identifier identifier else_clause block expression_statement assignment identifier binary_operator identifier identifier expression_statement assignment subscript identifier identifier call attribute subscript identifier identifier identifier argument_list identifier return_statement identifier
Converts a dict of RDF values into a SQL-ready form.
def remove_badge(self, kind): self.update(__raw__={ '$pull': { 'badges': {'kind': kind} } }) self.reload() on_badge_removed.send(self, kind=kind) post_save.send(self.__class__, document=self)
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list keyword_argument identifier dictionary pair string string_start string_content string_end dictionary pair string string_start string_content string_end dictionary pair string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier identifier
Perform an atomic removal for a given badge
def ensure_compliance(self): if not self.modules: return try: loaded_modules = self._get_loaded_modules() non_compliant_modules = [] for module in self.modules: if module in loaded_modules: log("Module '%s' is enabled but should not be." % (module), level=INFO) non_compliant_modules.append(module) if len(non_compliant_modules) == 0: return for module in non_compliant_modules: self._disable_module(module) self._restart_apache() except subprocess.CalledProcessError as e: log('Error occurred auditing apache module compliance. ' 'This may have been already reported. ' 'Output is: %s' % e.output, level=ERROR)
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block return_statement try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier list for_statement identifier attribute identifier identifier block if_statement comparison_operator identifier identifier block expression_statement call identifier argument_list binary_operator string string_start string_content string_end parenthesized_expression identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator call identifier argument_list identifier integer block return_statement for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list except_clause as_pattern attribute identifier identifier as_pattern_target identifier block expression_statement call identifier argument_list binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end attribute identifier identifier keyword_argument identifier identifier
Ensures that the modules are not loaded.
def delete(self, monitor_id): if not self._state: raise InvalidState("State was not properly obtained from the app") monitors = self.list() bit = None for monitor in monitors: if monitor_id != monitor['monitor_id']: continue bit = monitor['monitor_id'] if not bit: raise MonitorNotFound("No monitor was found with that term.") url = self.ALERTS_DELETE_URL.format(requestX=self._state[3]) self._log.debug("Deleting alert using: %s" % url) payload = [None, monitor_id] params = json.dumps(payload, separators=(',', ':')) data = {'params': params} response = self._session.post(url, data=data, headers=self.HEADERS) if response.status_code != 200: raise ActionError("Failed to delete by ID: %s" % response.content) return True
module function_definition identifier parameters identifier identifier block if_statement not_operator attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier none for_statement identifier identifier block if_statement comparison_operator identifier subscript identifier string string_start string_content string_end block continue_statement expression_statement assignment identifier subscript identifier string string_start string_content string_end if_statement not_operator identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier subscript attribute identifier identifier integer expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment identifier list none identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier tuple string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier integer block raise_statement call identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier return_statement true
Delete a monitor by ID.
def to_python(self, value, resource): if isinstance(value, dict): d = { self.aliases.get(k, k): self.to_python(v, resource) if isinstance(v, (dict, list)) else v for k, v in six.iteritems(value) } return type(self.class_name, (), d) elif isinstance(value, list): return [self.to_python(x, resource) if isinstance(x, (dict, list)) else x for x in value] else: return value
module function_definition identifier parameters identifier identifier identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier dictionary_comprehension pair call attribute attribute identifier identifier identifier argument_list identifier identifier conditional_expression call attribute identifier identifier argument_list identifier identifier call identifier argument_list identifier tuple identifier identifier identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list identifier return_statement call identifier argument_list attribute identifier identifier tuple identifier elif_clause call identifier argument_list identifier identifier block return_statement list_comprehension conditional_expression call attribute identifier identifier argument_list identifier identifier call identifier argument_list identifier tuple identifier identifier identifier for_in_clause identifier identifier else_clause block return_statement identifier
Dictionary to Python object
def table_convert_geometry(metadata, table_name): from sqlalchemy import Table from ..orm import Geometry table = Table(table_name, metadata, autoload=True) for c in table.columns: if c.name == 'geometry': c.type = Geometry return table
module function_definition identifier parameters identifier identifier block import_from_statement dotted_name identifier dotted_name identifier import_from_statement relative_import import_prefix dotted_name identifier dotted_name identifier expression_statement assignment identifier call identifier argument_list identifier identifier keyword_argument identifier true for_statement identifier attribute identifier identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier identifier return_statement identifier
Get table metadata from the database.
def image2surface(img): if not CAIRO_AVAILABLE: raise Exception("Cairo not available(). image2surface() cannot work.") global g_lock with g_lock: img_io = io.BytesIO() img.save(img_io, format="PNG") img_io.seek(0) return cairo.ImageSurface.create_from_png(img_io)
module function_definition identifier parameters identifier block if_statement not_operator identifier block raise_statement call identifier argument_list string string_start string_content string_end global_statement identifier with_statement with_clause with_item identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list integer return_statement call attribute attribute identifier identifier identifier argument_list identifier
Convert a PIL image into a Cairo surface
def fetch_url(src, dst): if sys.version_info[0] > 2: import urllib.request class URLopener(urllib.request.FancyURLopener): def http_error_default(self, url, fp, errcode, errmsg, headers): sys.stderr.write("ERROR: could not fetch {0}\n".format(url)) sys.exit(-1) else: import urllib class URLopener(urllib.FancyURLopener): def http_error_default(self, url, fp, errcode, errmsg, headers): sys.stderr.write("ERROR: could not fetch {0}\n".format(url)) sys.exit(-1) dirname = os.path.dirname(dst) if dirname != '': if not os.path.isdir(dirname): os.makedirs(dirname) opener = URLopener() opener.retrieve(src, dst)
module function_definition identifier parameters identifier identifier block if_statement comparison_operator subscript attribute identifier identifier integer integer block import_statement dotted_name identifier identifier class_definition identifier argument_list attribute attribute identifier identifier identifier block function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list unary_operator integer else_clause block import_statement dotted_name identifier class_definition identifier argument_list attribute identifier identifier block function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list unary_operator integer expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator identifier string string_start string_end block 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 expression_statement call attribute identifier identifier argument_list identifier identifier
Fetch file from URL src and save it to dst.
def upload_files(self, abspaths, relpaths, remote_objects): for relpath in relpaths: abspath = [p for p in abspaths if p[len(self.file_root):] == relpath][0] cloud_datetime = remote_objects[relpath] if relpath in remote_objects else None local_datetime = datetime.datetime.utcfromtimestamp(os.stat(abspath).st_mtime) if cloud_datetime and local_datetime < cloud_datetime: self.skip_count += 1 if not self.quiet: print("Skipped {0}: not modified.".format(relpath)) continue if relpath in remote_objects: self.update_count += 1 else: self.create_count += 1 self.upload_file(abspath, relpath)
module function_definition identifier parameters identifier identifier identifier identifier block for_statement identifier identifier block expression_statement assignment identifier subscript list_comprehension identifier for_in_clause identifier identifier if_clause comparison_operator subscript identifier slice call identifier argument_list attribute identifier identifier identifier integer expression_statement assignment identifier conditional_expression subscript identifier identifier comparison_operator identifier identifier none expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute call attribute identifier identifier argument_list identifier identifier if_statement boolean_operator identifier comparison_operator identifier identifier block expression_statement augmented_assignment attribute identifier identifier integer if_statement not_operator attribute identifier identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier continue_statement if_statement comparison_operator identifier identifier block expression_statement augmented_assignment attribute identifier identifier integer else_clause block expression_statement augmented_assignment attribute identifier identifier integer expression_statement call attribute identifier identifier argument_list identifier identifier
Determines files to be uploaded and call ``upload_file`` on each.
def run(state, command, args): from ..core import do_run do_run( command=command, args=args, three=state.three, python=state.python, pypi_mirror=state.pypi_mirror )
module function_definition identifier parameters identifier identifier identifier block import_from_statement relative_import import_prefix dotted_name identifier dotted_name identifier expression_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier
Spawns a command installed into the virtualenv.
def write(self, stream): topology = self.createTopology() def write_it(stream): transportOut = TMemoryBuffer() protocolOut = TBinaryProtocol.TBinaryProtocol(transportOut) topology.write(protocolOut) bytes = transportOut.getvalue() stream.write(bytes) if isinstance(stream, six.string_types): with open(stream, 'wb') as f: write_it(f) else: write_it(stream) return topology
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier if_statement call identifier argument_list identifier attribute identifier identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call identifier argument_list identifier else_clause block expression_statement call identifier argument_list identifier return_statement identifier
Writes the topology to a stream or file.
def remove_address(self, fqdn, address): " Remove an address of a domain." for record in self.list_address(fqdn): if record.address == address: record.delete() break
module function_definition identifier parameters identifier identifier identifier block expression_statement string string_start string_content string_end for_statement identifier call attribute identifier identifier argument_list identifier block if_statement comparison_operator attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list break_statement
Remove an address of a domain.
def _gql(cls, query_string, *args, **kwds): from .query import gql return gql('SELECT * FROM %s %s' % (cls._class_name(), query_string), *args, **kwds)
module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block import_from_statement relative_import import_prefix dotted_name identifier dotted_name identifier return_statement call identifier argument_list binary_operator string string_start string_content string_end tuple call attribute identifier identifier argument_list identifier list_splat identifier dictionary_splat identifier
Run a GQL query.
def from_val(val_schema): definition = getattr(val_schema, "definition", val_schema) if isinstance( val_schema, BaseSchema) else val_schema if isinstance(definition, dict): return _dict_to_teleport(definition) if isinstance(definition, list): if len(definition) == 1: return {"Array": from_val(definition[0])} if definition in VAL_PRIMITIVES: return VAL_PRIMITIVES[definition] raise SerializationError( "Serializing %r not (yet) supported." % definition)
module function_definition identifier parameters identifier block expression_statement assignment identifier conditional_expression call identifier argument_list identifier string string_start string_content string_end identifier call identifier argument_list identifier identifier identifier if_statement call identifier argument_list identifier identifier block return_statement call identifier argument_list identifier if_statement call identifier argument_list identifier identifier block if_statement comparison_operator call identifier argument_list identifier integer block return_statement dictionary pair string string_start string_content string_end call identifier argument_list subscript identifier integer if_statement comparison_operator identifier identifier block return_statement subscript identifier identifier raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier
Serialize a val schema to teleport.
def compute_frontier_difficulty(parent_header: BlockHeader, timestamp: int) -> int: validate_gt(timestamp, parent_header.timestamp, title="Header timestamp") offset = parent_header.difficulty // DIFFICULTY_ADJUSTMENT_DENOMINATOR difficulty_minimum = min(parent_header.difficulty, DIFFICULTY_MINIMUM) if timestamp - parent_header.timestamp < FRONTIER_DIFFICULTY_ADJUSTMENT_CUTOFF: base_difficulty = max( parent_header.difficulty + offset, difficulty_minimum, ) else: base_difficulty = max( parent_header.difficulty - offset, difficulty_minimum, ) num_bomb_periods = ( (parent_header.block_number + 1) // BOMB_EXPONENTIAL_PERIOD ) - BOMB_EXPONENTIAL_FREE_PERIODS if num_bomb_periods >= 0: difficulty = max( base_difficulty + 2**num_bomb_periods, DIFFICULTY_MINIMUM, ) else: difficulty = base_difficulty return difficulty
module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type identifier type identifier block expression_statement call identifier argument_list identifier attribute identifier identifier keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier binary_operator attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier identifier if_statement comparison_operator binary_operator identifier attribute identifier identifier identifier block expression_statement assignment identifier call identifier argument_list binary_operator attribute identifier identifier identifier identifier else_clause block expression_statement assignment identifier call identifier argument_list binary_operator attribute identifier identifier identifier identifier expression_statement assignment identifier binary_operator parenthesized_expression binary_operator parenthesized_expression binary_operator attribute identifier identifier integer identifier identifier if_statement comparison_operator identifier integer block expression_statement assignment identifier call identifier argument_list binary_operator identifier binary_operator integer identifier identifier else_clause block expression_statement assignment identifier identifier return_statement identifier
Computes the difficulty for a frontier block based on the parent block.
def detach(self, ids=None, touch=True): if isinstance(ids, orator.orm.model.Model): ids = ids.get_key() if ids is None: ids = [] query = self._new_pivot_query() if not isinstance(ids, list): ids = [ids] if len(ids) > 0: query.where_in(self._other_key, ids) if touch: self.touch_if_touching() results = query.delete() return results
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier true block if_statement call identifier argument_list identifier attribute attribute attribute identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier none block expression_statement assignment identifier list expression_statement assignment identifier call attribute identifier identifier argument_list if_statement not_operator call identifier argument_list identifier identifier block expression_statement assignment identifier list identifier if_statement comparison_operator call identifier argument_list identifier integer block expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list return_statement identifier
Detach models from the relationship.
def export_dashboards(session): logging.info('Starting export') dashboards = session.query(Dashboard) dashboard_ids = [] for dashboard in dashboards: dashboard_ids.append(dashboard.id) data = Dashboard.export_dashboards(dashboard_ids) return data
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier list for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement identifier
Returns all dashboards metadata as a json dump
def cont_r(self, percent=0.9, N=None): if not hasattr(self, 'F'): self.fs_r(N=self.rank) return apply_along_axis(lambda _: _/self.L[:N], 1, apply_along_axis(lambda _: _*self.r, 0, self.F[:, :N]**2))
module function_definition identifier parameters identifier default_parameter identifier float default_parameter identifier none block if_statement not_operator call identifier argument_list identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier return_statement call identifier argument_list lambda lambda_parameters identifier binary_operator identifier subscript attribute identifier identifier slice identifier integer call identifier argument_list lambda lambda_parameters identifier binary_operator identifier attribute identifier identifier integer binary_operator subscript attribute identifier identifier slice slice identifier integer
Return the contribution of each row.
def defined_annotation_keywords(self) -> Set[str]: return ( set(self.annotation_pattern) | set(self.annotation_url) | set(self.annotation_list) )
module function_definition identifier parameters identifier type generic_type identifier type_parameter type identifier block return_statement parenthesized_expression binary_operator binary_operator call identifier argument_list attribute identifier identifier call identifier argument_list attribute identifier identifier call identifier argument_list attribute identifier identifier
Get the set of all keywords defined as annotations in this graph.
def ls_files(client, names, authors, include, exclude, format): records = _filter( client, names=names, authors=authors, include=include, exclude=exclude ) DATASET_FILES_FORMATS[format](client, records)
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call subscript identifier identifier argument_list identifier identifier
List files in dataset.
def OnInsertTabs(self, event): with undo.group(_("Insert table")): self.grid.actions.insert_tabs(self.grid.current_table - 1, 1) self.grid.GetTable().ResetView() self.grid.actions.zoom() event.Skip()
module function_definition identifier parameters identifier identifier block with_statement with_clause with_item call attribute identifier identifier argument_list call identifier argument_list string string_start string_content string_end block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list binary_operator attribute attribute identifier identifier identifier integer integer expression_statement call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list
Insert one table into grid
def _consolidate_inplace(self): def f(): self._data = self._data.consolidate() self._protect_consolidate(f)
module function_definition identifier parameters identifier block function_definition identifier parameters block expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier
Consolidate data in place and return None
def FingerprintFile(self, pathspec, max_filesize=None, request_data=None): request = rdf_client_action.FingerprintRequest(pathspec=pathspec) if max_filesize is not None: request.max_filesize = max_filesize request.AddRequest( fp_type=rdf_client_action.FingerprintTuple.Type.FPT_GENERIC, hashers=[ rdf_client_action.FingerprintTuple.HashType.MD5, rdf_client_action.FingerprintTuple.HashType.SHA1, rdf_client_action.FingerprintTuple.HashType.SHA256 ]) request.AddRequest( fp_type=rdf_client_action.FingerprintTuple.Type.FPT_PE_COFF, hashers=[ rdf_client_action.FingerprintTuple.HashType.MD5, rdf_client_action.FingerprintTuple.HashType.SHA1, rdf_client_action.FingerprintTuple.HashType.SHA256 ]) self.CallClient( self.fingerprint_file_mixin_client_action, request, next_state="ProcessFingerprint", request_data=request_data)
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier if_statement comparison_operator identifier none block expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier attribute attribute attribute identifier identifier identifier identifier keyword_argument identifier list attribute attribute attribute identifier identifier identifier identifier attribute attribute attribute identifier identifier identifier identifier attribute attribute attribute identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier attribute attribute attribute identifier identifier identifier identifier keyword_argument identifier list attribute attribute attribute identifier identifier identifier identifier attribute attribute attribute identifier identifier identifier identifier attribute attribute attribute identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier
Launch a fingerprint client action.
def show_analyzer_status(): ecode = 0 try: image=contexts['anchore_allimages'][imagelist[0]] analyzer_status = contexts['anchore_db'].load_analyzer_manifest(image.meta['imageId']) result = {image.meta['imageId']:{'result':{'header':['Analyzer', 'Status', '*Type', 'LastExec', 'Exitcode', 'Checksum'], 'rows':[]}}} for script in analyzer_status.keys(): adata = analyzer_status[script] nicetime = datetime.datetime.fromtimestamp(adata['timestamp']).strftime('%Y-%m-%d %H:%M:%S') try: row = [script.split('/')[-1], adata['status'], adata['atype'], nicetime, str(adata['returncode']), adata['csum']] result[image.meta['imageId']]['result']['rows'].append(row) except: pass if result: anchore_utils.print_result(config, result) except: anchore_print_err("operation failed") ecode = 1 contexts['anchore_allimages'].clear() sys.exit(ecode)
module function_definition identifier parameters block expression_statement assignment identifier integer try_statement block expression_statement assignment identifier subscript subscript identifier string string_start string_content string_end subscript identifier integer expression_statement assignment identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier dictionary pair subscript attribute identifier identifier string string_start string_content string_end dictionary pair string string_start string_content string_end dictionary pair string string_start string_content string_end 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 string string_start string_content string_end pair string string_start string_content string_end list for_statement identifier call attribute identifier identifier argument_list block expression_statement assignment identifier subscript identifier identifier expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end try_statement block expression_statement assignment identifier list subscript call attribute identifier identifier argument_list string string_start string_content string_end unary_operator integer subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end identifier call identifier argument_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement call attribute subscript subscript subscript identifier subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier argument_list identifier except_clause block pass_statement if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier identifier except_clause block expression_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier integer expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list expression_statement call attribute identifier identifier argument_list identifier
Show analyzer status for specified image
def _set_interactivity(self, interactivity): event_default = 'hover' if interactivity is None: return if isinstance(interactivity, (tuple, list)): self.interactivity = event_default interactive_cols = '\n'.join( '@{0}: ${0}'.format(col) for col in interactivity ) elif isinstance(interactivity, str): self.interactivity = event_default interactive_cols = '@{0}: ${0}'.format(interactivity) elif isinstance(interactivity, dict): self.interactivity = interactivity.get('event', event_default) self.header = interactivity.get('header') interactive_cols = '\n'.join( '@{0}: ${0}'.format(col) for col in interactivity['cols'] ) else: raise ValueError('`interactivity` must be a str, a list of str, ' 'or a dict with a `cols` key') self.styling = '\n'.join([interactive_cols, self.styling])
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier string string_start string_content string_end if_statement comparison_operator identifier none block return_statement if_statement call identifier argument_list identifier tuple identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement assignment identifier call attribute string string_start string_content escape_sequence string_end identifier generator_expression call attribute string string_start string_content string_end identifier argument_list identifier for_in_clause identifier identifier elif_clause call identifier argument_list identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier elif_clause call identifier argument_list identifier identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute string string_start string_content escape_sequence string_end identifier generator_expression call attribute string string_start string_content string_end identifier argument_list identifier for_in_clause identifier subscript identifier string string_start string_content string_end else_clause block raise_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute string string_start string_content escape_sequence string_end identifier argument_list list identifier attribute identifier identifier
Adds interactivity syntax to the styling
def clean(file_, imports): modules_not_imported = compare_modules(file_, imports) re_remove = re.compile("|".join(modules_not_imported)) to_write = [] try: f = open_func(file_, "r+") except OSError: logging.error("Failed on file: {}".format(file_)) raise else: for i in f.readlines(): if re_remove.match(i) is None: to_write.append(i) f.seek(0) f.truncate() for i in to_write: f.write(i) finally: f.close() logging.info("Successfully cleaned up requirements in " + file_)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier list try_statement block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end except_clause identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier raise_statement else_clause block for_statement identifier call attribute identifier identifier argument_list block if_statement comparison_operator call attribute identifier identifier argument_list identifier none block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier finally_clause block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier
Remove modules that aren't imported in project from file.
def _element_to_bson(key, value, check_keys, opts): if not isinstance(key, string_type): raise InvalidDocument("documents must have only string keys, " "key was %r" % (key,)) if check_keys: if key.startswith("$"): raise InvalidDocument("key %r must not start with '$'" % (key,)) if "." in key: raise InvalidDocument("key %r must not contain '.'" % (key,)) name = _make_name(key) return _name_value_to_bson(name, value, check_keys, opts)
module function_definition identifier parameters identifier identifier identifier identifier block if_statement not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end tuple identifier if_statement identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier if_statement comparison_operator string string_start string_content string_end identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier expression_statement assignment identifier call identifier argument_list identifier return_statement call identifier argument_list identifier identifier identifier identifier
Encode a single key, value pair.
def state_cpfs(self) -> List[CPF]: _, cpfs = self.cpfs state_cpfs = [] for cpf in cpfs: name = utils.rename_next_state_fluent(cpf.name) if name in self.state_fluents: state_cpfs.append(cpf) state_cpfs = sorted(state_cpfs, key=lambda cpf: cpf.name) return state_cpfs
module function_definition identifier parameters identifier type generic_type identifier type_parameter type identifier block expression_statement assignment pattern_list identifier identifier attribute identifier identifier expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier lambda lambda_parameters identifier attribute identifier identifier return_statement identifier
Returns list of state-fluent CPFs.
def complete_all_trajectories(self): for index in range(self.batch_size): trajectory = self._trajectories[index] assert trajectory.is_active self._complete_trajectory(trajectory, index)
module function_definition identifier parameters identifier block for_statement identifier call identifier argument_list attribute identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier identifier assert_statement attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier
Essentially same as reset, but we don't have observations.
def com_google_fonts_check_glyf_unused_data(ttFont): try: expected_glyphs = len(ttFont.getGlyphOrder()) actual_glyphs = len(ttFont['glyf'].glyphs) diff = actual_glyphs - expected_glyphs if diff < 0: yield FAIL, Message("unreachable-data", ("Glyf table has unreachable data at the end of " " the table. Expected glyf table length {}" " (from loca table), got length" " {} (difference: {})").format( expected_glyphs, actual_glyphs, diff)) elif not diff: yield PASS, "There is no unused data at the end of the glyf table." else: raise Exception("Bug: fontTools did not raise an expected exception.") except fontTools.ttLib.TTLibError as error: if "not enough 'glyf' table data" in format(error): yield FAIL, Message("missing-data", ("Loca table references data beyond" " the end of the glyf table." " Expected glyf table length {}" " (from loca table).").format(expected_glyphs)) else: raise Exception("Bug: Unexpected fontTools exception.")
module function_definition identifier parameters identifier block try_statement block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list attribute subscript identifier string string_start string_content string_end identifier expression_statement assignment identifier binary_operator identifier identifier if_statement comparison_operator identifier integer block expression_statement yield expression_list identifier call identifier argument_list string string_start string_content string_end call attribute parenthesized_expression 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 identifier argument_list identifier identifier identifier elif_clause not_operator identifier block expression_statement yield expression_list identifier string string_start string_content string_end else_clause block raise_statement call identifier argument_list string string_start string_content string_end except_clause as_pattern attribute attribute identifier identifier identifier as_pattern_target identifier block if_statement comparison_operator string string_start string_content string_end call identifier argument_list identifier block expression_statement yield expression_list identifier call identifier argument_list string string_start string_content string_end call attribute parenthesized_expression 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 identifier argument_list identifier else_clause block raise_statement call identifier argument_list string string_start string_content string_end
Is there any unused data at the end of the glyf table?
def initialize_delete_state_map(self): self.fabric_state_del_map = { fw_const.INIT_STATE_STR: fw_const.OS_IN_NETWORK_STATE, fw_const.OS_IN_NETWORK_DEL_FAIL: fw_const.OS_IN_NETWORK_STATE, fw_const.OS_IN_NETWORK_DEL_SUCCESS: fw_const.INIT_STATE, fw_const.OS_OUT_NETWORK_DEL_FAIL: fw_const.OS_OUT_NETWORK_STATE, fw_const.OS_OUT_NETWORK_DEL_SUCCESS: fw_const.OS_IN_NETWORK_STATE, fw_const.OS_DUMMY_RTR_DEL_FAIL: fw_const.OS_DUMMY_RTR_STATE, fw_const.OS_DUMMY_RTR_DEL_SUCCESS: fw_const.OS_OUT_NETWORK_STATE, fw_const.DCNM_IN_NETWORK_DEL_FAIL: fw_const.DCNM_IN_NETWORK_STATE, fw_const.DCNM_IN_NETWORK_DEL_SUCCESS: fw_const.OS_DUMMY_RTR_STATE, fw_const.DCNM_IN_PART_UPDDEL_FAIL: fw_const.DCNM_IN_PART_UPDATE_STATE, fw_const.DCNM_IN_PART_UPDDEL_SUCCESS: fw_const.DCNM_IN_NETWORK_STATE, fw_const.DCNM_OUT_PART_DEL_FAIL: fw_const.DCNM_OUT_PART_STATE, fw_const.DCNM_OUT_PART_DEL_SUCCESS: fw_const.DCNM_IN_PART_UPDATE_STATE, fw_const.DCNM_OUT_NETWORK_DEL_FAIL: fw_const.DCNM_OUT_NETWORK_STATE, fw_const.DCNM_OUT_NETWORK_DEL_SUCCESS: fw_const.DCNM_OUT_PART_STATE, fw_const.DCNM_OUT_PART_UPDDEL_FAIL: fw_const.DCNM_OUT_PART_UPDATE_STATE, fw_const.DCNM_OUT_PART_UPDDEL_SUCCESS: fw_const.DCNM_OUT_NETWORK_STATE}
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier dictionary pair attribute identifier identifier attribute identifier identifier pair attribute identifier identifier attribute identifier identifier pair attribute identifier identifier attribute identifier identifier pair attribute identifier identifier attribute identifier identifier pair attribute identifier identifier attribute identifier identifier pair attribute identifier identifier attribute identifier identifier pair attribute identifier identifier attribute identifier identifier pair attribute identifier identifier attribute identifier identifier pair attribute identifier identifier attribute identifier identifier pair attribute identifier identifier attribute identifier identifier pair attribute identifier identifier attribute identifier identifier pair attribute identifier identifier attribute identifier identifier pair attribute identifier identifier attribute identifier identifier pair attribute identifier identifier attribute identifier identifier pair attribute identifier identifier attribute identifier identifier pair attribute identifier identifier attribute identifier identifier pair attribute identifier identifier attribute identifier identifier
This is a mapping of delete result message string to state.
def del_fields(self, *names): cls = type(self) self.__class__ = cls for n in names: if isinstance(getattr(cls, n, None), DataField): if n in self._field_values: del self._field_values[n] delattr(cls, n)
module function_definition identifier parameters identifier list_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier for_statement identifier identifier block if_statement call identifier argument_list call identifier argument_list identifier identifier none identifier block if_statement comparison_operator identifier attribute identifier identifier block delete_statement subscript attribute identifier identifier identifier expression_statement call identifier argument_list identifier identifier
Delete data fields from this struct instance
def headers(self): self._headers.update(**{'Accept-Language': self.language}) if self.__token: self._headers.update( **{'Authorization': 'Bearer %s' % self.__token}) return self._headers
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list dictionary_splat dictionary pair string string_start string_content string_end attribute identifier identifier if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list dictionary_splat dictionary pair string string_start string_content string_end binary_operator string string_start string_content string_end attribute identifier identifier return_statement attribute identifier identifier
Provide access to updated headers.
def rec_dict_to_numpy_dict(obj_dict): if type(obj_dict) == dict: return {key: rec_dict_to_numpy_dict(value) if value is not None else None for key, value in obj_dict.items()} elif obj_dict is None: return None else: return np.asarray(obj_dict)
module function_definition identifier parameters identifier block if_statement comparison_operator call identifier argument_list identifier identifier block return_statement dictionary_comprehension pair identifier conditional_expression call identifier argument_list identifier comparison_operator identifier none none for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list elif_clause comparison_operator identifier none block return_statement none else_clause block return_statement call attribute identifier identifier argument_list identifier
Same as dict_to_numpy_dict, but recursive
def gid_exists(gid): try: grp.getgrgid(gid) gid_exists = True except KeyError: gid_exists = False return gid_exists
module function_definition identifier parameters identifier block try_statement block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier true except_clause identifier block expression_statement assignment identifier false return_statement identifier
Check if a gid exists
def query_field_count(limit_num, kind='1'): return TabTag.select().where( TabTag.kind == kind ).order_by( TabTag.count.desc() ).limit(limit_num)
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block return_statement call attribute call attribute call attribute call attribute identifier identifier argument_list identifier argument_list comparison_operator attribute identifier identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier argument_list identifier
Query the posts count of certain category.
def _images(self, sys_output): import re gap_pattern = re.compile('\t|\s{2,}') image_list = [] output_lines = sys_output.split('\n') column_headers = gap_pattern.split(output_lines[0]) for i in range(1,len(output_lines)): columns = gap_pattern.split(output_lines[i]) if len(columns) == len(column_headers): image_details = {} for j in range(len(columns)): image_details[column_headers[j]] = columns[j] image_list.append(image_details) return image_list
module function_definition identifier parameters identifier identifier block import_statement dotted_name identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end expression_statement assignment identifier list expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier integer for_statement identifier call identifier argument_list integer call identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier identifier if_statement comparison_operator call identifier argument_list identifier call identifier argument_list identifier block expression_statement assignment identifier dictionary for_statement identifier call identifier argument_list call identifier argument_list identifier block expression_statement assignment subscript identifier subscript identifier identifier subscript identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
a helper method for parsing docker image output
def yesno(prompt): prompt += " [y/n]" a = "" while a not in ["y", "n"]: a = input(prompt).lower() return a == "y"
module function_definition identifier parameters identifier block expression_statement augmented_assignment identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_end while_statement comparison_operator identifier list string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier call attribute call identifier argument_list identifier identifier argument_list return_statement comparison_operator identifier string string_start string_content string_end
Returns True if user answers 'y'
def div(x, y, context=None): return _apply_function_in_current_context( BigFloat, mpfr.mpfr_div, ( BigFloat._implicit_convert(x), BigFloat._implicit_convert(y), ), context, )
module function_definition identifier parameters identifier identifier default_parameter identifier none block return_statement call identifier argument_list identifier attribute identifier identifier tuple call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier identifier
Return ``x`` divided by ``y``.
def portal(self, portalID=None): if portalID is None: portalID = self.portalSelf.id url = "%s/%s" % (self.root, portalID) return Portal(url=url, securityHandler=self._securityHandler, proxy_url=self._proxy_url, proxy_port=self._proxy_port, initalize=True)
module function_definition identifier parameters identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier binary_operator string string_start string_content string_end tuple attribute identifier identifier identifier return_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier true
returns a specific reference to a portal
def if_body_action(self, text, loc, arg): exshared.setpos(loc, text) if DEBUG > 0: print("IF_BODY:",arg) if DEBUG == 2: self.symtab.display() if DEBUG > 2: return label = self.codegen.label("false{0}".format(self.false_label_number), True, False) self.codegen.jump(self.relexp_code, True, label) self.codegen.newline_label("true{0}".format(self.label_number), True, True) self.label_stack.append(self.false_label_number) self.label_stack.append(self.label_number)
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier if_statement comparison_operator identifier integer block expression_statement call identifier argument_list string string_start string_content string_end identifier if_statement comparison_operator identifier integer block expression_statement call attribute attribute identifier identifier identifier argument_list if_statement comparison_operator identifier integer block return_statement expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier true false expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier true identifier expression_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier true true 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
Code executed after recognising if statement's body
async def repeat(ctx, times: int, content='repeating...'): for i in range(times): await ctx.send(content)
module function_definition identifier parameters identifier typed_parameter identifier type identifier default_parameter identifier string string_start string_content string_end block for_statement identifier call identifier argument_list identifier block expression_statement await call attribute identifier identifier argument_list identifier
Repeats a message multiple times.
def getThirdPartyLibCompilerFlags(self, libs): fmt = PrintingFormat.singleLine() if libs[0] == '--multiline': fmt = PrintingFormat.multiLine() libs = libs[1:] platformDefaults = True if libs[0] == '--nodefaults': platformDefaults = False libs = libs[1:] details = self.getThirdpartyLibs(libs, includePlatformDefaults=platformDefaults) return details.getCompilerFlags(self.getEngineRoot(), fmt)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator subscript identifier integer string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier subscript identifier slice integer expression_statement assignment identifier true if_statement comparison_operator subscript identifier integer string string_start string_content string_end block expression_statement assignment identifier false expression_statement assignment identifier subscript identifier slice integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier
Retrieves the compiler flags for building against the Unreal-bundled versions of the specified third-party libraries
def list_services(): for importer, modname, ispkg in pkgutil.iter_modules(services.__path__): if ispkg is False: importer.find_module(modname).load_module(modname) services_list = list() for s in services.serviceBase.__subclasses__(): services_list.append(s.__name__.lower()) return services_list
module function_definition identifier parameters block for_statement pattern_list identifier identifier identifier call attribute identifier identifier argument_list attribute identifier identifier block if_statement comparison_operator identifier false block expression_statement call attribute call attribute identifier identifier argument_list identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list for_statement identifier call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list return_statement identifier
returns list of available services
def add_slave(self, slave, container_name="widget"): cont = getattr(self, container_name, None) if cont is None: raise AttributeError( 'Container name must be a member of the delegate') cont.add(slave.widget) self.slaves.append(slave) return slave
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list identifier identifier none if_statement comparison_operator identifier none block raise_statement call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement identifier
Add a slave delegate
def line(self, text, style=None, verbosity=None): if style: styled = "<%s>%s</>" % (style, text) else: styled = text self._io.write_line(styled, verbosity)
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none block if_statement identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier identifier else_clause block expression_statement assignment identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier
Write a string as information output.
def register_incoming_conn(self, conn): assert conn, "conn is required" conn.set_outbound_pending_change_callback(self._on_conn_change) self.connections.appendleft(conn) self._set_on_close_cb(conn) self._on_conn_change()
module function_definition identifier parameters identifier identifier block assert_statement identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list
Add incoming connection into the heap.
def clean_out_dir(directory): if not isinstance(directory, path): directory = path(directory) for file_path in directory.files(): file_path.remove() for dir_path in directory.dirs(): dir_path.rmtree()
module function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier for_statement identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list for_statement identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list
Delete all the files and subdirectories in a directory.
def _almost_equal(a, b): threshold = 1e-9 diff = np.abs(a - b) return (diff < threshold)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier float expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator identifier identifier return_statement parenthesized_expression comparison_operator identifier identifier
Check if the two numbers are almost equal
def source(source_id=None, **kwargs): if source_id is not None: kwargs['source_id'] = source_id elif 'id' in kwargs: source_id = kwargs.pop('id') kwargs['source_id'] = source_id if 'releases' in kwargs: kwargs.pop('releases') path = 'releases' else: path = None return Fred().source(path, **kwargs)
module function_definition identifier parameters default_parameter identifier none dictionary_splat_pattern identifier block if_statement comparison_operator identifier none block expression_statement assignment subscript identifier string string_start string_content string_end identifier elif_clause comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end identifier if_statement comparison_operator string string_start string_content string_end identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end else_clause block expression_statement assignment identifier none return_statement call attribute call identifier argument_list identifier argument_list identifier dictionary_splat identifier
Get a source of economic data.
def clear(self, actors=()): if not utils.isSequence(actors): actors = [actors] if len(actors): for a in actors: self.removeActor(a) else: for a in settings.collectable_actors: self.removeActor(a) settings.collectable_actors = [] self.actors = [] for a in self.getActors(): self.renderer.RemoveActor(a) for a in self.getVolumes(): self.renderer.RemoveVolume(a) for s in self.sliders: s.EnabledOff() for b in self.buttons: self.renderer.RemoveActor(b) for w in self.widgets: w.EnabledOff() for c in self.scalarbars: self.renderer.RemoveActor(c)
module function_definition identifier parameters identifier default_parameter identifier tuple block if_statement not_operator call attribute identifier identifier argument_list identifier block expression_statement assignment identifier list identifier if_statement call identifier argument_list identifier block for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier else_clause block for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier list expression_statement assignment attribute identifier identifier list for_statement identifier call attribute identifier identifier argument_list block expression_statement call attribute attribute identifier identifier identifier argument_list identifier for_statement identifier call attribute identifier identifier argument_list block expression_statement call attribute attribute identifier identifier identifier argument_list identifier for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list for_statement identifier attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list for_statement identifier attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Delete specified list of actors, by default delete all.
def _process_req_txt(req): if req.status_code == 404: return '' if req.status_code != 200: raise DapiCommError('Response of the server was {code}'.format(code=req.status_code)) return req.text
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier integer block return_statement string string_start string_end if_statement comparison_operator attribute identifier identifier integer block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier attribute identifier identifier return_statement attribute identifier identifier
Returns a processed request or raises an exception
def initialize_minimum_needs_post_processors(): processors = [] for field in minimum_needs_fields: field_key = field['key'] field_name = field['name'] field_description = field['description'] need_parameter = field['need_parameter'] processor = { 'key': 'post_processor_{key}'.format(key=field_key), 'name': '{field_name} Post Processor'.format( field_name=field_name), 'description': field_description, 'input': { 'population': { 'value': displaced_field, 'type': field_input_type, }, 'amount': { 'type': needs_profile_input_type, 'value': need_parameter.name, } }, 'output': { 'needs': { 'value': field, 'type': function_process, 'function': multiply } } } processors.append(processor) return processors
module function_definition identifier parameters block expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier pair string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end dictionary pair string string_start string_content string_end dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end dictionary pair string string_start string_content string_end dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Generate definitions for minimum needs post processors.
def cli(env, identifier, wait): compute = SoftLayer.HardwareManager(env.client) compute_id = helpers.resolve_id(compute.resolve_ids, identifier, 'hardware') ready = compute.wait_for_ready(compute_id, wait) if ready: env.fout("READY") else: raise exceptions.CLIAbort("Server %s not ready" % compute_id)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end else_clause block raise_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier
Check if a server is ready.
def spawn_missing_master(self): d = defer.succeed(None) if callable(self.on_master_missing_cb): d.addCallback(defer.drop_param, self.on_master_missing_cb) return d
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list none if_statement call identifier argument_list attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier return_statement identifier
Notifies the standalone slave agency that the master agency is missing
def _piped_bamprep_region(data, region, out_file, tmp_dir): if _need_prep(data): prep_params = _get_prep_params(data) _piped_bamprep_region_gatk(data, region, prep_params, out_file, tmp_dir) else: raise ValueError("No realignment specified")
module function_definition identifier parameters identifier identifier identifier identifier block if_statement call identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement call identifier argument_list identifier identifier identifier identifier identifier else_clause block raise_statement call identifier argument_list string string_start string_content string_end
Do work of preparing BAM input file on the selected region.
def clean(all=False, docs=False, dist=False, extra=None): run('find . -type f -name "*.py[co]" -delete') run('find . -type d -name "__pycache__" -delete') patterns = ['build', '*.egg-info/'] if all or docs: patterns.append('doc/build/*') if all or dist: patterns.append('dist') if extra: patterns.append(extra) for pattern in patterns: run('rm -rf {}'.format(pattern))
module function_definition identifier parameters default_parameter identifier false default_parameter identifier false default_parameter identifier false default_parameter identifier none block expression_statement call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end if_statement boolean_operator identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end if_statement boolean_operator identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier for_statement identifier identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier
Clean up build files
def from_file(self, filename): f = open(filename, 'rb') while True: data = f.read(10480) if not data: break self.update(data) f.close()
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end while_statement true block expression_statement assignment identifier call attribute identifier identifier argument_list integer if_statement not_operator identifier block break_statement expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list
Update running digest with content of named file.
def _setsizes(self, cursor=None): if cursor is None: cursor = self._cursor if self._inputsizes: cursor.setinputsizes(self._inputsizes) for column, size in self._outputsizes.items(): if column is None: cursor.setoutputsize(size) else: cursor.setoutputsize(size, column)
module function_definition identifier parameters identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier attribute identifier identifier if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier identifier
Set stored input and output sizes for cursor execution.
def _format_sync_list(self, records): results = {} for attributes in records: if not isinstance(attributes, dict): id, attributes = attributes, {} else: id = list(attributes.keys())[0] attributes = attributes[id] results[id] = attributes return results
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary for_statement identifier identifier block if_statement not_operator call identifier argument_list identifier identifier block expression_statement assignment pattern_list identifier identifier expression_list identifier dictionary else_clause block expression_statement assignment identifier subscript call identifier argument_list call attribute identifier identifier argument_list integer expression_statement assignment identifier subscript identifier identifier expression_statement assignment subscript identifier identifier identifier return_statement identifier
Format the sync list so that it is keyed by ID.
def setup_db(self, couch, dbname): my_db = None self.log.debug('Setting up DB: %s' % dbname) if dbname not in couch: self.log.info("DB doesn't exist so creating DB: %s", dbname) try: my_db = couch.create(dbname) except: self.log.critical("Race condition caught") raise RuntimeError("Race condition caught when creating DB") try: auth_doc = {} auth_doc['_id'] = '_design/auth' auth_doc['language'] = 'javascript' auth_doc['validate_doc_update'] = my_db.save(auth_doc) except: self.log.error('Could not set permissions of %s' % dbname) else: my_db = couch[dbname] return my_db
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier none expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end identifier if_statement comparison_operator identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end raise_statement call identifier argument_list string string_start string_content string_end try_statement block expression_statement assignment identifier dictionary expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list identifier except_clause block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end identifier else_clause block expression_statement assignment identifier subscript identifier identifier return_statement identifier
Setup and configure DB
def _getAllEvents(self, request): home = request.site.root_page return getAllEvents(request, home=home)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier return_statement call identifier argument_list identifier keyword_argument identifier identifier
Return all the events in this site.
def _copy_calibration(self, calibration): for key, item in calibration.__dict__.items(): self.__dict__[key] = item
module function_definition identifier parameters identifier identifier block for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block expression_statement assignment subscript attribute identifier identifier identifier identifier
Copy another ``StereoCalibration`` object's values.
def make_headers(worksheet): headers = {} cell_idx = 0 while cell_idx < worksheet.ncols: cell_type = worksheet.cell_type(0, cell_idx) if cell_type == 1: header = slughifi(worksheet.cell_value(0, cell_idx)) if not header.startswith("_"): headers[cell_idx] = header cell_idx += 1 return headers
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary expression_statement assignment identifier integer while_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list integer identifier if_statement comparison_operator identifier integer block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list integer identifier if_statement not_operator call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment subscript identifier identifier identifier expression_statement augmented_assignment identifier integer return_statement identifier
Make headers from worksheet