code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def _parse_hostvar_file(self, hostname, path): first_line = open(path, 'r').readline() if first_line.startswith('$ANSIBLE_VAULT'): self.log.warning("Skipping encrypted vault file {0}".format(path)) return try: self.log.debug("Reading host vars from {}".format(path)) f = codecs.open(path, 'r', encoding='utf8') invars = ihateyaml.safe_load(f) f.close() except Exception as err: self.log.warning("Yaml couldn't load '{0}'. Skipping. Error was: {1}".format(path, err)) return if invars is None: return if hostname == "all": for hostname in self.hosts_all(): self.update_host(hostname, {'hostvars': invars}, overwrite=False) else: self.update_host(hostname, {'hostvars': invars}, overwrite=True)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute call identifier argument_list identifier string string_start string_content string_end identifier argument_list if_statement call attribute identifier identifier argument_list string string_start string_content string_end 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 try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list except_clause as_pattern identifier as_pattern_target 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 identifier return_statement if_statement comparison_operator identifier none block return_statement if_statement comparison_operator identifier string string_start string_content string_end block for_statement identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier dictionary pair string string_start string_content string_end identifier keyword_argument identifier false else_clause block expression_statement call attribute identifier identifier argument_list identifier dictionary pair string string_start string_content string_end identifier keyword_argument identifier true
Parse a host var file and apply it to host `hostname`.
def enumerate_layer_fields(self, layer): descriptor = self.get_descriptor_for_layer(layer) return [field['name'] for field in descriptor['fields']]
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement list_comprehension subscript identifier string string_start string_content string_end for_in_clause identifier subscript identifier string string_start string_content string_end
Pulls out all of the field names for a layer.
def push_build_status(id): response = utils.checked_api_call(pnc_api.build_push, 'status', build_record_id=id) if response: return utils.format_json(response)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier string string_start string_content string_end keyword_argument identifier identifier if_statement identifier block return_statement call attribute identifier identifier argument_list identifier
Get status of Brew push.
def current_changed(self, index): editor = self.get_current_editor() if editor.lsp_ready and not editor.document_opened: editor.document_did_open() if index != -1: editor.setFocus() logger.debug("Set focus to: %s" % editor.filename) else: self.reset_statusbar.emit() self.opened_files_list_changed.emit() self.stack_history.refresh() self.stack_history.remove_and_append(index) try: logger.debug("Current changed: %d - %s" % (index, self.data[index].editor.filename)) except IndexError: pass self.update_plugin_title.emit() if editor is not None: try: self.current_file_changed.emit(self.data[index].filename, editor.get_position('cursor')) except IndexError: pass
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement boolean_operator attribute identifier identifier not_operator attribute identifier identifier block expression_statement call attribute identifier identifier argument_list if_statement comparison_operator identifier unary_operator integer block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list identifier try_statement block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier attribute attribute subscript attribute identifier identifier identifier identifier identifier except_clause identifier block pass_statement expression_statement call attribute attribute identifier identifier identifier argument_list if_statement comparison_operator identifier none block try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list attribute subscript attribute identifier identifier identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end except_clause identifier block pass_statement
Stack index has changed
def _write(self, session, openFile, replaceParamFile): openFile.write('Num_Sites: %s\n' % self.numSites) openFile.write('Elev_Base %s\n' % self.elevBase) openFile.write('Elev_2 %s\n' % self.elev2) openFile.write('Year Month Day Hour Temp_2\n') measurements = self.orographicMeasurements for measurement in measurements: dateTime = measurement.dateTime openFile.write('%s%s%s%s%s%s%s%s%.3f\n' % ( dateTime.year, ' ', dateTime.month, ' ' * (8 - len(str(dateTime.month))), dateTime.day, ' ' * (8 - len(str(dateTime.day))), dateTime.hour, ' ' * (8 - len(str(dateTime.hour))), measurement.temp2))
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end expression_statement assignment identifier attribute identifier identifier for_statement identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end tuple attribute identifier identifier string string_start string_content string_end attribute identifier identifier binary_operator string string_start string_content string_end parenthesized_expression binary_operator integer call identifier argument_list call identifier argument_list attribute identifier identifier attribute identifier identifier binary_operator string string_start string_content string_end parenthesized_expression binary_operator integer call identifier argument_list call identifier argument_list attribute identifier identifier attribute identifier identifier binary_operator string string_start string_content string_end parenthesized_expression binary_operator integer call identifier argument_list call identifier argument_list attribute identifier identifier attribute identifier identifier
Orographic Gage File Write to File Method
def _print(self, msg, color=None, arrow=False, indent=None): if color: msg = colored(msg, color) if arrow: msg = colored('===> ', 'blue') + msg if indent: msg = (' ' * indent) + msg print(msg) return msg
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier false default_parameter identifier none block if_statement identifier block expression_statement assignment identifier call identifier argument_list identifier identifier if_statement identifier block expression_statement assignment identifier binary_operator call identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier if_statement identifier block expression_statement assignment identifier binary_operator parenthesized_expression binary_operator string string_start string_content string_end identifier identifier expression_statement call identifier argument_list identifier return_statement identifier
Print the msg with the color provided.
def on_switch_page(self, notebook, page_pointer, page_num, user_param1=None): page = notebook.get_nth_page(page_num) for tab_info in list(self.tabs.values()): if tab_info['page'] is page: state_m = tab_info['state_m'] sm_id = state_m.state.get_state_machine().state_machine_id selected_state_m = self.current_state_machine_m.selection.get_selected_state() if selected_state_m is not state_m and sm_id in self.model.state_machine_manager.state_machines: self.model.selected_state_machine_id = sm_id self.current_state_machine_m.selection.set(state_m) return
module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list block if_statement comparison_operator subscript identifier string string_start string_content string_end identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier attribute call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list if_statement boolean_operator comparison_operator identifier identifier comparison_operator identifier attribute attribute attribute identifier identifier identifier identifier block expression_statement assignment attribute attribute identifier identifier identifier identifier expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier return_statement
Update state selection when the active tab was changed
def _finalize_axis(self, key): if 'title' in self.handles: self.handles['title'].set_visible(self.show_title) self.drawn = True if self.subplot: return self.handles['axis'] else: fig = self.handles['fig'] if not getattr(self, 'overlaid', False) and self._close_figures: plt.close(fig) return fig
module function_definition identifier parameters identifier identifier block if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier true if_statement attribute identifier identifier block return_statement subscript attribute identifier identifier string string_start string_content string_end else_clause block expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end if_statement boolean_operator not_operator call identifier argument_list identifier string string_start string_content string_end false attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
General method to finalize the axis and plot.
def format_variable_map(variable_map, join_lines=True): rows = [] rows.append(("Key", "Variable", "Shape", "Type", "Collections", "Device")) var_to_collections = _get_vars_to_collections(variable_map) sort_key = lambda item: (item[0], item[1].name) for key, var in sorted(variable_map_items(variable_map), key=sort_key): shape = "x".join(str(dim) for dim in var.get_shape().as_list()) dtype = repr(var.dtype.base_dtype).replace("tf.", "") coll = ", ".join(sorted(var_to_collections[var])) rows.append((key, var.op.name, shape, dtype, coll, _format_device(var))) return _format_table(rows, join_lines)
module function_definition identifier parameters identifier default_parameter identifier true block expression_statement assignment identifier list expression_statement call attribute identifier identifier argument_list tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier lambda lambda_parameters identifier tuple subscript identifier integer attribute subscript identifier integer identifier for_statement pattern_list identifier identifier call identifier argument_list call identifier argument_list identifier keyword_argument identifier identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier generator_expression call identifier argument_list identifier for_in_clause identifier call attribute call attribute identifier identifier argument_list identifier argument_list expression_statement assignment identifier call attribute call identifier argument_list attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end string string_start string_end expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list call identifier argument_list subscript identifier identifier expression_statement call attribute identifier identifier argument_list tuple identifier attribute attribute identifier identifier identifier identifier identifier identifier call identifier argument_list identifier return_statement call identifier argument_list identifier identifier
Takes a key-to-variable map and formats it as a table.
def recon_all(subj_id,anatomies): if not environ_setup: setup_freesurfer() if isinstance(anatomies,basestring): anatomies = [anatomies] nl.run([os.path.join(freesurfer_home,'bin','recon-all'),'-all','-subjid',subj_id] + [['-i',anat] for anat in anatomies])
module function_definition identifier parameters identifier identifier block if_statement not_operator identifier block expression_statement call identifier argument_list if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier list identifier expression_statement call attribute identifier identifier argument_list binary_operator list call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier list_comprehension list string string_start string_content string_end identifier for_in_clause identifier identifier
Run the ``recon_all`` script
def str_or_unicode(text): encoding = sys.stdout.encoding if sys.version_info > (3, 0): return text.encode(encoding).decode(encoding) return text.encode(encoding)
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier if_statement comparison_operator attribute identifier identifier tuple integer integer block return_statement call attribute call attribute identifier identifier argument_list identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier
handle python 3 unicode and python 2.7 byte strings
def log(x, context=None): return _apply_function_in_current_context( BigFloat, mpfr.mpfr_log, (BigFloat._implicit_convert(x),), context, )
module function_definition identifier parameters identifier default_parameter identifier none block return_statement call identifier argument_list identifier attribute identifier identifier tuple call attribute identifier identifier argument_list identifier identifier
Return the natural logarithm of x.
def requirement(self) -> FetchRequirement: key_name = self.key if key_name == b'ALL': return FetchRequirement.NONE elif key_name == b'KEYSET': keyset_reqs = {key.requirement for key in self.filter_key_set} return FetchRequirement.reduce(keyset_reqs) elif key_name == b'OR': left, right = self.filter_key_or key_or_reqs = {left.requirement, right.requirement} return FetchRequirement.reduce(key_or_reqs) elif key_name in (b'SENTBEFORE', b'SENTON', b'SENTSINCE', b'BCC', b'CC', b'FROM', b'SUBJECT', b'TO', b'HEADER'): return FetchRequirement.HEADERS elif key_name in (b'BODY', b'TEXT', b'LARGER', b'SMALLER'): return FetchRequirement.BODY else: return FetchRequirement.METADATA
module function_definition identifier parameters identifier type identifier block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block return_statement attribute identifier identifier elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier set_comprehension attribute identifier identifier for_in_clause identifier attribute identifier identifier return_statement call attribute identifier identifier argument_list identifier elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment pattern_list identifier identifier attribute identifier identifier expression_statement assignment identifier set attribute identifier identifier attribute identifier identifier return_statement call attribute identifier identifier argument_list identifier elif_clause comparison_operator identifier tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block return_statement attribute identifier identifier elif_clause comparison_operator identifier tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block return_statement attribute identifier identifier else_clause block return_statement attribute identifier identifier
Indicates the data required to fulfill this search key.
def _get_current_deployment_id(self): deploymentId = '' stage = __salt__['boto_apigateway.describe_api_stage'](restApiId=self.restApiId, stageName=self._stage_name, **self._common_aws_args).get('stage') if stage: deploymentId = stage.get('deploymentId') return deploymentId
module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_end expression_statement assignment identifier call attribute call subscript identifier string string_start string_content string_end argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier dictionary_splat attribute identifier identifier identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier
Helper method to find the deployment id that the stage name is currently assocaited with.
def now_micros(absolute=False) -> int: micros = int(time.time() * 1e6) if absolute: return micros return micros - EPOCH_MICROS
module function_definition identifier parameters default_parameter identifier false type identifier block expression_statement assignment identifier call identifier argument_list binary_operator call attribute identifier identifier argument_list float if_statement identifier block return_statement identifier return_statement binary_operator identifier identifier
Return current micros since epoch as integer.
def frange(start, end, step): if start <= end: step = abs(step) else: step = -abs(step) while start < end: yield start start += step
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator identifier identifier block expression_statement assignment identifier call identifier argument_list identifier else_clause block expression_statement assignment identifier unary_operator call identifier argument_list identifier while_statement comparison_operator identifier identifier block expression_statement yield identifier expression_statement augmented_assignment identifier identifier
A range implementation which can handle floats
def _file_model_from_path(self, path, content=False, format=None): model = base_model(path) model["type"] = "file" if self.fs.isfile(path): model["last_modified"] = model["created"] = self.fs.lstat(path)["ST_MTIME"] else: model["last_modified"] = model["created"] = DUMMY_CREATED_DATE if content: try: content = self.fs.read(path) except NoSuchFile as e: self.no_such_entity(e.path) except GenericFSError as e: self.do_error(str(e), 500) model["format"] = format or "text" model["content"] = content model["mimetype"] = mimetypes.guess_type(path)[0] or "text/plain" if format == "base64": model["format"] = format or "base64" from base64 import b64decode model["content"] = b64decode(content) return model
module function_definition identifier parameters identifier identifier default_parameter identifier false default_parameter identifier none block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment subscript identifier string string_start string_content string_end assignment subscript identifier string string_start string_content string_end subscript call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end else_clause block expression_statement assignment subscript identifier string string_start string_content string_end assignment subscript identifier string string_start string_content string_end identifier if_statement identifier block try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier integer expression_statement assignment subscript identifier string string_start string_content string_end boolean_operator identifier string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment subscript identifier string string_start string_content string_end boolean_operator subscript call attribute identifier identifier argument_list identifier integer string string_start string_content string_end if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment subscript identifier string string_start string_content string_end boolean_operator identifier string string_start string_content string_end import_from_statement dotted_name identifier dotted_name identifier expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list identifier return_statement identifier
Build a file model from database record.
def parse_values(self, query): values = {} for name, filt in self.filters.items(): val = filt.parse_value(query) if val is None: continue values[name] = val return values
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block continue_statement expression_statement assignment subscript identifier identifier identifier return_statement identifier
extract values from query
def clean_text(text): new_text = re.sub(ur'\p{P}+', ' ', text) new_text = [stem(i) for i in new_text.lower().split() if not re.findall(r'[0-9]', i)] new_text = ' '.join(new_text) return new_text
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 expression_statement assignment identifier list_comprehension call identifier argument_list identifier for_in_clause identifier call attribute call attribute identifier identifier argument_list identifier argument_list if_clause not_operator call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier return_statement identifier
Clean text for TFIDF.
def ClassName(self, name, separator='_'): if name is None: return name if name.startswith(('protorpc.', 'message_types.', 'apitools.base.protorpclite.', 'apitools.base.protorpclite.message_types.')): return name name = self.__StripName(name) name = self.__ToCamel(name, separator=separator) return self.CleanName(name)
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end block if_statement comparison_operator identifier none block return_statement identifier if_statement call attribute identifier identifier argument_list tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block return_statement identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier return_statement call attribute identifier identifier argument_list identifier
Generate a valid class name from name.
def unregisterAPI(self, name): if name.startswith('public/'): target = 'public' name = name[len('public/'):] else: target = self.servicename name = name removes = [m for m in self.handler.handlers.keys() if m.target == target and m.name == name] for m in removes: self.handler.unregisterHandler(m)
module function_definition identifier parameters identifier identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier slice call identifier argument_list string string_start string_content string_end else_clause block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier identifier expression_statement assignment identifier list_comprehension identifier for_in_clause identifier call attribute attribute attribute identifier identifier identifier identifier argument_list if_clause boolean_operator comparison_operator attribute identifier identifier identifier comparison_operator attribute identifier identifier identifier for_statement identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Remove an API from this handler
def local_project(v, V, u=None): dv = TrialFunction(V) v_ = TestFunction(V) a_proj = inner(dv, v_)*dx b_proj = inner(v, v_)*dx solver = LocalSolver(a_proj, b_proj) solver.factorize() if u is None: u = Function(V) solver.solve_local_rhs(u) return u else: solver.solve_local_rhs(u) return
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier binary_operator call identifier argument_list identifier identifier identifier expression_statement assignment identifier binary_operator call identifier argument_list identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier return_statement
Element-wise projection using LocalSolver
def multi_split(txt, delims): res = [txt] for delimChar in delims: txt, res = res, [] for word in txt: if len(word) > 1: res += word.split(delimChar) return res
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list identifier for_statement identifier identifier block expression_statement assignment pattern_list identifier identifier expression_list identifier list for_statement identifier identifier block if_statement comparison_operator call identifier argument_list identifier integer block expression_statement augmented_assignment identifier call attribute identifier identifier argument_list identifier return_statement identifier
split by multiple delimiters
def replace_header(self, header_text): with open(self.outfile, 'rt') as fp: _, body = self.split_header(fp) with open(self.outfile, 'wt') as fp: fp.write(header_text) fp.writelines(body)
module function_definition identifier parameters identifier 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 assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier 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 identifier expression_statement call attribute identifier identifier argument_list identifier
Replace pip-compile header with custom text
def load_yaml(file): if hasattr(yaml, "full_load"): return yaml.full_load(file) else: return yaml.load(file)
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier string string_start string_content string_end block return_statement call attribute identifier identifier argument_list identifier else_clause block return_statement call attribute identifier identifier argument_list identifier
If pyyaml > 5.1 use full_load to avoid warning
def endSections(self, level=u'0'): iSectionsClosed = self.storeSectionState(level) self.document.append("</section>\n" * iSectionsClosed)
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end identifier
Closes all sections of level >= sectnum. Defaults to closing all open sections
def run(self): self._log.info('Starting Pulsar Search Interface') authorizer = DummyAuthorizer() authorizer.add_user(self._config['login']['user'], self._config['login']['psswd'], '.', perm=self._config['login']['perm']) authorizer.add_anonymous(os.getcwd()) handler = FTPHandler handler.authorizer = authorizer handler.abstracted_fs = PulsarFileSystem handler.banner = "SKA SDP pulsar search interface." address = (self._config['address']['listen'], self._config['address']['port']) server = FTPServer(address, handler) server.max_cons = 256 server.max_cons_per_ip = 5 server.serve_forever()
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end keyword_argument identifier subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement assignment identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier tuple subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier integer expression_statement call attribute identifier identifier argument_list
Start the FTP Server for pulsar search.
def dfromdm(dm): if np.size(dm)>1: dm = np.atleast_1d(dm) return 10**(1+dm/5)
module function_definition identifier parameters identifier block if_statement comparison_operator call attribute identifier identifier argument_list identifier integer block expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement binary_operator integer parenthesized_expression binary_operator integer binary_operator identifier integer
Returns distance given distance modulus.
def list_users(self, instance, limit=None, marker=None): return instance.list_users(limit=limit, marker=marker)
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none block return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier
Returns all users for the specified instance.
def load_eidos_curation_table(): url = 'https://raw.githubusercontent.com/clulab/eidos/master/' + \ 'src/main/resources/org/clulab/wm/eidos/english/confidence/' + \ 'rule_summary.tsv' res = StringIO(requests.get(url).text) table = pandas.read_table(res, sep='\t') table = table.drop(table.index[len(table)-1]) return table
module function_definition identifier parameters block expression_statement assignment identifier binary_operator binary_operator string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call identifier argument_list attribute call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content escape_sequence string_end expression_statement assignment identifier call attribute identifier identifier argument_list subscript attribute identifier identifier binary_operator call identifier argument_list identifier integer return_statement identifier
Return a pandas table of Eidos curation data.
def DictKeyColumns(d): 'Return a list of Column objects from dictionary keys.' return [ColumnItem(k, k, type=deduceType(d[k])) for k in d.keys()]
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end return_statement list_comprehension call identifier argument_list identifier identifier keyword_argument identifier call identifier argument_list subscript identifier identifier for_in_clause identifier call attribute identifier identifier argument_list
Return a list of Column objects from dictionary keys.
def validate(schema): try: tableschema.validate(schema) click.echo("Schema is valid") sys.exit(0) except tableschema.exceptions.ValidationError as exception: click.echo("Schema is not valid") click.echo(exception.errors) sys.exit(1)
module function_definition identifier parameters identifier block try_statement block 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 integer except_clause as_pattern attribute attribute identifier identifier identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list integer
Validate that a supposed schema is in fact a Table Schema.
def send_preview(self): response = self.session.request("method:queuePreview", [ self.data ]) self.data = response return self
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end list attribute identifier identifier expression_statement assignment attribute identifier identifier identifier return_statement identifier
Send a preview of this draft.
def getLiftOps(self, valu, cmpr='='): if valu is None: iops = (('pref', b''),) return ( ('indx', ('byprop', self.pref, iops)), ) if cmpr == '~=': return ( ('form:re', (self.name, valu, {})), ) lops = self.type.getLiftOps('form', cmpr, (None, self.name, valu)) if lops is not None: return lops iops = self.type.getIndxOps(valu, cmpr) return ( ('indx', ('byprop', self.pref, iops)), )
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end block if_statement comparison_operator identifier none block expression_statement assignment identifier tuple tuple string string_start string_content string_end string string_start string_end return_statement tuple tuple string string_start string_content string_end tuple string string_start string_content string_end attribute identifier identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block return_statement tuple tuple string string_start string_content string_end tuple attribute identifier identifier identifier dictionary expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier tuple none attribute identifier identifier identifier if_statement comparison_operator identifier none block return_statement identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier return_statement tuple tuple string string_start string_content string_end tuple string string_start string_content string_end attribute identifier identifier identifier
Get a set of lift operations for use with an Xact.
def print_param_defaults(self_): cls = self_.cls for key,val in cls.__dict__.items(): if isinstance(val,Parameter): print(cls.__name__+'.'+key+ '='+ repr(val.default))
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block if_statement call identifier argument_list identifier identifier block expression_statement call identifier argument_list binary_operator binary_operator binary_operator binary_operator attribute identifier identifier string string_start string_content string_end identifier string string_start string_content string_end call identifier argument_list attribute identifier identifier
Print the default values of all cls's Parameters.
def _is_impossible_by_count(self, state): counts = {tile_type: 0 for tile_type in base.Tile._all_types} standard_wildcard_type = '2' for p, tile in state.board.positions_with_tile(): tile_type = tile._type try: int(tile_type) counts[standard_wildcard_type] += 1 except ValueError: counts[tile_type] += 1 skullbomb = counts['*'] skull = counts['s'] wildcard = counts[standard_wildcard_type] red = counts['r'] green = counts['g'] blue = counts['b'] yellow = counts['y'] exp = counts['x'] money = counts['m'] if skullbomb and skullbomb + skull >= 3: return False if wildcard: if any(wildcard + color >= 3 for color in (red, green, blue, yellow)): return False if any(tile and tile < 3 for tile in (red, green, blue, yellow, exp, money, skull)): return True return False
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary_comprehension pair identifier integer for_in_clause identifier attribute attribute identifier identifier identifier expression_statement assignment identifier string string_start string_content string_end for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block expression_statement assignment identifier attribute identifier identifier try_statement block expression_statement call identifier argument_list identifier expression_statement augmented_assignment subscript identifier identifier integer except_clause identifier block expression_statement augmented_assignment subscript identifier identifier integer 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 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 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 if_statement boolean_operator identifier comparison_operator binary_operator identifier identifier integer block return_statement false if_statement identifier block if_statement call identifier generator_expression comparison_operator binary_operator identifier identifier integer for_in_clause identifier tuple identifier identifier identifier identifier block return_statement false if_statement call identifier generator_expression boolean_operator identifier comparison_operator identifier integer for_in_clause identifier tuple identifier identifier identifier identifier identifier identifier identifier block return_statement true return_statement false
Disallow any board that has insufficient tile count to solve.
def fromDict(cls, _dict): obj = cls() obj.__dict__.update(_dict) return obj
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement identifier
Builds instance from dictionary of properties.
def _sample_slices_in_dim(self, view, num_slices, non_empty_slices): if self._sampling_method == 'linear': return self._linear_selection(non_empty_slices=non_empty_slices, num_slices=num_slices) elif self._sampling_method == 'percentage': return self._percent_selection(non_empty_slices=non_empty_slices) elif self._sampling_method == 'callable': return self._selection_by_callable(view=view, non_empty_slices=non_empty_slices, num_slices=num_slices) else: raise NotImplementedError('Invalid state for the class!')
module function_definition identifier parameters identifier identifier identifier identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier else_clause block raise_statement call identifier argument_list string string_start string_content string_end
Samples the slices in the given dimension according the chosen strategy.
def _get_entity_prop(self, entity, prop): variant = self.params.get('variant') lang = self.params.get('lang') if entity.get(prop): ent = entity[prop] try: return ent[variant or lang].get('value') except AttributeError: return ent.get('value')
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end if_statement call attribute identifier identifier argument_list identifier block expression_statement assignment identifier subscript identifier identifier try_statement block return_statement call attribute subscript identifier boolean_operator identifier identifier identifier argument_list string string_start string_content string_end except_clause identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end
returns Wikidata entity property value
def pop(self): if len(self.stack): os.chdir(self.stack.pop())
module function_definition identifier parameters identifier block if_statement call identifier argument_list attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list
Pop dir off stack and change to it.
def drop_prior_information(self): if self.jco is None: self.logger.statement("can't drop prior info, LinearAnalysis.jco is None") return nprior_str = str(self.pst.nprior) self.log("removing " + nprior_str + " prior info from jco, pst, and " + "obs cov") pi_names = list(self.pst.prior_names) missing = [name for name in pi_names if name not in self.jco.obs_names] if len(missing) > 0: raise Exception("LinearAnalysis.drop_prior_information(): "+ " prior info not found: {0}".format(missing)) if self.jco is not None: self.__jco.drop(pi_names, axis=0) self.__pst.prior_information = self.pst.null_prior self.__pst.control_data.pestmode = "estimation" self.log("removing " + nprior_str + " prior info from jco, pst, and " + "obs cov")
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end return_statement expression_statement assignment identifier call identifier argument_list attribute attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator binary_operator binary_operator string string_start string_content string_end identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call identifier argument_list attribute attribute identifier identifier identifier expression_statement assignment identifier list_comprehension identifier for_in_clause identifier identifier if_clause comparison_operator identifier attribute attribute identifier identifier identifier if_statement comparison_operator call identifier argument_list identifier integer 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 identifier if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier integer expression_statement assignment attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier expression_statement assignment attribute attribute attribute identifier identifier identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list binary_operator binary_operator binary_operator string string_start string_content string_end identifier string string_start string_content string_end string string_start string_content string_end
drop the prior information from the jco and pst attributes
def request_args(self): args = flask.request.args data_raw = {} for field_name, field in self.args_schema.fields.items(): alternate_field_name = field.load_from if MA2 else field.data_key if alternate_field_name and alternate_field_name in args: field_name = alternate_field_name elif field_name not in args: continue value = args.getlist(field_name) if not self.is_list_field(field) and len(value) == 1: value = value[0] data_raw[field_name] = value return self.deserialize_args(data_raw)
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier call attribute attribute attribute identifier identifier identifier identifier argument_list block expression_statement assignment identifier conditional_expression attribute identifier identifier identifier attribute identifier identifier if_statement boolean_operator identifier comparison_operator identifier identifier block expression_statement assignment identifier identifier elif_clause comparison_operator identifier identifier block continue_statement expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement boolean_operator not_operator call attribute identifier identifier argument_list identifier comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier subscript identifier integer expression_statement assignment subscript identifier identifier identifier return_statement call attribute identifier identifier argument_list identifier
Use args_schema to parse request query arguments.
def set(self, safe_len=False, **kwds): if kwds: d = self.kwds() d.update(kwds) self.reset(**d) if safe_len and self.item: self.leng = _len
module function_definition identifier parameters identifier default_parameter identifier false dictionary_splat_pattern identifier block if_statement identifier block 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 dictionary_splat identifier if_statement boolean_operator identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier identifier
Set one or more attributes.
def requested_perm(self, perm, obj, check_groups=True): return self.has_perm(perm, obj, check_groups, False)
module function_definition identifier parameters identifier identifier identifier default_parameter identifier true block return_statement call attribute identifier identifier argument_list identifier identifier identifier false
Check if user requested a permission for the given object
def _imm_new(cls): imm = object.__new__(cls) params = cls._pimms_immutable_data_['params'] for (p,dat) in six.iteritems(params): dat = dat[0] if dat: object.__setattr__(imm, p, dat[0]) _imm_clear(imm) dd = object.__getattribute__(imm, '__dict__') dd['_pimms_immutable_is_init'] = True return imm
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end for_statement tuple_pattern identifier identifier call attribute identifier identifier argument_list identifier block expression_statement assignment identifier subscript identifier integer if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier identifier subscript identifier integer expression_statement call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end true return_statement identifier
All immutable new classes use a hack to make sure the post-init cleanup occurs.
def dist(self, other): dx = self.x - other.x dy = self.y - other.y return math.sqrt(dx**2 + dy**2)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier binary_operator attribute identifier identifier attribute identifier identifier expression_statement assignment identifier binary_operator attribute identifier identifier attribute identifier identifier return_statement call attribute identifier identifier argument_list binary_operator binary_operator identifier integer binary_operator identifier integer
Distance to some other point.
def render_widgets(kb_app: kb, sphinx_app: Sphinx, doctree: doctree, fromdocname: str, ): builder: StandaloneHTMLBuilder = sphinx_app.builder for node in doctree.traverse(widget): w = sphinx_app.env.widgets.get(node.name) context = builder.globalcontext.copy() context['resources'] = sphinx_app.env.resources context['references'] = sphinx_app.env.references output = w.render(sphinx_app, context) listing = [nodes.raw('', output, format='html')] node.replace_self(listing)
module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier block expression_statement assignment identifier type identifier attribute identifier identifier for_statement identifier call attribute identifier identifier argument_list identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end attribute attribute identifier identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier list call attribute identifier identifier argument_list string string_start string_end identifier keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier
Go through docs and replace widget directive with rendering
def filter_queryset(self, attrs, queryset): if self.instance is not None: for field_name in self.fields: if field_name not in attrs: attrs[field_name] = getattr(self.instance, field_name) filter_kwargs = { field_name: attrs[field_name] for field_name in self.fields } return queryset.filter(**filter_kwargs)
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator attribute identifier identifier none block for_statement identifier attribute identifier identifier block if_statement comparison_operator identifier identifier block expression_statement assignment subscript identifier identifier call identifier argument_list attribute identifier identifier identifier expression_statement assignment identifier dictionary_comprehension pair identifier subscript identifier identifier for_in_clause identifier attribute identifier identifier return_statement call attribute identifier identifier argument_list dictionary_splat identifier
Filter the queryset to all instances matching the given attributes.
def _check_shape(shape): if isinstance(shape, tuple): for dim in shape: if (isinstance(dim, tuple) and len(dim) == 2 and isinstance(dim[0], int) and isinstance(dim[1], int)): if dim[0] < 0: raise ValueError("expected low dimension to be >= 0") if dim[1] < 0: raise ValueError("expected high dimension to be >= 0") if dim[0] > dim[1]: raise ValueError("expected low <= high dimensions") else: raise TypeError("expected shape dimension to be (int, int)") else: raise TypeError("expected shape to be tuple of (int, int)")
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block for_statement identifier identifier block if_statement parenthesized_expression boolean_operator boolean_operator boolean_operator call identifier argument_list identifier identifier comparison_operator call identifier argument_list identifier integer call identifier argument_list subscript identifier integer identifier call identifier argument_list subscript identifier integer identifier block if_statement comparison_operator subscript identifier integer integer block raise_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator subscript identifier integer integer block raise_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator subscript identifier integer subscript identifier integer block raise_statement call identifier argument_list string string_start string_content string_end else_clause block raise_statement call identifier argument_list string string_start string_content string_end else_clause block raise_statement call identifier argument_list string string_start string_content string_end
Verify that a shape has the right format.
def question_mark(self, request, obj): obj.question = obj.question + '?' obj.save()
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment attribute identifier identifier binary_operator attribute identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list
Add a question mark.
def check(): dist_path = Path(DIST_PATH) if not dist_path.exists() or not list(dist_path.glob('*')): print("No distribution files found. Please run 'build' command first") return subprocess.check_call(['twine', 'check', 'dist/*'])
module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list identifier if_statement boolean_operator not_operator call attribute identifier identifier argument_list not_operator call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement call identifier argument_list string string_start string_content string_end return_statement expression_statement 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
Checks the long description.
def memorized_ttinfo(*args): try: return _ttinfo_cache[args] except KeyError: ttinfo = ( memorized_timedelta(args[0]), memorized_timedelta(args[1]), args[2] ) _ttinfo_cache[args] = ttinfo return ttinfo
module function_definition identifier parameters list_splat_pattern identifier block try_statement block return_statement subscript identifier identifier except_clause identifier block expression_statement assignment identifier tuple call identifier argument_list subscript identifier integer call identifier argument_list subscript identifier integer subscript identifier integer expression_statement assignment subscript identifier identifier identifier return_statement identifier
Create only one instance of each distinct tuple
def _create_attachment(self, filename, content, mimetype=None): if mimetype is None: mimetype, _ = mimetypes.guess_type(filename) if mimetype is None: mimetype = DEFAULT_ATTACHMENT_MIME_TYPE basetype, subtype = mimetype.split("/", 1) if basetype == "text": attachment = SafeMIMEText( smart_bytes(content, DEFAULT_CHARSET), subtype, DEFAULT_CHARSET ) else: attachment = MIMEBase(basetype, subtype) attachment.set_payload(content) encode_base64(attachment) if filename: attachment.add_header( "Content-Disposition", "attachment", filename=filename ) return attachment
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement assignment identifier identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end integer if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier identifier identifier identifier else_clause block expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier identifier return_statement identifier
Convert the filename, content, mimetype triple to attachment.
def _has(self, key, exact=0): if not exact: try: key = self.getfullkey(key) return 1 except KeyError: return 0 else: return key in self.data
module function_definition identifier parameters identifier identifier default_parameter identifier integer block if_statement not_operator identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement integer except_clause identifier block return_statement integer else_clause block return_statement comparison_operator identifier attribute identifier identifier
Returns false if key is not found or is ambiguous
def formatSI(n) -> str: s = '' if n < 0: n = -n s += '-' if type(n) is int and n < 1000: s = str(n) + ' ' elif n < 1e-22: s = '0.00 ' else: assert n < 9.99e26 log = int(math.floor(math.log10(n))) i, j = divmod(log, 3) for _try in range(2): templ = '%.{}f'.format(2 - j) val = templ % (n * 10 ** (-3 * i)) if val != '1000': break i += 1 j = 0 s += val + ' ' if i != 0: s += 'yzafpnum kMGTPEZY'[i + 8] return s
module function_definition identifier parameters identifier type identifier block expression_statement assignment identifier string string_start string_end if_statement comparison_operator identifier integer block expression_statement assignment identifier unary_operator identifier expression_statement augmented_assignment identifier string string_start string_content string_end if_statement boolean_operator comparison_operator call identifier argument_list identifier identifier comparison_operator identifier integer block expression_statement assignment identifier binary_operator call identifier argument_list identifier string string_start string_content string_end elif_clause comparison_operator identifier float block expression_statement assignment identifier string string_start string_content string_end else_clause block assert_statement comparison_operator identifier float expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier integer for_statement identifier call identifier argument_list integer block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list binary_operator integer identifier expression_statement assignment identifier binary_operator identifier parenthesized_expression binary_operator identifier binary_operator integer parenthesized_expression binary_operator unary_operator integer identifier if_statement comparison_operator identifier string string_start string_content string_end block break_statement expression_statement augmented_assignment identifier integer expression_statement assignment identifier integer expression_statement augmented_assignment identifier binary_operator identifier string string_start string_content string_end if_statement comparison_operator identifier integer block expression_statement augmented_assignment identifier subscript string string_start string_content string_end binary_operator identifier integer return_statement identifier
Format the integer or float n to 3 significant digits + SI prefix.
def replace_rep_after(text: str) -> str: "Replace repetitions at the character level in `text` after the repetition" def _replace_rep(m): c, cc = m.groups() return f"{c}{TK_REP}{len(cc)+1}" re_rep = re.compile(r"(\S)(\1{2,})") return re_rep.sub(_replace_rep, text)
module function_definition identifier parameters typed_parameter identifier type identifier type identifier block expression_statement string string_start string_content string_end function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list return_statement string string_start interpolation identifier interpolation identifier interpolation binary_operator call identifier argument_list identifier integer string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement call attribute identifier identifier argument_list identifier identifier
Replace repetitions at the character level in `text` after the repetition
def install_brew(target_path): if not os.path.exists(target_path): try: os.makedirs(target_path) except OSError: logger.warn("Unable to create directory %s for brew." % target_path) logger.warn("Skipping...") return extract_targz(HOMEBREW_URL, target_path, remove_common_prefix=True)
module function_definition identifier parameters identifier block if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block try_statement block expression_statement call attribute identifier identifier argument_list identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement expression_statement call identifier argument_list identifier identifier keyword_argument identifier true
Install brew to the target path
def flatten(nested_list): return_list = [] for i in nested_list: if isinstance(i,list): return_list += flatten(i) else: return_list.append(i) return return_list
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier identifier block if_statement call identifier argument_list identifier identifier block expression_statement augmented_assignment identifier call identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
converts a list-of-lists to a single flat list
def fromkeys(cls, iterable, value, **kwargs): return cls(((k, value) for k in iterable), **kwargs)
module function_definition identifier parameters identifier identifier identifier dictionary_splat_pattern identifier block return_statement call identifier argument_list generator_expression tuple identifier identifier for_in_clause identifier identifier dictionary_splat identifier
Return a new pqict mapping keys from an iterable to the same value.
def delete_metadata(address=None, tx_hash=None, block_hash=None, api_key=None, coin_symbol='btc'): assert is_valid_coin_symbol(coin_symbol), coin_symbol assert api_key, 'api_key required' kwarg = get_valid_metadata_identifier( coin_symbol=coin_symbol, address=address, tx_hash=tx_hash, block_hash=block_hash, ) url = make_url(coin_symbol, meta=True, **kwarg) params = {'token': api_key} r = requests.delete(url, params=params, verify=True, timeout=TIMEOUT_IN_SECONDS) return get_valid_json(r, allow_204=True)
module function_definition identifier parameters default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier string string_start string_content string_end block assert_statement call identifier argument_list identifier identifier assert_statement identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier true dictionary_splat identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier true keyword_argument identifier identifier return_statement call identifier argument_list identifier keyword_argument identifier true
Only available for metadata that was embedded privately.
def body(self): res = self._body[self.bcount]() self.bcount += 1 return res
module function_definition identifier parameters identifier block expression_statement assignment identifier call subscript attribute identifier identifier attribute identifier identifier argument_list expression_statement augmented_assignment attribute identifier identifier integer return_statement identifier
Returns the axis instance where the light curves will be shown
def dist_is_editable(dist): for path_item in sys.path: egg_link = os.path.join(path_item, dist.project_name + '.egg-link') if os.path.isfile(egg_link): return True return False
module function_definition identifier parameters identifier block for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier binary_operator attribute identifier identifier string string_start string_content string_end if_statement call attribute attribute identifier identifier identifier argument_list identifier block return_statement true return_statement false
Return True if given Distribution is an editable install.
def movetree(src, dst): try: shutil.move(src, dst) except: copytree(src, dst, symlinks=True, hardlinks=True) shutil.rmtree(src)
module function_definition identifier parameters identifier identifier block try_statement block expression_statement call attribute identifier identifier argument_list identifier identifier except_clause block expression_statement call identifier argument_list identifier identifier keyword_argument identifier true keyword_argument identifier true expression_statement call attribute identifier identifier argument_list identifier
Attempts a move, and falls back to a copy+delete if this fails
def workaround_lowering_pass(ir_blocks, query_metadata_table): new_ir_blocks = [] for block in ir_blocks: if isinstance(block, Filter): new_block = _process_filter_block(query_metadata_table, block) else: new_block = block new_ir_blocks.append(new_block) return new_ir_blocks
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list for_statement identifier identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier else_clause block expression_statement assignment identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Extract locations from TernaryConditionals and rewrite their Filter blocks as necessary.
def attrs(self, dynamizer): ret = { self.key: { 'Action': self.action, } } if not is_null(self.value): ret[self.key]['Value'] = dynamizer.encode(self.value) return ret
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary pair attribute identifier identifier dictionary pair string string_start string_content string_end attribute identifier identifier if_statement not_operator call identifier argument_list attribute identifier identifier block expression_statement assignment subscript subscript identifier attribute identifier identifier string string_start string_content string_end call attribute identifier identifier argument_list attribute identifier identifier return_statement identifier
Get the attributes for the update
def should_copy(column): if not isinstance(column.type, Serial): return True if column.nullable: return True if not column.server_default: return True return False
module function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list attribute identifier identifier identifier block return_statement true if_statement attribute identifier identifier block return_statement true if_statement not_operator attribute identifier identifier block return_statement true return_statement false
Determine if a column should be copied.
def preview(directory=None, host=None, port=None, watch=True): directory = directory or '.' host = host or '127.0.0.1' port = port or 5000 out_directory = build(directory) os.chdir(out_directory) Handler = SimpleHTTPServer.SimpleHTTPRequestHandler httpd = SocketServer.TCPServer((host, port), Handler) print ' * Serving on http://%s:%s/' % (host, port) httpd.serve_forever()
module function_definition identifier parameters default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier true block expression_statement assignment identifier boolean_operator identifier string string_start string_content string_end expression_statement assignment identifier boolean_operator identifier string string_start string_content string_end expression_statement assignment identifier boolean_operator identifier integer expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list tuple identifier identifier identifier print_statement binary_operator string string_start string_content string_end tuple identifier identifier expression_statement call attribute identifier identifier argument_list
Runs a local server to preview the working directory of a repository.
def write_main_socket(c): the_stdin_thread.socket_write.send(c) while True: try: the_stdin_thread.socket_write.recv(1) except socket.error as e: if e.errno != errno.EINTR: raise else: break
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier while_statement true block try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list integer except_clause as_pattern attribute identifier identifier as_pattern_target identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block raise_statement else_clause block break_statement
Synchronous write to the main socket, wait for ACK
def _process_cidr_file(self, file): data = {'cidr': list(), 'countries': set(), 'city_country_mapping': dict()} allowed_countries = settings.IPGEOBASE_ALLOWED_COUNTRIES for cidr_info in self._line_to_dict(file, field_names=settings.IPGEOBASE_CIDR_FIELDS): city_id = cidr_info['city_id'] if cidr_info['city_id'] != '-' else None if city_id is not None: data['city_country_mapping'].update({cidr_info['city_id']: cidr_info['country_code']}) if allowed_countries and cidr_info['country_code'] not in allowed_countries: continue data['cidr'].append({'start_ip': cidr_info['start_ip'], 'end_ip': cidr_info['end_ip'], 'country_id': cidr_info['country_code'], 'city_id': city_id}) data['countries'].add(cidr_info['country_code']) return data
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end call identifier argument_list pair string string_start string_content string_end call identifier argument_list pair string string_start string_content string_end call identifier argument_list expression_statement assignment identifier attribute identifier identifier for_statement identifier call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier block expression_statement assignment identifier conditional_expression subscript identifier string string_start string_content string_end comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end none if_statement comparison_operator identifier none block expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list dictionary pair subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end if_statement boolean_operator identifier comparison_operator subscript identifier string string_start string_content string_end identifier block continue_statement expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list dictionary pair string string_start string_content string_end subscript identifier string string_start string_content string_end pair string string_start string_content string_end subscript identifier string string_start string_content string_end pair string string_start string_content string_end subscript identifier string string_start string_content string_end pair string string_start string_content string_end identifier expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list subscript identifier string string_start string_content string_end return_statement identifier
Iterate over ip info and extract useful data
def update_backward_window(turn_from, tick_from, turn_to, tick_to, updfun, branchd): if turn_from in branchd: for future_state in reversed(branchd[turn_from][:tick_from]): updfun(*future_state) for midturn in range(turn_from-1, turn_to, -1): if midturn in branchd: for future_state in reversed(branchd[midturn][:]): updfun(*future_state) if turn_to in branchd: for future_state in reversed(branchd[turn_to][tick_to+1:]): updfun(*future_state)
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block if_statement comparison_operator identifier identifier block for_statement identifier call identifier argument_list subscript subscript identifier identifier slice identifier block expression_statement call identifier argument_list list_splat identifier for_statement identifier call identifier argument_list binary_operator identifier integer identifier unary_operator integer block if_statement comparison_operator identifier identifier block for_statement identifier call identifier argument_list subscript subscript identifier identifier slice block expression_statement call identifier argument_list list_splat identifier if_statement comparison_operator identifier identifier block for_statement identifier call identifier argument_list subscript subscript identifier identifier slice binary_operator identifier integer block expression_statement call identifier argument_list list_splat identifier
Iterate backward over a window of time in ``branchd`` and call ``updfun`` on the values
def report(self, request: 'Request'=None, state: Text=None): self._make_context(request, state) self.client.captureException() self._clear_context()
module function_definition identifier parameters identifier typed_default_parameter identifier type string string_start string_content string_end none typed_default_parameter identifier type identifier none block expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list
Report current exception to Sentry.
async def get_sleep_timer_settings(self) -> List[Setting]: return [ Setting.make(**x) for x in await self.services["system"]["getSleepTimerSettings"]({}) ]
module function_definition identifier parameters identifier type generic_type identifier type_parameter type identifier block return_statement list_comprehension call attribute identifier identifier argument_list dictionary_splat identifier for_in_clause 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
Get sleep timer settings.
def convert2geojson(jsonfile, src_srs, dst_srs, src_file): if os.path.exists(jsonfile): os.remove(jsonfile) if sysstr == 'Windows': exepath = '"%s/Lib/site-packages/osgeo/ogr2ogr"' % sys.exec_prefix else: exepath = FileClass.get_executable_fullpath('ogr2ogr') s = '%s -f GeoJSON -s_srs "%s" -t_srs %s %s %s' % ( exepath, src_srs, dst_srs, jsonfile, src_file) UtilClass.run_command(s)
module function_definition identifier parameters identifier identifier identifier identifier block if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier binary_operator string string_start string_content string_end attribute identifier identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier
convert shapefile to geojson file
def sendStatusPing(self): data = parse.urlencode({"key": self.key, "version": self.version}).encode() req = request.Request("https://redunda.sobotics.org/status.json", data) response = request.urlopen(req) jsonReturned = json.loads(response.read().decode("utf-8")) self.location = jsonReturned["location"] self.shouldStandby = jsonReturned["should_standby"] self.eventCount = jsonReturned["event_count"]
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute 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 identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute call attribute identifier identifier argument_list identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end
Sends a status ping to Redunda with the instance key specified while constructing the object.
def _text_file(self, url): try: with open(url, 'r', encoding='utf-8') as file: return file.read() except FileNotFoundError: print('File `{}` not found'.format(url)) sys.exit(0)
module function_definition identifier parameters identifier identifier block try_statement block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end as_pattern_target identifier block return_statement call attribute identifier identifier argument_list except_clause identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list integer
return the content of a file
def reset(self): self.command_stack = [] self.scripts = set() self.watches = [] self.watching = False self.explicit_transaction = False
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier list expression_statement assignment attribute identifier identifier call identifier argument_list expression_statement assignment attribute identifier identifier list expression_statement assignment attribute identifier identifier false expression_statement assignment attribute identifier identifier false
Reset back to empty pipeline.
def crawl_fig(self, fig): with self.renderer.draw_figure(fig=fig, props=utils.get_figure_properties(fig)): for ax in fig.axes: self.crawl_ax(ax)
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 identifier keyword_argument identifier call attribute identifier identifier argument_list identifier block for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier
Crawl the figure and process all axes
def select_by_field(self, base, field, value): Ac = self.ACCES return groups.Collection(Ac(base, i) for i, row in self.items() if row[field] == value)
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier attribute identifier identifier return_statement call attribute identifier identifier generator_expression call identifier argument_list identifier identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list if_clause comparison_operator subscript identifier identifier identifier
Return collection of acces whose field equal value
def _get_data_segments(channels, start, end, connection): allsegs = io_nds2.get_availability(channels, start, end, connection=connection) return allsegs.intersection(allsegs.keys())
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier keyword_argument identifier identifier return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list
Get available data segments for the given channels
def children(self): from warnings import warn warn("Deprecated. Use Scraper.descendants.", DeprecationWarning) for descendant in self.descendants: yield descendant
module function_definition identifier parameters identifier block import_from_statement dotted_name identifier dotted_name identifier expression_statement call identifier argument_list string string_start string_content string_end identifier for_statement identifier attribute identifier identifier block expression_statement yield identifier
Former, misleading name for descendants.
def getReqId(self) -> int: if not self.isReady(): raise ConnectionError('Not connected') newId = self._reqIdSeq self._reqIdSeq += 1 return newId
module function_definition identifier parameters identifier type identifier block if_statement not_operator call attribute identifier identifier argument_list block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier attribute identifier identifier expression_statement augmented_assignment attribute identifier identifier integer return_statement identifier
Get new request ID.
def parse_to_tree(text): xml_text = cabocha.as_xml(text) tree = Tree(xml_text) return tree
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier return_statement identifier
Parse text using CaboCha, then return Tree instance.
def check_that_operator_can_be_applied_to_produces_items(op, g1, g2): g1_tmp_copy = g1.spawn() g2_tmp_copy = g2.spawn() sample_item_1 = next(g1_tmp_copy) sample_item_2 = next(g2_tmp_copy) try: op(sample_item_1, sample_item_2) except TypeError: raise TypeError(f"Operator '{op.__name__}' cannot be applied to items produced by {g1} and {g2} " f"(which have type {type(sample_item_1)} and {type(sample_item_2)}, respectively)")
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier try_statement block expression_statement call identifier argument_list identifier identifier except_clause identifier block raise_statement call identifier argument_list concatenated_string string string_start string_content interpolation attribute identifier identifier string_content interpolation identifier string_content interpolation identifier string_content string_end string string_start string_content interpolation call identifier argument_list identifier string_content interpolation call identifier argument_list identifier string_content string_end
Helper function to check that the operator `op` can be applied to items produced by g1 and g2.
def filter(self, qs, value): _id = None if value is not None: _, _id = from_global_id(value) return super(GlobalIDFilter, self).filter(qs, _id)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier none if_statement comparison_operator identifier none block expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier return_statement call attribute call identifier argument_list identifier identifier identifier argument_list identifier identifier
Convert the filter value to a primary key before filtering
def clean_name(self): "Avoid name clashes between static and dynamic attributes." name = self.cleaned_data['name'] reserved_names = self._meta.model._meta.get_all_field_names() if name not in reserved_names: return name raise ValidationError(_('Attribute name must not clash with reserved names' ' ("%s")') % '", "'.join(reserved_names))
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute attribute attribute identifier identifier identifier identifier identifier argument_list if_statement comparison_operator identifier identifier block return_statement identifier raise_statement call identifier argument_list binary_operator call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list identifier
Avoid name clashes between static and dynamic attributes.
def speak(self, text): if not self.is_valid_string(text): raise Exception("%s is not ISO-8859-1 compatible." % (text)) if len(text) > 1023: lines = self.word_wrap(text, width=1023) for line in lines: self.queue.put("S%s" % (line)) else: self.queue.put("S%s" % (text))
module function_definition identifier parameters identifier identifier block if_statement not_operator call attribute identifier identifier argument_list identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end parenthesized_expression identifier if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier integer for_statement identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end parenthesized_expression identifier else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end parenthesized_expression identifier
The main function to convert text into speech.
def update_metric(self, metric, labels, pre_sliced=False): for current_exec, (texec, islice) in enumerate(zip(self.train_execs, self.slices)): if not pre_sliced: labels_slice = [label[islice] for label in labels] else: labels_slice = labels[current_exec] metric.update(labels_slice, texec.outputs)
module function_definition identifier parameters identifier identifier identifier default_parameter identifier false block for_statement pattern_list identifier tuple_pattern identifier identifier call identifier argument_list call identifier argument_list attribute identifier identifier attribute identifier identifier block if_statement not_operator identifier block expression_statement assignment identifier list_comprehension subscript identifier identifier for_in_clause identifier identifier else_clause block expression_statement assignment identifier subscript identifier identifier expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier
Update evaluation metric with label and current outputs.
def _init_usrgos(self, goids): usrgos = set() goids_missing = set() _go2obj = self.gosubdag.go2obj for goid in goids: if goid in _go2obj: usrgos.add(goid) else: goids_missing.add(goid) if goids_missing: print("MISSING GO IDs: {GOs}".format(GOs=goids_missing)) print("{N} of {M} GO IDs ARE MISSING".format(N=len(goids_missing), M=len(goids))) return usrgos
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier attribute attribute identifier identifier identifier for_statement identifier identifier block if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier call identifier argument_list identifier keyword_argument identifier call identifier argument_list identifier return_statement identifier
Return user GO IDs which have GO Terms.
def real_pathspec(self): pathspec = self.Get(self.Schema.PATHSPEC) stripped_components = [] parent = self while not pathspec and len(parent.urn.Split()) > 1: stripped_components.append(parent.urn.Basename()) pathspec = parent.Get(parent.Schema.PATHSPEC) parent = FACTORY.Open(parent.urn.Dirname(), token=self.token) if pathspec: if stripped_components: new_path = utils.JoinPath(*reversed(stripped_components[:-1])) pathspec.Append( rdf_paths.PathSpec(path=new_path, pathtype=pathspec.last.pathtype)) else: raise IOError("Item has no pathspec.") return pathspec
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier expression_statement assignment identifier list expression_statement assignment identifier identifier while_statement boolean_operator not_operator identifier comparison_operator call identifier argument_list call attribute attribute identifier identifier identifier argument_list integer block expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier if_statement identifier block if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list list_splat call identifier argument_list subscript identifier slice unary_operator integer expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier else_clause block raise_statement call identifier argument_list string string_start string_content string_end return_statement identifier
Returns a pathspec for an aff4 object even if there is none stored.
def on_comment_entered(self): text_edit = self.findChild(QtWidgets.QWidget, "CommentBox") comment = text_edit.text() context = self.controller.context context.data["comment"] = comment placeholder = self.findChild(QtWidgets.QLabel, "CommentPlaceholder") placeholder.setVisible(not comment)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list not_operator identifier
The user has typed a comment
def _get_private_room(self, invitees: List[User]): return self._client.create_room( None, invitees=[user.user_id for user in invitees], is_public=False, )
module function_definition identifier parameters identifier typed_parameter identifier type generic_type identifier type_parameter type identifier block return_statement call attribute attribute identifier identifier identifier argument_list none keyword_argument identifier list_comprehension attribute identifier identifier for_in_clause identifier identifier keyword_argument identifier false
Create an anonymous, private room and invite peers
def hash_text(text): md5 = hashlib.md5() md5.update(text) return md5.hexdigest()
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list
Return MD5 hash of a string.
def _gwf_channel_segments(path, channel, warn=True): stream = open_gwf(path) toc = stream.GetTOC() secs = toc.GetGTimeS() nano = toc.GetGTimeN() dur = toc.GetDt() readers = [getattr(stream, 'ReadFr{0}Data'.format(type_.title())) for type_ in ("proc", "sim", "adc")] for i, (s, ns, dt) in enumerate(zip(secs, nano, dur)): for read in readers: try: read(i, channel) except (IndexError, ValueError): continue readers = [read] epoch = LIGOTimeGPS(s, ns) yield Segment(epoch, epoch + dt) break else: if warn: warnings.warn( "{0!r} not found in frame {1} of {2}".format( channel, i, path), )
module function_definition identifier parameters identifier identifier default_parameter identifier true block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier list_comprehension call identifier argument_list identifier call attribute string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list for_in_clause identifier tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end for_statement pattern_list identifier tuple_pattern identifier identifier identifier call identifier argument_list call identifier argument_list identifier identifier identifier block for_statement identifier identifier block try_statement block expression_statement call identifier argument_list identifier identifier except_clause tuple identifier identifier block continue_statement expression_statement assignment identifier list identifier expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement yield call identifier argument_list identifier binary_operator identifier identifier break_statement else_clause block if_statement identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier identifier
Yields the segments containing data for ``channel`` in this GWF path
def Times(self, val): return Point(self.x * val, self.y * val, self.z * val)
module function_definition identifier parameters identifier identifier block return_statement call identifier argument_list binary_operator attribute identifier identifier identifier binary_operator attribute identifier identifier identifier binary_operator attribute identifier identifier identifier
Returns a new point which is pointwise multiplied by val.
def usage(): global options l = len(options['long']) options['shortlist'] = [s for s in options['short'] if s is not ":"] print("python -m behave2cucumber [-h] [-d level|--debug=level]") for i in range(l): print(" -{0}|--{1:20} {2}".format(options['shortlist'][i], options['long'][i], options['descriptions'][i]))
module function_definition identifier parameters block global_statement identifier expression_statement assignment identifier call identifier argument_list subscript identifier string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end list_comprehension identifier for_in_clause identifier subscript identifier string string_start string_content string_end if_clause comparison_operator identifier string string_start string_content string_end expression_statement call identifier argument_list string string_start string_content string_end for_statement identifier call identifier argument_list identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list subscript subscript identifier string string_start string_content string_end identifier subscript subscript identifier string string_start string_content string_end identifier subscript subscript identifier string string_start string_content string_end identifier
Print out a usage message
def live_streaming(self): url = STREAM_ENDPOINT params = STREAMING_BODY params['from'] = "{0}_web".format(self.user_id) params['to'] = self.device_id params['resource'] = "cameras/{0}".format(self.device_id) params['transId'] = "web!{0}".format(self.xcloud_id) headers = {'xCloudId': self.xcloud_id} _LOGGER.debug("Streaming device %s", self.name) _LOGGER.debug("Device params %s", params) _LOGGER.debug("Device headers %s", headers) ret = self._session.query(url, method='POST', extra_params=params, extra_headers=headers) _LOGGER.debug("Streaming results %s", ret) if ret.get('success'): return ret.get('data').get('url') return ret.get('data')
module function_definition identifier parameters identifier block expression_statement assignment identifier identifier expression_statement assignment identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list 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 call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement call attribute identifier identifier argument_list string string_start string_content string_end block return_statement call attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier argument_list string string_start string_content string_end return_statement call attribute identifier identifier argument_list string string_start string_content string_end
Return live streaming generator.
def read_config(): config = _load_config() if config.get(CFG_IGNORE_DEFAULT_RULES[1], False): del IGNORE[:] if CFG_IGNORE[1] in config: IGNORE.extend(p for p in config[CFG_IGNORE[1]] if p) if CFG_IGNORE_BAD_IDEAS[1] in config: IGNORE_BAD_IDEAS.extend(p for p in config[CFG_IGNORE_BAD_IDEAS[1]] if p)
module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list if_statement call attribute identifier identifier argument_list subscript identifier integer false block delete_statement subscript identifier slice if_statement comparison_operator subscript identifier integer identifier block expression_statement call attribute identifier identifier generator_expression identifier for_in_clause identifier subscript identifier subscript identifier integer if_clause identifier if_statement comparison_operator subscript identifier integer identifier block expression_statement call attribute identifier identifier generator_expression identifier for_in_clause identifier subscript identifier subscript identifier integer if_clause identifier
Read configuration from file if possible.
def populateImagesFromSurveys(self, surveys=dss2 + twomass): coordinatetosearch = '{0.ra.deg} {0.dec.deg}'.format(self.center) paths = astroquery.skyview.SkyView.get_images( position=coordinatetosearch, radius=self.radius, survey=surveys) self.images = [Image(p[0], s) for p, s in zip(paths, surveys)]
module function_definition identifier parameters identifier default_parameter identifier binary_operator identifier identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier expression_statement assignment attribute identifier identifier list_comprehension call identifier argument_list subscript identifier integer identifier for_in_clause pattern_list identifier identifier call identifier argument_list identifier identifier
Load images from archives.
def cli(env, identifier): manager = SoftLayer.SSLManager(env.client) certificate = manager.get_certificate(identifier) write_cert(certificate['commonName'] + '.crt', certificate['certificate']) write_cert(certificate['commonName'] + '.key', certificate['privateKey']) if 'intermediateCertificate' in certificate: write_cert(certificate['commonName'] + '.icc', certificate['intermediateCertificate']) if 'certificateSigningRequest' in certificate: write_cert(certificate['commonName'] + '.csr', certificate['certificateSigningRequest'])
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list binary_operator subscript identifier string string_start string_content string_end string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement call identifier argument_list binary_operator subscript identifier string string_start string_content string_end string string_start string_content string_end subscript identifier string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement call identifier argument_list binary_operator subscript identifier string string_start string_content string_end string string_start string_content string_end subscript identifier string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement call identifier argument_list binary_operator subscript identifier string string_start string_content string_end string string_start string_content string_end subscript identifier string string_start string_content string_end
Download SSL certificate and key file.
def generate_query_report(self, db_uri, parsed_query, db_name, collection_name): index_analysis = None recommendation = None namespace = parsed_query['ns'] indexStatus = "unknown" index_cache_entry = self._ensure_index_cache(db_uri, db_name, collection_name) query_analysis = self._generate_query_analysis(parsed_query, db_name, collection_name) if ((query_analysis['analyzedFields'] != []) and query_analysis['supported']): index_analysis = self._generate_index_analysis(query_analysis, index_cache_entry['indexes']) indexStatus = index_analysis['indexStatus'] if index_analysis['indexStatus'] != 'full': recommendation = self._generate_recommendation(query_analysis, db_name, collection_name) if not validate_yaml(recommendation['index']): recommendation = None query_analysis['supported'] = False return OrderedDict({ 'queryMask': parsed_query['queryMask'], 'indexStatus': indexStatus, 'parsed': parsed_query, 'namespace': namespace, 'queryAnalysis': query_analysis, 'indexAnalysis': index_analysis, 'recommendation': recommendation })
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier none expression_statement assignment identifier none expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier if_statement parenthesized_expression boolean_operator parenthesized_expression comparison_operator subscript identifier string string_start string_content string_end list subscript identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier string string_start string_content string_end if_statement comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier if_statement not_operator call identifier argument_list subscript identifier string string_start string_content string_end block expression_statement assignment identifier none expression_statement assignment subscript identifier string string_start string_content string_end false return_statement call identifier argument_list dictionary pair string string_start string_content string_end subscript identifier string string_start string_content string_end pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier
Generates a comprehensive report on the raw query