code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def start_selection(self, selection_type=SelectionType.CHARACTERS): self.selection_state = SelectionState(self.cursor_position, selection_type)
module function_definition identifier parameters identifier default_parameter identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier identifier
Take the current cursor position as the start of this selection.
def prepare(self, context): if __debug__: log.debug("Assigning thread local request context.") self.local.context = context
module function_definition identifier parameters identifier identifier block if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute attribute identifier identifier identifier identifier
Executed prior to processing a request.
def update(self): cursor = u"█" if self._canvas.unicode_aware else "O" back = u"░" if self._canvas.unicode_aware else "|" try: sb_pos = self._get_pos() sb_pos = min(1, max(0, sb_pos)) sb_pos = max(int(self._height * sb_pos) - 1, 0) except ZeroDivisionError: sb_pos = 0 (colour, attr, bg) = self._palette["scroll"] y = self._canvas.start_line if self._absolute else 0 for dy in range(self._height): self._canvas.print_at(cursor if dy == sb_pos else back, self._x, y + self._y + dy, colour, attr, bg)
module function_definition identifier parameters identifier block expression_statement assignment identifier conditional_expression string string_start string_content string_end attribute attribute identifier identifier identifier string string_start string_content string_end expression_statement assignment identifier conditional_expression string string_start string_content string_end attribute attribute identifier identifier identifier string string_start string_content string_end try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list integer call identifier argument_list integer identifier expression_statement assignment identifier call identifier argument_list binary_operator call identifier argument_list binary_operator attribute identifier identifier identifier integer integer except_clause identifier block expression_statement assignment identifier integer expression_statement assignment tuple_pattern identifier identifier identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier conditional_expression attribute attribute identifier identifier identifier attribute identifier identifier integer for_statement identifier call identifier argument_list attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list conditional_expression identifier comparison_operator identifier identifier identifier attribute identifier identifier binary_operator binary_operator identifier attribute identifier identifier identifier identifier identifier identifier
Draw the scroll bar.
def reset (self): super(HttpUrl, self).reset() self.headers = {} self.auth = None self.ssl_cipher = None self.ssl_cert = None
module function_definition identifier parameters identifier block expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier dictionary expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier none
Initialize HTTP specific variables.
def Field(self, field, Value = None): if Value == None: try: return self.__Bitmap[field] except KeyError: return None elif Value == 1 or Value == 0: self.__Bitmap[field] = Value else: raise ValueError
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement comparison_operator identifier none block try_statement block return_statement subscript attribute identifier identifier identifier except_clause identifier block return_statement none elif_clause boolean_operator comparison_operator identifier integer comparison_operator identifier integer block expression_statement assignment subscript attribute identifier identifier identifier identifier else_clause block raise_statement identifier
Add field to bitmap
def fulltext_delete(self, index, docs=None, queries=None): xml = Document() root = xml.createElement('delete') if docs: for doc in docs: doc_element = xml.createElement('id') text = xml.createTextNode(doc) doc_element.appendChild(text) root.appendChild(doc_element) if queries: for query in queries: query_element = xml.createElement('query') text = xml.createTextNode(query) query_element.appendChild(text) root.appendChild(query_element) xml.appendChild(root) self._request('POST', self.solr_update_path(index), {'Content-Type': 'text/xml'}, xml.toxml().encode('utf-8'))
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement identifier block for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier if_statement identifier block for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list identifier dictionary pair string string_start string_content string_end string string_start string_content string_end call attribute call attribute identifier identifier argument_list identifier argument_list string string_start string_content string_end
Removes documents from the full-text index.
def squawk(self) -> Set[str]: return set(self.data.squawk.ffill().bfill())
module function_definition identifier parameters identifier type generic_type identifier type_parameter type identifier block return_statement call identifier argument_list call attribute call attribute attribute attribute identifier identifier identifier identifier argument_list identifier argument_list
Returns all the unique squawk values in the trajectory.
def _visit_filesystem(self): self.logger.debug("Parsing File System content.") root_partition = self._filesystem.inspect_get_roots()[0] yield from self._root_dirent() for entry in self._filesystem.filesystem_walk(root_partition): yield Dirent( entry['tsk_inode'], self._filesystem.path('/' + entry['tsk_name']), entry['tsk_size'], entry['tsk_type'], True if entry['tsk_flags'] & TSK_ALLOC else False, timestamp(entry['tsk_atime_sec'], entry['tsk_atime_nsec']), timestamp(entry['tsk_mtime_sec'], entry['tsk_mtime_nsec']), timestamp(entry['tsk_ctime_sec'], entry['tsk_ctime_nsec']), timestamp(entry['tsk_crtime_sec'], entry['tsk_crtime_nsec']))
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier subscript call attribute attribute identifier identifier identifier argument_list integer expression_statement yield call attribute identifier identifier argument_list for_statement identifier call attribute attribute identifier identifier identifier argument_list identifier block expression_statement yield call identifier argument_list subscript identifier string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end conditional_expression true binary_operator subscript identifier string string_start string_content string_end identifier false call identifier argument_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end call identifier argument_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end call identifier argument_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end call identifier argument_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end
Walks through the filesystem content.
def echo_attributes(request, config_loader_path=None, template='djangosaml2/echo_attributes.html'): state = StateCache(request.session) conf = get_config(config_loader_path, request) client = Saml2Client(conf, state_cache=state, identity_cache=IdentityCache(request.session)) subject_id = _get_subject_id(request.session) try: identity = client.users.get_identity(subject_id, check_not_on_or_after=False) except AttributeError: return HttpResponse("No active SAML identity found. Are you sure you have logged in via SAML?") return render(request, template, {'attributes': identity[0]})
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier false except_clause identifier block return_statement call identifier argument_list string string_start string_content string_end return_statement call identifier argument_list identifier identifier dictionary pair string string_start string_content string_end subscript identifier integer
Example view that echo the SAML attributes of an user
def showHostDivision(self, headless): scoop.logger.info('Worker d--istribution: ') for worker, number in self.worker_hosts: first_worker = (worker == self.worker_hosts[0][0]) scoop.logger.info(' {0}:\t{1} {2}'.format( worker, number - 1 if first_worker or headless else str(number), "+ origin" if first_worker or headless else "", ) )
module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end for_statement pattern_list identifier identifier attribute identifier identifier block expression_statement assignment identifier parenthesized_expression comparison_operator identifier subscript subscript attribute identifier identifier integer integer 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 conditional_expression binary_operator identifier integer boolean_operator identifier identifier call identifier argument_list identifier conditional_expression string string_start string_content string_end boolean_operator identifier identifier string string_start string_end
Show the worker distribution over the hosts.
def establish_scp_conn(self): ssh_connect_params = self.ssh_ctl_chan._connect_params_dict() self.scp_conn = self.ssh_ctl_chan._build_ssh_client() self.scp_conn.connect(**ssh_connect_params) self.scp_client = scp.SCPClient(self.scp_conn.get_transport())
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list dictionary_splat identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list
Establish the secure copy connection.
def datetime2literal_rnc(d: datetime.datetime, c: Optional[Dict]) -> str: dt = d.isoformat(" ") return _mysql.string_literal(dt, c)
module function_definition identifier parameters typed_parameter identifier type attribute identifier identifier typed_parameter identifier type generic_type identifier type_parameter type identifier type identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement call attribute identifier identifier argument_list identifier identifier
Format a DateTime object as something MySQL will actually accept.
def _asciify_list(data): ret = [] for item in data: if isinstance(item, unicode): item = _remove_accents(item) item = item.encode('utf-8') elif isinstance(item, list): item = _asciify_list(item) elif isinstance(item, dict): item = _asciify_dict(item) ret.append(item) return ret
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end elif_clause 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 identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Ascii-fies list values
def copy_directory(src, dest, force=False): if os.path.exists(dest) and force is True: shutil.rmtree(dest) try: shutil.copytree(src, dest) except OSError as e: if e.errno == errno.ENOTDIR: shutil.copy(src, dest) else: bot.error('Directory not copied. Error: %s' % e) sys.exit(1)
module function_definition identifier parameters identifier identifier default_parameter identifier false block if_statement boolean_operator call attribute attribute identifier identifier identifier argument_list identifier comparison_operator identifier true block expression_statement call attribute identifier identifier argument_list identifier try_statement block expression_statement call attribute identifier identifier argument_list identifier identifier except_clause as_pattern identifier as_pattern_target identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list integer
Copy an entire directory recursively
def supernodes(self, reordered = True): if reordered: return [list(self.snode[self.snptr[k]:self.snptr[k+1]]) for k in range(self.Nsn)] else: return [list(self.__p[self.snode[self.snptr[k]:self.snptr[k+1]]]) for k in range(self.Nsn)]
module function_definition identifier parameters identifier default_parameter identifier true block if_statement identifier block return_statement list_comprehension call identifier argument_list subscript attribute identifier identifier slice subscript attribute identifier identifier identifier subscript attribute identifier identifier binary_operator identifier integer for_in_clause identifier call identifier argument_list attribute identifier identifier else_clause block return_statement list_comprehension call identifier argument_list subscript attribute identifier identifier subscript attribute identifier identifier slice subscript attribute identifier identifier identifier subscript attribute identifier identifier binary_operator identifier integer for_in_clause identifier call identifier argument_list attribute identifier identifier
Returns a list of supernode sets
def _disallow_state(self, state): disallow_methods = (self._is_duplicate_board, self._is_impossible_by_count) for disallow_method in disallow_methods: if disallow_method(state): return True return False
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier tuple attribute identifier identifier attribute identifier identifier for_statement identifier identifier block if_statement call identifier argument_list identifier block return_statement true return_statement false
Disallow states that are not useful to continue simulating.
def find_atomics(formula: Formula) -> Set[PLAtomic]: f = formula res = set() if isinstance(formula, PLFormula): res = formula.find_atomics() else: res.add(f) return res
module function_definition identifier parameters typed_parameter identifier type identifier type generic_type identifier type_parameter type identifier block expression_statement assignment identifier identifier expression_statement assignment identifier call identifier argument_list if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list else_clause block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Finds all the atomic formulas
def ae_core_density(self): mesh, values, attrib = self._parse_radfunc("ae_core_density") return RadialFunction(mesh, values)
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement call identifier argument_list identifier identifier
The all-electron radial density.
def auto_start_vm(self): if self.enable: try: yield from self.start() except GNS3VMError as e: try: yield from self._controller.add_compute(compute_id="vm", name="GNS3 VM ({})".format(self.current_engine().vmname), host=None, force=True) except aiohttp.web.HTTPConflict: pass log.error("Can't start the GNS3 VM: %s", str(e))
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block try_statement block expression_statement yield call attribute identifier identifier argument_list except_clause as_pattern identifier as_pattern_target identifier block try_statement block expression_statement yield call attribute attribute identifier identifier identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier call attribute string string_start string_content string_end identifier argument_list attribute call attribute identifier identifier argument_list identifier keyword_argument identifier none keyword_argument identifier true except_clause attribute attribute identifier identifier identifier block pass_statement expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list identifier
Auto start the GNS3 VM if require
def organization_inspect_template_path(cls, organization, inspect_template): return google.api_core.path_template.expand( "organizations/{organization}/inspectTemplates/{inspect_template}", organization=organization, inspect_template=inspect_template, )
module function_definition identifier parameters identifier identifier identifier block return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier
Return a fully-qualified organization_inspect_template string.
async def on_raw(self, message): self.logger.debug('<< %s', message._raw) if not message._valid: self.logger.warning('Encountered strictly invalid IRC message from server: %s', message._raw) if isinstance(message.command, int): cmd = str(message.command).zfill(3) else: cmd = message.command method = 'on_raw_' + cmd.lower() try: self._handler_top_level = True handler = getattr(self, method) self._handler_top_level = False await handler(message) except: self.logger.exception('Failed to execute %s handler.', method)
module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end attribute identifier identifier if_statement not_operator attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end attribute identifier identifier if_statement call identifier argument_list attribute identifier identifier identifier block expression_statement assignment identifier call attribute call identifier argument_list attribute identifier identifier identifier argument_list integer else_clause block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier binary_operator string string_start string_content string_end call attribute identifier identifier argument_list try_statement block expression_statement assignment attribute identifier identifier true expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment attribute identifier identifier false expression_statement await call identifier argument_list identifier except_clause block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier
Handle a single message.
def real(self): return matrix(self.tt.real(), n=self.n, m=self.m)
module function_definition identifier parameters identifier block return_statement call identifier argument_list call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier
Return real part of a matrix.
def _extrapolation(self, extrapolate): modes = ['extrapolate', 'raise', 'const', 'border'] if extrapolate not in modes: msg = 'invalid extrapolation mode {}'.format(extrapolate) raise ValueError(msg) if extrapolate == 'raise': self.bounds_error = True self.extrapolate = False else: self.extrapolate = True self.bounds_error = False self.extrapolate_mode = extrapolate
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end if_statement comparison_operator identifier identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier raise_statement call identifier argument_list identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier true expression_statement assignment attribute identifier identifier false else_clause block expression_statement assignment attribute identifier identifier true expression_statement assignment attribute identifier identifier false expression_statement assignment attribute identifier identifier identifier
Check permited values of extrapolation.
def subclasses(cls): seen = set() queue = set([cls]) while queue: c = queue.pop() seen.add(c) sc = c.__subclasses__() for c in sc: if c not in seen: queue.add(c) seen.remove(cls) return seen
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call identifier argument_list list identifier while_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier identifier block if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Return a set of all Ent subclasses, recursively.
def saveDbf(self, target): if not hasattr(target, "write"): target = os.path.splitext(target)[0] + '.dbf' self.dbf = self.__getFileObj(target) self.__dbfHeader() self.__dbfRecords()
module function_definition identifier parameters identifier identifier block if_statement not_operator call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier binary_operator subscript call attribute attribute identifier identifier identifier argument_list identifier integer string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list
Save a dbf file.
def execute_command(self, request, command, frame): return Response(frame.console.eval(command), mimetype="text/html")
module function_definition identifier parameters identifier identifier identifier identifier block return_statement call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end
Execute a command in a console.
def add_config_path(path): if not os.path.isfile(path): warnings.warn("Config file does not exist: {path}".format(path=path)) return False _base, ext = os.path.splitext(path) if ext and ext[1:] in PARSERS: parser = ext[1:] else: parser = PARSER parser_class = PARSERS[parser] _check_parser(parser_class, parser) if parser != PARSER: msg = ( "Config for {added} parser added, but used {used} parser. " "Set up right parser via env var: " "export LUIGI_CONFIG_PARSER={added}" ) warnings.warn(msg.format(added=parser, used=PARSER)) parser_class.add_config_path(path) return True
module function_definition identifier parameters identifier block if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier return_statement false expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement boolean_operator identifier comparison_operator subscript identifier slice integer identifier block expression_statement assignment identifier subscript identifier slice integer else_clause block expression_statement assignment identifier identifier expression_statement assignment identifier subscript identifier identifier expression_statement call identifier argument_list identifier identifier if_statement comparison_operator identifier identifier block expression_statement assignment identifier 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 expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement true
Select config parser by file extension and add path into parser.
def copy(self, existing_inputs): return PPOPolicyGraph( self.observation_space, self.action_space, self.config, existing_inputs=existing_inputs)
module function_definition identifier parameters identifier identifier block return_statement call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier keyword_argument identifier identifier
Creates a copy of self using existing input placeholders.
def __setup_dfs_data(graph, adj): dfs_data = __get_dfs_data(graph, adj) dfs_data['graph'] = graph dfs_data['adj'] = adj L1, L2 = __low_point_dfs(dfs_data) dfs_data['lowpoint_1_lookup'] = L1 dfs_data['lowpoint_2_lookup'] = L2 edge_weights = __calculate_edge_weights(dfs_data) dfs_data['edge_weights'] = edge_weights return dfs_data
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier return_statement identifier
Sets up the dfs_data object, for consistency.
def resolve_addresses(user, useralias, to, cc, bcc): addresses = {"recipients": []} if to is not None: make_addr_alias_target(to, addresses, "To") elif cc is not None and bcc is not None: make_addr_alias_target([user, useralias], addresses, "To") else: addresses["recipients"].append(user) if cc is not None: make_addr_alias_target(cc, addresses, "Cc") if bcc is not None: make_addr_alias_target(bcc, addresses, "Bcc") return addresses
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end list if_statement comparison_operator identifier none block expression_statement call identifier argument_list identifier identifier string string_start string_content string_end elif_clause boolean_operator comparison_operator identifier none comparison_operator identifier none block expression_statement call identifier argument_list list identifier identifier identifier string string_start string_content string_end else_clause block expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement call identifier argument_list identifier identifier string string_start string_content string_end if_statement comparison_operator identifier none block expression_statement call identifier argument_list identifier identifier string string_start string_content string_end return_statement identifier
Handle the targets addresses, adding aliases when defined
def print_object(self, tobj): if tobj.death: self.stream.write('%-32s ( free ) %-35s\n' % ( trunc(tobj.name, 32, left=1), trunc(tobj.repr, 35))) else: self.stream.write('%-32s 0x%08x %-35s\n' % ( trunc(tobj.name, 32, left=1), tobj.id, trunc(tobj.repr, 35) )) if tobj.trace: self.stream.write(_format_trace(tobj.trace)) for (timestamp, size) in tobj.snapshots: self.stream.write(' %-30s %s\n' % ( pp_timestamp(timestamp), pp(size.size) )) self._print_refs(size.refs, size.size) if tobj.death is not None: self.stream.write(' %-30s finalize\n' % ( pp_timestamp(tobj.death), ))
module function_definition identifier parameters identifier identifier block if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end tuple call identifier argument_list attribute identifier identifier integer keyword_argument identifier integer call identifier argument_list attribute identifier identifier integer else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end tuple call identifier argument_list attribute identifier identifier integer keyword_argument identifier integer attribute identifier identifier call identifier argument_list attribute identifier identifier integer if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list attribute identifier identifier for_statement tuple_pattern identifier identifier attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end tuple call identifier argument_list identifier call identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end tuple call identifier argument_list attribute identifier identifier
Print the gathered information of object `tobj` in human-readable format.
def selection_pos(self): buff = self._vim.current.buffer beg = buff.mark('<') end = buff.mark('>') return beg, end
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute attribute attribute identifier identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement expression_list identifier identifier
Return start and end positions of the visual selection respectively.
def bundles(): for bundle in sorted(bundles_module.bundles.keys()): if bundle.startswith('.'): continue try: ingestions = list( map(text_type, bundles_module.ingestions_for_bundle(bundle)) ) except OSError as e: if e.errno != errno.ENOENT: raise ingestions = [] for timestamp in ingestions or ["<no ingestions>"]: click.echo("%s %s" % (bundle, timestamp))
module function_definition identifier parameters block for_statement identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block continue_statement try_statement block expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier call attribute identifier identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block raise_statement expression_statement assignment identifier list for_statement identifier boolean_operator identifier list string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier
List all of the available data bundles.
def mark_as_required(self): if self not in tf.get_collection(bookkeeper.GraphKeys.MARKED_LOSSES): tf.add_to_collection(bookkeeper.GraphKeys.MARKED_LOSSES, self)
module function_definition identifier parameters identifier block if_statement comparison_operator identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list attribute attribute identifier identifier identifier identifier
Adds this loss to the MARKED_LOSSES collection.
def fix_flags(self, flags): FlagsError = base_plugin.FlagsError if flags.version_tb: pass elif flags.inspect: if flags.logdir and flags.event_file: raise FlagsError( 'Must specify either --logdir or --event_file, but not both.') if not (flags.logdir or flags.event_file): raise FlagsError('Must specify either --logdir or --event_file.') elif not flags.db and not flags.logdir: raise FlagsError('A logdir or db must be specified. ' 'For example `tensorboard --logdir mylogdir` ' 'or `tensorboard --db sqlite:~/.tensorboard.db`. ' 'Run `tensorboard --helpfull` for details and examples.') if flags.path_prefix.endswith('/'): flags.path_prefix = flags.path_prefix[:-1]
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier if_statement attribute identifier identifier block pass_statement elif_clause attribute identifier identifier block if_statement boolean_operator attribute identifier identifier attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement not_operator parenthesized_expression boolean_operator attribute identifier identifier attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end elif_clause boolean_operator not_operator attribute identifier identifier not_operator attribute identifier identifier block raise_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end if_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block expression_statement assignment attribute identifier identifier subscript attribute identifier identifier slice unary_operator integer
Fixes standard TensorBoard CLI flags to parser.
def entropy(string): entropy = 0 for number in range(256): result = float(string.encode('utf-8').count( chr(number))) / len(string.encode('utf-8')) if result != 0: entropy = entropy - result * math.log(result, 2) return entropy
module function_definition identifier parameters identifier block expression_statement assignment identifier integer for_statement identifier call identifier argument_list integer block expression_statement assignment identifier binary_operator call identifier argument_list call attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier argument_list call identifier argument_list identifier call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier integer block expression_statement assignment identifier binary_operator identifier binary_operator identifier call attribute identifier identifier argument_list identifier integer return_statement identifier
Calculate the entropy of a string.
def url_report(self, scan_url, apikey): url = self.base_url + "url/report" params = {"apikey": apikey, 'resource': scan_url} rate_limit_clear = self.rate_limit() if rate_limit_clear: response = requests.post(url, params=params, headers=self.headers) if response.status_code == self.HTTP_OK: json_response = response.json() return json_response elif response.status_code == self.HTTP_RATE_EXCEEDED: time.sleep(20) else: self.logger.error("sent: %s, HTTP: %d", scan_url, response.status_code) time.sleep(self.public_api_sleep_time)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier binary_operator attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list return_statement identifier elif_clause comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list integer else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier
Send URLS for list of past malicous associations
def _get_framed(self, buf, offset, insert_payload): header_offset = offset + self._header_len self.length = insert_payload(buf, header_offset, self.payload) struct.pack_into(self._header_fmt, buf, offset, self.preamble, self.msg_type, self.sender, self.length) crc_offset = header_offset + self.length preamble_bytes = 1 crc_over_len = self._header_len + self.length - preamble_bytes self.crc = crc16jit(buf, offset+1, 0, crc_over_len) struct.pack_into(self._crc_fmt, buf, crc_offset, self.crc) length = preamble_bytes + crc_over_len + self._crc_len return length
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier binary_operator identifier attribute identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement assignment identifier binary_operator identifier attribute identifier identifier expression_statement assignment identifier integer expression_statement assignment identifier binary_operator binary_operator attribute identifier identifier attribute identifier identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list identifier binary_operator identifier integer integer identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier identifier attribute identifier identifier expression_statement assignment identifier binary_operator binary_operator identifier identifier attribute identifier identifier return_statement identifier
Returns the framed message and updates the CRC.
def check(self, data): if isinstance(data, Iterable): data = "".join(str(x) for x in data) try: data = str(data) except UnicodeDecodeError: return False return bool(data and self.__regexp.match(data))
module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute string string_start string_end identifier generator_expression call identifier argument_list identifier for_in_clause identifier identifier try_statement block expression_statement assignment identifier call identifier argument_list identifier except_clause identifier block return_statement false return_statement call identifier argument_list boolean_operator identifier call attribute attribute identifier identifier identifier argument_list identifier
returns True if any match any regexp
def Get(self): args = user_pb2.ApiGetClientApprovalArgs( client_id=self.client_id, approval_id=self.approval_id, username=self.username) result = self._context.SendRequest("GetClientApproval", args) return ClientApproval( data=result, username=self._context.username, context=self._context)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier return_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier attribute identifier identifier
Fetch and return a proper ClientApproval object.
def index(self): c.pynipap_version = pynipap.__version__ try: c.nipapd_version = pynipap.nipapd_version() except: c.nipapd_version = 'unknown' c.nipap_db_version = pynipap.nipap_db_version() return render('/version.html')
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier attribute identifier identifier try_statement block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list except_clause block expression_statement assignment attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list return_statement call identifier argument_list string string_start string_content string_end
Display NIPAP version info
def open_recruitment(self, n=1): logger.info("Multi recruitment running for {} participants".format(n)) recruitments = [] messages = {} remaining = n for recruiter, count in self.recruiters(n): if not count: break if recruiter.nickname in messages: result = recruiter.recruit(count) recruitments.extend(result) else: result = recruiter.open_recruitment(count) recruitments.extend(result["items"]) messages[recruiter.nickname] = result["message"] remaining -= count if remaining <= 0: break logger.info( ( "Multi-recruited {} out of {} participants, " "using {} recruiters." ).format(n - remaining, n, len(messages)) ) return {"items": recruitments, "message": "\n".join(messages.values())}
module function_definition identifier parameters identifier default_parameter identifier integer block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier list expression_statement assignment identifier dictionary expression_statement assignment identifier identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list identifier block if_statement not_operator identifier block break_statement if_statement comparison_operator attribute identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end expression_statement assignment subscript identifier attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement augmented_assignment identifier identifier if_statement comparison_operator identifier integer block break_statement expression_statement call attribute identifier identifier argument_list call attribute parenthesized_expression concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list binary_operator identifier identifier identifier call identifier argument_list identifier return_statement dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end call attribute string string_start string_content escape_sequence string_end identifier argument_list call attribute identifier identifier argument_list
Return initial experiment URL list.
def datetime(self): date_string = '%s %s %s' % (self._day, self._date, self._year) return datetime.strptime(date_string, '%a %B %d %Y')
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple attribute identifier identifier attribute identifier identifier attribute identifier identifier return_statement call attribute identifier identifier argument_list identifier string string_start string_content string_end
Returns a datetime object representing the date the game was played.
def fixed(self): decision = False for record in self.history: if record["when"] < self.options.since.date: continue if not decision and record["when"] < self.options.until.date: for change in record["changes"]: if (change["field_name"] == "status" and change["added"] == "MODIFIED" and change["removed"] != "CLOSED"): decision = True else: for change in record["changes"]: if (change["field_name"] == "status" and change["added"] == "ASSIGNED"): decision = False return decision
module function_definition identifier parameters identifier block expression_statement assignment identifier false for_statement identifier attribute identifier identifier block if_statement comparison_operator subscript identifier string string_start string_content string_end attribute attribute attribute identifier identifier identifier identifier block continue_statement if_statement boolean_operator not_operator identifier comparison_operator subscript identifier string string_start string_content string_end attribute attribute attribute identifier identifier identifier identifier block for_statement identifier subscript identifier string string_start string_content string_end block if_statement parenthesized_expression boolean_operator boolean_operator comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier true else_clause block for_statement identifier subscript identifier string string_start string_content string_end block if_statement parenthesized_expression boolean_operator comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier false return_statement identifier
Moved to MODIFIED and not later moved to ASSIGNED
def delete(self, *args, **kwargs): super(UpdateCountsMixin, self).delete(*args, **kwargs) self.update_count()
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list list_splat identifier dictionary_splat identifier expression_statement call attribute identifier identifier argument_list
custom delete method to update counts
def manifest_path_is_old(self, path): mtime = os.path.getmtime(path) return (time.time() - mtime) > 24*60*60
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier return_statement comparison_operator parenthesized_expression binary_operator call attribute identifier identifier argument_list identifier binary_operator binary_operator integer integer integer
return true if path is more than a day old
def to_add(self): kwd = { 'pager': '', } self.render('misc/entity/entity_add.html', cfg=config.CMS_CFG, kwd=kwd, userinfo=self.userinfo)
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier
To add the entity.
def setNewPassword(self, url, username, password): self.br.add_password(url, username, password)
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier identifier
Public method to manually set the credentials for a url in the browser.
def _build_dependent_model_list(self, obj_schema): dep_models_list = [] if obj_schema: obj_schema['type'] = obj_schema.get('type', 'object') if obj_schema['type'] == 'array': dep_models_list.extend(self._build_dependent_model_list(obj_schema.get('items', {}))) else: ref = obj_schema.get('$ref') if ref: ref_obj_model = ref.split("/")[-1] ref_obj_schema = self._models().get(ref_obj_model) dep_models_list.extend(self._build_dependent_model_list(ref_obj_schema)) dep_models_list.extend([ref_obj_model]) else: properties = obj_schema.get('properties') if properties: for _, prop_obj_schema in six.iteritems(properties): dep_models_list.extend(self._build_dependent_model_list(prop_obj_schema)) return list(set(dep_models_list))
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end if_statement comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end dictionary else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement assignment identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end unary_operator integer expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list list identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier return_statement call identifier argument_list call identifier argument_list identifier
Helper function to build the list of models the given object schema is referencing.
def _begin_request(self): headers = self.m2req.headers self._request = HTTPRequest(connection=self, method=headers.get("METHOD"), uri=self.m2req.path, version=headers.get("VERSION"), headers=headers, remote_ip=headers.get("x-forwarded-for")) if len(self.m2req.body) > 0: self._request.body = self.m2req.body if self.m2req.is_disconnect(): self.finish() elif headers.get("x-mongrel2-upload-done", None): expected = headers.get("x-mongrel2-upload-start", "BAD") upload = headers.get("x-mongrel2-upload-done", None) if expected == upload: self.request_callback(self._request) elif headers.get("x-mongrel2-upload-start", None): pass else: self.request_callback(self._request)
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator call identifier argument_list attribute attribute identifier identifier identifier integer block expression_statement assignment attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier if_statement call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list elif_clause call attribute identifier identifier argument_list string string_start string_content string_end none block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end none if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier elif_clause call attribute identifier identifier argument_list string string_start string_content string_end none block pass_statement else_clause block expression_statement call attribute identifier identifier argument_list attribute identifier identifier
Actually start executing this request.
def _send_request(self): if isinstance(self._worker, str): classname = self._worker else: classname = '%s.%s' % (self._worker.__module__, self._worker.__name__) self.request_id = str(uuid.uuid4()) self.send({'request_id': self.request_id, 'worker': classname, 'data': self._args})
module function_definition identifier parameters identifier block if_statement call identifier argument_list attribute identifier identifier identifier block expression_statement assignment identifier attribute identifier identifier else_clause block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end attribute identifier identifier
Sends the request to the backend.
def checkVersion(self): r = self.doQuery('version') if r.status_code == 200: data = r.json() if data['result'] == 'Ok' and data['version'] == self.PI_API_VERSION and data['protocol'] == self.PI_API_NAME: return True return False
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator attribute identifier identifier integer block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement boolean_operator boolean_operator comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end comparison_operator subscript identifier string string_start string_content string_end attribute identifier identifier comparison_operator subscript identifier string string_start string_content string_end attribute identifier identifier block return_statement true return_statement false
Check if the server use the same version of our protocol
def next(self): if self._order_by == 'oldest': return self.newer if self._order_by == 'newest': return self.older return None
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block return_statement attribute identifier identifier if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block return_statement attribute identifier identifier return_statement none
Gets the next page, respecting sort order
def transformation(func): @wraps(func) def func_as_transformation(*args, **kwargs): if hasattr(args[0], 'history'): history = args[0].history else: history = [] image = func(*args, **kwargs) image = Image.from_array(image, log_in_history=False) image.history = history image.history.append('Applied {} transform'.format(func.__name__)) if AutoWrite.on: fpath = AutoName.name(func) try: if AutoWrite.auto_safe_dtype: safe_range_im = 255 * normalise(image) pil_im = PIL.Image.fromarray(safe_range_im.astype(np.uint8)) else: pil_im = PIL.Image.fromarray(image) except TypeError: raise(TypeError( "Cannot handle this data type: {}".format(image.dtype))) pil_im.save(fpath) return image return func_as_transformation
module function_definition identifier parameters identifier block decorated_definition decorator call identifier argument_list identifier function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block if_statement call identifier argument_list subscript identifier integer string string_start string_content string_end block expression_statement assignment identifier attribute subscript identifier integer identifier else_clause block expression_statement assignment identifier list expression_statement assignment identifier call identifier argument_list list_splat identifier dictionary_splat identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier false expression_statement assignment attribute identifier identifier 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 if_statement attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier try_statement block if_statement attribute identifier identifier block expression_statement assignment identifier binary_operator integer call identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier else_clause block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier except_clause identifier block raise_statement parenthesized_expression call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier return_statement identifier
Function decorator to turn another function into a transformation.
def rows(self, offs): lkey = s_common.int64en(offs) for lkey, byts in self.slab.scanByRange(lkey, db=self.db): indx = s_common.int64un(lkey) yield indx, byts
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement yield expression_list identifier identifier
Iterate over raw indx, bytes tuples from a given offset.
def profile_dir(name): if name: possible_path = Path(name) if possible_path.exists(): return possible_path profiles = list(read_profiles()) try: if name: profile = next(p for p in profiles if p.name == name) else: profile = next(p for p in profiles if p.default) except StopIteration: raise ProfileNotFoundError(name) return profile.path
module function_definition identifier parameters identifier block if_statement identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement call attribute identifier identifier argument_list block return_statement identifier expression_statement assignment identifier call identifier argument_list call identifier argument_list try_statement block if_statement identifier block expression_statement assignment identifier call identifier generator_expression identifier for_in_clause identifier identifier if_clause comparison_operator attribute identifier identifier identifier else_clause block expression_statement assignment identifier call identifier generator_expression identifier for_in_clause identifier identifier if_clause attribute identifier identifier except_clause identifier block raise_statement call identifier argument_list identifier return_statement attribute identifier identifier
Return path to FF profile for a given profile name or path.
def assign_contributor_permissions(obj, contributor=None): for permission in get_all_perms(obj): assign_perm(permission, contributor if contributor else obj.contributor, obj)
module function_definition identifier parameters identifier default_parameter identifier none block for_statement identifier call identifier argument_list identifier block expression_statement call identifier argument_list identifier conditional_expression identifier identifier attribute identifier identifier identifier
Assign all permissions to object's contributor.
def create_table(self, model_class): if model_class.is_system_model(): raise DatabaseException("You can't create system table") if getattr(model_class, 'engine') is None: raise DatabaseException("%s class must define an engine" % model_class.__name__) self._send(model_class.create_table_sql(self))
module function_definition identifier parameters identifier identifier block if_statement call attribute identifier identifier argument_list block raise_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator call identifier argument_list identifier string string_start string_content string_end none block raise_statement call identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier
Creates a table for the given model class, if it does not exist already.
def imdecode(image_path): import os assert os.path.exists(image_path), image_path + ' not found' im = cv2.imread(image_path) return im
module function_definition identifier parameters identifier block import_statement dotted_name identifier assert_statement call attribute attribute identifier identifier identifier argument_list identifier binary_operator identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement identifier
Return BGR image read by opencv
def timeit_profile(stmt, number, repeat, setup, profiler_factory, pickle_protocol, dump_filename, mono, **_ignored): del _ignored globals_ = {} exec_(setup, globals_) if number is None: dummy_profiler = profiler_factory() dummy_profiler.start() for x in range(1, 10): number = 10 ** x t = time.time() for y in range(number): exec_(stmt, globals_) if time.time() - t >= 0.2: break dummy_profiler.stop() del dummy_profiler code = compile('for _ in range(%d): %s' % (number, stmt), 'STATEMENT', 'exec') __profile__(stmt, code, globals_, profiler_factory, pickle_protocol=pickle_protocol, dump_filename=dump_filename, mono=mono)
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier identifier dictionary_splat_pattern identifier block delete_statement identifier expression_statement assignment identifier dictionary expression_statement call identifier argument_list identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list for_statement identifier call identifier argument_list integer integer block expression_statement assignment identifier binary_operator integer identifier expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier call identifier argument_list identifier block expression_statement call identifier argument_list identifier identifier if_statement comparison_operator binary_operator call attribute identifier identifier argument_list identifier float block break_statement expression_statement call attribute identifier identifier argument_list delete_statement identifier expression_statement assignment identifier call identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier string string_start string_content string_end string string_start string_content string_end expression_statement call identifier argument_list identifier identifier identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
Profile a Python statement like timeit.
def action_set(values): cmd = ['action-set'] for k, v in list(values.items()): cmd.append('{}={}'.format(k, v)) subprocess.check_call(cmd)
module function_definition identifier parameters identifier block expression_statement assignment identifier list string string_start string_content string_end for_statement pattern_list identifier identifier call identifier argument_list call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier
Sets the values to be returned after the action finishes
def filter(self, intersects): try: crs = self.crs vector = intersects.geometry if isinstance(intersects, GeoFeature) else intersects prepared_shape = prep(vector.get_shape(crs)) hits = [] for feature in self: target_shape = feature.geometry.get_shape(crs) if prepared_shape.overlaps(target_shape) or prepared_shape.intersects(target_shape): hits.append(feature) except IndexError: hits = [] return FeatureCollection(hits)
module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier conditional_expression attribute identifier identifier call identifier argument_list identifier identifier identifier expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list identifier expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement boolean_operator call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier except_clause identifier block expression_statement assignment identifier list return_statement call identifier argument_list identifier
Filter results that intersect a given GeoFeature or Vector.
def dpsi2_dmuS(self, dL_dpsi2, Z, mu, S, target_mu, target_S): self._psi_computations(Z, mu, S) tmp = (self.inv_lengthscale2 * self._psi2[:, :, :, None]) / self._psi2_denom target_mu += -2.*(dL_dpsi2[:, :, :, None] * tmp * self._psi2_mudist).sum(1).sum(1) target_S += (dL_dpsi2[:, :, :, None] * tmp * (2.*self._psi2_mudist_sq - 1)).sum(1).sum(1)
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier identifier expression_statement assignment identifier binary_operator parenthesized_expression binary_operator attribute identifier identifier subscript attribute identifier identifier slice slice slice none attribute identifier identifier expression_statement augmented_assignment identifier binary_operator unary_operator float call attribute call attribute parenthesized_expression binary_operator binary_operator subscript identifier slice slice slice none identifier attribute identifier identifier identifier argument_list integer identifier argument_list integer expression_statement augmented_assignment identifier call attribute call attribute parenthesized_expression binary_operator binary_operator subscript identifier slice slice slice none identifier parenthesized_expression binary_operator binary_operator float attribute identifier identifier integer identifier argument_list integer identifier argument_list integer
Think N,num_inducing,num_inducing,input_dim
def locate_path(dname, recurse_down=True): tried_fpaths = [] root_dir = os.getcwd() while root_dir is not None: dpath = join(root_dir, dname) if exists(dpath): return dpath else: tried_fpaths.append(dpath) _new_root = dirname(root_dir) if _new_root == root_dir: root_dir = None break else: root_dir = _new_root if not recurse_down: break msg = 'Cannot locate dname=%r' % (dname,) msg = ('\n[sysreq!] Checked: '.join(tried_fpaths)) print(msg) raise ImportError(msg)
module function_definition identifier parameters identifier default_parameter identifier true block expression_statement assignment identifier list expression_statement assignment identifier call attribute identifier identifier argument_list while_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list identifier identifier if_statement call identifier argument_list identifier block return_statement identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier identifier block expression_statement assignment identifier none break_statement else_clause block expression_statement assignment identifier identifier if_statement not_operator identifier block break_statement expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier expression_statement assignment identifier parenthesized_expression call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier expression_statement call identifier argument_list identifier raise_statement call identifier argument_list identifier
Search for a path
def userinfo_claims(self, access_token, scope_request, claims_request): id_token = oidc.userinfo(access_token, scope_request, claims_request) return id_token.claims
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier return_statement attribute identifier identifier
Return the claims for the requested parameters.
def validate(text, file, schema_type): content = None if text: print('Validating text input...') content = text if file: print('Validating file input...') content = file.read() if content is None: click.secho('Please give either text input or a file path. See help for more details.', fg='red') exit(1) try: if schema_type == 'dependencies': validator = DependenciesSchemaValidator() elif schema_type == 'actions': validator = ActionsSchemaValidator() else: raise Exception('Unknown type') validator.validate_json(content) click.secho('Valid JSON schema!', fg='green') except Exception as e: click.secho('Invalid JSON schema!', fg='red') raise e
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier none if_statement identifier block expression_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier identifier if_statement identifier block expression_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement call identifier argument_list integer try_statement block if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list else_clause block raise_statement call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end raise_statement identifier
Validate JSON input using dependencies-schema
def _copy(self): ins = copy.copy(self) ins._fire_page_number(self.page_number + 1) return ins
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list binary_operator attribute identifier identifier integer return_statement identifier
needs to update page numbers
def _read_interleaved(self, f, data_objects): log.debug("Reading interleaved data point by point") object_data = {} points_added = {} for obj in data_objects: object_data[obj.path] = obj._new_segment_data() points_added[obj.path] = 0 while any([points_added[o.path] < o.number_values for o in data_objects]): for obj in data_objects: if points_added[obj.path] < obj.number_values: object_data[obj.path][points_added[obj.path]] = ( obj._read_value(f)) points_added[obj.path] += 1 for obj in data_objects: obj.tdms_object._update_data(object_data[obj.path])
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier dictionary expression_statement assignment identifier dictionary for_statement identifier identifier block expression_statement assignment subscript identifier attribute identifier identifier call attribute identifier identifier argument_list expression_statement assignment subscript identifier attribute identifier identifier integer while_statement call identifier argument_list list_comprehension comparison_operator subscript identifier attribute identifier identifier attribute identifier identifier for_in_clause identifier identifier block for_statement identifier identifier block if_statement comparison_operator subscript identifier attribute identifier identifier attribute identifier identifier block expression_statement assignment subscript subscript identifier attribute identifier identifier subscript identifier attribute identifier identifier parenthesized_expression call attribute identifier identifier argument_list identifier expression_statement augmented_assignment subscript identifier attribute identifier identifier integer for_statement identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list subscript identifier attribute identifier identifier
Read interleaved data that doesn't have a numpy type
def request_length(self): remainder = self.stop_at - self.offset return self.chunk_size if remainder > self.chunk_size else remainder
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator attribute identifier identifier attribute identifier identifier return_statement conditional_expression attribute identifier identifier comparison_operator identifier attribute identifier identifier identifier
Return length of next chunk upload.
def _query(options, collection_name, num_to_skip, num_to_return, query, field_selector, opts, check_keys): encoded = _dict_to_bson(query, check_keys, opts) if field_selector: efs = _dict_to_bson(field_selector, False, opts) else: efs = b"" max_bson_size = max(len(encoded), len(efs)) return b"".join([ _pack_int(options), _make_c_string(collection_name), _pack_int(num_to_skip), _pack_int(num_to_return), encoded, efs]), max_bson_size
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier identifier if_statement identifier block expression_statement assignment identifier call identifier argument_list identifier false identifier else_clause block expression_statement assignment identifier string string_start string_end expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier call identifier argument_list identifier return_statement expression_list call attribute string string_start string_end identifier argument_list list call identifier argument_list identifier call identifier argument_list identifier call identifier argument_list identifier call identifier argument_list identifier identifier identifier identifier
Get an OP_QUERY message.
def _characterize_header(self, header, hgroups): out = [] for h in [header[g[0]] for g in hgroups]: this_ctype = None for ctype, names in self._col_types.items(): if h.startswith(names): this_ctype = ctype break out.append(this_ctype) return out
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier list for_statement identifier list_comprehension subscript identifier subscript identifier integer for_in_clause identifier identifier block expression_statement assignment identifier none for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block if_statement call attribute identifier identifier argument_list identifier block expression_statement assignment identifier identifier break_statement expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Characterize header groups into different data types.
def update(self, permission): self.needs.update(permission.needs) self.excludes.update(permission.excludes)
module function_definition identifier parameters identifier identifier block 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
In-place update of permissions.
def profiles(self): selected_profiles = [] for config in self.included_profiles: profile_selected = False profile_name = config.get('profile_name') if profile_name == self.args.profile: profile_selected = True elif config.get('group') is not None and config.get('group') == self.args.group: profile_selected = True elif self.args.group in config.get('groups', []): profile_selected = True if profile_selected: install_json_filename = config.get('install_json') ij = {} if install_json_filename is not None: ij = self.load_install_json(install_json_filename) config['install_json'] = ij selected_profiles.append(config) self.reports.add_profile(config, profile_selected) if not selected_profiles: print('{}{}No profiles selected to run.'.format(c.Style.BRIGHT, c.Fore.YELLOW)) return selected_profiles
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier attribute identifier identifier block expression_statement assignment identifier false expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier attribute attribute identifier identifier identifier block expression_statement assignment identifier true elif_clause boolean_operator comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end none comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end attribute attribute identifier identifier identifier block expression_statement assignment identifier true elif_clause comparison_operator attribute attribute identifier identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end list block expression_statement assignment identifier true if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier dictionary if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier if_statement not_operator identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier return_statement identifier
Return all selected profiles.
def compute_transitive_deps_by_target(self, targets): sorted_targets = reversed(sort_targets(targets)) transitive_deps_by_target = defaultdict(set) for target in sorted_targets: transitive_deps = set() for dep in target.dependencies: transitive_deps.update(transitive_deps_by_target.get(dep, [])) transitive_deps.add(dep) if hasattr(target, 'java_sources'): for java_source_target in target.java_sources: for transitive_dep in java_source_target.dependencies: transitive_deps_by_target[java_source_target].add(transitive_dep) transitive_deps_by_target[target] = transitive_deps return transitive_deps_by_target
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier list expression_statement call attribute identifier identifier argument_list identifier if_statement call identifier argument_list identifier string string_start string_content string_end block for_statement identifier attribute identifier identifier block for_statement identifier attribute identifier identifier block expression_statement call attribute subscript identifier identifier identifier argument_list identifier expression_statement assignment subscript identifier identifier identifier return_statement identifier
Map from target to all the targets it depends on, transitively.
def which(component, path_str): def is_exe(fpath): return os.path.exists(fpath) and os.access(fpath, os.X_OK) fpath, fname = os.path.split(component) if fpath: if is_exe(component): return component else: for path in path_str.split(os.pathsep): exe_file = os.path.join(path, component) if is_exe(exe_file): return exe_file
module function_definition identifier parameters identifier identifier block function_definition identifier parameters identifier block return_statement boolean_operator call attribute attribute identifier identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier attribute identifier identifier expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement identifier block if_statement call identifier argument_list identifier block return_statement identifier else_clause block for_statement identifier call attribute identifier identifier argument_list attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier if_statement call identifier argument_list identifier block return_statement identifier
helper method having same behaviour as "which" os command.
def sharedFiles(self): 'iterate over shared files and get their public URI' for f in self.sharing.files.iterchildren(): yield (f.attrib['name'], f.attrib['uuid'], 'https://www.jottacloud.com/p/%s/%s' % (self.jfs.username, f.publicURI.text))
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end for_statement identifier call attribute attribute attribute identifier identifier identifier identifier argument_list block expression_statement yield tuple subscript attribute identifier identifier string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end binary_operator string string_start string_content string_end tuple attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier
iterate over shared files and get their public URI
def new_game(self): self.game = self.game_class(self, self.screen) self.save()
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list
Creates a new game of 2048.
def to_esc(self): chunks = chunked(self.stream, 2) return ''.join(r'\x' + ''.join(pair) for pair in chunks)
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier integer return_statement call attribute string string_start string_end identifier generator_expression binary_operator string string_start string_content string_end call attribute string string_start string_end identifier argument_list identifier for_in_clause identifier identifier
Convert to escape string.
def find_release(package, releases, dependencies=None): dependencies = dependencies if dependencies is not None else {} for release in releases: url = release['url'] old_priority = dependencies.get(package, {}).get('priority', 0) for suffix, priority in SUFFIXES.items(): if url.endswith(suffix): if old_priority < priority: sha256 = release['digests']['sha256'] dependencies[package] = { 'package': package, 'url': url, 'sha256': sha256, 'priority': priority, } return dependencies[package]
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier conditional_expression identifier comparison_operator identifier none dictionary for_statement identifier identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier dictionary identifier argument_list string string_start string_content string_end integer for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement call attribute identifier identifier argument_list identifier block if_statement comparison_operator identifier identifier block expression_statement assignment identifier subscript subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript identifier identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier return_statement subscript identifier identifier
Return the best release.
def getpreferredencoding(): _encoding = locale.getpreferredencoding(False) if six.PY2 and not sys.platform == "win32": _default_encoding = locale.getdefaultlocale()[1] if _default_encoding is not None: _encoding = _default_encoding return _encoding
module function_definition identifier parameters block expression_statement assignment identifier call attribute identifier identifier argument_list false if_statement boolean_operator attribute identifier identifier not_operator comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier subscript call attribute identifier identifier argument_list integer if_statement comparison_operator identifier none block expression_statement assignment identifier identifier return_statement identifier
Determine the proper output encoding for terminal rendering
def _mark_master_dead(self, master): if self._syndics[master].done(): syndic = self._syndics[master].result() self._syndics[master] = syndic.reconnect() else: log.info( 'Attempting to mark %s as dead, although it is already ' 'marked dead', master )
module function_definition identifier parameters identifier identifier block if_statement call attribute subscript attribute identifier identifier identifier identifier argument_list block expression_statement assignment identifier call attribute subscript attribute identifier identifier identifier identifier argument_list expression_statement assignment subscript attribute identifier identifier identifier call attribute identifier identifier argument_list else_clause block expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end identifier
Mark a master as dead. This will start the sign-in routine
def update(self, milliseconds): self.__sort_up() for obj in self.__up_objects: obj.update(milliseconds)
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier
Updates all of the objects in our world.
def _find_devices_mac(self): self.keyboards.append(Keyboard(self)) self.mice.append(MightyMouse(self)) self.mice.append(Mouse(self))
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier
Find devices on Mac.
def list_eids(self): entities = self.list() return sorted([int(eid) for eid in entities])
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list return_statement call identifier argument_list list_comprehension call identifier argument_list identifier for_in_clause identifier identifier
Returns a list of all known eids
def _calculate_cluster_distance(end_iter): out = [] sizes = [] for x in end_iter: out.append(x) sizes.append(x.end1 - x.start1) sizes.append(x.end2 - x.start2) distance = sum(sizes) // len(sizes) return distance, out
module function_definition identifier parameters identifier block expression_statement assignment identifier list expression_statement assignment identifier list for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list binary_operator attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator attribute identifier identifier attribute identifier identifier expression_statement assignment identifier binary_operator call identifier argument_list identifier call identifier argument_list identifier return_statement expression_list identifier identifier
Compute allowed distance for clustering based on end confidence intervals.
def state_pop(self): "Restore the state of the output functions saved by state_push." for of in self.output_fns: if hasattr(of,'state_pop'): of.state_pop() super(PatternGenerator, self).state_pop()
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end for_statement identifier attribute identifier identifier block if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list
Restore the state of the output functions saved by state_push.
def upsert(cls, name, **fields): instance = cls.get(name) if instance: instance._set_fields(fields) else: instance = cls(name=name, **fields) instance = failsafe_add(cls.query.session, instance, name=name) return instance
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier dictionary_splat identifier expression_statement assignment identifier call identifier argument_list attribute attribute identifier identifier identifier identifier keyword_argument identifier identifier return_statement identifier
Insert or update an instance
def url_to_attrs_dict(url, url_attr): result = dict() if isinstance(url, six.string_types): url_value = url else: try: url_value = url["url"] except TypeError: raise BootstrapError( 'Function "url_to_attrs_dict" expects a string or a dict with key "url".' ) crossorigin = url.get("crossorigin", None) integrity = url.get("integrity", None) if crossorigin: result["crossorigin"] = crossorigin if integrity: result["integrity"] = integrity result[url_attr] = url_value return result
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list if_statement call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier identifier else_clause block try_statement block expression_statement assignment identifier subscript identifier string string_start string_content string_end except_clause 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 string string_start string_content string_end none expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end none if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment subscript identifier identifier identifier return_statement identifier
Sanitize url dict as used in django-bootstrap3 settings.
def _reinsert_root_tag_prefix(v): if hasattr(v, 'original_prefix'): original_prefix = v.original_prefix del v.original_prefix v.tag = ''.join(('{', v.nsmap[original_prefix], '}VOEvent')) return
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier attribute identifier identifier delete_statement attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute string string_start string_end identifier argument_list tuple string string_start string_content string_end subscript attribute identifier identifier identifier string string_start string_content string_end return_statement
Returns namespace prefix to root tag, if it had one.
def pubkey(self, identity, ecdh=False): with self.device: pubkey = self.device.pubkey(ecdh=ecdh, identity=identity) return formats.decompress_pubkey( pubkey=pubkey, curve_name=identity.curve_name)
module function_definition identifier parameters identifier identifier default_parameter identifier false block with_statement with_clause with_item attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier
Return public key as VerifyingKey object.
def generate_image_from_url(url=None, timeout=30): file_name = posixpath.basename(url) img_tmp = NamedTemporaryFile(delete=True) try: response = requests.get(url, timeout=timeout) response.raise_for_status() except Exception as e: return None, None img_tmp.write(response.content) img_tmp.flush() image = File(img_tmp) image.seek(0) return file_name, image
module function_definition identifier parameters default_parameter identifier none default_parameter identifier integer block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier true try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list except_clause as_pattern identifier as_pattern_target identifier block return_statement expression_list none none expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list integer return_statement expression_list identifier identifier
Downloads and saves a image from url into a file.
def _add_observation_to_means(self, xj, yj): self._mean_x_in_window = ((self.window_size * self._mean_x_in_window + xj) / (self.window_size + 1.0)) self._mean_y_in_window = ((self.window_size * self._mean_y_in_window + yj) / (self.window_size + 1.0))
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment attribute identifier identifier parenthesized_expression binary_operator parenthesized_expression binary_operator binary_operator attribute identifier identifier attribute identifier identifier identifier parenthesized_expression binary_operator attribute identifier identifier float expression_statement assignment attribute identifier identifier parenthesized_expression binary_operator parenthesized_expression binary_operator binary_operator attribute identifier identifier attribute identifier identifier identifier parenthesized_expression binary_operator attribute identifier identifier float
Update the means without recalculating for the addition of one observation.
def sign_nonce(key, nonce): return Cryptodome.Hash.HMAC.new(key, nonce, digestmod=Cryptodome.Hash.SHA256).digest()
module function_definition identifier parameters identifier identifier block return_statement call attribute call attribute attribute attribute identifier identifier identifier identifier argument_list identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier identifier argument_list
sign the server nonce from the WWW-Authenticate header with an authKey
def flux_expr(self, reaction): if isinstance(reaction, dict): return self._v.expr(iteritems(reaction)) return self._v(reaction)
module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier identifier block return_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier
Get LP expression representing the reaction flux.
def _nonblocking_read(self): with Nonblocking(self.in_stream): if PY3: try: data = os.read(self.in_stream.fileno(), READ_SIZE) except BlockingIOError: return 0 if data: self.unprocessed_bytes.extend(data[i:i+1] for i in range(len(data))) return len(data) else: return 0 else: try: data = os.read(self.in_stream.fileno(), READ_SIZE) except OSError: return 0 else: self.unprocessed_bytes.extend(data) return len(data)
module function_definition identifier parameters identifier block with_statement with_clause with_item call identifier argument_list attribute identifier identifier block if_statement identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier except_clause identifier block return_statement integer if_statement identifier block expression_statement call attribute attribute identifier identifier identifier generator_expression subscript identifier slice identifier binary_operator identifier integer for_in_clause identifier call identifier argument_list call identifier argument_list identifier return_statement call identifier argument_list identifier else_clause block return_statement integer else_clause block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier except_clause identifier block return_statement integer else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement call identifier argument_list identifier
Returns the number of characters read and adds them to self.unprocessed_bytes
def cancel(ctx, orders, account): print_tx(ctx.bitshares.cancel(orders, account=account))
module function_definition identifier parameters identifier identifier identifier block expression_statement call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier
Cancel one or multiple orders
def datagramReceived(self, data): try: obj = json.loads(data) except ValueError, e: log.err(e, 'Invalid JSON in stream: %r' % data) return if u'text' in obj: obj = Status.fromDict(obj) else: log.msg('Unsupported object %r' % obj) return self.callback(obj)
module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause identifier identifier block expression_statement call attribute identifier identifier argument_list identifier binary_operator string string_start string_content string_end identifier return_statement if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier return_statement expression_statement call attribute identifier identifier argument_list identifier
Decode the JSON-encoded datagram and call the callback.
def class_in_progress(stack=None): if stack is None: stack = inspect.stack() for frame in stack: statement_list = frame[4] if statement_list is None: continue if statement_list[0].strip().startswith('class '): return True return False
module function_definition identifier parameters default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier identifier block expression_statement assignment identifier subscript identifier integer if_statement comparison_operator identifier none block continue_statement if_statement call attribute call attribute subscript identifier integer identifier argument_list identifier argument_list string string_start string_content string_end block return_statement true return_statement false
True if currently inside a class definition, else False.
def check_gcdt_update(): try: inst_version, latest_version = get_package_versions('gcdt') if inst_version < latest_version: log.warn('Please consider an update to gcdt version: %s' % latest_version) except GracefulExit: raise except Exception: log.warn('PyPi appears to be down - we currently can\'t check for newer gcdt versions')
module function_definition identifier parameters block try_statement block expression_statement assignment pattern_list identifier identifier call identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier except_clause identifier block raise_statement except_clause identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end
Check whether a newer gcdt is available and output a warning.
def perform_srl(responses, prompt): predictor = Predictor.from_path("https://s3-us-west-2.amazonaws.com/allennlp/models/srl-model-2018.05.25.tar.gz") sentences = [{"sentence": prompt + " " + response} for response in responses] output = predictor.predict_batch_json(sentences) full_output = [{"sentence": prompt + response, "response": response, "srl": srl} for (response, srl) in zip(responses, output)] return full_output
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier list_comprehension dictionary pair string string_start string_content string_end binary_operator binary_operator identifier string string_start string_content string_end identifier for_in_clause identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier list_comprehension dictionary pair string string_start string_content string_end binary_operator identifier identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier for_in_clause tuple_pattern identifier identifier call identifier argument_list identifier identifier return_statement identifier
Perform semantic role labeling on a list of responses, given a prompt.