code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def read_rels(archive): xml_source = archive.read(ARC_WORKBOOK_RELS) tree = fromstring(xml_source) for element in safe_iterator(tree, '{%s}Relationship' % PKG_REL_NS): rId = element.get('Id') pth = element.get("Target") typ = element.get('Type') if pth.startswith("/xl"): pth = pth.replace("/xl", "xl") elif not pth.startswith("xl") and not pth.startswith(".."): pth = "xl/" + pth yield rId, {'path':pth, 'type':typ}
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier for_statement identifier call identifier argument_list identifier binary_operator string string_start string_content string_end identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment 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 if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end elif_clause boolean_operator not_operator call attribute identifier identifier argument_list string string_start string_content string_end not_operator call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier binary_operator string string_start string_content string_end identifier expression_statement yield expression_list identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier
Read relationships for a workbook
def _read_services(self, services): for service in services: parser = FritzSCDPParser(self.address, self.port, service) actions = parser.get_actions() service.actions = {action.name: action for action in actions} self.services[service.name] = service
module function_definition identifier parameters identifier identifier block for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier dictionary_comprehension pair attribute identifier identifier identifier for_in_clause identifier identifier expression_statement assignment subscript attribute identifier identifier attribute identifier identifier identifier
Get actions from services.
def stmt_lambdef_handle(self, original, loc, tokens): if len(tokens) == 2: params, stmts = tokens elif len(tokens) == 3: params, stmts, last = tokens if "tests" in tokens: stmts = stmts.asList() + ["return " + last] else: stmts = stmts.asList() + [last] else: raise CoconutInternalException("invalid statement lambda tokens", tokens) name = self.stmt_lambda_name() body = openindent + self.stmt_lambda_proc("\n".join(stmts)) + closeindent if isinstance(params, str): self.stmt_lambdas.append( "def " + name + params + ":\n" + body, ) else: params.insert(0, name) self.stmt_lambdas.append( "".join(self.name_match_funcdef_handle(original, loc, params)) + body, ) return name
module function_definition identifier parameters identifier identifier identifier identifier block if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment pattern_list identifier identifier identifier elif_clause comparison_operator call identifier argument_list identifier integer block expression_statement assignment pattern_list identifier identifier identifier identifier if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list list binary_operator string string_start string_content string_end identifier else_clause block expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list list identifier else_clause block raise_statement call identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier binary_operator binary_operator identifier call attribute identifier identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier identifier if_statement call identifier argument_list identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator binary_operator binary_operator binary_operator string string_start string_content string_end identifier identifier string string_start string_content escape_sequence string_end identifier else_clause block expression_statement call attribute identifier identifier argument_list integer identifier expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator call attribute string string_start string_end identifier argument_list call attribute identifier identifier argument_list identifier identifier identifier identifier return_statement identifier
Process multi-line lambdef statements.
def X(self, value): if isinstance(value, (int, float, long, types.NoneType)): self._x = value
module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier tuple identifier identifier identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier identifier
sets the X coordinate
def before(self): user = self.request.user() if user and user.verified_at is None: self.request.redirect('/email/verify')
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list if_statement boolean_operator identifier comparison_operator attribute identifier identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end
Run This Middleware Before The Route Executes.
def validate(self, _portfolio, _account, _algo_datetime, _algo_current_data): if _account.leverage > self.max_leverage: self.fail()
module function_definition identifier parameters identifier identifier identifier identifier identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list
Fail if the leverage is greater than the allowed leverage.
async def load_saved_device_info(self): _LOGGER.debug("Loading saved device info.") deviceinfo = [] if self._workdir: _LOGGER.debug("Really Loading saved device info.") try: device_file = '{}/{}'.format(self._workdir, DEVICE_INFO_FILE) with open(device_file, 'r') as infile: try: deviceinfo = json.load(infile) _LOGGER.debug("Saved device file loaded") except json.decoder.JSONDecodeError: _LOGGER.debug("Loading saved device file failed") except FileNotFoundError: _LOGGER.debug("Saved device file not found") for device in deviceinfo: self._add_saved_device_info(**device)
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier list if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end try_statement block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier identifier with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end except_clause attribute attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end except_clause identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list dictionary_splat identifier
Load device information from the device info file.
def _get_hosts_from_ports(self, ports): hosts = map(lambda x: 'localhost:%d' % int(x.strip()), ports.split(',')) return list(set(hosts))
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list lambda lambda_parameters identifier binary_operator string string_start string_content string_end call identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end return_statement call identifier argument_list call identifier argument_list identifier
validate hostnames from a list of ports
def _linear_constraints(self, om): A, l, u = om.linear_constraints() return A, l, u
module function_definition identifier parameters identifier identifier block expression_statement assignment pattern_list identifier identifier identifier call attribute identifier identifier argument_list return_statement expression_list identifier identifier identifier
Returns the linear problem constraints.
def clean_requires_python(candidates): all_candidates = [] sys_version = ".".join(map(str, sys.version_info[:3])) from packaging.version import parse as parse_version py_version = parse_version(os.environ.get("PIP_PYTHON_VERSION", sys_version)) for c in candidates: from_location = attrgetter("location.requires_python") requires_python = getattr(c, "requires_python", from_location(c)) if requires_python: if requires_python.isdigit(): requires_python = ">={0},<{1}".format( requires_python, int(requires_python) + 1 ) try: specifierset = SpecifierSet(requires_python) except InvalidSpecifier: continue else: if not specifierset.contains(py_version): continue all_candidates.append(c) return all_candidates
module function_definition identifier parameters identifier block expression_statement assignment identifier list expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier subscript attribute identifier identifier slice integer import_from_statement dotted_name identifier identifier aliased_import dotted_name identifier identifier expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end call identifier argument_list identifier if_statement identifier block if_statement call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier binary_operator call identifier argument_list identifier integer try_statement block expression_statement assignment identifier call identifier argument_list identifier except_clause identifier block continue_statement else_clause block if_statement not_operator call attribute identifier identifier argument_list identifier block continue_statement expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Get a cleaned list of all the candidates with valid specifiers in the `requires_python` attributes.
def pymatgen_mol(self): sp = [] coords = [] for atom in ob.OBMolAtomIter(self._obmol): sp.append(atom.GetAtomicNum()) coords.append([atom.GetX(), atom.GetY(), atom.GetZ()]) return Molecule(sp, coords)
module function_definition identifier parameters identifier block expression_statement assignment identifier list expression_statement assignment identifier list for_statement identifier call attribute identifier identifier argument_list attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list list call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list return_statement call identifier argument_list identifier identifier
Returns pymatgen Molecule object.
def show_image(kwargs, call=None): if call != 'function': raise SaltCloudSystemExit( 'The show_image action must be called with -f or --function.' ) params = {'ImageId.1': kwargs['image'], 'Action': 'DescribeImages'} result = aws.query(params, setname='tagSet', location=get_location(), provider=get_provider(), opts=__opts__, sigver='4') log.info(result) return result
module function_definition identifier parameters identifier default_parameter identifier none block if_statement comparison_operator identifier string string_start string_content string_end block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end subscript identifier string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier call identifier argument_list keyword_argument identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Show the details from EC2 concerning an AMI
def page_title(self, title): if world.browser.title != title: raise AssertionError( "Page title expected to be {!r}, got {!r}.".format( title, world.browser.title))
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute attribute identifier identifier identifier identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier attribute attribute identifier identifier identifier
Assert the page title matches the given text.
def __open(self, url, headers=None, data=None, baseurl=""): headers = headers or {} if not baseurl: baseurl = self.baseurl req = Request("%s%s" % (baseurl, url), headers=headers) _LOGGER.debug(url) try: req.data = urlencode(data).encode('utf-8') except TypeError: pass opener = build_opener() try: resp = opener.open(req) charset = resp.info().get('charset', 'utf-8') data = json.loads(resp.read().decode(charset)) opener.close() _LOGGER.debug(json.dumps(data)) return data except HTTPError as exception_: if exception_.code == 408: _LOGGER.debug("%s", exception_) return False raise TeslaException(exception_.code)
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier string string_start string_end block expression_statement assignment identifier boolean_operator identifier dictionary if_statement not_operator identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier try_statement block expression_statement assignment attribute identifier identifier call attribute call identifier argument_list identifier identifier argument_list string string_start string_content string_end except_clause identifier block pass_statement expression_statement assignment identifier call identifier argument_list try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list call attribute call attribute identifier identifier argument_list identifier argument_list identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier return_statement identifier except_clause as_pattern identifier as_pattern_target identifier block if_statement comparison_operator attribute identifier identifier integer block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement false raise_statement call identifier argument_list attribute identifier identifier
Use raw urlopen command.
def stop(self): if self.original_handler is not None: signal.signal(signal.SIGWINCH, self.original_handler)
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier
Stop trapping WINCH signals and restore the previous WINCH handler.
def save(self, t, base=0, heap=False): c, k = _keytuple(t) if k and k not in _typedefs: _typedefs[k] = self if c and c not in _typedefs: if t.__module__ in _builtin_modules: k = _kind_ignored else: k = self.kind _typedefs[c] = _Typedef(base=_basicsize(type(t), base=base, heap=heap), refs=_type_refs, both=False, kind=k, type=t) elif isbuiltin(t) and t not in _typedefs: _typedefs[t] = _Typedef(base=_basicsize(t, base=base), both=False, kind=_kind_ignored, type=t) else: raise KeyError('asizeof typedef %r bad: %r %r' % (self, (c, k), self.both))
module function_definition identifier parameters identifier identifier default_parameter identifier integer default_parameter identifier false block expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier if_statement boolean_operator identifier comparison_operator identifier identifier block expression_statement assignment subscript identifier identifier identifier if_statement boolean_operator identifier comparison_operator identifier identifier block if_statement comparison_operator attribute identifier identifier identifier block expression_statement assignment identifier identifier else_clause block expression_statement assignment identifier attribute identifier identifier expression_statement assignment subscript identifier identifier call identifier argument_list keyword_argument identifier call identifier argument_list call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier false keyword_argument identifier identifier keyword_argument identifier identifier elif_clause boolean_operator call identifier argument_list identifier comparison_operator identifier identifier block expression_statement assignment subscript identifier identifier call identifier argument_list keyword_argument identifier call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier false keyword_argument identifier identifier keyword_argument identifier identifier else_clause block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier tuple identifier identifier attribute identifier identifier
Save this typedef plus its class typedef.
def __get_host(node, vm_): if __get_ssh_interface(vm_) == 'private_ips' or vm_['external_ip'] is None: ip_address = node.private_ips[0] log.info('Salt node data. Private_ip: %s', ip_address) else: ip_address = node.public_ips[0] log.info('Salt node data. Public_ip: %s', ip_address) if ip_address: return ip_address return node.name
module function_definition identifier parameters identifier identifier block if_statement boolean_operator comparison_operator call identifier argument_list identifier string string_start string_content string_end comparison_operator subscript identifier string string_start string_content string_end none block expression_statement assignment identifier subscript attribute identifier identifier integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier else_clause block expression_statement assignment identifier subscript attribute identifier identifier integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement identifier block return_statement identifier return_statement attribute identifier identifier
Return public IP, private IP, or hostname for the libcloud 'node' object
def update_devices(self, devices): for qspacket in devices: try: qsid = qspacket[QS_ID] except KeyError: _LOGGER.debug("Device without ID: %s", qspacket) continue if qsid not in self: self[qsid] = QSDev(data=qspacket) dev = self[qsid] dev.data = qspacket newqs = _legacy_status(qspacket[QS_VALUE]) if dev.is_dimmer: newqs = min(round(math.pow(newqs, self.dim_adj)), 100) newin = round(newqs * _MAX / 100) if abs(dev.value - newin) > 1: _LOGGER.debug("%s qs=%s --> %s", qsid, newqs, newin) dev.value = newin self._cb_value_changed(self, qsid, newin)
module function_definition identifier parameters identifier identifier block for_statement identifier identifier block try_statement block expression_statement assignment identifier subscript identifier identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier continue_statement if_statement comparison_operator identifier identifier block expression_statement assignment subscript identifier identifier call identifier argument_list keyword_argument identifier identifier expression_statement assignment identifier subscript identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list subscript identifier identifier if_statement attribute identifier identifier block expression_statement assignment identifier call identifier argument_list call identifier argument_list call attribute identifier identifier argument_list identifier attribute identifier identifier integer expression_statement assignment identifier call identifier argument_list binary_operator binary_operator identifier identifier integer if_statement comparison_operator call identifier argument_list binary_operator attribute identifier identifier identifier integer block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier identifier
Update values from response of URL_DEVICES, callback if changed.
def check_initialized(method): def _decorator(self, *args, **kwargs): if self._arguments is None or self._options is None: raise RuntimeError('using an uninitialized configuration') return method(self, *args, **kwargs) return _decorator
module function_definition identifier parameters identifier block function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block if_statement boolean_operator comparison_operator attribute identifier identifier none comparison_operator attribute identifier identifier none block raise_statement call identifier argument_list string string_start string_content string_end return_statement call identifier argument_list identifier list_splat identifier dictionary_splat identifier return_statement identifier
Check that the configuration object was initialized.
def __add_import(self, original_token): sid = self.__new_sid() token = SymbolToken(original_token.text, sid, original_token.location) self.__add(token) return token
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list attribute identifier identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Adds a token, normalizing only the SID
def create_ca_bundle_for_names(self, bundle_name, names): records = [rec for name, rec in self.store.store.items() if name in names] return self.create_bundle( bundle_name, names=[r['parent_ca'] for r in records])
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier list_comprehension identifier for_in_clause pattern_list identifier identifier call attribute attribute attribute identifier identifier identifier identifier argument_list if_clause comparison_operator identifier identifier return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier list_comprehension subscript identifier string string_start string_content string_end for_in_clause identifier identifier
Create a CA bundle to trust only certs defined in names
def output_service(gandi, service, status, justify=10): output_line(gandi, service, status, justify)
module function_definition identifier parameters identifier identifier identifier default_parameter identifier integer block expression_statement call identifier argument_list identifier identifier identifier identifier
Helper to output a status service information.
def parse(self, buf): self._tokenizer = tokenize_asdl(buf) self._advance() return self._parse_module()
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list return_statement call attribute identifier identifier argument_list
Parse the ASDL in the buffer and return an AST with a Module root.
def parse_line(self, text, fh=None): match = self.ok.match(text) if match: return self._parse_result(True, match, fh) match = self.not_ok.match(text) if match: return self._parse_result(False, match, fh) if self.diagnostic.match(text): return Diagnostic(text) match = self.plan.match(text) if match: return self._parse_plan(match) match = self.bail.match(text) if match: return Bail(match.group("reason")) match = self.version.match(text) if match: return self._parse_version(match) return Unknown()
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement identifier block return_statement call attribute identifier identifier argument_list true identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement identifier block return_statement call attribute identifier identifier argument_list false identifier identifier if_statement call attribute attribute identifier identifier identifier argument_list identifier block return_statement call identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement identifier block return_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement identifier block return_statement call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement identifier block return_statement call attribute identifier identifier argument_list identifier return_statement call identifier argument_list
Parse a line into whatever TAP category it belongs.
def send_msg_to_clients(client_ids, msg, error=False): if error: stream = "stderr" else: stream = "stdout" response = [{"message": None, "type": "console", "payload": msg, "stream": stream}] for client_id in client_ids: logger.info("emiting message to websocket client id " + client_id) socketio.emit( "gdb_response", response, namespace="/gdb_listener", room=client_id )
module function_definition identifier parameters identifier identifier default_parameter identifier false block if_statement identifier block expression_statement assignment identifier string string_start string_content string_end else_clause block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier list dictionary pair string string_start string_content string_end none pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier for_statement identifier identifier 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 string string_start string_content string_end identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier
Send message to all clients
def array_sha256(a): dtype = str(a.dtype).encode() shape = numpy.array(a.shape) sha = hashlib.sha256() sha.update(dtype) sha.update(shape) sha.update(a.tobytes()) return sha.hexdigest()
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute call identifier argument_list attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list 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 call attribute identifier identifier argument_list return_statement call attribute identifier identifier argument_list
Create a SHA256 hash from a Numpy array.
def _simulate_mixture(self, op: ops.Operation, data: _StateAndBuffer, indices: List[int]) -> None: probs, unitaries = zip(*protocols.mixture(op)) index = np.random.choice(range(len(unitaries)), p=probs) shape = (2,) * (2 * len(indices)) unitary = unitaries[index].astype(self._dtype).reshape(shape) result = linalg.targeted_left_multiply(unitary, data.state, indices, out=data.buffer) data.buffer = data.state data.state = result
module function_definition identifier parameters identifier typed_parameter identifier type attribute identifier identifier typed_parameter identifier type identifier typed_parameter identifier type generic_type identifier type_parameter type identifier type none block expression_statement assignment pattern_list identifier identifier call identifier argument_list list_splat call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call identifier argument_list call identifier argument_list identifier keyword_argument identifier identifier expression_statement assignment identifier binary_operator tuple integer parenthesized_expression binary_operator integer call identifier argument_list identifier expression_statement assignment identifier call attribute call attribute subscript identifier identifier identifier argument_list attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier identifier keyword_argument identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier identifier
Simulate an op that is a mixtures of unitaries.
def _call_pip(self, name=None, prefix=None, extra_args=None, callback=None): cmd_list = self._pip_cmd(name=name, prefix=prefix) cmd_list.extend(extra_args) process_worker = ProcessWorker(cmd_list, pip=True, callback=callback) process_worker.sig_finished.connect(self._start) self._queue.append(process_worker) self._start() return process_worker
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier true keyword_argument identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list return_statement identifier
Call pip in QProcess worker.
def cli(obj): for k, v in obj.items(): if isinstance(v, list): v = ', '.join(v) click.echo('{:20}: {}'.format(k, v))
module function_definition identifier parameters identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier
Display client config downloaded from API server.
def _bowtie_args_from_config(data): config = data['config'] qual_format = config["algorithm"].get("quality_format", "") if qual_format.lower() == "illumina": qual_flags = ["--phred64-quals"] else: qual_flags = [] multi_mappers = config["algorithm"].get("multiple_mappers", True) multi_flags = ["-M", 1] if multi_mappers else ["-m", 1] multi_flags = [] if data["analysis"].lower().startswith("smallrna-seq") else multi_flags cores = config.get("resources", {}).get("bowtie", {}).get("cores", None) num_cores = config["algorithm"].get("num_cores", 1) core_flags = ["-p", str(num_cores)] if num_cores > 1 else [] return core_flags + qual_flags + multi_flags
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end string string_start string_end if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier list string string_start string_content string_end else_clause block expression_statement assignment identifier list expression_statement assignment identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end true expression_statement assignment identifier conditional_expression list string string_start string_content string_end integer identifier list string string_start string_content string_end integer expression_statement assignment identifier conditional_expression list call attribute call attribute subscript identifier string string_start string_content string_end identifier argument_list identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call attribute call attribute call attribute identifier identifier argument_list string string_start string_content string_end dictionary identifier argument_list string string_start string_content string_end dictionary identifier argument_list string string_start string_content string_end none expression_statement assignment identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end integer expression_statement assignment identifier conditional_expression list string string_start string_content string_end call identifier argument_list identifier comparison_operator identifier integer list return_statement binary_operator binary_operator identifier identifier identifier
Configurable high level options for bowtie.
def start_response(self, status = 200, headers = [], clearheaders = True, disabletransferencoding = False): "Start to send response" if self._sendHeaders: raise HttpProtocolException('Cannot modify response, headers already sent') self.status = status self.disabledeflate = disabletransferencoding if clearheaders: self.sent_headers = headers[:] else: self.sent_headers.extend(headers)
module function_definition identifier parameters identifier default_parameter identifier integer default_parameter identifier list default_parameter identifier true default_parameter identifier false block expression_statement string string_start string_content string_end if_statement attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier if_statement identifier block expression_statement assignment attribute identifier identifier subscript identifier slice else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Start to send response
def tweet_list_handler(request, tweet_list_builder, msg_prefix=""): tweets = tweet_list_builder(request.access_token()) print (len(tweets), 'tweets found') if tweets: twitter_cache.initialize_user_queue(user_id=request.access_token(), queue=tweets) text_to_read_out = twitter_cache.user_queue(request.access_token()).read_out_next(MAX_RESPONSE_TWEETS) message = msg_prefix + text_to_read_out + ", say 'next' to hear more, or reply to a tweet by number." return alexa.create_response(message=message, end_session=False) else: return alexa.create_response(message="Sorry, no tweets found, please try something else", end_session=False)
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_end block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list expression_statement call identifier argument_list call identifier argument_list identifier string string_start string_content string_end if_statement identifier block expression_statement call attribute identifier identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list keyword_argument identifier identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier argument_list identifier expression_statement assignment identifier binary_operator binary_operator identifier identifier string string_start string_content string_end return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier false else_clause block return_statement call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier false
This is a generic function to handle any intent that reads out a list of tweets
def map_azure_exceptions(key=None, exc_pass=()): from azure.common import AzureMissingResourceHttpError, AzureHttpError,\ AzureException try: yield except AzureMissingResourceHttpError as ex: if ex.__class__.__name__ not in exc_pass: s = str(ex) if s.startswith(u"The specified container does not exist."): raise IOError(s) raise KeyError(key) except AzureHttpError as ex: if ex.__class__.__name__ not in exc_pass: raise IOError(str(ex)) except AzureException as ex: if ex.__class__.__name__ not in exc_pass: raise IOError(str(ex))
module function_definition identifier parameters default_parameter identifier none default_parameter identifier tuple block import_from_statement dotted_name identifier identifier dotted_name identifier dotted_name identifier line_continuation dotted_name identifier try_statement block expression_statement yield except_clause as_pattern identifier as_pattern_target identifier block if_statement comparison_operator attribute attribute identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement call attribute identifier identifier argument_list string string_start string_content string_end block raise_statement call identifier argument_list identifier raise_statement call identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block if_statement comparison_operator attribute attribute identifier identifier identifier identifier block raise_statement call identifier argument_list call identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block if_statement comparison_operator attribute attribute identifier identifier identifier identifier block raise_statement call identifier argument_list call identifier argument_list identifier
Map Azure-specific exceptions to the simplekv-API.
def clone(self, repo, ref, deps=()): if os.path.isdir(repo): repo = os.path.abspath(repo) def clone_strategy(directory): env = git.no_git_env() def _git_cmd(*args): cmd_output('git', *args, cwd=directory, env=env) _git_cmd('init', '.') _git_cmd('remote', 'add', 'origin', repo) try: self._shallow_clone(ref, _git_cmd) except CalledProcessError: self._complete_clone(ref, _git_cmd) return self._new_repo(repo, ref, deps, clone_strategy)
module function_definition identifier parameters identifier identifier identifier default_parameter identifier tuple block if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list function_definition identifier parameters list_splat_pattern identifier block expression_statement call identifier argument_list string string_start string_content string_end list_splat identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement call identifier argument_list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier try_statement block expression_statement call attribute identifier identifier argument_list identifier identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list identifier identifier return_statement call attribute identifier identifier argument_list identifier identifier identifier identifier
Clone the given url and checkout the specific ref.
def highlightBlock(self, text): if self._allow_highlight: start = self.previousBlockState() + 1 end = start + len(text) for i, (fmt, letter) in enumerate(self._charlist[start:end]): self.setFormat(i, 1, fmt) self.setCurrentBlockState(end) self.highlight_spaces(text)
module function_definition identifier parameters identifier identifier block if_statement attribute identifier identifier block expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list integer expression_statement assignment identifier binary_operator identifier call identifier argument_list identifier for_statement pattern_list identifier tuple_pattern identifier identifier call identifier argument_list subscript attribute identifier identifier slice identifier identifier block expression_statement call attribute identifier identifier argument_list identifier integer identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier
Actually highlight the block
def lorentz_deriv((x, y, z), t0, sigma=10., beta=8./3, rho=28.0): return [sigma * (y - x), x * (rho - z) - y, x * y - beta * z]
module function_definition identifier parameters tuple_pattern identifier identifier identifier identifier default_parameter identifier float default_parameter identifier binary_operator float integer default_parameter identifier float block return_statement list binary_operator identifier parenthesized_expression binary_operator identifier identifier binary_operator binary_operator identifier parenthesized_expression binary_operator identifier identifier identifier binary_operator binary_operator identifier identifier binary_operator identifier identifier
Compute the time-derivative of a Lorentz system.
def reloc_var(var_name, reloc_delta, pointer, var_type): template = '{0} {3}{1} = RELOC_VAR(_{1}, {2}, {0});\n' return template.format( var_type, var_name, reloc_delta, '*' if pointer else '' )
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier string string_start string_content escape_sequence string_end return_statement call attribute identifier identifier argument_list identifier identifier identifier conditional_expression string string_start string_content string_end identifier string string_start string_end
Build C source code to relocate a variable.
def interface_by_name(self, name): if name in self._devinfo: return self._devinfo[name] raise KeyError("No device named {}".format(name))
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block return_statement subscript attribute identifier identifier identifier raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier
Given a device name, return the corresponding interface object
def update(context, resource, **kwargs): etag = kwargs.pop('etag') id = kwargs.pop('id') data = utils.sanitize_kwargs(**kwargs) uri = '%s/%s/%s' % (context.dci_cs_api, resource, id) r = context.session.put(uri, timeout=HTTP_TIMEOUT, headers={'If-match': etag}, json=data) return r
module function_definition identifier parameters identifier identifier dictionary_splat_pattern 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 string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list dictionary_splat identifier expression_statement assignment identifier binary_operator string string_start string_content string_end tuple attribute identifier identifier identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier dictionary pair string string_start string_content string_end identifier keyword_argument identifier identifier return_statement identifier
Update a specific resource
def _translate_struct(inner_dict): try: optional = inner_dict['optional'].items() required = inner_dict['required'].items() except KeyError as ex: raise DeserializationError("Missing key: {}".format(ex)) except AttributeError as ex: raise DeserializationError( "Invalid Structure: {}".format(inner_dict)) val_dict = {k: _translate(v) for k, v in required} val_dict.update({Optional(k): _translate(v) for k, v in optional}) return val_dict
module function_definition identifier parameters identifier block try_statement block expression_statement assignment identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list expression_statement assignment identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list except_clause as_pattern identifier as_pattern_target identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier dictionary_comprehension pair identifier call identifier argument_list identifier for_in_clause pattern_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list dictionary_comprehension pair call identifier argument_list identifier call identifier argument_list identifier for_in_clause pattern_list identifier identifier identifier return_statement identifier
Translate a teleport Struct into a val subschema.
def stop_recording(self): if not self._recording: raise Exception("Cannot stop a video recording when it's not recording!") self._cmd_q.put(('stop',)) self._recording = False
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list tuple string string_start string_content string_end expression_statement assignment attribute identifier identifier false
Stops writing video to file.
def _add_modifiers(self, sql, blueprint, column): for modifier in self._modifiers: method = '_modify_%s' % modifier if hasattr(self, method): sql += getattr(self, method)(blueprint, column) return sql
module function_definition identifier parameters identifier identifier identifier identifier block for_statement identifier attribute identifier identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end identifier if_statement call identifier argument_list identifier identifier block expression_statement augmented_assignment identifier call call identifier argument_list identifier identifier argument_list identifier identifier return_statement identifier
Add the column modifiers to the deifinition
def max_values(args): return Interval(max(x.low for x in args), max(x.high for x in args))
module function_definition identifier parameters identifier block return_statement call identifier argument_list call identifier generator_expression attribute identifier identifier for_in_clause identifier identifier call identifier generator_expression attribute identifier identifier for_in_clause identifier identifier
Return possible range for max function.
def load_adjustment_values(self, c): for mast in self: c.execute( ' SELECT name, val\n' ' FROM adjustment_values\n' ' WHERE prst = ?\n' 'ORDER BY seq_nmbr', (mast.prst,) ) for name, val in c: mast.adj_vals.append(AdjustmentValue(name, val))
module function_definition identifier parameters identifier identifier block for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content escape_sequence string_end string string_start string_content escape_sequence string_end string string_start string_content escape_sequence string_end string string_start string_content string_end tuple attribute identifier identifier for_statement pattern_list identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier identifier
load adjustment values for auto shape types in self
def mmap_key(metric_name, name, labelnames, labelvalues): labels = dict(zip(labelnames, labelvalues)) return json.dumps([metric_name, name, labels], sort_keys=True)
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier identifier return_statement call attribute identifier identifier argument_list list identifier identifier identifier keyword_argument identifier true
Format a key for use in the mmap file.
def broadcast(self): log.debug("Broadcasting M-SEARCH to %s:%s", self.mcast_ip, self.mcast_port) request = '\r\n'.join(("M-SEARCH * HTTP/1.1", "HOST:{mcast_ip}:{mcast_port}", "ST:upnp:rootdevice", "MX:2", 'MAN:"ssdp:discover"', "", "")).format(**self.__dict__) self.server.sendto(request.encode(), (self.mcast_ip, self.mcast_port))
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute call attribute string string_start string_content escape_sequence escape_sequence string_end identifier argument_list tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_end string string_start string_end identifier argument_list dictionary_splat attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list tuple attribute identifier identifier attribute identifier identifier
Send a multicast M-SEARCH request asking for devices to report in.
def app_to_object(self): if self.tagClass != Tag.applicationTagClass: raise ValueError("application tag required") klass = self._app_tag_class[self.tagNumber] if not klass: return None return klass(self)
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier subscript attribute identifier identifier attribute identifier identifier if_statement not_operator identifier block return_statement none return_statement call identifier argument_list identifier
Return the application object encoded by the tag.
def to_eng(num_in): x = decimal.Decimal(str(num_in)) eng_not = x.normalize().to_eng_string() return(eng_not)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list return_statement parenthesized_expression identifier
Return number in engineering notation.
def create(prefix, params, hint): current = getattr(_BlockScope._current, "value", None) if current is None: if prefix is None: if not hasattr(_name.NameManager._current, "value"): _name.NameManager._current.value = _name.NameManager() prefix = _name.NameManager._current.value.get(None, hint) + '_' if params is None: params = ParameterDict(prefix) else: params = ParameterDict(params.prefix, params) return prefix, params if prefix is None: count = current._counter.get(hint, 0) prefix = '%s%d_'%(hint, count) current._counter[hint] = count + 1 if params is None: parent = current._block.params params = ParameterDict(parent.prefix+prefix, parent._shared) else: params = ParameterDict(params.prefix, params) return current._block.prefix+prefix, params
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier string string_start string_content string_end none if_statement comparison_operator identifier none block if_statement comparison_operator identifier none block if_statement not_operator call identifier argument_list attribute attribute identifier identifier identifier string string_start string_content string_end block expression_statement assignment attribute attribute attribute identifier identifier identifier identifier call attribute identifier identifier argument_list expression_statement assignment identifier binary_operator call attribute attribute attribute attribute identifier identifier identifier identifier identifier argument_list none identifier string string_start string_content string_end if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list identifier else_clause block expression_statement assignment identifier call identifier argument_list attribute identifier identifier identifier return_statement expression_list identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier integer expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier identifier expression_statement assignment subscript attribute identifier identifier identifier binary_operator identifier integer if_statement comparison_operator identifier none block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list binary_operator attribute identifier identifier identifier attribute identifier identifier else_clause block expression_statement assignment identifier call identifier argument_list attribute identifier identifier identifier return_statement expression_list binary_operator attribute attribute identifier identifier identifier identifier identifier
Creates prefix and params for new `Block`.
def on_mouse_release(self, x: int, y: int, button, mods): if button in [1, 4]: self.example.mouse_release_event( x, self.buffer_height - y, 1 if button == 1 else 2, )
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type identifier identifier identifier block if_statement comparison_operator identifier list integer integer block expression_statement call attribute attribute identifier identifier identifier argument_list identifier binary_operator attribute identifier identifier identifier conditional_expression integer comparison_operator identifier integer integer
Handle mouse release events and forward to example window
def compute_result_enum(self) -> RobotScanResultEnum: for payload_enum, server_responses in self._payload_responses.items(): if server_responses[0] != server_responses[1]: return RobotScanResultEnum.UNKNOWN_INCONSISTENT_RESULTS if len(set([server_responses[0] for server_responses in self._payload_responses.values()])) == 1: return RobotScanResultEnum.NOT_VULNERABLE_NO_ORACLE response_1 = self._payload_responses[RobotPmsPaddingPayloadEnum.WRONG_FIRST_TWO_BYTES][0] response_2 = self._payload_responses[RobotPmsPaddingPayloadEnum.WRONG_POSITION_00][0] response_3 = self._payload_responses[RobotPmsPaddingPayloadEnum.NO_00_IN_THE_MIDDLE][0] if response_1 == response_2 == response_3: return RobotScanResultEnum.VULNERABLE_WEAK_ORACLE else: return RobotScanResultEnum.VULNERABLE_STRONG_ORACLE
module function_definition identifier parameters identifier type identifier block for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block if_statement comparison_operator subscript identifier integer subscript identifier integer block return_statement attribute identifier identifier if_statement comparison_operator call identifier argument_list call identifier argument_list list_comprehension subscript identifier integer for_in_clause identifier call attribute attribute identifier identifier identifier argument_list integer block return_statement attribute identifier identifier expression_statement assignment identifier subscript subscript attribute identifier identifier attribute identifier identifier integer expression_statement assignment identifier subscript subscript attribute identifier identifier attribute identifier identifier integer expression_statement assignment identifier subscript subscript attribute identifier identifier attribute identifier identifier integer if_statement comparison_operator identifier identifier identifier block return_statement attribute identifier identifier else_clause block return_statement attribute identifier identifier
Look at the server's response to each ROBOT payload and return the conclusion of the analysis.
def create_tab(self, location=None): eb = self._get_or_create_editor_buffer(location) self.tab_pages.insert(self.active_tab_index + 1, TabPage(Window(eb))) self.active_tab_index += 1
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator attribute identifier identifier integer call identifier argument_list call identifier argument_list identifier expression_statement augmented_assignment attribute identifier identifier integer
Create a new tab page.
def pull_parent(collector, image, **kwargs): log.warning("DEPRECATED - use pull_dependencies instead") pull_dependencies(collector, image, **kwargs)
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list identifier identifier dictionary_splat identifier
DEPRECATED - use pull_dependencies instead
def execute(self, query): c = self.conn.cursor() result = c.execute(query) for i in result: yield i
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement identifier identifier block expression_statement yield identifier
Execute a query directly on the database.
def update(self, **kwargs): data = kwargs.get('data') if data is not None: if (util.pd and isinstance(data, util.pd.DataFrame) and list(data.columns) != list(self.data.columns) and self._index): data = data.reset_index() self.verify(data) kwargs['data'] = self._concat(data) self._count += 1 super(Buffer, self).update(**kwargs)
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier none block if_statement parenthesized_expression boolean_operator boolean_operator boolean_operator attribute identifier identifier call identifier argument_list identifier attribute attribute identifier identifier identifier comparison_operator call identifier argument_list attribute identifier identifier call identifier argument_list attribute attribute identifier identifier identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list identifier expression_statement augmented_assignment attribute identifier identifier integer expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list dictionary_splat identifier
Overrides update to concatenate streamed data up to defined length.
def load_segment(self, f, is_irom_segment=False): file_offs = f.tell() (offset, size) = struct.unpack('<II', f.read(8)) self.warn_if_unusual_segment(offset, size, is_irom_segment) segment_data = f.read(size) if len(segment_data) < size: raise FatalError('End of file reading segment 0x%x, length %d (actual length %d)' % (offset, size, len(segment_data))) segment = ImageSegment(offset, segment_data, file_offs) self.segments.append(segment) return segment
module function_definition identifier parameters identifier identifier default_parameter identifier false block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment tuple_pattern identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement identifier
Load the next segment from the image file
def validate(self): if self.validation_state != ValidationState.UNKNOWN: return self.validation_state == ValidationState.VALID if self.validator: try: self.validator.validate(self.document) except ValidationError as e: cursor_position = e.cursor_position self.cursor_position = min(max(0, cursor_position), len(self.text)) self.validation_state = ValidationState.INVALID self.validation_error = e return False self.validation_state = ValidationState.VALID self.validation_error = None return True
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block return_statement comparison_operator attribute identifier identifier attribute identifier identifier if_statement attribute identifier identifier block try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list call identifier argument_list integer identifier call identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier identifier return_statement false expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier none return_statement true
Returns `True` if valid.
def setup_options(opts): if opts.quiet: logger.log.setLevel(logging.WARNING) logger.GLOBAL_LOG_LEVEL = logging.WARNING if opts.verbose: logger.log.setLevel(logging.DEBUG) logger.GLOBAL_LOG_LEVEL = logging.DEBUG
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier
Takes any actions necessary based on command line options
def match_date(self, value, strict=False): value = stringify(value) try: parse(value) except Exception: self.shout('Value %r is not a valid date', strict, value)
module function_definition identifier parameters identifier identifier default_parameter identifier false block expression_statement assignment identifier call identifier argument_list identifier try_statement block expression_statement call identifier argument_list identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier
if value is a date
def ls(types, as_json): sensors = W1ThermSensor.get_available_sensors(types) if as_json: data = [ {"id": i, "hwid": s.id, "type": s.type_name} for i, s in enumerate(sensors, 1) ] click.echo(json.dumps(data, indent=4, sort_keys=True)) else: click.echo( "Found {0} sensors:".format(click.style(str(len(sensors)), bold=True)) ) for i, sensor in enumerate(sensors, 1): click.echo( " {0}. HWID: {1} Type: {2}".format( click.style(str(i), bold=True), click.style(sensor.id, bold=True), click.style(sensor.type_name, bold=True), ) )
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement assignment identifier list_comprehension dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier for_in_clause pattern_list identifier identifier call identifier argument_list identifier integer expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier integer keyword_argument identifier true else_clause block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list call identifier argument_list call identifier argument_list identifier keyword_argument identifier true for_statement pattern_list identifier identifier call identifier argument_list identifier integer block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list call identifier argument_list identifier keyword_argument identifier true call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier true call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier true
List all available sensors
def ssh_user(self, cluster='main'): if not self.config.has_section(cluster): raise SystemExit("Cluster '%s' not defined in %s" % (cluster, self.config_file)) try: return self.config.get(cluster, 'ssh_user') except NoOptionError: return pwd.getpwuid(os.getuid()).pw_name
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier attribute identifier identifier try_statement block return_statement call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end except_clause identifier block return_statement attribute call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier
Return the ssh user for a cluster or current user if undefined.
def _button_plus_clicked(self, n): self._button_save.setEnabled(True) self.insert_colorpoint(self._colorpoint_list[n][0], self._colorpoint_list[n][1], self._colorpoint_list[n][2]) self._build_gui()
module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list true expression_statement call attribute identifier identifier argument_list subscript subscript attribute identifier identifier identifier integer subscript subscript attribute identifier identifier identifier integer subscript subscript attribute identifier identifier identifier integer expression_statement call attribute identifier identifier argument_list
Create a new colorpoint.
def cli(conf): if conf: if not os.path.isfile(conf): raise click.exceptions.BadParameter("{} is not a file".format(conf)) try: config.conf.load_config(config_path=conf) except exceptions.ConfigurationException as e: raise click.exceptions.BadParameter(str(e)) twisted_observer = legacy_twisted_log.PythonLoggingObserver() twisted_observer.start() config.conf.setup_logging()
module function_definition identifier parameters identifier block if_statement identifier block if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block raise_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier except_clause as_pattern attribute identifier identifier as_pattern_target identifier block raise_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list
The fedora-messaging command line interface.
def do_imports(self): self.do_import('worker_class', Worker) self.do_import('queue_model', self.options.worker_class.queue_model) self.do_import('error_model', self.options.worker_class.error_model) self.do_import('callback', self.options.worker_class.callback)
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute attribute attribute identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute attribute attribute identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute attribute attribute identifier identifier identifier identifier
Import all importable options
def _render_html(self, libraries): title = self.options.get("title", "Keyword Documentation") date = time.strftime("%A %B %d, %I:%M %p") cci_version = cumulusci.__version__ stylesheet_path = os.path.join(os.path.dirname(__file__), "stylesheet.css") with open(stylesheet_path) as f: stylesheet = f.read() jinjaenv = jinja2.Environment( loader=jinja2.FileSystemLoader(os.path.dirname(__file__)), autoescape=False ) jinjaenv.filters["robot_html"] = robot.utils.html_format template = jinjaenv.get_template("template.html") return template.render( libraries=libraries, title=title, cci_version=cci_version, stylesheet=stylesheet, date=date, )
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end with_statement with_clause with_item as_pattern call identifier argument_list identifier as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier false expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end attribute attribute identifier identifier identifier 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 keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
Generate the html. `libraries` is a list of LibraryDocumentation objects
def list_features(self): response, status_code = self.__pod__.System.get_v1_admin_system_features_list( sessionToken=self.__session__ ).result() self.logger.debug('%s: %s' % (status_code, response)) return status_code, response
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier call attribute call attribute attribute attribute identifier identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier return_statement expression_list identifier identifier
list features the pod supports
def people(self): if self.cache['people']: return self.cache['people'] people_xml = self.bc.people_within_project(self.id) for person_node in ET.fromstring(people_xml).findall('person'): p = Person(person_node) self.cache['people'][p.id] = p return self.cache['people']
module function_definition identifier parameters identifier block if_statement subscript attribute identifier identifier string string_start string_content string_end block return_statement subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier for_statement identifier call attribute call attribute identifier identifier argument_list identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment subscript subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier identifier return_statement subscript attribute identifier identifier string string_start string_content string_end
Dictionary of people on the project, keyed by id
def upload_prev(ver, doc_root='./'): 'push a copy of older release to appropriate version directory' local_dir = doc_root + 'build/html' remote_dir = '/usr/share/nginx/pandas/pandas-docs/version/%s/' % ver cmd = 'cd %s; rsync -avz . pandas@pandas.pydata.org:%s -essh' cmd = cmd % (local_dir, remote_dir) print cmd if os.system(cmd): raise SystemExit( 'Upload to %s from %s failed' % (remote_dir, local_dir)) local_dir = doc_root + 'build/latex' pdf_cmd = 'cd %s; scp pandas.pdf pandas@pandas.pydata.org:%s' pdf_cmd = pdf_cmd % (local_dir, remote_dir) if os.system(pdf_cmd): raise SystemExit('Upload PDF to %s from %s failed' % (ver, doc_root))
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block expression_statement string string_start string_content string_end expression_statement assignment identifier binary_operator identifier string string_start string_content string_end expression_statement assignment identifier binary_operator string string_start string_content string_end identifier expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier binary_operator identifier tuple identifier identifier print_statement identifier if_statement call attribute identifier identifier argument_list identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier expression_statement assignment identifier binary_operator identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier binary_operator identifier tuple identifier identifier if_statement call attribute identifier identifier argument_list identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier
push a copy of older release to appropriate version directory
def collect(self): for root, dirname, files in walk(self.migration_home): for file_name in file_filter(files, "*.py"): file_name = file_name.replace('.py', '') file = None try: if file_name == '__init__': continue file, pathname, description = find_module( file_name, [root]) load_module(file_name, file, pathname, description) finally: if file is not None: file.close()
module function_definition identifier parameters identifier block for_statement pattern_list identifier identifier identifier call identifier argument_list attribute identifier identifier block for_statement identifier call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end expression_statement assignment identifier none try_statement block if_statement comparison_operator identifier string string_start string_content string_end block continue_statement expression_statement assignment pattern_list identifier identifier identifier call identifier argument_list identifier list identifier expression_statement call identifier argument_list identifier identifier identifier identifier finally_clause block if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list
Walks self.migration_home and load all potential migration modules
def can_subscribe_to_topic(self, topic, user): return ( user.is_authenticated and not topic.has_subscriber(user) and self._perform_basic_permission_check(topic.forum, user, 'can_read_forum') )
module function_definition identifier parameters identifier identifier identifier block return_statement parenthesized_expression boolean_operator boolean_operator attribute identifier identifier not_operator call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list attribute identifier identifier identifier string string_start string_content string_end
Given a topic, checks whether the user can add it to their subscription list.
def config(self, configlet, plane, **attributes): try: config_text = configlet.format(**attributes) except KeyError as exp: raise CommandSyntaxError("Configuration template error: {}".format(str(exp))) return self.driver.config(config_text, plane)
module function_definition identifier parameters identifier identifier identifier dictionary_splat_pattern identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list dictionary_splat identifier except_clause as_pattern identifier as_pattern_target identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier identifier
Apply config to the device.
def _stringify_number(v): if isinstance(v, (float, Decimal)): if math.isinf(v) and v > 0: v = 'Infinity' elif math.isinf(v) and v < 0: v = '-Infinity' else: v = '{:f}'.format(v) elif isinstance(v, BinarySize): v = '{:d}'.format(int(v)) elif isinstance(v, int): v = '{:d}'.format(v) else: v = str(v) return v
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier tuple identifier identifier block if_statement boolean_operator call attribute identifier identifier argument_list identifier comparison_operator identifier integer block expression_statement assignment identifier string string_start string_content string_end elif_clause boolean_operator call attribute identifier identifier argument_list identifier comparison_operator identifier integer block expression_statement assignment identifier string string_start string_content string_end else_clause block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier elif_clause call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier elif_clause call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier else_clause block expression_statement assignment identifier call identifier argument_list identifier return_statement identifier
Stringify a number, preventing unwanted scientific notations.
def check_options(options, parser): if not options.get('release_environment', None): print("release environment is required") parser.print_help() return os.EX_USAGE return 0
module function_definition identifier parameters identifier identifier block if_statement not_operator call attribute identifier identifier argument_list string string_start string_content string_end none block expression_statement call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list return_statement attribute identifier identifier return_statement integer
check options requirements, print and return exit value
def _list2array(lst): if lst and isinstance(lst[0], cp.ndarray): return cp.hstack(lst) else: return cp.asarray(lst)
module function_definition identifier parameters identifier block if_statement boolean_operator identifier call identifier argument_list subscript identifier integer attribute identifier identifier block return_statement call attribute identifier identifier argument_list identifier else_clause block return_statement call attribute identifier identifier argument_list identifier
Convert a list to a numpy array.
def open(self, path, mode='r', *args, **kwargs): return open(os.path.join(os.path.dirname(self.path), path), mode=mode, *args, **kwargs)
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end list_splat_pattern identifier dictionary_splat_pattern identifier block return_statement call identifier argument_list call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier keyword_argument identifier identifier list_splat identifier dictionary_splat identifier
Proxy to function `open` with path to the current file.
def to_pickle(self, filename): with open(filename, 'wb') as f: pickle.dump(self, f)
module function_definition identifier parameters identifier identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier identifier
Save Camera to a pickle file, given a filename.
def printParams(paramDictionary, all=False, log=None): if log is not None: def output(msg): log.info(msg) else: def output(msg): print(msg) if not paramDictionary: output('No parameters were supplied') else: for key in sorted(paramDictionary): if all or (not isinstance(paramDictionary[key], dict)) \ and key[0] != '_': output('\t' + '\t'.join([str(key) + ' :', str(paramDictionary[key])])) if log is None: output('\n')
module function_definition identifier parameters identifier default_parameter identifier false default_parameter identifier none block if_statement comparison_operator identifier none block function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list identifier else_clause block function_definition identifier parameters identifier block expression_statement call identifier argument_list identifier if_statement not_operator identifier block expression_statement call identifier argument_list string string_start string_content string_end else_clause block for_statement identifier call identifier argument_list identifier block if_statement boolean_operator identifier boolean_operator parenthesized_expression not_operator call identifier argument_list subscript identifier identifier identifier line_continuation comparison_operator subscript identifier integer string string_start string_content string_end block expression_statement call identifier argument_list binary_operator string string_start string_content escape_sequence string_end call attribute string string_start string_content escape_sequence string_end identifier argument_list list binary_operator call identifier argument_list identifier string string_start string_content string_end call identifier argument_list subscript identifier identifier if_statement comparison_operator identifier none block expression_statement call identifier argument_list string string_start string_content escape_sequence string_end
Print nicely the parameters from the dictionary.
def set(*args, **kw): if len(args) == 0: if len(kw) != 0: for keyword, value in kw.items(): keyword = untranslateName(keyword) svalue = str(value) _varDict[keyword] = svalue else: listVars(prefix=" ", equals="=") else: if (len(args) != 1 or len(kw) != 0 or not isinstance(args[0], string_types) or args[0][:1] != '@'): raise SyntaxError("set requires name=value pairs")
module function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block if_statement comparison_operator call identifier argument_list identifier integer block if_statement comparison_operator call identifier argument_list identifier integer block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment subscript identifier identifier identifier else_clause block expression_statement call identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end else_clause block if_statement parenthesized_expression boolean_operator boolean_operator boolean_operator comparison_operator call identifier argument_list identifier integer comparison_operator call identifier argument_list identifier integer not_operator call identifier argument_list subscript identifier integer identifier comparison_operator subscript subscript identifier integer slice integer string string_start string_content string_end block raise_statement call identifier argument_list string string_start string_content string_end
Set IRAF environment variables.
def update_line(self, trace, xdata, ydata, side='left', draw=False, update_limits=True): x = self.conf.get_mpl_line(trace) x.set_data(xdata, ydata) datarange = [xdata.min(), xdata.max(), ydata.min(), ydata.max()] self.conf.set_trace_datarange(datarange, trace=trace) axes = self.axes if side == 'right': axes = self.get_right_axes() if update_limits: self.set_viewlimits() if draw: self.draw()
module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier string string_start string_content string_end default_parameter identifier false default_parameter identifier true block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier list call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement identifier block expression_statement call attribute identifier identifier argument_list if_statement identifier block expression_statement call attribute identifier identifier argument_list
update a single trace, for faster redraw
def devectorize_utterance(self, utterance): utterance = self.swap_pad_and_zero(utterance) return self.ie.inverse_transform(utterance).tolist()
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement call attribute call attribute attribute identifier identifier identifier argument_list identifier identifier argument_list
Take in a sequence of indices and transform it back into a tokenized utterance
def fourier(x, N): term = 0. for n in range(1, N, 2): term += (1. / n) * math.sin(n * math.pi * x / L) return (4. / (math.pi)) * term
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier float for_statement identifier call identifier argument_list integer identifier integer block expression_statement augmented_assignment identifier binary_operator parenthesized_expression binary_operator float identifier call attribute identifier identifier argument_list binary_operator binary_operator binary_operator identifier attribute identifier identifier identifier identifier return_statement binary_operator parenthesized_expression binary_operator float parenthesized_expression attribute identifier identifier identifier
Fourier approximation with N terms
def ask_for_input_with_prompt(cls, ui, prompt='', **options): return cls.get_appropriate_helper(ui).ask_for_input_with_prompt(prompt=prompt, **options)
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_end dictionary_splat_pattern identifier block return_statement call attribute call attribute identifier identifier argument_list identifier identifier argument_list keyword_argument identifier identifier dictionary_splat identifier
Ask user for written input with prompt
def all_matches(grammar, text): for tokens, start, stop in grammar.parseWithTabs().scanString(text): yield unpack(tokens), start, stop
module function_definition identifier parameters identifier identifier block for_statement pattern_list identifier identifier identifier call attribute call attribute identifier identifier argument_list identifier argument_list identifier block expression_statement yield expression_list call identifier argument_list identifier identifier identifier
Find all matches for grammar in text.
def GetPattern(self): stoptimes = self.GetStopTimes() return tuple(st.stop for st in stoptimes)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list return_statement call identifier generator_expression attribute identifier identifier for_in_clause identifier identifier
Return a tuple of Stop objects, in the order visited
def _validate_cmdfinalization_callable(cls, func: Callable[[plugin.CommandFinalizationData], plugin.CommandFinalizationData]) -> None: cls._validate_callable_param_count(func, 1) signature = inspect.signature(func) _, param = list(signature.parameters.items())[0] if param.annotation != plugin.CommandFinalizationData: raise TypeError("{} must have one parameter declared with type " "'cmd2.plugin.CommandFinalizationData'".format(func.__name__)) if signature.return_annotation != plugin.CommandFinalizationData: raise TypeError("{} must declare return a return type of " "'cmd2.plugin.CommandFinalizationData'".format(func.__name__))
module function_definition identifier parameters identifier typed_parameter identifier type generic_type identifier type_parameter type list attribute identifier identifier type attribute identifier identifier type none block expression_statement call attribute identifier identifier argument_list identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment pattern_list identifier identifier subscript call identifier argument_list call attribute attribute identifier identifier identifier argument_list integer if_statement comparison_operator attribute identifier identifier attribute identifier identifier block raise_statement call identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list attribute identifier identifier if_statement comparison_operator attribute identifier identifier attribute identifier identifier block raise_statement call identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list attribute identifier identifier
Check parameter and return types for command finalization hooks.
def decorator(target): def decorate(fn): spec = inspect.getargspec(fn) names = tuple(spec[0]) + spec[1:3] + (fn.__name__,) targ_name, fn_name = unique_symbols(names, 'target', 'fn') metadata = dict(target=targ_name, fn=fn_name) metadata.update(format_argspec_plus(spec, grouped=False)) code = 'lambda %(args)s: %(target)s(%(fn)s, %(apply_kw)s)' % ( metadata) decorated = eval(code, {targ_name: target, fn_name: fn}) decorated.__defaults__ = getattr(fn, 'im_func', fn).__defaults__ return update_wrapper(decorated, fn) return update_wrapper(decorate, target)
module function_definition identifier parameters identifier block function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator binary_operator call identifier argument_list subscript identifier integer subscript identifier slice integer integer tuple attribute identifier identifier expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier keyword_argument identifier false expression_statement assignment identifier binary_operator string string_start string_content string_end parenthesized_expression identifier expression_statement assignment identifier call identifier argument_list identifier dictionary pair identifier identifier pair identifier identifier expression_statement assignment attribute identifier identifier attribute call identifier argument_list identifier string string_start string_content string_end identifier identifier return_statement call identifier argument_list identifier identifier return_statement call identifier argument_list identifier identifier
A signature-matching decorator factory.
def at_line(self, line: FileLine) -> Iterator[Statement]: num = line.num for stmt in self.in_file(line.filename): if stmt.location.start.line == num: yield stmt
module function_definition identifier parameters identifier typed_parameter identifier type identifier type generic_type identifier type_parameter type identifier block expression_statement assignment identifier attribute identifier identifier for_statement identifier call attribute identifier identifier argument_list attribute identifier identifier block if_statement comparison_operator attribute attribute attribute identifier identifier identifier identifier identifier block expression_statement yield identifier
Returns an iterator over all of the statements located at a given line.
def _get_baremetal_switch_info(self, link_info): try: switch_info = link_info['switch_info'] if not isinstance(switch_info, dict): switch_info = jsonutils.loads(switch_info) except Exception as e: LOG.error("switch_info can't be decoded: %(exp)s", {"exp": e}) switch_info = {} return switch_info
module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment identifier subscript identifier string string_start string_content string_end if_statement not_operator call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end dictionary pair string string_start string_content string_end identifier expression_statement assignment identifier dictionary return_statement identifier
Get switch_info dictionary from context.
def namespace_inclusion_builder(namespace: Strings) -> NodePredicate: if isinstance(namespace, str): def namespace_filter(_: BELGraph, node: BaseEntity) -> bool: return NAMESPACE in node and node[NAMESPACE] == namespace elif isinstance(namespace, Iterable): namespaces = set(namespace) def namespace_filter(_: BELGraph, node: BaseEntity) -> bool: return NAMESPACE in node and node[NAMESPACE] in namespaces else: raise TypeError('Invalid type for argument: {}'.format(namespace)) return namespace_filter
module function_definition identifier parameters typed_parameter identifier type identifier type identifier block if_statement call identifier argument_list identifier identifier block function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type identifier type identifier block return_statement boolean_operator comparison_operator identifier identifier comparison_operator subscript identifier identifier identifier elif_clause call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type identifier type identifier block return_statement boolean_operator comparison_operator identifier identifier comparison_operator subscript identifier identifier identifier else_clause block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier return_statement identifier
Build a predicate for namespace inclusion.
def randomString(length, chrs=None): if chrs is None: return getBytes(length) else: n = len(chrs) return ''.join([chrs[randrange(n)] for _ in xrange(length)])
module function_definition identifier parameters identifier default_parameter identifier none block if_statement comparison_operator identifier none block return_statement call identifier argument_list identifier else_clause block expression_statement assignment identifier call identifier argument_list identifier return_statement call attribute string string_start string_end identifier argument_list list_comprehension subscript identifier call identifier argument_list identifier for_in_clause identifier call identifier argument_list identifier
Produce a string of length random bytes, chosen from chrs.
def _check_app_is_valid(client): try: if 'refresh_token' in client.creds: client.exchange_refresh_token() else: existing.get_token_info() return True except TokenEndpointError as e: return False
module function_definition identifier parameters identifier block try_statement block if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement call attribute identifier identifier argument_list else_clause block expression_statement call attribute identifier identifier argument_list return_statement true except_clause as_pattern identifier as_pattern_target identifier block return_statement false
Check to see if the app has valid creds.
def _translate_src_register_oprnd(self, operand): reg_info = self._arch_alias_mapper.get(operand.name, None) if reg_info: var_base_name, offset = reg_info var_size = self._arch_regs_size[var_base_name] else: var_base_name = operand.name var_size = operand.size var_name = self._get_var_name(var_base_name) ret_val = self.make_bitvec(var_size, var_name) if reg_info: ret_val = smtfunction.extract(ret_val, offset, operand.size) return ret_val
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier none if_statement identifier block expression_statement assignment pattern_list identifier identifier identifier expression_statement assignment identifier subscript attribute identifier identifier identifier else_clause block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier attribute identifier identifier return_statement identifier
Translate source register operand to SMT expr.
def objects_to_record(self): o = self.get_object() o.about = self._bundle.metadata.about o.identity = self._dataset.identity.ident_dict o.names = self._dataset.identity.names_dict o.contacts = self._bundle.metadata.contacts self.set_object(o)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier attribute attribute attribute identifier identifier identifier identifier expression_statement assignment attribute identifier identifier attribute attribute attribute identifier identifier identifier identifier expression_statement assignment attribute identifier identifier attribute attribute attribute identifier identifier identifier identifier expression_statement assignment attribute identifier identifier attribute attribute attribute identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier
Write from object metadata to the record. Note that we don't write everything
def add(self, labels, value): if type(value) not in (float, int): raise TypeError("Summary only works with digits (int, float)") with mutex: try: e = self.get_value(labels) except KeyError: e = quantile.Estimator(*self.__class__.DEFAULT_INVARIANTS) self.set_value(labels, e) e.observe(float(value))
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator call identifier argument_list identifier tuple identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end with_statement with_clause with_item identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause identifier block expression_statement assignment identifier call attribute identifier identifier argument_list list_splat attribute attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier
Add adds a single observation to the summary.
def _get_post_data_to_create_dns_entry(self, rtype, name, content, identifier=None): is_update = identifier is not None if is_update: records = self._list_records_internal(identifier=identifier) assert len(records) == 1, 'ID is not unique or does not exist' record = records[0] LOGGER.debug('Create post data to update record: %s', record) data = { 'id': str(identifier) if is_update else '', 'action': 'save', 'name': name, 'type': rtype, 'content': content, 'prio': str(record['priority']) if is_update else '10', 'ttl': str(record['ttl']) if is_update else '360', 'commit': '' } ttl = self._get_lexicon_option('ttl') if ttl and ttl > 360: data['ttl'] = str(ttl) prio = self._get_lexicon_option('priority') if prio and prio > 0: data['prio'] = str(prio) return data
module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier none block expression_statement assignment identifier comparison_operator identifier none if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier assert_statement comparison_operator call identifier argument_list identifier integer string string_start string_content string_end expression_statement assignment identifier subscript identifier integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end conditional_expression call identifier argument_list identifier identifier string string_start string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end 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 conditional_expression call identifier argument_list subscript identifier string string_start string_content string_end identifier string string_start string_content string_end pair string string_start string_content string_end conditional_expression call identifier argument_list subscript identifier string string_start string_content string_end identifier string string_start string_content string_end pair string string_start string_content string_end string string_start string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement boolean_operator identifier comparison_operator identifier integer block expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement boolean_operator identifier comparison_operator identifier integer block expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list identifier return_statement identifier
Build and return the post date that is needed to create a DNS entry.
def descape(self, string, defs=None): if defs is None: defs = html_entities.entitydefs f = lambda m: defs[m.group(1)] if len(m.groups()) > 0 else m.group(0) return self.html_entity_re.sub(f, string)
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier lambda lambda_parameters identifier conditional_expression subscript identifier call attribute identifier identifier argument_list integer comparison_operator call identifier argument_list call attribute identifier identifier argument_list integer call attribute identifier identifier argument_list integer return_statement call attribute attribute identifier identifier identifier argument_list identifier identifier
Decodes html entities from a given string
def from_url(cls, url, **kwargs): url = urllib3.util.parse_url(url) if url.host: kwargs.setdefault('host', url.host) if url.port: kwargs.setdefault('port', url.port) if url.scheme == 'https': kwargs.setdefault('connection_class', urllib3.HTTPSConnectionPool) return cls(**kwargs)
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier return_statement call identifier argument_list dictionary_splat identifier
Create a client from a url.
def _backward_delete_char(text, pos): if pos == 0: return text, pos return text[:pos - 1] + text[pos:], pos - 1
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier integer block return_statement expression_list identifier identifier return_statement expression_list binary_operator subscript identifier slice binary_operator identifier integer subscript identifier slice identifier binary_operator identifier integer
Delete the character behind pos.
def inject_context(self): navbar = filter(lambda entry: entry.visible, self.navbar_entries) return {'navbar': navbar}
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list lambda lambda_parameters identifier attribute identifier identifier attribute identifier identifier return_statement dictionary pair string string_start string_content string_end identifier
Return a dict used for a template context.
def user_agent(self): components = ["/".join(x) for x in self.user_agent_components.items()] return " ".join(components)
module function_definition identifier parameters identifier block expression_statement assignment identifier list_comprehension call attribute string string_start string_content string_end identifier argument_list identifier for_in_clause identifier call attribute attribute identifier identifier identifier argument_list return_statement call attribute string string_start string_content string_end identifier argument_list identifier
Return the formatted user agent string.