code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def init_database(self): with contextlib.closing(self.database.cursor()) as cursor: cursor.execute( )
module function_definition identifier parameters identifier block with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list
Initialize database, if it has not been initialized yet.
def templatesCollector(text, open, close): others = [] spans = [i for i in findBalanced(text, open, close)] spanscopy = copy(spans) for i in range(len(spans)): start, end = spans[i] o = text[start:end] ol = o.lower() if 'vaata|' in ol or 'wikitable' in ol: spanscopy.remove(spans[i]) continue others.append(o) text = dropSpans(spanscopy, text) return text, others
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier list expression_statement assignment identifier list_comprehension identifier for_in_clause identifier call identifier argument_list identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier for_statement identifier call identifier argument_list call identifier argument_list identifier block expression_statement assignment pattern_list identifier identifier subscript identifier identifier expression_statement assignment identifier subscript identifier slice identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement boolean_operator comparison_operator string string_start string_content string_end identifier comparison_operator string string_start string_content string_end identifier block expression_statement call attribute identifier identifier argument_list subscript identifier identifier continue_statement expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier identifier return_statement expression_list identifier identifier
leaves related articles and wikitables in place
def _get_child_mock(mock, **kw): attribute = "." + kw["name"] if "name" in kw else "()" mock_name = _extract_mock_name(mock) + attribute raise AttributeError(mock_name)
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier conditional_expression binary_operator string string_start string_content string_end subscript identifier string string_start string_content string_end comparison_operator string string_start string_content string_end identifier string string_start string_content string_end expression_statement assignment identifier binary_operator call identifier argument_list identifier identifier raise_statement call identifier argument_list identifier
Intercepts call to generate new mocks and raises instead
def magnitude(a): "calculates the magnitude of a vecor" from math import sqrt sum = 0 for coord in a: sum += coord ** 2 return sqrt(sum)
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end import_from_statement dotted_name identifier dotted_name identifier expression_statement assignment identifier integer for_statement identifier identifier block expression_statement augmented_assignment identifier binary_operator identifier integer return_statement call identifier argument_list identifier
calculates the magnitude of a vecor
def RecordHelloWorld(handler, t): url = "%s/receive_recording.py" % THIS_URL t.startRecording(url) t.say ("Hello, World.") t.stopRecording() json = t.RenderJson() logging.info ("RecordHelloWorld json: %s" % json) handler.response.out.write(json)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier
Demonstration of recording a message.
def restart(uuid, **kwargs): from .worker_engine import restart_worker return text_type(restart_worker(uuid, **kwargs).uuid)
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block import_from_statement relative_import import_prefix dotted_name identifier dotted_name identifier return_statement call identifier argument_list attribute call identifier argument_list identifier dictionary_splat identifier identifier
Restart the workflow from a given workflow engine UUID.
def _init_norm(self, weights): with tf.variable_scope("init_norm"): flat = tf.reshape(weights, [-1, self.layer_depth]) return tf.reshape(tf.norm(flat, axis=0), (self.layer_depth,))
module function_definition identifier parameters identifier identifier block with_statement with_clause with_item call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list identifier list unary_operator integer attribute identifier identifier return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier integer tuple attribute identifier identifier
Set the norm of the weight vector.
def make_result(self): result = {} if self._base_image_build: result[BASE_IMAGE_KOJI_BUILD] = self._base_image_build if self._parent_builds: result[PARENT_IMAGES_KOJI_BUILDS] = self._parent_builds return result if result else None
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary if_statement attribute identifier identifier block expression_statement assignment subscript identifier identifier attribute identifier identifier if_statement attribute identifier identifier block expression_statement assignment subscript identifier identifier attribute identifier identifier return_statement conditional_expression identifier identifier none
Construct the result dict to be preserved in the build metadata.
def _proc_cyclic(self): main_axis, rot = max(self.rot_sym, key=lambda v: v[1]) self.sch_symbol = "C{}".format(rot) mirror_type = self._find_mirror(main_axis) if mirror_type == "h": self.sch_symbol += "h" elif mirror_type == "v": self.sch_symbol += "v" elif mirror_type == "": if self.is_valid_op(SymmOp.rotoreflection(main_axis, angle=180 / rot)): self.sch_symbol = "S{}".format(2 * rot)
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier call identifier argument_list attribute identifier identifier keyword_argument identifier lambda lambda_parameters identifier subscript identifier integer expression_statement assignment attribute identifier identifier call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement augmented_assignment attribute identifier identifier string string_start string_content string_end elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement augmented_assignment attribute identifier identifier string string_start string_content string_end elif_clause comparison_operator identifier string string_start string_end block if_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier binary_operator integer identifier block expression_statement assignment attribute identifier identifier call attribute string string_start string_content string_end identifier argument_list binary_operator integer identifier
Handles cyclic group molecules.
def do_expire(self): _timeouts = deepcopy(self.timeouts) for key, value in _timeouts.items(): if value - self.clock.now() < timedelta(0): del self.timeouts[key] if key in self.redis: self.redis.pop(key, None)
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement comparison_operator binary_operator identifier call attribute attribute identifier identifier identifier argument_list call identifier argument_list integer block delete_statement subscript attribute identifier identifier identifier if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier none
Expire objects assuming now == time
def send(session_id, message): try: socket = CLIENTS[session_id][1] except KeyError: raise NoSocket("There is no socket with the session ID: " + session_id) socket.send(message)
module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment identifier subscript subscript identifier identifier integer except_clause identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier
Send a message to the socket for the given session ID.
def prep(config=None, path=None): if config is None: config = parse() if path is None: path = os.getcwd() root = config.get('root', 'path') root = os.path.join(path, root) root = os.path.realpath(root) os.environ['SCIDASH_HOME'] = root if sys.path[0] != root: sys.path.insert(0, root)
module function_definition identifier parameters default_parameter identifier none default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end identifier if_statement comparison_operator subscript attribute identifier identifier integer identifier block expression_statement call attribute attribute identifier identifier identifier argument_list integer identifier
Prepare to read the configuration information.
async def get_volume_information(self) -> List[Volume]: res = await self.services["audio"]["getVolumeInformation"]({}) volume_info = [Volume.make(services=self.services, **x) for x in res] if len(volume_info) < 1: logging.warning("Unable to get volume information") elif len(volume_info) > 1: logging.debug("The device seems to have more than one volume setting.") return volume_info
module function_definition identifier parameters identifier type generic_type identifier type_parameter type identifier block expression_statement assignment identifier await call subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end argument_list dictionary expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier dictionary_splat identifier for_in_clause identifier identifier if_statement comparison_operator call identifier argument_list identifier integer block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end elif_clause comparison_operator call identifier argument_list identifier integer block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier
Get the volume information.
def reissue(self, order_id, csr, software_id, organization_handle, approver_email=None, signature_hash_algorithm=None, domain_validation_methods=None, hostnames=None, technical_handle=None): response = self.request(E.reissueSslCertRequest( E.id(order_id), E.csr(csr), E.softwareId(software_id), E.organizationHandle(organization_handle), OE('approverEmail', approver_email), OE('signatureHashAlgorithm', signature_hash_algorithm), OE('domainValidationMethods', domain_validation_methods, transform=_domain_validation_methods), OE('hostNames', hostnames, transform=_simple_array), OE('technicalHandle', technical_handle), )) return int(response.data.id)
module function_definition identifier parameters identifier identifier identifier identifier identifier default_parameter identifier none 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 call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier call identifier argument_list string string_start string_content string_end identifier call identifier argument_list string string_start string_content string_end identifier call identifier argument_list string string_start string_content string_end identifier keyword_argument identifier identifier call identifier argument_list string string_start string_content string_end identifier keyword_argument identifier identifier call identifier argument_list string string_start string_content string_end identifier return_statement call identifier argument_list attribute attribute identifier identifier identifier
Reissue an SSL certificate order
def update_rule_entry(self, rule_info): if rule_info.get('status') == 'up': self.add_rule_entry(rule_info) if rule_info.get('status') == 'down': self.remove_rule_entry(rule_info)
module function_definition identifier parameters identifier identifier block if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier
Update the rule_info list.
def format(self, record): if record.levelno == logging.DEBUG: record.msg = ' {}'.format(record.msg) return super(AuditLogFormatter, self).format(record)
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier return_statement call attribute call identifier argument_list identifier identifier identifier argument_list identifier
Space debug messages for more legibility.
def extract_library_properties_from_selected_row(self): (model, row) = self.view.get_selection().get_selected() tree_item_key = model[row][self.ID_STORAGE_ID] library_item = model[row][self.ITEM_STORAGE_ID] library_path = model[row][self.LIB_PATH_STORAGE_ID] if isinstance(library_item, dict): os_path = model[row][self.OS_PATH_STORAGE_ID] return os_path, None, None, tree_item_key assert isinstance(library_item, string_types) library_os_path = library_item library_name = library_os_path.split(os.path.sep)[-1] return library_os_path, library_path, library_name, tree_item_key
module function_definition identifier parameters identifier block expression_statement assignment tuple_pattern identifier identifier call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list expression_statement assignment identifier subscript subscript identifier identifier attribute identifier identifier expression_statement assignment identifier subscript subscript identifier identifier attribute identifier identifier expression_statement assignment identifier subscript subscript identifier identifier attribute identifier identifier if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier subscript subscript identifier identifier attribute identifier identifier return_statement expression_list identifier none none identifier assert_statement call identifier argument_list identifier identifier expression_statement assignment identifier identifier expression_statement assignment identifier subscript call attribute identifier identifier argument_list attribute attribute identifier identifier identifier unary_operator integer return_statement expression_list identifier identifier identifier identifier
Extracts properties library_os_path, library_path, library_name and tree_item_key from tree store row
def makecsvdiffs(thediffs, dtls, n1, n2): def ishere(val): if val == None: return "not here" else: return "is here" rows = [] rows.append(['file1 = %s' % (n1, )]) rows.append(['file2 = %s' % (n2, )]) rows.append('') rows.append(theheader(n1, n2)) keys = list(thediffs.keys()) keys.sort() dtlssorter = DtlsSorter(dtls) keys = sorted(keys, key=dtlssorter.getkey) for key in keys: if len(key) == 2: rw2 = [''] + [ishere(i) for i in thediffs[key]] else: rw2 = list(thediffs[key]) rw1 = list(key) rows.append(rw1 + rw2) return rows
module function_definition identifier parameters identifier identifier identifier identifier block function_definition identifier parameters identifier block if_statement comparison_operator identifier none block return_statement string string_start string_content string_end else_clause block return_statement string string_start string_content string_end expression_statement assignment identifier list expression_statement call attribute identifier identifier argument_list list binary_operator string string_start string_content string_end tuple identifier expression_statement call attribute identifier identifier argument_list list binary_operator string string_start string_content string_end tuple identifier expression_statement call attribute identifier identifier argument_list string string_start string_end expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier attribute identifier identifier for_statement identifier identifier block if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier binary_operator list string string_start string_end list_comprehension call identifier argument_list identifier for_in_clause identifier subscript identifier identifier else_clause block expression_statement assignment identifier call identifier argument_list subscript identifier identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list binary_operator identifier identifier return_statement identifier
return the csv to be displayed
def unescape(s, unicode_action="replace"): import HTMLParser hp = HTMLParser.HTMLParser() s = hp.unescape(s) s = s.encode('ascii', unicode_action) s = s.replace("\n", "").strip() return s
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block import_statement dotted_name identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end string string_start string_end identifier argument_list return_statement identifier
Unescape HTML strings, and convert &amp; etc.
def call_git_branch(): try: with open(devnull, "w") as fnull: arguments = [GIT_COMMAND, 'rev-parse', '--abbrev-ref', 'HEAD'] return check_output(arguments, cwd=CURRENT_DIRECTORY, stderr=fnull).decode("ascii").strip() except (OSError, CalledProcessError): return None
module function_definition identifier parameters block try_statement 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 assignment identifier list identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end return_statement call attribute call attribute call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier identifier argument_list string string_start string_content string_end identifier argument_list except_clause tuple identifier identifier block return_statement none
return the string output of git desribe
def show_std_icons(): app = qapplication() dialog = ShowStdIcons(None) dialog.show() sys.exit(app.exec_())
module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call identifier argument_list none expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list
Show all standard Icons
def parse_player_info(self, player): if not player.ishltv: self.player_info[player.name] = { "user_id": player.userID, "guid": player.guid, "bot": player.fakeplayer, }
module function_definition identifier parameters identifier identifier block if_statement not_operator attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier attribute identifier identifier dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier
Parse a PlayerInfo struct. This arrives before a FileInfo message
def _write_items(self, row_lookup, col_lookup, item): self.qc.write_items(row_lookup, col_lookup, item)
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier identifier
Perform remote write and replace blocks.
def unauthorized_callback(self): return redirect(self.login_url(params=dict(next=request.url)))
module function_definition identifier parameters identifier block return_statement call identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier call identifier argument_list keyword_argument identifier attribute identifier identifier
Redirect to login url with next param set as request.url
def parse_plain_scalar_indent(TokenClass): def callback(lexer, match, context): text = match.group() if len(text) <= context.indent: context.stack.pop() context.stack.pop() return if text: yield match.start(), TokenClass, text context.pos = match.end() return callback
module function_definition identifier parameters identifier block function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator call identifier argument_list identifier attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list return_statement if_statement identifier block expression_statement yield expression_list call attribute identifier identifier argument_list identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list return_statement identifier
Process indentation spaces in a plain scalar.
def _tensors(cls, fluents: Sequence[FluentPair]) -> Iterable[tf.Tensor]: for _, fluent in fluents: tensor = cls._output_size(fluent.tensor) yield tensor
module function_definition identifier parameters identifier typed_parameter identifier type generic_type identifier type_parameter type identifier type generic_type identifier type_parameter type attribute identifier identifier block for_statement pattern_list identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement yield identifier
Yields the `fluents`' tensors.
def vtableEqual(a, objectStart, b): N.enforce_number(objectStart, N.UOffsetTFlags) if len(a) * N.VOffsetTFlags.bytewidth != len(b): return False for i, elem in enumerate(a): x = encode.Get(packer.voffset, b, i * N.VOffsetTFlags.bytewidth) if x == 0 and elem == 0: pass else: y = objectStart - elem if x != y: return False return True
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier if_statement comparison_operator binary_operator call identifier argument_list identifier attribute attribute identifier identifier identifier call identifier argument_list identifier block return_statement false for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier identifier binary_operator identifier attribute attribute identifier identifier identifier if_statement boolean_operator comparison_operator identifier integer comparison_operator identifier integer block pass_statement else_clause block expression_statement assignment identifier binary_operator identifier identifier if_statement comparison_operator identifier identifier block return_statement false return_statement true
vtableEqual compares an unwritten vtable to a written vtable.
def setup_signing(self, secret_key, sign_outgoing=True, allow_unsigned_callback=None, initial_timestamp=None, link_id=None): self.mav.signing.secret_key = secret_key self.mav.signing.sign_outgoing = sign_outgoing self.mav.signing.allow_unsigned_callback = allow_unsigned_callback if link_id is None: global global_link_id link_id = global_link_id global_link_id = min(global_link_id + 1, 255) self.mav.signing.link_id = link_id if initial_timestamp is None: epoch_offset = 1420070400 now = max(time.time(), epoch_offset) initial_timestamp = now - epoch_offset initial_timestamp = int(initial_timestamp * 100 * 1000) self.mav.signing.timestamp = initial_timestamp
module function_definition identifier parameters identifier identifier default_parameter identifier true default_parameter identifier none default_parameter identifier none default_parameter identifier none block expression_statement assignment attribute attribute attribute identifier identifier identifier identifier identifier expression_statement assignment attribute attribute attribute identifier identifier identifier identifier identifier expression_statement assignment attribute attribute attribute identifier identifier identifier identifier identifier if_statement comparison_operator identifier none block global_statement identifier expression_statement assignment identifier identifier expression_statement assignment identifier call identifier argument_list binary_operator identifier integer integer expression_statement assignment attribute attribute attribute identifier identifier identifier identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier integer expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator identifier identifier expression_statement assignment identifier call identifier argument_list binary_operator binary_operator identifier integer integer expression_statement assignment attribute attribute attribute identifier identifier identifier identifier identifier
setup for MAVLink2 signing
def clearOldCalibrations(self, date=None): self.coeffs['dark current'] = [self.coeffs['dark current'][-1]] self.coeffs['noise'] = [self.coeffs['noise'][-1]] for light in self.coeffs['flat field']: self.coeffs['flat field'][light] = [ self.coeffs['flat field'][light][-1]] for light in self.coeffs['lens']: self.coeffs['lens'][light] = [self.coeffs['lens'][light][-1]]
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end list subscript subscript attribute identifier identifier string string_start string_content string_end unary_operator integer expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end list subscript subscript attribute identifier identifier string string_start string_content string_end unary_operator integer for_statement identifier subscript attribute identifier identifier string string_start string_content string_end block expression_statement assignment subscript subscript attribute identifier identifier string string_start string_content string_end identifier list subscript subscript subscript attribute identifier identifier string string_start string_content string_end identifier unary_operator integer for_statement identifier subscript attribute identifier identifier string string_start string_content string_end block expression_statement assignment subscript subscript attribute identifier identifier string string_start string_content string_end identifier list subscript subscript subscript attribute identifier identifier string string_start string_content string_end identifier unary_operator integer
if not only a specific date than remove all except of the youngest calibration
def query(cls, name, type_=Type.String, description=None, required=None, default=None, minimum=None, maximum=None, enum=None, **options): if minimum is not None and maximum is not None and minimum > maximum: raise ValueError("Minimum must be less than or equal to the maximum.") return cls(name, In.Query, type_, None, description, required=required, default=default, minimum=minimum, maximum=maximum, enum=enum, **options)
module function_definition identifier parameters identifier identifier default_parameter identifier attribute identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none dictionary_splat_pattern identifier block if_statement boolean_operator boolean_operator comparison_operator identifier none comparison_operator identifier none comparison_operator identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end return_statement call identifier argument_list identifier attribute identifier identifier identifier none identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier dictionary_splat identifier
Define a query parameter
def cc(filename: 'input source file', output: 'output file name. default to be replacing input file\'s suffix with ".py"' = None, name: 'name of language' = 'unname'): lang = Language(name) with Path(filename).open('r') as fr: build_language(fr.read(), lang, filename) if not output: base, _ = os.path.splitext(filename) output = base + '.py' lang.dump(output)
module function_definition identifier parameters typed_parameter identifier type string string_start string_content string_end typed_default_parameter identifier type string string_start string_content escape_sequence string_end none typed_default_parameter identifier type string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list identifier with_statement with_clause with_item as_pattern call attribute call identifier argument_list identifier identifier argument_list string string_start string_content string_end as_pattern_target identifier block expression_statement call identifier argument_list call attribute identifier identifier argument_list identifier identifier if_statement not_operator identifier block expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier binary_operator identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier
rbnf source code compiler.
def initialize_env_specs(hparams, env_problem_name): if env_problem_name: env = registry.env_problem(env_problem_name, batch_size=hparams.batch_size) else: env = rl_utils.setup_env(hparams, hparams.batch_size, hparams.eval_max_num_noops, hparams.rl_env_max_episode_steps, env_name=hparams.rl_env_name) env.start_new_epoch(0) return rl.make_real_env_fn(env)
module function_definition identifier parameters identifier identifier block if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list integer return_statement call attribute identifier identifier argument_list identifier
Initializes env_specs using the appropriate env.
def _resolve_path(self, path): filepath = None mimetype = None for root, dirs, files in self.filter_files(self.path): error_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'error_templates', path) try: with open(error_path): mimetype, encoding = mimetypes.guess_type(error_path) filepath = error_path except IOError: pass if self.base: basepath = os.path.join(root, self.blueprint_name, path) try: with open(basepath): mimetype, encoding = mimetypes.guess_type(basepath) filepath = basepath except IOError: pass fullpath = os.path.join(root, path) try: with open(fullpath): mimetype, encoding = mimetypes.guess_type(fullpath) filepath = fullpath except IOError: pass return filepath, mimetype
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier none expression_statement assignment identifier none for_statement pattern_list identifier identifier identifier call attribute identifier identifier argument_list attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end identifier try_statement block with_statement with_clause with_item call identifier argument_list identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier identifier except_clause identifier block pass_statement if_statement attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier attribute identifier identifier identifier try_statement block with_statement with_clause with_item call identifier argument_list identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier identifier except_clause identifier block pass_statement expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier try_statement block with_statement with_clause with_item call identifier argument_list identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier identifier except_clause identifier block pass_statement return_statement expression_list identifier identifier
Resolve static file paths
def update(self, *args): "Appends any passed in byte arrays to the digest object." for string in args: self._hobj.update(string) self._fobj = None
module function_definition identifier parameters identifier list_splat_pattern identifier block expression_statement string string_start string_content string_end for_statement identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier none
Appends any passed in byte arrays to the digest object.
def update(self, **kwargs): url_str = self.base_url + '/%s' % kwargs['alarm_id'] del kwargs['alarm_id'] resp = self.client.create(url=url_str, method='PUT', json=kwargs) return resp
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier binary_operator attribute identifier identifier binary_operator string string_start string_content string_end subscript identifier string string_start string_content string_end delete_statement subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier return_statement identifier
Update a specific alarm definition.
def show_all(imgs:Collection[Image], r:int=1, c:Optional[int]=None, figsize=(12,6)): "Show all `imgs` using `r` rows" imgs = listify(imgs) if c is None: c = len(imgs)//r for i,ax in plot_flat(r,c,figsize): imgs[i].show(ax)
module function_definition identifier parameters typed_parameter identifier type generic_type identifier type_parameter type identifier typed_default_parameter identifier type identifier integer typed_default_parameter identifier type generic_type identifier type_parameter type identifier none default_parameter identifier tuple integer integer block expression_statement string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement assignment identifier binary_operator call identifier argument_list identifier identifier for_statement pattern_list identifier identifier call identifier argument_list identifier identifier identifier block expression_statement call attribute subscript identifier identifier identifier argument_list identifier
Show all `imgs` using `r` rows
def linter_functions_from_filters(whitelist=None, blacklist=None): def _keyvalue_pair_if(dictionary, condition): return { k: v for (k, v) in dictionary.items() if condition(k) } def _check_list(check_list, cond): def _check_against_list(key): return cond(check_list, key) if check_list is not None else True return _check_against_list linter_functions = LINTER_FUNCTIONS linter_functions = _keyvalue_pair_if(linter_functions, _check_list(whitelist, lambda l, k: k in l)) linter_functions = _keyvalue_pair_if(linter_functions, _check_list(blacklist, lambda l, k: k not in l)) for code, linter_function in linter_functions.items(): yield (code, linter_function)
module function_definition identifier parameters default_parameter identifier none default_parameter identifier none block function_definition identifier parameters identifier identifier block return_statement dictionary_comprehension pair identifier identifier for_in_clause tuple_pattern identifier identifier call attribute identifier identifier argument_list if_clause call identifier argument_list identifier function_definition identifier parameters identifier identifier block function_definition identifier parameters identifier block return_statement conditional_expression call identifier argument_list identifier identifier comparison_operator identifier none true return_statement identifier expression_statement assignment identifier identifier expression_statement assignment identifier call identifier argument_list identifier call identifier argument_list identifier lambda lambda_parameters identifier identifier comparison_operator identifier identifier expression_statement assignment identifier call identifier argument_list identifier call identifier argument_list identifier lambda lambda_parameters identifier identifier comparison_operator identifier identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement yield tuple identifier identifier
Yield tuples of _LinterFunction matching whitelist but not blacklist.
def current_user_was_last_verifier(analysis): verifiers = analysis.getVerificators() return verifiers and verifiers[:-1] == api.get_current_user().getId()
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list return_statement boolean_operator identifier comparison_operator subscript identifier slice unary_operator integer call attribute call attribute identifier identifier argument_list identifier argument_list
Returns whether the current user was the last verifier or not
def handler(ca_file=None): def request(url, message, **kwargs): scheme, host, port, path = spliturl(url) if scheme != "https": ValueError("unsupported scheme: %s" % scheme) connection = HTTPSConnection(host, port, ca_file) try: body = message.get('body', "") headers = dict(message.get('headers', [])) connection.request(message['method'], path, body, headers) response = connection.getresponse() finally: connection.close() return { 'status': response.status, 'reason': response.reason, 'headers': response.getheaders(), 'body': BytesIO(response.read()) } return request
module function_definition identifier parameters default_parameter identifier none block function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block expression_statement assignment pattern_list identifier identifier identifier identifier call identifier argument_list identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier try_statement 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 call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end list expression_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list finally_clause block expression_statement call attribute identifier identifier argument_list return_statement dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end call attribute identifier identifier argument_list pair string string_start string_content string_end call identifier argument_list call attribute identifier identifier argument_list return_statement identifier
Returns an HTTP request handler configured with the given ca_file.
def _put_obj(irods_path, obj): text = json.dumps(obj, indent=2) _put_text(irods_path, text)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier integer expression_statement call identifier argument_list identifier identifier
Put python object into iRODS as JSON text.
def _write_header(self): 'Writes the header to the underlying file object.' header = b'scrypt' + CHR0 + struct.pack('>BII', int(math.log(self.N, 2)), self.r, self.p) + self.salt checksum = hashlib.sha256(header).digest()[:16] header += checksum self._checksumer = hmac.new(self.key[32:], msg = header, digestmod = hashlib.sha256) checksum = self._checksumer.digest() header += checksum self._checksumer.update(checksum) self._fp.write(header) self._crypto = aesctr.AESCounterModeOfOperation(key = self.key[:32]) self._done_header = True
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier binary_operator binary_operator binary_operator string string_start string_content string_end identifier call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier integer attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement assignment identifier subscript call attribute call attribute identifier identifier argument_list identifier identifier argument_list slice integer expression_statement augmented_assignment identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list subscript attribute identifier identifier slice integer keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement augmented_assignment identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list keyword_argument identifier subscript attribute identifier identifier slice integer expression_statement assignment attribute identifier identifier true
Writes the header to the underlying file object.
def _get_string_type_from_token(token_type): return_value = None if token_type in [TokenType.BeginSingleQuotedLiteral, TokenType.EndSingleQuotedLiteral]: return_value = "Single" elif token_type in [TokenType.BeginDoubleQuotedLiteral, TokenType.EndDoubleQuotedLiteral]: return_value = "Double" assert return_value is not None return return_value
module function_definition identifier parameters identifier block expression_statement assignment identifier none if_statement comparison_operator identifier list attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier string string_start string_content string_end elif_clause comparison_operator identifier list attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier string string_start string_content string_end assert_statement comparison_operator identifier none return_statement identifier
Return 'Single' or 'Double' depending on what kind of string this is.
def repack_all(self): non_na_sequences = [s for s in self.sequences if ' ' not in s] self.pack_new_sequences(non_na_sequences) return
module function_definition identifier parameters identifier block expression_statement assignment identifier list_comprehension identifier for_in_clause identifier attribute identifier identifier if_clause comparison_operator string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier return_statement
Repacks the side chains of all Polymers in the Assembly.
def CleanName(name): name = re.sub('[^_A-Za-z0-9]', '_', name) if name[0].isdigit(): name = '_%s' % name while keyword.iskeyword(name): name = '%s_' % name if name.startswith('__'): name = 'f%s' % name return name
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier if_statement call attribute subscript identifier integer identifier argument_list block expression_statement assignment identifier binary_operator string string_start string_content string_end identifier while_statement call attribute identifier identifier argument_list identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end identifier if_statement 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 return_statement identifier
Perform generic name cleaning.
def _get_data_versions(data): genome_dir = install.get_genome_dir(data["genome_build"], data["dirs"].get("galaxy"), data) if genome_dir: version_file = os.path.join(genome_dir, "versions.csv") if version_file and os.path.exists(version_file): return version_file return None
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end identifier if_statement identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end if_statement boolean_operator identifier call attribute attribute identifier identifier identifier argument_list identifier block return_statement identifier return_statement none
Retrieve CSV file with version information for reference data.
def _validate(cls, kind): if kind not in cls._valid_kinds: mesg = "'kind' must be one of {}, {}, {}, or {}." raise ValueError(mesg.format(*cls._valid_kinds)) else: return kind
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier string string_start string_content string_end raise_statement call identifier argument_list call attribute identifier identifier argument_list list_splat attribute identifier identifier else_clause block return_statement identifier
Validate the kind argument.
def __GetChunk(self, start, end, additional_headers=None): self.EnsureInitialized() request = http_wrapper.Request(url=self.url) self.__SetRangeHeader(request, start, end=end) if additional_headers is not None: request.headers.update(additional_headers) return http_wrapper.MakeRequest( self.bytes_http, request, retry_func=self.retry_func, retries=self.num_retries)
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier keyword_argument identifier identifier if_statement comparison_operator identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list attribute identifier identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier
Retrieve a chunk, and return the full response.
def revoke_token(access_token): response = requests.post( get_revoke_token_url(), data={ 'token': access_token, 'client_id': settings.API_CLIENT_ID, 'client_secret': settings.API_CLIENT_SECRET, }, timeout=15 ) return response.status_code == 200
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list keyword_argument identifier 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 keyword_argument identifier integer return_statement comparison_operator attribute identifier identifier integer
Instructs the API to delete this access token and associated refresh token
def list_managers_view(request): managerset = Manager.objects.filter(active=True) return render_to_response('list_managers.html', { 'page_name': "Managers", 'managerset': managerset, }, context_instance=RequestContext(request))
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier true return_statement call identifier argument_list string string_start string_content string_end dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end identifier keyword_argument identifier call identifier argument_list identifier
Show a list of manager positions with links to view in detail.
def _get_names(dirs): alphabets = set() label_names = {} for d in dirs: for example in _walk_omniglot_dir(d): alphabet, alphabet_char_id, label, _ = example alphabets.add(alphabet) label_name = "%s_%d" % (alphabet, alphabet_char_id) if label in label_names: assert label_names[label] == label_name else: label_names[label] = label_name label_names = [label_names[k] for k in sorted(label_names)] return alphabets, label_names
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier dictionary for_statement identifier identifier block for_statement identifier call identifier argument_list identifier block expression_statement assignment pattern_list identifier identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier identifier if_statement comparison_operator identifier identifier block assert_statement comparison_operator subscript identifier identifier identifier else_clause block expression_statement assignment subscript identifier identifier identifier expression_statement assignment identifier list_comprehension subscript identifier identifier for_in_clause identifier call identifier argument_list identifier return_statement expression_list identifier identifier
Get alphabet and label names, union across all dirs.
def morph_cost(self) -> Optional["Cost"]: if self.tech_alias is None or self.tech_alias[0] in {UnitTypeId.TECHLAB, UnitTypeId.REACTOR}: return None tech_alias_cost_minerals = max([self._game_data.units[tech_alias.value].cost.minerals for tech_alias in self.tech_alias]) tech_alias_cost_vespene = max([self._game_data.units[tech_alias.value].cost.vespene for tech_alias in self.tech_alias]) return Cost( self._proto.mineral_cost - tech_alias_cost_minerals, self._proto.vespene_cost - tech_alias_cost_vespene, self._proto.build_time )
module function_definition identifier parameters identifier type generic_type identifier type_parameter type string string_start string_content string_end block if_statement boolean_operator comparison_operator attribute identifier identifier none comparison_operator subscript attribute identifier identifier integer set attribute identifier identifier attribute identifier identifier block return_statement none expression_statement assignment identifier call identifier argument_list list_comprehension attribute attribute subscript attribute attribute identifier identifier identifier attribute identifier identifier identifier identifier for_in_clause identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list list_comprehension attribute attribute subscript attribute attribute identifier identifier identifier attribute identifier identifier identifier identifier for_in_clause identifier attribute identifier identifier return_statement call identifier argument_list binary_operator attribute attribute identifier identifier identifier identifier binary_operator attribute attribute identifier identifier identifier identifier attribute attribute identifier identifier identifier
This returns 150 minerals for OrbitalCommand instead of 550
def collection(path, *stats): def initMethod(self): init(self, path) attributes = {'__init__': initMethod} for stat in stats: attributes[stat.getName()] = stat newClass = type('Stats:%s' % path, (object,), attributes) instance = newClass() for stat in stats: default = stat._getInit() if default: setattr(instance, stat.getName(), default) return instance
module function_definition identifier parameters identifier list_splat_pattern identifier block function_definition identifier parameters identifier block expression_statement call identifier argument_list identifier identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier for_statement identifier identifier block expression_statement assignment subscript identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list binary_operator string string_start string_content string_end identifier tuple identifier identifier expression_statement assignment identifier call identifier argument_list for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement identifier block expression_statement call identifier argument_list identifier call attribute identifier identifier argument_list identifier return_statement identifier
Creates a named stats collection object.
def generate_static(self, path): if not path: return "" if path[0] == '/': return "%s?v=%s" % (path, self.version) return "%s/%s?v=%s" % (self.static, path, self.version)
module function_definition identifier parameters identifier identifier block if_statement not_operator identifier block return_statement string string_start string_end if_statement comparison_operator subscript identifier integer string string_start string_content string_end block return_statement binary_operator string string_start string_content string_end tuple identifier attribute identifier identifier return_statement binary_operator string string_start string_content string_end tuple attribute identifier identifier identifier attribute identifier identifier
This method generates a valid path to the public folder of the running project
def add_group(self, group_attribs=None, parent=None): if parent is None: parent = self.tree.getroot() elif not self.contains_group(parent): warnings.warn('The requested group {0} does not belong to ' 'this Document'.format(parent)) if group_attribs is None: group_attribs = {} else: group_attribs = group_attribs.copy() return SubElement(parent, '{{{0}}}g'.format( SVG_NAMESPACE['svg']), group_attribs)
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list elif_clause not_operator call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement assignment identifier dictionary else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list return_statement call identifier argument_list identifier call attribute string string_start string_content string_end identifier argument_list subscript identifier string string_start string_content string_end identifier
Add an empty group element to the SVG.
def recover_and_supervise(recovery_file): try: logging.info("Attempting to recover Supervisor data from " + recovery_file) with open(recovery_file) as rf: recovery_data = json.load(rf) monitor_data = recovery_data['monitor_data'] dependencies = recovery_data['dependencies'] args = recovery_data['args'] except: logging.error("Could not recover monitor data, exiting...") return 1 logging.info("Data successfully loaded, resuming Supervisor") supervise_until_complete(monitor_data, dependencies, args, recovery_file)
module function_definition identifier parameters identifier block try_statement block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier 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 identifier expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier string string_start string_content string_end except_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list identifier identifier identifier identifier
Retrieve monitor data from recovery_file and resume monitoring
def clean_by_request(self, request): if request not in self.request_map: return for tag, matcher, future in self.request_map[request]: self._timeout_future(tag, matcher, future) if future in self.timeout_map: tornado.ioloop.IOLoop.current().remove_timeout(self.timeout_map[future]) del self.timeout_map[future] del self.request_map[request]
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block return_statement for_statement pattern_list identifier identifier identifier subscript attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier identifier if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute call attribute attribute attribute identifier identifier identifier identifier argument_list identifier argument_list subscript attribute identifier identifier identifier delete_statement subscript attribute identifier identifier identifier delete_statement subscript attribute identifier identifier identifier
Remove all futures that were waiting for request `request` since it is done waiting
def PortPathMatcher(cls, port_path): if isinstance(port_path, str): port_path = [int(part) for part in SYSFS_PORT_SPLIT_RE.split(port_path)] return lambda device: device.port_path == port_path
module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier list_comprehension call identifier argument_list identifier for_in_clause identifier call attribute identifier identifier argument_list identifier return_statement lambda lambda_parameters identifier comparison_operator attribute identifier identifier identifier
Returns a device matcher for the given port path.
def on_created(self, event): if self.trigger != "create": return action_input = ActionInput(event, "", self.name) flows.Global.MESSAGE_DISPATCHER.send_message(action_input)
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block return_statement expression_statement assignment identifier call identifier argument_list identifier string string_start string_end attribute identifier identifier expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier
Fired when something's been created
def mask_average(dset,mask): o = nl.run(['3dmaskave','-q','-mask',mask,dset]) if o: return float(o.output.split()[-1])
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier identifier if_statement identifier block return_statement call identifier argument_list subscript call attribute attribute identifier identifier identifier argument_list unary_operator integer
Returns average of voxels in ``dset`` within non-zero voxels of ``mask``
def _prt_line_detail(self, prt, line, lnum=""): data = zip(self.flds, line.split('\t')) txt = ["{:2}) {:13} {}".format(i, hdr, val) for i, (hdr, val) in enumerate(data)] prt.write("{LNUM}\n{TXT}\n".format(LNUM=lnum, TXT='\n'.join(txt)))
module function_definition identifier parameters identifier identifier identifier default_parameter identifier string string_start string_end block expression_statement assignment identifier call identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end expression_statement assignment identifier list_comprehension call attribute string string_start string_content string_end identifier argument_list identifier identifier identifier for_in_clause pattern_list identifier tuple_pattern identifier identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content escape_sequence escape_sequence string_end identifier argument_list keyword_argument identifier identifier keyword_argument identifier call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier
Print each field and its value.
def _new_song(self): s = self.song if self.shuffle: self.song = self.shuffles[random.randrange(len(self.shuffles))] else: self.song += 1 if self.song >= len(self.loop): self.song = 0 self.dif_song = s != self.song self.pos = 0
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier if_statement attribute identifier identifier block expression_statement assignment attribute identifier identifier subscript attribute identifier identifier call attribute identifier identifier argument_list call identifier argument_list attribute identifier identifier else_clause block expression_statement augmented_assignment attribute identifier identifier integer if_statement comparison_operator attribute identifier identifier call identifier argument_list attribute identifier identifier block expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier comparison_operator identifier attribute identifier identifier expression_statement assignment attribute identifier identifier integer
Used internally to get a metasong index.
def _send(self, msg, buffers=None): if self.comm is not None and self.comm.kernel is not None: self.comm.send(data=msg, buffers=buffers)
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement boolean_operator comparison_operator attribute identifier identifier none comparison_operator attribute attribute identifier identifier identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier
Sends a message to the model in the front-end.
def _parse_date_hungarian(dateString): m = _hungarian_date_format_re.match(dateString) if not m or m.group(2) not in _hungarian_months: return None month = _hungarian_months[m.group(2)] day = m.group(3) if len(day) == 1: day = '0' + day hour = m.group(4) if len(hour) == 1: hour = '0' + hour w3dtfdate = '%(year)s-%(month)s-%(day)sT%(hour)s:%(minute)s%(zonediff)s' % \ {'year': m.group(1), 'month': month, 'day': day,\ 'hour': hour, 'minute': m.group(5),\ 'zonediff': m.group(6)} return _parse_date_w3dtf(w3dtfdate)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement boolean_operator not_operator identifier comparison_operator call attribute identifier identifier argument_list integer identifier block return_statement none expression_statement assignment identifier subscript identifier call attribute identifier identifier argument_list integer expression_statement assignment identifier call attribute identifier identifier argument_list integer if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list integer if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier binary_operator string string_start string_content string_end identifier expression_statement assignment identifier binary_operator string string_start string_content string_end line_continuation dictionary pair string string_start string_content string_end call attribute identifier identifier argument_list integer 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 call attribute identifier identifier argument_list integer pair string string_start string_content string_end call attribute identifier identifier argument_list integer return_statement call identifier argument_list identifier
Parse a string according to a Hungarian 8-bit date format.
def _idToStr(self, x): if x < 0: sign = -1 elif x == 0: return self._idChars[0] else: sign = 1 x *= sign digits = [] while x: digits.append(self._idChars[x % self._idCharsCnt]) x //= self._idCharsCnt if sign < 0: digits.append('-') digits.reverse() return ''.join(digits)
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier integer block expression_statement assignment identifier unary_operator integer elif_clause comparison_operator identifier integer block return_statement subscript attribute identifier identifier integer else_clause block expression_statement assignment identifier integer expression_statement augmented_assignment identifier identifier expression_statement assignment identifier list while_statement identifier block expression_statement call attribute identifier identifier argument_list subscript attribute identifier identifier binary_operator identifier attribute identifier identifier expression_statement augmented_assignment identifier attribute identifier identifier if_statement comparison_operator identifier integer block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list return_statement call attribute string string_start string_end identifier argument_list identifier
Convert VCD id in int to string
def who_am_i(): me = url['me'].format(token) r = requests.get(me, params={'client_id': CLIENT_ID}) r.raise_for_status() current_user = r.json() logger.debug(me) logger.info('Hello {0}!'.format(current_user['username'])) return current_user
module function_definition identifier parameters block expression_statement assignment identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier dictionary pair string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list 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 call attribute string string_start string_content string_end identifier argument_list subscript identifier string string_start string_content string_end return_statement identifier
Display username from current token and check for validity
def in_file(self, fn: str) -> Iterator[Statement]: yield from self.__file_to_statements.get(fn, [])
module function_definition identifier parameters identifier typed_parameter identifier type identifier type generic_type identifier type_parameter type identifier block expression_statement yield call attribute attribute identifier identifier identifier argument_list identifier list
Returns an iterator over all of the statements belonging to a file.
def recent(self, include=None): return self._query_zendesk(self.endpoint.recent, 'ticket', id=None, include=include)
module function_definition identifier parameters identifier default_parameter identifier none block return_statement call attribute identifier identifier argument_list attribute attribute identifier identifier identifier string string_start string_content string_end keyword_argument identifier none keyword_argument identifier identifier
Retrieve the most recent tickets
def list(): running_list = [] parser = argparse.ArgumentParser() parser.add_argument('--logdir') parser.add_argument('--port') for p in psutil.process_iter(): if p.name() != 'tensorboard' or p.status() == psutil.STATUS_ZOMBIE: continue cmd_args = p.cmdline() del cmd_args[0:2] args = parser.parse_args(cmd_args) running_list.append({'pid': p.pid, 'logdir': args.logdir, 'port': args.port}) return pd.DataFrame(running_list)
module function_definition identifier parameters block expression_statement assignment identifier list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end for_statement identifier call attribute identifier identifier argument_list block if_statement boolean_operator comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end comparison_operator call attribute identifier identifier argument_list attribute identifier identifier block continue_statement expression_statement assignment identifier call attribute identifier identifier argument_list delete_statement subscript identifier slice integer integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier return_statement call attribute identifier identifier argument_list identifier
List running TensorBoard instances.
def from_filename(cls, path_string, origin=MISSING, **kwargs): path = Path(path_string) return cls.from_path(path, origin, **kwargs)
module function_definition identifier parameters identifier identifier default_parameter identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier identifier dictionary_splat identifier
Read Sass source from a String specifying the path
def _add_access_token_to_response(self, response, access_token): response['access_token'] = access_token.value response['token_type'] = access_token.type response['expires_in'] = access_token.expires_in
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier
Adds the Access Token and the associated parameters to the Token Response.
def _merge_dicts(first, second): new = deepcopy(first) for k, v in second.items(): if isinstance(v, dict) and v: ret = _merge_dicts(new.get(k, dict()), v) new[k] = ret else: new[k] = second[k] return new
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement boolean_operator call identifier argument_list identifier identifier identifier block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list identifier call identifier argument_list identifier expression_statement assignment subscript identifier identifier identifier else_clause block expression_statement assignment subscript identifier identifier subscript identifier identifier return_statement identifier
Merge the 'second' multiple-dictionary into the 'first' one.
def _set_data(self, data, offset=None, copy=False): data = np.array(data, copy=copy) data = self._normalize_shape(data) if offset is None: self._resize(data.shape) elif all([i == 0 for i in offset]) and data.shape == self._shape: self._resize(data.shape) offset = offset or tuple([0 for i in range(self._ndim)]) assert len(offset) == self._ndim for i in range(len(data.shape)-1): if offset[i] + data.shape[i] > self._shape[i]: raise ValueError("Data is too large") self._glir.command('DATA', self._id, offset, data)
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier false block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list attribute identifier identifier elif_clause boolean_operator call identifier argument_list list_comprehension comparison_operator identifier integer for_in_clause identifier identifier comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier boolean_operator identifier call identifier argument_list list_comprehension integer for_in_clause identifier call identifier argument_list attribute identifier identifier assert_statement comparison_operator call identifier argument_list identifier attribute identifier identifier for_statement identifier call identifier argument_list binary_operator call identifier argument_list attribute identifier identifier integer block if_statement comparison_operator binary_operator subscript identifier identifier subscript attribute identifier identifier identifier subscript attribute identifier 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 string string_start string_content string_end attribute identifier identifier identifier identifier
Internal method for set_data.
def _init_hdrgo_sortby(self, hdrgo_sortby, sortby): if hdrgo_sortby is not None: return hdrgo_sortby if sortby is not None: return sortby return self.sortby
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator identifier none block return_statement identifier if_statement comparison_operator identifier none block return_statement identifier return_statement attribute identifier identifier
Initialize header sort function.
def unregister_callback(callback_id): global _callbacks obj = _callbacks.pop(callback_id, None) threads = [] if obj is not None: t, quit = obj quit.set() threads.append(t) for t in threads: t.join()
module function_definition identifier parameters identifier block global_statement identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier none expression_statement assignment identifier list if_statement comparison_operator identifier none block expression_statement assignment pattern_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list
unregister a callback registration
def encode_hdr(self, boundary): boundary = encode_and_quote(boundary) headers = ["--%s" % boundary] if self.filename: disposition = 'form-data; name="%s"; filename="%s"' % (self.name, self.filename) else: disposition = 'form-data; name="%s"' % self.name headers.append("Content-Disposition: %s" % disposition) if self.filetype: filetype = self.filetype else: filetype = "text/plain; charset=utf-8" headers.append("Content-Type: %s" % filetype) headers.append("") headers.append("") return "\r\n".join(headers)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier list binary_operator string string_start string_content string_end identifier if_statement attribute identifier identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple attribute identifier identifier attribute identifier identifier else_clause block expression_statement assignment identifier binary_operator string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier if_statement attribute identifier identifier block expression_statement assignment identifier attribute identifier identifier else_clause block expression_statement assignment identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list string string_start string_end expression_statement call attribute identifier identifier argument_list string string_start string_end return_statement call attribute string string_start string_content escape_sequence escape_sequence string_end identifier argument_list identifier
Returns the header of the encoding of this parameter
def _preallocate_samples(self): self.prealloc_samples_ = [] for i in range(self.num_prealloc_samples_): self.prealloc_samples_.append(self.sample())
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier list for_statement identifier call identifier argument_list attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list
Preallocate samples for faster adaptive sampling.
def native_string_to_unicode(s, encoding="ascii", errors="strict"): if not isinstance(s, str): raise TypeError("{} must be type str, not {}".format(s, type(s))) if str is unicode: return s else: return s.decode(encoding=encoding, errors=errors)
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_content string_end block if_statement not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier call identifier argument_list identifier if_statement comparison_operator identifier identifier block return_statement identifier else_clause block return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier
Ensure that the native string ``s`` is converted to ``unicode``.
def most_seen_works_card(kind=None, num=10): object_list = most_seen_works(kind=kind, num=num) object_list = chartify(object_list, 'num_views', cutoff=1) if kind: card_title = 'Most seen {}'.format( Work.get_kind_name_plural(kind).lower()) else: card_title = 'Most seen works' return { 'card_title': card_title, 'score_attr': 'num_views', 'object_list': object_list, 'name_attr': 'title', 'use_cite': True, }
module function_definition identifier parameters default_parameter identifier none default_parameter identifier integer block expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end keyword_argument identifier integer if_statement identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list call attribute call attribute identifier identifier argument_list identifier identifier argument_list else_clause block expression_statement assignment identifier string string_start string_content string_end return_statement dictionary pair string string_start string_content string_end identifier 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 string string_start string_content string_end pair string string_start string_content string_end true
Displays a card showing the Works that are associated with the most Events.
def detect_sv(align_bam, genome_build, dirs, config): work_dir = utils.safe_makedir(os.path.join(dirs["work"], "structural")) pair_stats = shared.calc_paired_insert_stats(align_bam) fix_bam = remove_nopairs(align_bam, work_dir, config) tier2_align = tiered_alignment(fix_bam, "2", True, [], genome_build, pair_stats, work_dir, dirs, config) if tier2_align: tier3_align = tiered_alignment(tier2_align, "3", "Ex 1100", ["-t", "300"], genome_build, pair_stats, work_dir, dirs, config) if tier3_align: hydra_bps = hydra_breakpoints(tier3_align, pair_stats)
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end true list identifier identifier identifier identifier identifier if_statement identifier block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end list string string_start string_content string_end string string_start string_content string_end identifier identifier identifier identifier identifier if_statement identifier block expression_statement assignment identifier call identifier argument_list identifier identifier
Detect structural variation from discordant aligned pairs.
def storage_list(storage_name=None): _args = ['storage-list', '--format=json'] if storage_name: _args.append(storage_name) try: return json.loads(subprocess.check_output(_args).decode('UTF-8')) except ValueError: return None except OSError as e: import errno if e.errno == errno.ENOENT: return [] raise
module function_definition identifier parameters default_parameter identifier none block expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier try_statement block return_statement call attribute identifier identifier argument_list call attribute call attribute identifier identifier argument_list identifier identifier argument_list string string_start string_content string_end except_clause identifier block return_statement none except_clause as_pattern identifier as_pattern_target identifier block import_statement dotted_name identifier if_statement comparison_operator attribute identifier identifier attribute identifier identifier block return_statement list raise_statement
List the storage IDs for the unit
def next_frame_sv2p_atari(): hparams = next_frame_sv2p() hparams.video_num_input_frames = 4 hparams.video_num_target_frames = 4 hparams.action_injection = "multiplicative" hparams.num_iterations_1st_stage = 12000 hparams.num_iterations_2nd_stage = 12000 hparams.anneal_end = 40000 hparams.latent_loss_multiplier_schedule = "noisy_linear_cosine_decay" hparams.latent_loss_multiplier = 1e-3 hparams.information_capacity = 0.0 hparams.small_mode = True return hparams
module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier float expression_statement assignment attribute identifier identifier float expression_statement assignment attribute identifier identifier true return_statement identifier
SV2P model for atari.
def _parse_invite(client, command, actor, args): target, _, channel = args.rpartition(" ") client.dispatch_event("INVITE", actor, target, channel.lower())
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment pattern_list identifier identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier call attribute identifier identifier argument_list
Parse an INVITE and dispatch an event.
def select_and_start_cluster(self, platform): clusters = self.reactor_config.get_enabled_clusters_for_platform(platform) if not clusters: raise UnknownPlatformException('No clusters found for platform {}!' .format(platform)) retry_contexts = { cluster.name: ClusterRetryContext(self.max_cluster_fails) for cluster in clusters } while True: try: possible_cluster_info = self.get_clusters(platform, retry_contexts, clusters) except AllClustersFailedException as ex: cluster = ClusterInfo(None, platform, None, None) build_info = WorkerBuildInfo(build=None, cluster_info=cluster, logger=self.log) build_info.monitor_exception = repr(ex) self.worker_builds.append(build_info) return for cluster_info in possible_cluster_info: ctx = retry_contexts[cluster_info.cluster.name] try: self.log.info('Attempting to start build for platform %s on cluster %s', platform, cluster_info.cluster.name) self.do_worker_build(cluster_info) return except OsbsException: ctx.try_again_later(self.failure_retry_delay)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement not_operator 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 attribute identifier identifier call identifier argument_list attribute identifier identifier for_in_clause identifier identifier while_statement true block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement assignment identifier call identifier argument_list none identifier none none expression_statement assignment identifier call identifier argument_list keyword_argument identifier none keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement for_statement identifier identifier block expression_statement assignment identifier subscript identifier attribute attribute identifier identifier identifier try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier attribute attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement except_clause identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier
Choose a cluster and start a build on it
def _from_dict(cls, _dict): args = {} if 'input' in _dict: args['input'] = MessageInput._from_dict(_dict.get('input')) if 'intents' in _dict: args['intents'] = [ RuntimeIntent._from_dict(x) for x in (_dict.get('intents')) ] if 'entities' in _dict: args['entities'] = [ RuntimeEntity._from_dict(x) for x in (_dict.get('entities')) ] if 'alternate_intents' in _dict: args['alternate_intents'] = _dict.get('alternate_intents') if 'context' in _dict: args['context'] = Context._from_dict(_dict.get('context')) if 'output' in _dict: args['output'] = OutputData._from_dict(_dict.get('output')) if 'actions' in _dict: args['actions'] = [ DialogNodeAction._from_dict(x) for x in (_dict.get('actions')) ] return cls(**args)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier parenthesized_expression call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier parenthesized_expression call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier parenthesized_expression call attribute identifier identifier argument_list string string_start string_content string_end return_statement call identifier argument_list dictionary_splat identifier
Initialize a MessageRequest object from a json dictionary.
def _compute_dynamic_properties(self, builder): splits = self.splits for split_info in utils.tqdm( splits.values(), desc="Computing statistics...", unit=" split"): try: split_name = split_info.name dataset_feature_statistics, schema = get_dataset_feature_statistics( builder, split_name) split_info.statistics.CopyFrom(dataset_feature_statistics) self.as_proto.schema.CopyFrom(schema) except tf.errors.InvalidArgumentError: logging.error(("%s's info() property specifies split %s, but it " "doesn't seem to have been generated. Please ensure " "that the data was downloaded for this split and re-run " "download_and_prepare."), self.name, split_name) raise self._set_splits(splits)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier for_statement identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end block try_statement block expression_statement assignment identifier attribute identifier identifier expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier except_clause attribute attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list parenthesized_expression concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end attribute identifier identifier identifier raise_statement expression_statement call attribute identifier identifier argument_list identifier
Update from the DatasetBuilder.
def sense(self): cmd_name = random.choice(self.senses) param = '' if cmd_name == 'ls': if random.randint(0, 1): param = '-l' elif cmd_name == 'uname': opts = 'asnrvmpio' start = random.randint(0, len(opts) - 2) end = random.randint(start + 1, len(opts) - 1) param = '-{}'.format(opts[start:end]) command = getattr(self, cmd_name) command(param)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier string string_start string_end if_statement comparison_operator identifier string string_start string_content string_end block if_statement call attribute identifier identifier argument_list integer integer block expression_statement assignment identifier string string_start string_content string_end elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list integer binary_operator call identifier argument_list identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator identifier integer binary_operator call identifier argument_list identifier integer expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list subscript identifier slice identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement call identifier argument_list identifier
Launch a command in the 'senses' List, and update the current state.
def clear_to_reset(self, config_vars): super(RemoteBridgeState, self).clear_to_reset(config_vars) self.status = BRIDGE_STATUS.IDLE self.error = 0
module function_definition identifier parameters identifier identifier block expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier integer
Clear the RemoteBridge subsystem to its reset state.
def unfreeze(self): g = get_root(self).globals self.filter.configure(state='normal') dtype = g.observe.rtype() if dtype == 'data caution' or dtype == 'data' or dtype == 'technical': self.prog_ob.configure(state='normal') self.pi.configure(state='normal') self.target.enable() self.observers.configure(state='normal') self.comment.configure(state='normal')
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute call identifier argument_list identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list if_statement boolean_operator boolean_operator comparison_operator identifier string string_start string_content string_end comparison_operator identifier string string_start string_content string_end comparison_operator identifier string string_start string_content string_end block expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier string string_start string_content string_end
Unfreeze all settings so that they can be altered
def to_matrix(np_array): if len(np_array.shape) == 2: return Matrices.dense(np_array.shape[0], np_array.shape[1], np_array.ravel()) else: raise Exception("An MLLib Matrix can only be created from a two-dimensional " + "numpy array, got {}".format(len(np_array.shape)))
module function_definition identifier parameters identifier block if_statement comparison_operator call identifier argument_list attribute identifier identifier integer block return_statement call attribute identifier identifier argument_list subscript attribute identifier identifier integer subscript attribute identifier identifier integer call attribute identifier identifier argument_list else_clause block raise_statement call identifier argument_list binary_operator string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list call identifier argument_list attribute identifier identifier
Convert numpy array to MLlib Matrix
def delete_vnic_template_for_vlan(self, vlan_id): with self.session.begin(subtransactions=True): try: self.session.query(ucsm_model.VnicTemplate).filter_by( vlan_id=vlan_id).delete() except orm.exc.NoResultFound: return
module function_definition identifier parameters identifier identifier block with_statement with_clause with_item call attribute attribute identifier identifier identifier argument_list keyword_argument identifier true block try_statement block expression_statement call attribute call attribute call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier argument_list keyword_argument identifier identifier identifier argument_list except_clause attribute attribute identifier identifier identifier block return_statement
Deletes VNIC Template for a vlan_id and physnet if it exists.
def handle_source_positions(self, call_id, payload): self.log.debug('handle_source_positions: in %s', Pretty(payload)) call_options = self.call_options[call_id] word_under_cursor = call_options.get("word_under_cursor") positions = payload["positions"] if not positions: self.editor.raw_message("No usages of <{}> found".format(word_under_cursor)) return qf_list = [] for p in positions: position = p["position"] preview = str(p["preview"]) if "preview" in p else "<no preview>" item = self.editor.to_quickfix_item(str(position["file"]), position["line"], preview, "info") qf_list.append(item) qf_sorted = sorted(qf_list, key=itemgetter('filename', 'lnum')) self.editor.write_quickfix_list(qf_sorted, "Usages of <{}>".format(word_under_cursor))
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end call identifier argument_list identifier expression_statement assignment identifier subscript attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier subscript identifier string string_start string_content string_end if_statement not_operator identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier return_statement expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier conditional_expression call identifier argument_list subscript identifier string string_start string_content string_end comparison_operator string string_start string_content string_end identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call identifier argument_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier call identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list identifier call attribute string string_start string_content string_end identifier argument_list identifier
Handler for source positions
def disconnect(self): old_api = object.__getattribute__(self, '_api') new_api = API.build_hardware_simulator( loop=old_api._loop, config=copy.copy(old_api.config)) setattr(self, '_api', new_api)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement call identifier argument_list identifier string string_start string_content string_end identifier
Disconnect from connected hardware.
def _add_cmd_output(self, cmd, suggest_filename=None, root_symlink=None, timeout=300, stderr=True, chroot=True, runat=None, env=None, binary=False, sizelimit=None, pred=None): cmdt = ( cmd, suggest_filename, root_symlink, timeout, stderr, chroot, runat, env, binary, sizelimit ) _tuplefmt = ("('%s', '%s', '%s', %s, '%s', '%s', '%s', '%s', '%s', " "'%s')") _logstr = "packed command tuple: " + _tuplefmt self._log_debug(_logstr % cmdt) if self.test_predicate(cmd=True, pred=pred): self.collect_cmds.append(cmdt) self._log_info("added cmd output '%s'" % cmd) else: self._log_info("skipped cmd output '%s' due to predicate (%s)" % (cmd, self.get_predicate(cmd=True, pred=pred)))
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier integer default_parameter identifier true default_parameter identifier true default_parameter identifier none default_parameter identifier none default_parameter identifier false default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier tuple identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier expression_statement assignment identifier parenthesized_expression concatenated_string string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier binary_operator string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list binary_operator identifier identifier if_statement call attribute identifier identifier argument_list keyword_argument identifier true keyword_argument identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier else_clause block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier call attribute identifier identifier argument_list keyword_argument identifier true keyword_argument identifier identifier
Internal helper to add a single command to the collection list.
def delete_port_binding(self, port, host): if not self.get_instance_type(port): return for pb_key in self._get_binding_keys(port, host): pb_res = MechResource(pb_key, a_const.PORT_BINDING_RESOURCE, a_const.DELETE) self.provision_queue.put(pb_res)
module function_definition identifier parameters identifier identifier identifier block if_statement not_operator call attribute identifier identifier argument_list identifier block return_statement for_statement identifier call attribute identifier identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier attribute identifier identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Enqueue port binding delete
def _next_sample_index(self): return self.rng.choice(self.n_active, p=(self.stream_weights_ / self.weight_norm_))
module function_definition identifier parameters identifier block return_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier keyword_argument identifier parenthesized_expression binary_operator attribute identifier identifier attribute identifier identifier
StochasticMux chooses its next sample stream randomly
def write(self): with open(self.log_path, "w") as f: json.dump(self.log_dict, f, indent=1)
module function_definition identifier parameters identifier block with_statement with_clause with_item as_pattern call identifier argument_list attribute identifier identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier keyword_argument identifier integer
Dump JSON to file
def check_network_id(network_id, web3: Web3): while True: current_id = int(web3.version.network) if network_id != current_id: raise RuntimeError( f'Raiden was running on network with id {network_id} and it detected ' f'that the underlying ethereum client network id changed to {current_id}.' f' Changing the underlying blockchain while the Raiden node is running ' f'is not supported.', ) gevent.sleep(CHECK_NETWORK_ID_INTERVAL)
module function_definition identifier parameters identifier typed_parameter identifier type identifier block while_statement true block expression_statement assignment identifier call identifier argument_list attribute attribute identifier identifier identifier if_statement comparison_operator identifier identifier block raise_statement call identifier argument_list concatenated_string string string_start string_content interpolation identifier string_content string_end string string_start string_content interpolation identifier string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier
Check periodically if the underlying ethereum client's network id has changed
def _run_sync(self, method: Callable, *args, **kwargs) -> Any: if self.loop.is_running(): raise RuntimeError("Event loop is already running.") if not self.is_connected: self.loop.run_until_complete(self.connect()) task = asyncio.Task(method(*args, **kwargs), loop=self.loop) result = self.loop.run_until_complete(task) self.loop.run_until_complete(self.quit()) return result
module function_definition identifier parameters identifier typed_parameter identifier type identifier list_splat_pattern identifier dictionary_splat_pattern identifier type identifier block if_statement call attribute attribute identifier identifier identifier argument_list block raise_statement call identifier argument_list string string_start string_content string_end if_statement not_operator attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list list_splat identifier dictionary_splat identifier keyword_argument identifier attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list return_statement identifier
Utility method to run commands synchronously for testing.
def _get_deps(deps, tree_base, saltenv='base'): deps_list = '' if deps is None: return deps_list if not isinstance(deps, list): raise SaltInvocationError( '\'deps\' must be a Python list or comma-separated string' ) for deprpm in deps: parsed = _urlparse(deprpm) depbase = os.path.basename(deprpm) dest = os.path.join(tree_base, depbase) if parsed.scheme: __salt__['cp.get_url'](deprpm, dest, saltenv=saltenv) else: shutil.copy(deprpm, dest) deps_list += ' {0}'.format(dest) return deps_list
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier string string_start string_end if_statement comparison_operator identifier none block return_statement identifier if_statement not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list string string_start string_content escape_sequence escape_sequence string_end for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier if_statement attribute identifier identifier block expression_statement call subscript identifier string string_start string_content string_end argument_list identifier identifier keyword_argument identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement augmented_assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier return_statement identifier
Get include string for list of dependent rpms to build package
def delete_node(self, key_chain): node = self._data for key in key_chain[:-1]: node = node[key] del node[key_chain[-1]]
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier for_statement identifier subscript identifier slice unary_operator integer block expression_statement assignment identifier subscript identifier identifier delete_statement subscript identifier subscript identifier unary_operator integer
key_chain is an array of keys giving the path to the node that should be deleted.