code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def trigger_event(self, module_name, event): if module_name: self._py3_wrapper.events_thread.process_event(module_name, event)
module function_definition identifier parameters identifier identifier identifier block if_statement identifier block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier identifier
Trigger an event on a named module.
def _sge_get_slots(xmlstring): rootxml = ET.fromstring(xmlstring) my_machine_dict = {} for queue_list in rootxml.iter("Queue-List"): my_hostname = queue_list.find("name").text.rsplit("@")[-1] my_slots = queue_list.find("slots_total").text my_machine_dict[my_hostname] = {} my_machine_dict[my_hostname]["slots_total"] = int(my_slots) return my_machine_dict
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier dictionary for_statement identifier call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier subscript call attribute attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier argument_list string string_start string_content string_end unary_operator integer expression_statement assignment identifier attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment subscript identifier identifier dictionary expression_statement assignment subscript subscript identifier identifier string string_start string_content string_end call identifier argument_list identifier return_statement identifier
Get slot information from qstat
def extract(ctx, input, output): log.info('chemdataextractor.extract') log.info('Reading %s' % input.name) doc = Document.from_file(input, fname=input.name) records = [record.serialize(primitive=True) for record in doc.records] jsonstring = json.dumps(records, indent=2, ensure_ascii=False) output.write(jsonstring)
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list keyword_argument identifier true for_in_clause identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier integer keyword_argument identifier false expression_statement call attribute identifier identifier argument_list identifier
Run ChemDataExtractor on a document.
def _cbGotHello(self, busName): self.busName = busName self.factory._ok(self)
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Called in reply to the initial Hello remote method invocation
def _load_config_file(self): with open(self._config_file) as f: config = yaml.safe_load(f) patch_config(config, self.__environment_configuration) return config
module function_definition identifier parameters identifier block with_statement with_clause with_item as_pattern call identifier argument_list attribute identifier identifier as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list identifier attribute identifier identifier return_statement identifier
Loads config.yaml from filesystem and applies some values which were set via ENV
def category_count(self): category_dict = self.categories count_dict = {category: len( category_dict[category]) for category in category_dict} return count_dict
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier dictionary_comprehension pair identifier call identifier argument_list subscript identifier identifier for_in_clause identifier identifier return_statement identifier
Returns the number of categories in `categories`.
def save(self) -> None: logger.info('saving registry to: %s', self.__registry_fn) d = [s.to_dict() for s in self] os.makedirs(self.__path, exist_ok=True) with open(self.__registry_fn, 'w') as f: yaml.dump(d, f, indent=2, default_flow_style=False) logger.info('saved registry to: %s', self.__registry_fn)
module function_definition identifier parameters identifier type none block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list for_in_clause identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier true 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 identifier keyword_argument identifier integer keyword_argument identifier false expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier
Saves the contents of the source manager to disk.
def visibility(vis: Number, unit: str = 'm') -> str: if not vis: return 'Visibility unknown' if vis.value is None or '/' in vis.repr: ret_vis = vis.spoken else: ret_vis = translate.visibility(vis, unit=unit) if unit == 'm': unit = 'km' ret_vis = ret_vis[:ret_vis.find(' (')].lower().replace(unit, '').strip() ret_vis = core.spoken_number(core.remove_leading_zeros(ret_vis)) ret = 'Visibility ' + ret_vis if unit in SPOKEN_UNITS: if '/' in vis.repr and 'half' not in ret: ret += ' of a' ret += ' ' + SPOKEN_UNITS[unit] if not (('one half' in ret and ' and ' not in ret) or 'of a' in ret): ret += 's' else: ret += unit return ret
module function_definition identifier parameters typed_parameter identifier type identifier typed_default_parameter identifier type identifier string string_start string_content string_end type identifier block if_statement not_operator identifier block return_statement string string_start string_content string_end if_statement boolean_operator comparison_operator attribute identifier identifier none comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement assignment identifier attribute identifier identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute call attribute call attribute subscript identifier slice call attribute identifier identifier argument_list string string_start string_content string_end identifier argument_list identifier argument_list identifier string string_start string_end identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator string string_start string_content string_end identifier if_statement comparison_operator identifier identifier block if_statement boolean_operator comparison_operator string string_start string_content string_end attribute identifier identifier comparison_operator string string_start string_content string_end identifier block expression_statement augmented_assignment identifier string string_start string_content string_end expression_statement augmented_assignment identifier binary_operator string string_start string_content string_end subscript identifier identifier if_statement not_operator parenthesized_expression boolean_operator parenthesized_expression boolean_operator comparison_operator string string_start string_content string_end identifier comparison_operator string string_start string_content string_end identifier comparison_operator string string_start string_content string_end identifier block expression_statement augmented_assignment identifier string string_start string_content string_end else_clause block expression_statement augmented_assignment identifier identifier return_statement identifier
Format visibility details into a spoken word string
def create_mv_rule(tensorprod_rule, dim): def mv_rule(order, sparse=False, part=None): if sparse: order = numpy.ones(dim, dtype=int)*order tensorprod_rule_ = lambda order, part=part:\ tensorprod_rule(order, part=part) return chaospy.quad.sparse_grid(tensorprod_rule_, order) return tensorprod_rule(order, part=part) return mv_rule
module function_definition identifier parameters identifier identifier block function_definition identifier parameters identifier default_parameter identifier false default_parameter identifier none block if_statement identifier block expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list identifier keyword_argument identifier identifier identifier expression_statement assignment identifier lambda lambda_parameters identifier default_parameter identifier identifier line_continuation call identifier argument_list identifier keyword_argument identifier identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier identifier return_statement call identifier argument_list identifier keyword_argument identifier identifier return_statement identifier
Convert tensor product rule into a multivariate quadrature generator.
def update_displayed_information(self): for source in self.controller.sources: source_name = source.get_source_name() if (any(self.graphs_menu.active_sensors[source_name]) or any(self.summary_menu.active_sensors[source_name])): source.update() for graph in self.visible_graphs.values(): graph.update() for summary in self.visible_summaries.values(): summary.update() if self.controller.stress_conroller.get_current_mode() != 'Monitor': self.clock_view.set_text(seconds_to_text( (timeit.default_timer() - self.controller.stress_start_time)))
module function_definition identifier parameters identifier block for_statement identifier attribute attribute identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement parenthesized_expression boolean_operator call identifier argument_list subscript attribute attribute identifier identifier identifier identifier call identifier argument_list subscript attribute attribute identifier identifier identifier identifier block expression_statement call attribute identifier identifier argument_list for_statement identifier call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list for_statement identifier call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list if_statement comparison_operator call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list parenthesized_expression binary_operator call attribute identifier identifier argument_list attribute attribute identifier identifier identifier
Update all the graphs that are being displayed
def _render_table(data, fields=None): return IPython.core.display.HTML(datalab.utils.commands.HtmlBuilder.render_table(data, fields))
module function_definition identifier parameters identifier default_parameter identifier none block return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list call attribute attribute attribute attribute identifier identifier identifier identifier identifier argument_list identifier identifier
Helper to render a list of dictionaries as an HTML display object.
def attach(self, to_linode, config=None): result = self._client.post('{}/attach'.format(Volume.api_endpoint), model=self, data={ "linode_id": to_linode.id if issubclass(type(to_linode), Base) else to_linode, "config": None if not config else config.id if issubclass(type(config), Base) else config, }) if not 'id' in result: raise UnexpectedResponseError('Unexpected response when attaching volume!', json=result) self._populate(result) return True
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier dictionary pair string string_start string_content string_end conditional_expression attribute identifier identifier call identifier argument_list call identifier argument_list identifier identifier identifier pair string string_start string_content string_end conditional_expression none not_operator identifier conditional_expression attribute identifier identifier call identifier argument_list call identifier argument_list identifier identifier identifier if_statement not_operator comparison_operator string string_start string_content string_end identifier block raise_statement call identifier argument_list string string_start string_content string_end keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement true
Attaches this Volume to the given Linode
def eval_string(stri): 'evaluate expressions passed as string' tokens = shlex.split(stri) return run_write_read(['plash', 'eval'], '\n'.join(tokens).encode()).decode()
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement call attribute call identifier argument_list list string string_start string_content string_end string string_start string_content string_end call attribute call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier identifier argument_list identifier argument_list
evaluate expressions passed as string
def _generate(self): u self._data['key'] = self.key self._data['value'] = self.value self._data['host'] = self.host self._data['clock'] = self.clock
module function_definition identifier parameters identifier block expression_statement identifier expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier
u"""overrided in each modules.
def prepare_callable(self, fn, partial=False): notes, keyword_notes = self.get_annotations(fn) return self.prepare_notes(*notes, __partial=partial, **keyword_notes)
module function_definition identifier parameters identifier identifier default_parameter identifier false block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list list_splat identifier keyword_argument identifier identifier dictionary_splat identifier
Prepare arguments required to apply function.
def _getSuperFunc(self, s, func): return getattr(super(self.cls(), s), func.__name__)
module function_definition identifier parameters identifier identifier identifier block return_statement call identifier argument_list call identifier argument_list call attribute identifier identifier argument_list identifier attribute identifier identifier
Return the the super function.
def geo_context_from_ref(self, ref): value = ref.get('value') if value: rc = self.doc.geolocs.get(value['@id']) return rc return None
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list subscript identifier string string_start string_content string_end return_statement identifier return_statement none
Return a ref context object given a location reference entry.
def run_epoch(self, epoch_info: EpochInfo, source: 'vel.api.Source'): epoch_info.on_epoch_begin() lr = epoch_info.optimizer.param_groups[-1]['lr'] print("|-------- Epoch {:06} Lr={:.6f} ----------|".format(epoch_info.global_epoch_idx, lr)) self.train_epoch(epoch_info, source) epoch_info.result_accumulator.freeze_results('train') self.validation_epoch(epoch_info, source) epoch_info.result_accumulator.freeze_results('val') epoch_info.on_epoch_end()
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier subscript subscript attribute attribute identifier identifier identifier unary_operator integer string string_start string_content string_end expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list
Run full epoch of learning
def setupDock(self): self.dock = QtWidgets.QDockWidget("Classes", self) self.dock.setWidget(self.tree) self.dock.setFeatures(QtWidgets.QDockWidget.NoDockWidgetFeatures) self.addDockWidget(QtCore.Qt.LeftDockWidgetArea, self.dock)
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list attribute attribute identifier identifier identifier attribute identifier identifier
Setup empty Dock at startup.
def visit_loginurl(self): url = self.config["loginurl"] if not url: return user, password = self.config.get_user_password(url) session = requests.Session() response = session.get(url) cgiuser = self.config["loginuserfield"] cgipassword = self.config["loginpasswordfield"] form = formsearch.search_form(response.content, cgiuser, cgipassword, encoding=response.encoding) form.data[cgiuser] = user form.data[cgipassword] = password for key, value in self.config["loginextrafields"].items(): form.data[key] = value formurl = urlparse.urljoin(url, form.url) response = session.post(formurl, data=form.data) self.cookies = session.cookies if len(self.cookies) == 0: raise LinkCheckerError("No cookies set by login URL %s" % url)
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end if_statement not_operator identifier block return_statement expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier subscript attribute identifier identifier 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 identifier identifier argument_list attribute identifier identifier identifier identifier keyword_argument identifier attribute identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier for_statement pattern_list identifier identifier call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list block expression_statement assignment subscript attribute identifier identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier if_statement comparison_operator call identifier argument_list attribute identifier identifier integer block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier
Check for a login URL and visit it.
def record_to_objects(self): from ambry.orm import SourceTable bsfile = self.record failures = set() for row in bsfile.dict_row_reader: st = self._dataset.source_table(row['table']) if st: st.columns[:] = [] self._dataset.commit() for row in bsfile.dict_row_reader: st = self._dataset.source_table(row['table']) if not st: st = self._dataset.new_source_table(row['table']) if 'datatype' not in row: row['datatype'] = 'unknown' del row['table'] st.add_column(**row) if failures: raise ConfigurationError('Failed to load source schema, missing sources: {} '.format(failures)) self._dataset.commit()
module function_definition identifier parameters identifier block import_from_statement dotted_name identifier identifier dotted_name identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list subscript identifier string string_start string_content string_end if_statement identifier block expression_statement assignment subscript attribute identifier identifier slice list expression_statement call attribute attribute identifier identifier identifier argument_list for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list subscript identifier string string_start string_content string_end if_statement not_operator identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list subscript identifier string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end delete_statement subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list dictionary_splat identifier if_statement identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list
Write from the stored file data to the source records
def validate(self, val): if self.validation: self.type.validate(val) if self.custom_validator is not None: self.custom_validator(val) return True
module function_definition identifier parameters identifier identifier block if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute identifier identifier argument_list identifier return_statement true
Validate values according to the requirement
def serialized_task(self, task: Task) -> Tuple[str, str]: return f"{task.hash}.json", task.json
module function_definition identifier parameters identifier typed_parameter identifier type identifier type generic_type identifier type_parameter type identifier type identifier block return_statement expression_list string string_start interpolation attribute identifier identifier string_content string_end attribute identifier identifier
Returns the name of the task definition file and its contents.
def rgb2gray(img): T = np.linalg.inv(np.array([ [1.0, 0.956, 0.621], [1.0, -0.272, -0.647], [1.0, -1.106, 1.703], ])) r_c, g_c, b_c = T[0] r, g, b = np.rollaxis(as_float_image(img), axis=-1) return r_c * r + g_c * g + b_c * b
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list list list float float float list float unary_operator float unary_operator float list float unary_operator float float expression_statement assignment pattern_list identifier identifier identifier subscript identifier integer expression_statement assignment pattern_list identifier identifier identifier call attribute identifier identifier argument_list call identifier argument_list identifier keyword_argument identifier unary_operator integer return_statement binary_operator binary_operator binary_operator identifier identifier binary_operator identifier identifier binary_operator identifier identifier
Converts an RGB image to grayscale using matlab's algorithm.
def stream_stdin_lines(): stdin = os.fdopen(sys.stdin.fileno(), 'r', 0) while True: line = stdin.readline() if line: yield line else: break
module function_definition identifier parameters block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end integer while_statement true block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement identifier block expression_statement yield identifier else_clause block break_statement
Generator for unbuffered line reading from STDIN
def CheckDataStoreAccess(self, token, subjects, requested_access="r"): if any(not x for x in subjects): raise ValueError("Subjects list can't contain empty URNs.") subjects = list(map(rdfvalue.RDFURN, subjects)) return (ValidateAccessAndSubjects(requested_access, subjects) and ValidateToken(token, subjects) and (token.supervisor or self._CheckAccessWithHelpers(token, subjects, requested_access)))
module function_definition identifier parameters identifier identifier identifier default_parameter identifier string string_start string_content string_end block if_statement call identifier generator_expression not_operator identifier for_in_clause identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list call identifier argument_list attribute identifier identifier identifier return_statement parenthesized_expression boolean_operator boolean_operator call identifier argument_list identifier identifier call identifier argument_list identifier identifier parenthesized_expression boolean_operator attribute identifier identifier call attribute identifier identifier argument_list identifier identifier identifier
Allow all access if token and requested access are valid.
def deactivate_mfa_device(self, user_name, serial_number): user = self.get_user(user_name) if serial_number not in user.mfa_devices: raise IAMNotFoundException( "Device {0} not found".format(serial_number) ) user.deactivate_mfa_device(serial_number)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier attribute identifier identifier block raise_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 identifier
Deactivate and detach MFA Device from user if device exists.
def rename(self, name): r = self._h._http_resource( method='PUT', resource=('apps', self.name), data={'app[name]': name} ) return r.ok
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier tuple string string_start string_content string_end attribute identifier identifier keyword_argument identifier dictionary pair string string_start string_content string_end identifier return_statement attribute identifier identifier
Renames app to given name.
def appt_exists(self, complex: str, house: str, appt: str) -> bool: try: self.check_appt(complex, house, appt) except exceptions.RumetrApptNotFound: return False return True
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier type identifier block try_statement block expression_statement call attribute identifier identifier argument_list identifier identifier identifier except_clause attribute identifier identifier block return_statement false return_statement true
Shortcut to check if appt exists in our database.
def _get_s16(self, msb, lsb): buf = struct.pack('>bB', self._get_s8(msb), self._get_u8(lsb)) return int(struct.unpack('>h', buf)[0])
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier return_statement call identifier argument_list subscript call attribute identifier identifier argument_list string string_start string_content string_end identifier integer
Convert 2 bytes into a signed int.
def write_workflow(self, request, opts, cwd, wftype='cwl'): workflow_url = request.get("workflow_url") if workflow_url.startswith('file://'): os.link(workflow_url[7:], os.path.join(cwd, "wes_workflow." + wftype)) workflow_url = os.path.join(cwd, "wes_workflow." + wftype) os.link(self.input_json, os.path.join(cwd, "wes_input.json")) self.input_json = os.path.join(cwd, "wes_input.json") extra_options = self.sort_toil_options(opts.getoptlist("extra")) if wftype == 'cwl': command_args = ['toil-cwl-runner'] + extra_options + [workflow_url, self.input_json] elif wftype == 'wdl': command_args = ['toil-wdl-runner'] + extra_options + [workflow_url, self.input_json] elif wftype == 'py': command_args = ['python'] + extra_options + [workflow_url] else: raise RuntimeError('workflow_type is not "cwl", "wdl", or "py": ' + str(wftype)) return command_args
module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list subscript identifier slice integer call attribute attribute identifier identifier identifier argument_list identifier binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier binary_operator string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier binary_operator binary_operator list string string_start string_content string_end identifier list identifier attribute identifier identifier elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier binary_operator binary_operator list string string_start string_content string_end identifier list identifier attribute identifier identifier elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier binary_operator binary_operator list string string_start string_content string_end identifier list identifier else_clause block raise_statement call identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier return_statement identifier
Writes a cwl, wdl, or python file as appropriate from the request dictionary.
def sigmafilter(data, sigmas, passes): for n in range(passes): meandata = np.mean(data[~np.isnan(data)]) sigma = np.std(data[~np.isnan(data)]) data[data > meandata+sigmas*sigma] = np.nan data[data < meandata-sigmas*sigma] = np.nan return data
module function_definition identifier parameters identifier identifier identifier block for_statement identifier call identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier unary_operator call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier unary_operator call attribute identifier identifier argument_list identifier expression_statement assignment subscript identifier comparison_operator identifier binary_operator identifier binary_operator identifier identifier attribute identifier identifier expression_statement assignment subscript identifier comparison_operator identifier binary_operator identifier binary_operator identifier identifier attribute identifier identifier return_statement identifier
Remove datapoints outside of a specified standard deviation range.
def create_book(self, *args, **kwargs): return Book( self._provider_manager, self._get_provider_session('book_admin_session').create_book(*args, **kwargs), self._runtime, self._proxy)
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block return_statement call identifier argument_list attribute identifier identifier call attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier argument_list list_splat identifier dictionary_splat identifier attribute identifier identifier attribute identifier identifier
Pass through to provider BookAdminSession.create_book
def build_vcf_inversion(x1, x2, genome_2bit): id1 = "hydra{0}".format(x1.name) start_coords = sorted([x1.start1, x1.end1, x2.start1, x2.end1]) end_coords = sorted([x1.start2, x1.end2, x2.start2, x2.start2]) start_pos = (start_coords[1] + start_coords[2]) // 2 end_pos = (end_coords[1] + end_coords[2]) // 2 base1 = genome_2bit[x1.chrom1].get(start_pos, start_pos + 1).upper() info = "SVTYPE=INV;IMPRECISE;CIPOS={cip1},{cip2};CIEND={cie1},{cie2};" \ "END={end};SVLEN={length}".format(cip1=start_pos - start_coords[0], cip2=start_coords[-1] - start_pos, cie1=end_pos - end_coords[0], cie2=end_coords[-1] - end_pos, end=end_pos, length=end_pos-start_pos) return VcfLine(x1.chrom1, start_pos, id1, base1, "<INV>", info)
module function_definition identifier parameters identifier 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 identifier argument_list list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement assignment identifier binary_operator parenthesized_expression binary_operator subscript identifier integer subscript identifier integer integer expression_statement assignment identifier binary_operator parenthesized_expression binary_operator subscript identifier integer subscript identifier integer integer expression_statement assignment identifier call attribute call attribute subscript identifier attribute identifier identifier identifier argument_list identifier binary_operator identifier integer identifier argument_list expression_statement assignment identifier call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list keyword_argument identifier binary_operator identifier subscript identifier integer keyword_argument identifier binary_operator subscript identifier unary_operator integer identifier keyword_argument identifier binary_operator identifier subscript identifier integer keyword_argument identifier binary_operator subscript identifier unary_operator integer identifier keyword_argument identifier identifier keyword_argument identifier binary_operator identifier identifier return_statement call identifier argument_list attribute identifier identifier identifier identifier identifier string string_start string_content string_end identifier
Provide representation of inversion from BedPE breakpoints.
def html_page(title="Page Title", body=""): html = "<html>\n<head><title>%s</title></head>\n<body>\n" % (title) html += "<h1>%s</h1>\n" % (title) html += body html += "</body>\n</html>\n" return html
module function_definition identifier parameters default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_end block expression_statement assignment identifier binary_operator string string_start string_content escape_sequence escape_sequence escape_sequence string_end parenthesized_expression identifier expression_statement augmented_assignment identifier binary_operator string string_start string_content escape_sequence string_end parenthesized_expression identifier expression_statement augmented_assignment identifier identifier expression_statement augmented_assignment identifier string string_start string_content escape_sequence escape_sequence string_end return_statement identifier
Create HTML page as string.
def moveDown(self, entry): if not entry: return entries = self.entries() next = entries[entries.index(entry) + 1] entry_q = entry.query() next_q = next.query() next.setQuery(entry_q) entry.setQuery(next_q)
module function_definition identifier parameters identifier identifier block if_statement not_operator identifier block return_statement expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier subscript identifier binary_operator call attribute identifier identifier argument_list identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier
Moves the current query down one entry.
def make_url(self, path, api_root=u'/v2/'): return urljoin(urljoin(self.url, api_root), path)
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end block return_statement call identifier argument_list call identifier argument_list attribute identifier identifier identifier identifier
Gets a full URL from just path.
def _scan_radio_channels(self, cradio, start=0, stop=125): return list(cradio.scan_channels(start, stop, (0xff,)))
module function_definition identifier parameters identifier identifier default_parameter identifier integer default_parameter identifier integer block return_statement call identifier argument_list call attribute identifier identifier argument_list identifier identifier tuple integer
Scan for Crazyflies between the supplied channels.
def save(self, filePath) : self.filename = filePath f = open(filePath, 'w') f.write(self.toStr()) f.flush() f.close()
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list
save the CSV to a file
def cache_finite_samples(f): cache = {} def wrap(*args): key = FRAME_RATE, args if key not in cache: cache[key] = [sample for sample in f(*args)] return (sample for sample in cache[key]) return wrap
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary function_definition identifier parameters list_splat_pattern identifier block expression_statement assignment identifier expression_list identifier identifier if_statement comparison_operator identifier identifier block expression_statement assignment subscript identifier identifier list_comprehension identifier for_in_clause identifier call identifier argument_list list_splat identifier return_statement generator_expression identifier for_in_clause identifier subscript identifier identifier return_statement identifier
Decorator to cache audio samples produced by the wrapped generator.
def putty_ignore_code(options, code): reporter, line_number, offset, text, check = get_reporter_state() try: line = reporter.lines[line_number - 1] except IndexError: line = '' options.ignore = options._orig_ignore options.select = options._orig_select for rule in options.putty_ignore: if rule.match(reporter.filename, line, list(reporter.counters) + [code]): if rule._append_codes: options.ignore = options.ignore + rule.codes else: options.ignore = rule.codes for rule in options.putty_select: if rule.match(reporter.filename, line, list(reporter.counters) + [code]): if rule._append_codes: options.select = options.select + rule.codes else: options.select = rule.codes return ignore_code(options, code)
module function_definition identifier parameters identifier identifier block expression_statement assignment pattern_list identifier identifier identifier identifier identifier call identifier argument_list try_statement block expression_statement assignment identifier subscript attribute identifier identifier binary_operator identifier integer except_clause identifier block expression_statement assignment identifier string string_start string_end expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier for_statement identifier attribute identifier identifier block if_statement call attribute identifier identifier argument_list attribute identifier identifier identifier binary_operator call identifier argument_list attribute identifier identifier list identifier block if_statement attribute identifier identifier block expression_statement assignment attribute identifier identifier binary_operator attribute identifier identifier attribute identifier identifier else_clause block expression_statement assignment attribute identifier identifier attribute identifier identifier for_statement identifier attribute identifier identifier block if_statement call attribute identifier identifier argument_list attribute identifier identifier identifier binary_operator call identifier argument_list attribute identifier identifier list identifier block if_statement attribute identifier identifier block expression_statement assignment attribute identifier identifier binary_operator attribute identifier identifier attribute identifier identifier else_clause block expression_statement assignment attribute identifier identifier attribute identifier identifier return_statement call identifier argument_list identifier identifier
Implement pep8 'ignore_code' hook.
def replace(self, hour=None, minute=None, second=None, microsecond=None, tzinfo=True): if hour is None: hour = self.hour if minute is None: minute = self.minute if second is None: second = self.second if microsecond is None: microsecond = self.microsecond if tzinfo is True: tzinfo = self.tzinfo _check_time_fields(hour, minute, second, microsecond) _check_tzinfo_arg(tzinfo) return time(hour, minute, second, microsecond, tzinfo)
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier true block if_statement comparison_operator identifier none block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier true block expression_statement assignment identifier attribute identifier identifier expression_statement call identifier argument_list identifier identifier identifier identifier expression_statement call identifier argument_list identifier return_statement call identifier argument_list identifier identifier identifier identifier identifier
Return a new time with new values for the specified fields.
def info(ctx): controller = ctx.obj['controller'] if controller.is_fips: click.echo('FIPS Approved Mode: {}'.format( 'Yes' if controller.is_in_fips_mode else 'No')) else: if controller.has_pin: try: click.echo( 'PIN is set, with {} tries left.'.format( controller.get_pin_retries())) except CtapError as e: if e.code == CtapError.ERR.PIN_BLOCKED: click.echo('PIN is blocked.') else: click.echo('PIN is not set.')
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list conditional_expression string string_start string_content string_end attribute identifier identifier string string_start string_content string_end else_clause block if_statement attribute identifier identifier block try_statement block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list except_clause as_pattern identifier as_pattern_target identifier block if_statement comparison_operator attribute identifier identifier attribute attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end
Display status of FIDO2 application.
def makeNodeID(Rec, ndType, extras = None): if ndType == 'raw': recID = Rec else: recID = Rec.get(ndType) if recID is None: pass elif isinstance(recID, list): recID = tuple(recID) else: recID = recID extraDict = {} if extras: for tag in extras: if tag == "raw": extraDict['Tag'] = Rec else: extraDict['Tag'] = Rec.get(tag) return recID, extraDict
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block pass_statement elif_clause call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier else_clause block expression_statement assignment identifier identifier expression_statement assignment identifier dictionary if_statement identifier block for_statement identifier identifier block 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 identifier else_clause block expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list identifier return_statement expression_list identifier identifier
Helper to make a node ID, extras is currently not used
def build(cls, node): if not isinstance(node, gast.FunctionDef): raise ValueError namer = cls() namer.names.update(get_names(node)) return namer
module function_definition identifier parameters identifier identifier block if_statement not_operator call identifier argument_list identifier attribute identifier identifier block raise_statement identifier expression_statement assignment identifier call identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier return_statement identifier
Construct a namer object for a given function scope.
def btc_is_p2sh_script( script_hex ): if script_hex.startswith("a914") and script_hex.endswith("87") and len(script_hex) == 46: return True else: return False
module function_definition identifier parameters identifier block if_statement boolean_operator boolean_operator call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end comparison_operator call identifier argument_list identifier integer block return_statement true else_clause block return_statement false
Is the given scriptpubkey a p2sh script?
def register_commands(self): for command in self._entry_points[self.COMMANDS_ENTRY_POINT].values(): command.load()
module function_definition identifier parameters identifier block for_statement identifier call attribute subscript attribute identifier identifier attribute identifier identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list
Load entry points for custom commands.
def initDeviceScan(self): self.__isIphone = self.detectIphoneOrIpod() self.__isAndroidPhone = self.detectAndroidPhone() self.__isTierTablet = self.detectTierTablet() self.__isTierIphone = self.detectTierIphone() self.__isTierRichCss = self.detectTierRichCss() self.__isTierGenericMobile = self.detectTierOtherPhones()
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list
Initialize Key Stored Values.
def major_rise_per_monomer(self): return numpy.cos(numpy.deg2rad(self.curve.alpha)) * self.minor_rise_per_residue
module function_definition identifier parameters identifier block return_statement binary_operator call attribute identifier identifier argument_list call attribute identifier identifier argument_list attribute attribute identifier identifier identifier attribute identifier identifier
Rise along super-helical axis per monomer.
def create(self, model): signals.pre_create.send(model.__class__, model=model) signals.pre_save.send(model.__class__, model=model) param = self.to_pg(model) query = query = query.format( cols=self.field_cols(model), dirty_cols=self.dirty_cols(model), dirty_vals=self.dirty_vals(model), table=model.rtype, ) result = self.query(query, param=param) signals.post_create.send(model.__class__, model=model) signals.post_save.send(model.__class__, model=model) return model.merge(result[0], clean=True)
module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier keyword_argument identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier keyword_argument identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier assignment identifier call attribute identifier identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list identifier keyword_argument identifier call attribute identifier identifier argument_list identifier keyword_argument identifier call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier keyword_argument identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier keyword_argument identifier identifier return_statement call attribute identifier identifier argument_list subscript identifier integer keyword_argument identifier true
Given a model object instance create it
def canFetchMore(self, parentIndex): parentItem = self.getItem(parentIndex) if not parentItem: return False return parentItem.canFetchChildren()
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator identifier block return_statement false return_statement call attribute identifier identifier argument_list
Returns true if there is more data available for parent; otherwise returns false.
def catch_all(path): return (dict(error='Invalid URL: /{}'.format(path), links=dict(root='{}{}'.format(request.url_root, PREFIX[1:]))), HTTPStatus.NOT_FOUND)
module function_definition identifier parameters identifier block return_statement tuple call identifier argument_list keyword_argument identifier call attribute string string_start string_content string_end identifier argument_list identifier keyword_argument identifier call identifier argument_list keyword_argument identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier subscript identifier slice integer attribute identifier identifier
Catch all path - return a JSON 404
def to_unicode(obj, encoding='utf-8'): if isinstance(obj, string_types) or isinstance(obj, binary_type): if not isinstance(obj, text_type): obj = text_type(obj, encoding) return obj
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block if_statement boolean_operator call identifier argument_list identifier identifier call identifier argument_list identifier identifier block if_statement not_operator call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier return_statement identifier
Convert string to unicode string
def display_with_id(self, obj, display_id, update=False): ip = get_ipython() if hasattr(ip, "kernel"): data, md = ip.display_formatter.format(obj) content = { 'data': data, 'metadata': md, 'transient': {'display_id': display_id}, } msg_type = 'update_display_data' if update else 'display_data' ip.kernel.session.send(ip.kernel.iopub_socket, msg_type, content, parent=ip.parent_header) else: display(obj)
module function_definition identifier parameters identifier identifier identifier default_parameter identifier false block expression_statement assignment identifier call identifier argument_list if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end dictionary pair string string_start string_content string_end identifier expression_statement assignment identifier conditional_expression string string_start string_content string_end identifier string string_start string_content string_end expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list attribute attribute identifier identifier identifier identifier identifier keyword_argument identifier attribute identifier identifier else_clause block expression_statement call identifier argument_list identifier
Create a new display with an id
def register_entity(self, entity_config): if not issubclass(entity_config, EntityConfig): raise ValueError('Must register entity config class of subclass EntityConfig') if entity_config.queryset is None: raise ValueError('Entity config must define queryset') model = entity_config.queryset.model self._entity_registry[model] = entity_config() for watching_model, entity_model_getter in entity_config.watching: self._entity_watching[watching_model].append((model, entity_model_getter))
module function_definition identifier parameters identifier identifier block if_statement not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator attribute identifier identifier none block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment subscript attribute identifier identifier identifier call identifier argument_list for_statement pattern_list identifier identifier attribute identifier identifier block expression_statement call attribute subscript attribute identifier identifier identifier identifier argument_list tuple identifier identifier
Registers an entity config
def flushall(args): cluster = Cluster.from_node(ClusterNode.from_uri(args.cluster)) for node in cluster.masters: node.flushall()
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list
Execute flushall in all cluster nodes.
def calculate_bbox_area(bbox, rows, cols): bbox = denormalize_bbox(bbox, rows, cols) x_min, y_min, x_max, y_max = bbox[:4] area = (x_max - x_min) * (y_max - y_min) return area
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier identifier expression_statement assignment pattern_list identifier identifier identifier identifier subscript identifier slice integer expression_statement assignment identifier binary_operator parenthesized_expression binary_operator identifier identifier parenthesized_expression binary_operator identifier identifier return_statement identifier
Calculate the area of a bounding box in pixels.
def add(self, component): old = self.get_component(component.id) if old: old.releases.extend(component.releases) return self.components[component.id] = component
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier if_statement identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier return_statement expression_statement assignment subscript attribute identifier identifier attribute identifier identifier identifier
Add component to the store
def getUserSignupDate(self): userinfo = self.getUserInfo() timestamp = int(float(userinfo["signupTimeSec"])) return time.strftime("%m/%d/%Y %H:%M", time.gmtime(timestamp))
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list call identifier argument_list subscript identifier string string_start string_content string_end return_statement call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list identifier
Returns the human readable date of when the user signed up for google reader.
def _get_balance(self): response = self.session.get(self.balance_url, verify=False) soup = BeautifulSoup(response.text, 'html.parser') first_line = soup.select( "table.data tr:nth-of-type(2)")[0].text.strip().split('\n') total, today = first_line[-2:] logging.info('%-26sTotal:%-8s', today, total) return '\n'.join([u"Today: {0}".format(today), "Total: {0}".format(total)])
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier keyword_argument identifier false expression_statement assignment identifier call identifier argument_list attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute call attribute attribute subscript call attribute identifier identifier argument_list string string_start string_content string_end integer identifier identifier argument_list identifier argument_list string string_start string_content escape_sequence string_end expression_statement assignment pattern_list identifier identifier subscript identifier slice unary_operator integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier return_statement call attribute string string_start string_content escape_sequence string_end identifier argument_list list call attribute string string_start string_content string_end identifier argument_list identifier call attribute string string_start string_content string_end identifier argument_list identifier
Get to know how much you totally have and how much you get today.
def wait_till_stopped(self, conf, container_id, timeout=10, message=None, waiting=True): stopped = False inspection = None for _ in until(timeout=timeout, action=message): try: inspection = conf.harpoon.docker_api.inspect_container(container_id) if not isinstance(inspection, dict): log.error("Weird response from inspecting the container\tresponse=%s", inspection) else: if not inspection["State"]["Running"]: stopped = True conf.container_id = None break else: break except (socket.timeout, ValueError): log.warning("Failed to inspect the container\tcontainer_id=%s", container_id) except DockerAPIError as error: if error.response.status_code != 404: raise else: break if not inspection: log.warning("Failed to inspect the container!") stopped = True exit_code = 1 else: exit_code = inspection["State"]["ExitCode"] return stopped, exit_code
module function_definition identifier parameters identifier identifier identifier default_parameter identifier integer default_parameter identifier none default_parameter identifier true block expression_statement assignment identifier false expression_statement assignment identifier none for_statement identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier block try_statement block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier if_statement not_operator call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end identifier else_clause block if_statement not_operator subscript subscript identifier string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier true expression_statement assignment attribute identifier identifier none break_statement else_clause block break_statement except_clause tuple attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end identifier except_clause as_pattern identifier as_pattern_target identifier block if_statement comparison_operator attribute attribute identifier identifier identifier integer block raise_statement else_clause block break_statement if_statement not_operator identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier true expression_statement assignment identifier integer else_clause block expression_statement assignment identifier subscript subscript identifier string string_start string_content string_end string string_start string_content string_end return_statement expression_list identifier identifier
Wait till a container is stopped
def Read(self, length): result = b"" length = int(length) length = min(length, self.size - self.offset) while length > 0: data = self._ReadPartial(length) if not data: break length -= len(data) result += data return result
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier string string_start string_end expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier binary_operator attribute identifier identifier attribute identifier identifier while_statement comparison_operator identifier integer block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator identifier block break_statement expression_statement augmented_assignment identifier call identifier argument_list identifier expression_statement augmented_assignment identifier identifier return_statement identifier
Read a block of data from the file.
def allow_relation(self, obj1, obj2, **hints): if obj1._meta.app_label != 'oldimporter' and obj2._meta.app_label != 'oldimporter': return True return None
module function_definition identifier parameters identifier identifier identifier dictionary_splat_pattern identifier block if_statement boolean_operator comparison_operator attribute attribute identifier identifier identifier string string_start string_content string_end comparison_operator attribute attribute identifier identifier identifier string string_start string_content string_end block return_statement true return_statement none
Relations between objects are allowed between nodeshot2 objects only
def sign(self, data): data = signing.b64_encode(data).decode() return self.signer.sign(data)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier identifier argument_list return_statement call attribute attribute identifier identifier identifier argument_list identifier
Create an URL-safe, signed token from ``data``.
def process_target(self): if isinstance(self.target, str): self.target = self.target.replace("'", "\'").replace('"', "\'") return "\"{target}\"".format(target=self.target) return self.target
module function_definition identifier parameters identifier block if_statement call identifier argument_list attribute identifier identifier identifier block expression_statement assignment attribute identifier identifier call attribute call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content escape_sequence string_end identifier argument_list string string_start string_content string_end string string_start string_content escape_sequence string_end return_statement call attribute string string_start string_content escape_sequence escape_sequence string_end identifier argument_list keyword_argument identifier attribute identifier identifier return_statement attribute identifier identifier
Return target with transformations, if any
def _compute_mean(self, C, g, mag, hypo_depth, rrup, vs30, pga_rock, imt): if hypo_depth > 100: hypo_depth = 100 delta = 0.00724 * 10 ** (0.507 * mag) R = np.sqrt(rrup ** 2 + delta ** 2) s_amp = self._compute_soil_amplification(C, vs30, pga_rock, imt) mean = ( C['c1'] + C['c2'] * mag + C['c3'] * hypo_depth + C['c4'] * R - g * np.log10(R) + s_amp ) return mean
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier identifier identifier block if_statement comparison_operator identifier integer block expression_statement assignment identifier integer expression_statement assignment identifier binary_operator float binary_operator integer parenthesized_expression binary_operator float identifier expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator binary_operator identifier integer binary_operator identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier identifier expression_statement assignment identifier parenthesized_expression binary_operator binary_operator binary_operator binary_operator binary_operator subscript identifier string string_start string_content string_end binary_operator subscript identifier string string_start string_content string_end identifier binary_operator subscript identifier string string_start string_content string_end identifier binary_operator subscript identifier string string_start string_content string_end identifier binary_operator identifier call attribute identifier identifier argument_list identifier identifier return_statement identifier
Compute mean according to equation 1, page 1706.
def add_tag_to_job(user, job_id): job = v1_utils.verify_existence_and_get(job_id, _TABLE) if not user.is_in_team(job['team_id']): raise dci_exc.Unauthorized() values = { 'job_id': job_id } job_tagged = tags.add_tag_to_resource(values, models.JOIN_JOBS_TAGS) return flask.Response(json.dumps(job_tagged), 201, content_type='application/json')
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement not_operator call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end block raise_statement call attribute identifier identifier argument_list 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 attribute identifier identifier return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier integer keyword_argument identifier string string_start string_content string_end
Add a tag to a job.
def _make_scaled_srcmap(self): self.logger.info('Computing scaled source map.') bexp0 = fits.open(self.files['bexpmap_roi']) bexp1 = fits.open(self.config['gtlike']['bexpmap']) srcmap = fits.open(self.config['gtlike']['srcmap']) if bexp0[0].data.shape != bexp1[0].data.shape: raise Exception('Wrong shape for input exposure map file.') bexp_ratio = bexp0[0].data / bexp1[0].data self.logger.info( 'Min/Med/Max exposure correction: %f %f %f' % (np.min(bexp_ratio), np.median( bexp_ratio), np.max(bexp_ratio))) for hdu in srcmap[1:]: if hdu.name == 'GTI': continue if hdu.name == 'EBOUNDS': continue hdu.data *= bexp_ratio srcmap.writeto(self.files['srcmap'], overwrite=True)
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 attribute identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier 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 expression_statement assignment identifier 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 if_statement comparison_operator attribute attribute subscript identifier integer identifier identifier attribute attribute subscript identifier integer identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier binary_operator attribute subscript identifier integer identifier attribute subscript identifier integer identifier expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end tuple call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier for_statement identifier subscript identifier slice integer block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block continue_statement if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block continue_statement expression_statement augmented_assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end keyword_argument identifier true
Make an exposure cube with the same binning as the counts map.
def path_selection_changed(self): idx = self.currentIndex() if idx == SELECT_OTHER: external_path = self.select_directory() if len(external_path) > 0: self.add_external_path(external_path) self.setCurrentIndex(self.count() - 1) else: self.setCurrentIndex(CWD) elif idx == CLEAR_LIST: reply = QMessageBox.question( self, _("Clear other directories"), _("Do you want to clear the list of other directories?"), QMessageBox.Yes | QMessageBox.No) if reply == QMessageBox.Yes: self.clear_external_paths() self.setCurrentIndex(CWD) elif idx >= EXTERNAL_PATHS: self.external_path = to_text_string(self.itemText(idx))
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator call identifier argument_list identifier integer block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list binary_operator call attribute identifier identifier argument_list integer else_clause block expression_statement call attribute identifier identifier argument_list identifier elif_clause comparison_operator identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier call identifier argument_list string string_start string_content string_end call identifier argument_list string string_start string_content string_end binary_operator attribute identifier identifier attribute identifier identifier if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier elif_clause comparison_operator identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list call attribute identifier identifier argument_list identifier
Handles when the current index of the combobox changes.
def _expand_directories(paths): for path in paths: path_ = Path(path) if path_.is_dir(): for expanded in path_.rglob('*'): yield str(expanded) else: yield path
module function_definition identifier parameters identifier block for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement call attribute identifier identifier argument_list block for_statement identifier call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement yield call identifier argument_list identifier else_clause block expression_statement yield identifier
Expand directory with all files it contains.
def eat_length(self, length): pos = self.pos if self.eos or pos + length > self.length: return None col = self.col row = self.row for char in self.string[pos:pos + length]: col += 1 pos += 1 if char == '\n': col = 0 row += 1 self.pos = pos self.col = col self.row = row if not self.has_space(): self.eos = 1
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier if_statement boolean_operator attribute identifier identifier comparison_operator binary_operator identifier identifier attribute identifier identifier block return_statement none expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier for_statement identifier subscript attribute identifier identifier slice identifier binary_operator identifier identifier block expression_statement augmented_assignment identifier integer expression_statement augmented_assignment identifier integer if_statement comparison_operator identifier string string_start string_content escape_sequence string_end block expression_statement assignment identifier integer expression_statement augmented_assignment identifier integer expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier if_statement not_operator call attribute identifier identifier argument_list block expression_statement assignment attribute identifier identifier integer
Move current position forward by length and sets eos if needed.
def delete(self) : if not self.URL : raise CreationError("Please save user first", None, None) r = self.connection.session.delete(self.URL) if r.status_code < 200 or r.status_code > 202 : raise DeletionError("Unable to delete user, url: %s, status: %s" %(r.url, r.status_code), r.content ) self.URL = None
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end none none expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier if_statement boolean_operator comparison_operator attribute identifier identifier integer comparison_operator attribute identifier identifier integer block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier none
Permanently remove the user
def purge(): all_hashes = read_all() used_hashes = read_used() for kind, hashes in used_hashes.items(): hashes = set(hashes) to_remove = set(all_hashes[kind]).difference(hashes) delete_from_directory_by_hashes(kind, to_remove) reset_used() write_out()
module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call identifier argument_list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute call identifier argument_list subscript identifier identifier identifier argument_list identifier expression_statement call identifier argument_list identifier identifier expression_statement call identifier argument_list expression_statement call identifier argument_list
Deletes all the cached files since the last call to reset_used that have not been used.
def place_center(window, width=None, height=None): screenGeometry = QApplication.desktop().screenGeometry() w, h = window.width(), window.height() if width is not None or height is not None: w = width if width is not None else w h = height if height is not None else h window.setGeometry(0, 0, w, h) x = (screenGeometry.width() - w) / 2 y = (screenGeometry.height() - h) / 2 window.move(x, y)
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list expression_statement assignment pattern_list identifier identifier expression_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list if_statement boolean_operator comparison_operator identifier none comparison_operator identifier none block expression_statement assignment identifier conditional_expression identifier comparison_operator identifier none identifier expression_statement assignment identifier conditional_expression identifier comparison_operator identifier none identifier expression_statement call attribute identifier identifier argument_list integer integer identifier identifier expression_statement assignment identifier binary_operator parenthesized_expression binary_operator call attribute identifier identifier argument_list identifier integer expression_statement assignment identifier binary_operator parenthesized_expression binary_operator call attribute identifier identifier argument_list identifier integer expression_statement call attribute identifier identifier argument_list identifier identifier
Places window in the center of the screen.
def start_task(self, func): task = self.loop.create_task(func(self)) self._started_tasks.append(task) def done_callback(done_task): self._started_tasks.remove(done_task) task.add_done_callback(done_callback) return task
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Start up a task
def list(self, engine): engine = self._get_engine(engine) vms = [] try: for vm in (yield from engine.list()): vms.append({"vmname": vm["vmname"]}) except GNS3VMError as e: if self.enable: raise e return vms
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier list try_statement block for_statement identifier parenthesized_expression yield call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end subscript identifier string string_start string_content string_end except_clause as_pattern identifier as_pattern_target identifier block if_statement attribute identifier identifier block raise_statement identifier return_statement identifier
List VMS for an engine
def inv_posdef(mat): chol = np.linalg.cholesky(mat) ident = np.eye(mat.shape[0]) res = solve_triangular(chol, ident, lower=True, overwrite_b=True) return np.transpose(res).dot(res)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list subscript attribute identifier identifier integer expression_statement assignment identifier call identifier argument_list identifier identifier keyword_argument identifier true keyword_argument identifier true return_statement call attribute call attribute identifier identifier argument_list identifier identifier argument_list identifier
Stable inverse of a positive definite matrix.
def initialize_directories(self): makedirs(self.config.source_index) makedirs(self.config.eggs_cache)
module function_definition identifier parameters identifier block expression_statement call identifier argument_list attribute attribute identifier identifier identifier expression_statement call identifier argument_list attribute attribute identifier identifier identifier
Automatically create local directories required by pip-accel.
def resp_set_hostfirmware(self, resp): if resp: self.host_firmware_version = float(str(str(resp.version >> 16) + "." + str(resp.version & 0xff))) self.host_firmware_build_timestamp = resp.build
module function_definition identifier parameters identifier identifier block if_statement identifier block expression_statement assignment attribute identifier identifier call identifier argument_list call identifier argument_list binary_operator binary_operator call identifier argument_list binary_operator attribute identifier identifier integer string string_start string_content string_end call identifier argument_list binary_operator attribute identifier identifier integer expression_statement assignment attribute identifier identifier attribute identifier identifier
Default callback for get_hostfirmware
def _load_url(url): try: response = requests.get(url) return BytesIO(response.content) except IOError as ex: parser.error("{url} could not be loaded remotely! ({ex})".format(url=url, ex=ex))
module function_definition identifier parameters identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement call 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 attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier
Loads a URL resource from a remote server
def _extract_object_params(self, name): params = self.request.query_params.lists() params_map = {} prefix = name[:-1] offset = len(prefix) for name, value in params: if name.startswith(prefix): if name.endswith('}'): name = name[offset:-1] elif name.endswith('}[]'): name = name[offset:-3] else: raise exceptions.ParseError( '"%s" is not a well-formed filter key.' % name ) else: continue params_map[name] = value return params_map
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list expression_statement assignment identifier dictionary expression_statement assignment identifier subscript identifier slice unary_operator integer expression_statement assignment identifier call identifier argument_list identifier for_statement pattern_list identifier identifier identifier block if_statement call attribute identifier identifier argument_list identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier subscript identifier slice identifier unary_operator integer elif_clause call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier subscript identifier slice identifier unary_operator integer else_clause block raise_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier else_clause block continue_statement expression_statement assignment subscript identifier identifier identifier return_statement identifier
Extract object params, return as dict
def update( self, request, pk=None, parent_lookup_seedteam=None, parent_lookup_seedteam__organization=None): user = get_object_or_404(User, pk=pk) team = self.check_team_permissions( request, parent_lookup_seedteam, parent_lookup_seedteam__organization) team.users.add(user) return Response(status=status.HTTP_204_NO_CONTENT)
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement call identifier argument_list keyword_argument identifier attribute identifier identifier
Add a user to a team.
def check_permissions(self, request): obj = ( hasattr(self, 'get_controlled_object') and self.get_controlled_object() or hasattr(self, 'get_object') and self.get_object() or getattr(self, 'object', None) ) user = request.user perms = self.get_required_permissions(self) has_permissions = self.perform_permissions_check(user, obj, perms) if not has_permissions and not user.is_authenticated: return HttpResponseRedirect('{}?{}={}'.format( resolve_url(self.login_url), self.redirect_field_name, urlquote(request.get_full_path()) )) elif not has_permissions: raise PermissionDenied
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier parenthesized_expression boolean_operator boolean_operator boolean_operator call identifier argument_list identifier string string_start string_content string_end call attribute identifier identifier argument_list boolean_operator call identifier argument_list identifier string string_start string_content string_end call attribute identifier identifier argument_list call identifier argument_list identifier string string_start string_content string_end none expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier if_statement boolean_operator not_operator identifier not_operator attribute identifier identifier block return_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list call identifier argument_list attribute identifier identifier attribute identifier identifier call identifier argument_list call attribute identifier identifier argument_list elif_clause not_operator identifier block raise_statement identifier
Retrieves the controlled object and perform the permissions check.
def supervise(args): project = args.project workspace = args.workspace namespace = args.namespace workflow = args.workflow sample_sets = args.sample_sets recovery_file = args.json_checkpoint if not sample_sets: r = fapi.get_entities(args.project, args.workspace, "sample_set") fapi._check_response_code(r, 200) sample_sets = [s['name'] for s in r.json()] message = "Sample Sets ({}):\n\t".format(len(sample_sets)) + \ "\n\t".join(sample_sets) prompt = "\nLaunch workflow in " + project + "/" + workspace + \ " on these sample sets? [Y\\n]: " if not args.yes and not _confirm_prompt(message, prompt): return return supervisor.supervise(project, workspace, namespace, workflow, sample_sets, recovery_file)
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier if_statement not_operator identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier integer expression_statement assignment identifier list_comprehension subscript identifier string string_start string_content string_end for_in_clause identifier call attribute identifier identifier argument_list expression_statement assignment identifier binary_operator call attribute string string_start string_content escape_sequence escape_sequence string_end identifier argument_list call identifier argument_list identifier call attribute string string_start string_content escape_sequence escape_sequence string_end identifier argument_list identifier expression_statement assignment identifier binary_operator binary_operator binary_operator binary_operator string string_start string_content escape_sequence string_end identifier string string_start string_content string_end identifier string string_start string_content escape_sequence string_end if_statement boolean_operator not_operator attribute identifier identifier not_operator call identifier argument_list identifier identifier block return_statement return_statement call attribute identifier identifier argument_list identifier identifier identifier identifier identifier identifier
Run legacy, Firehose-style workflow of workflows
def spin_gen_op(oper, gauge): slaves = len(gauge) oper['O'] = np.array([spin_gen(slaves, i, c) for i, c in enumerate(gauge)]) oper['O_d'] = np.transpose(oper['O'], (0, 2, 1)) oper['O_dO'] = np.einsum('...ij,...jk->...ik', oper['O_d'], oper['O']) oper['Sfliphop'] = spinflipandhop(slaves)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list list_comprehension call identifier argument_list identifier identifier identifier for_in_clause pattern_list identifier identifier call identifier argument_list identifier expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end tuple integer integer integer expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list identifier
Generates the generic spin matrices for the system
def of(cls, *documents: BioCDocument): if len(documents) <= 0: raise ValueError("There has to be at least one document.") c = BioCCollection() for document in documents: if document is None: raise ValueError('Document is None') c.add_document(document) return c
module function_definition identifier parameters identifier typed_parameter list_splat_pattern identifier type identifier block if_statement comparison_operator call identifier argument_list identifier integer block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list for_statement identifier identifier block if_statement comparison_operator identifier none block raise_statement call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Returns a collection documents
def emptyTrash(self): key = '/library/sections/%s/emptyTrash' % self.key self._server.query(key, method=self._server._session.put)
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier attribute attribute attribute identifier identifier identifier identifier
If a section has items in the Trash, use this option to empty the Trash.
def _update_project(self, project_name): project = self.projectdb.get(project_name) if not project: return None return self._load_project(project)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement not_operator identifier block return_statement none return_statement call attribute identifier identifier argument_list identifier
Update one project from database
def resume(self): log.info("Resuming cluster `%s` ...", self.name) failed = self._resume_all_nodes() for node in self.get_all_nodes(): node.update_ips() self._gather_node_ip_addresses( self.get_all_nodes(), self.start_timeout, self.ssh_probe_timeout) self.repository.save_or_update(self) if failed: log.warning( "Not all cluster nodes have been successfully " "restarted. Check error messages above and consider " "re-running `elasticluster resume %s` if " "necessary.", self.name) return if not self._setup_provider.resume_cluster(self): log.warning("Elasticluster was not able to guarantee that the " "cluster restarted correctly - check the errors " "above and check your config.")
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end attribute identifier identifier return_statement if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end
Resume all paused VMs in this cluster.
def make_posts(generator, metadata, url): reddit = generator.get_reddit() title = lxml.html.fromstring(metadata['title']).text_content() if reddit is None: log.info("Reddit plugin not enabled") return if metadata.get('status') == "draft": log.debug("ignoring draft %s" % title) return collection = generator.settings['REDDIT_POSTER_COLLECT_SUB'] sub = reddit.subreddit(collection) results = sub.search(title) if len([result for result in results]) > 0: log.debug("ignoring %s because it is already on sub %s " % (title, collection)) return try: submission = sub.submit(title, url=url, resubmit=False) cross_post(reddit, submission, metadata.get('subreddit')) except praw.exceptions.APIException as e: log.error("got an api exception: %s", e) except AssertionError as e: log.error("Received an assertion error %s", e)
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 call attribute attribute identifier identifier identifier argument_list subscript identifier string string_start string_content string_end identifier argument_list if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier return_statement expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator call identifier argument_list list_comprehension identifier for_in_clause identifier identifier integer block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier return_statement try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier false expression_statement call identifier argument_list identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end 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 identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier
Make posts on reddit if it's not a draft, on whatever subs are specified
def send_direct_message(self, text, user=None, delegate=None, screen_name=None, user_id=None, params={}): params = params.copy() if user is not None: params['user'] = user if user_id is not None: params['user_id'] = user_id if screen_name is not None: params['screen_name'] = screen_name params['text'] = text parser = txml.Direct(delegate) return self.__postPage('/direct_messages/new.xml', parser, params)
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier dictionary block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier none block expression_statement assignment subscript identifier string string_start string_content string_end identifier if_statement comparison_operator identifier none block expression_statement assignment subscript identifier string string_start string_content string_end identifier if_statement comparison_operator identifier none block expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier
Send a direct message
def copy_meta_from(self, ido): self._active_scalar_info = ido.active_scalar_info self._active_vectors_info = ido.active_vectors_info if hasattr(ido, '_textures'): self._textures = ido._textures
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier attribute identifier identifier
Copies vtki meta data onto this object from another object
def deconstruct(self): name, path, args, kwargs = super(AssetsFileField, self).deconstruct() kwargs['denormalize'] = False return name, path, args, kwargs
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier identifier identifier call attribute call identifier argument_list identifier identifier identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end false return_statement expression_list identifier identifier identifier identifier
Denormalize is always false migrations
def load_plugins(self, plugins_package): try: plugin_dir = find_spec(plugins_package).submodule_search_locations[0] except ImportError: logger.error( "Could not load plugins package '%(pkg)s'", {'pkg': plugins_package} ) return for module_path in self._get_plugin_module_paths(plugin_dir): spec = find_spec('{}.{}'.format(plugins_package, module_path)) m = module_from_spec(spec) spec.loader.exec_module(m) classes = inspect.getmembers(m, predicate=inspect.isclass) for _, klass in classes: if klass.__module__ != spec.name: continue if not klass.__name__.endswith('Plugin'): continue instance = klass() if self._is_plugin_ok(instance): self.plugins.add(instance)
module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment identifier subscript attribute call identifier argument_list identifier identifier integer except_clause identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end dictionary pair string string_start string_content string_end identifier return_statement for_statement identifier call attribute identifier identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier for_statement pattern_list identifier identifier identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block continue_statement if_statement not_operator call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block continue_statement expression_statement assignment identifier call identifier argument_list if_statement call attribute identifier identifier argument_list identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Load plugins from `plugins_package` module.
def throw_random( lengths, mask ): saved = None for i in range( maxtries ): try: return throw_random_bits( lengths, mask ) except MaxtriesException as e: saved = e continue raise e
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier none for_statement identifier call identifier argument_list identifier block try_statement block return_statement call identifier argument_list identifier identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement assignment identifier identifier continue_statement raise_statement identifier
Try multiple times to run 'throw_random'
def text_to_title(value): title = None if not value: return title words = value.split(" ") keep_words = [] for word in words: if word.endswith(".") or word.endswith(":"): keep_words.append(word) if len(word) > 1 and "<italic>" not in word and "<i>" not in word: break else: keep_words.append(word) if len(keep_words) > 0: title = " ".join(keep_words) if title.split(" ")[-1] != "spp.": title = title.rstrip(" .:") return title
module function_definition identifier parameters identifier block expression_statement assignment identifier none if_statement not_operator identifier block return_statement identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier list for_statement identifier identifier block if_statement boolean_operator call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier if_statement boolean_operator boolean_operator comparison_operator call identifier argument_list identifier integer comparison_operator string string_start string_content string_end identifier comparison_operator string string_start string_content string_end identifier block break_statement else_clause block expression_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier if_statement comparison_operator subscript call attribute identifier identifier argument_list string string_start string_content string_end unary_operator integer string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier
when a title is required, generate one from the value
def diff_non_uni(self, y, coords, dim, coefs): yd = np.zeros_like(y) ndims = len(y.shape) multi_slice = [slice(None, None)] * ndims ref_multi_slice = [slice(None, None)] * ndims for i, x in enumerate(coords): weights = coefs[i]["coefficients"] offsets = coefs[i]["offsets"] ref_multi_slice[dim] = i for off, w in zip(offsets, weights): multi_slice[dim] = i + off yd[ref_multi_slice] += w * y[multi_slice] return yd
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier binary_operator list call identifier argument_list none none identifier expression_statement assignment identifier binary_operator list call identifier argument_list none none identifier for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement assignment identifier subscript subscript identifier identifier string string_start string_content string_end expression_statement assignment identifier subscript subscript identifier identifier string string_start string_content string_end expression_statement assignment subscript identifier identifier identifier for_statement pattern_list identifier identifier call identifier argument_list identifier identifier block expression_statement assignment subscript identifier identifier binary_operator identifier identifier expression_statement augmented_assignment subscript identifier identifier binary_operator identifier subscript identifier identifier return_statement identifier
The core function to take a partial derivative on a non-uniform grid
def remove_peer_from_bgp_speaker(self, speaker_id, body=None): return self.put((self.bgp_speaker_path % speaker_id) + "/remove_bgp_peer", body=body)
module function_definition identifier parameters identifier identifier default_parameter identifier none block return_statement call attribute identifier identifier argument_list binary_operator parenthesized_expression binary_operator attribute identifier identifier identifier string string_start string_content string_end keyword_argument identifier identifier
Removes a peer from BGP speaker.
def how_many(self): if self.linkdates != []: if max(self.linkdates) <= list(time.localtime()): currentdate = max(self.linkdates) else: currentdate = list(time.localtime()) print(("This entry has its date set in the future. " "I will use your current local time as its date " "instead."), file=sys.stderr, flush=True) stop = sys.maxsize else: currentdate = [1, 1, 1, 0, 0] firstsync = self.retrieve_config('firstsync', '1') if firstsync == 'all': stop = sys.maxsize else: stop = int(firstsync) return currentdate, stop
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier list block if_statement comparison_operator call identifier argument_list attribute identifier identifier call identifier argument_list call attribute identifier identifier argument_list block expression_statement assignment identifier call identifier argument_list attribute identifier identifier else_clause block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list expression_statement call identifier argument_list parenthesized_expression concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end keyword_argument identifier attribute identifier identifier keyword_argument identifier true expression_statement assignment identifier attribute identifier identifier else_clause block expression_statement assignment identifier list integer integer integer integer integer expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier attribute identifier identifier else_clause block expression_statement assignment identifier call identifier argument_list identifier return_statement expression_list identifier identifier
Ascertain where to start downloading, and how many entries.
def _create_event(self, alert_type, msg_title, msg, server, tags=None): msg_title = 'Couchbase {}: {}'.format(server, msg_title) msg = 'Couchbase instance {} {}'.format(server, msg) return { 'timestamp': int(time.time()), 'event_type': 'couchbase_rebalance', 'msg_text': msg, 'msg_title': msg_title, 'alert_type': alert_type, 'source_type_name': self.SOURCE_TYPE_NAME, 'aggregation_key': server, 'tags': tags, }
module function_definition identifier parameters identifier identifier identifier identifier identifier default_parameter identifier none block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier identifier return_statement dictionary pair string string_start string_content string_end call identifier argument_list call attribute identifier identifier argument_list pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier
Create an event object