code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def create_report(self): data = self.create_data() try: json_string = json.dumps(data) except UnicodeDecodeError as e: log.error('ERROR: While preparing JSON:', exc_info=e) self.debug_bad_encoding(data) raise log_string = re.sub(r'"repo_token": "(.+?)"', '"repo_token": "[secure]"', json_string) log.debug(log_string) log.debug('==\nReporting %s files\n==\n', len(data['source_files'])) for source_file in data['source_files']: log.debug('%s - %s/%s', source_file['name'], sum(filter(None, source_file['coverage'])), len(source_file['coverage'])) return json_string
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier raise_statement expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence escape_sequence escape_sequence string_end call identifier argument_list subscript identifier string string_start string_content string_end for_statement identifier subscript identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end subscript identifier string string_start string_content string_end call identifier argument_list call identifier argument_list none subscript identifier string string_start string_content string_end call identifier argument_list subscript identifier string string_start string_content string_end return_statement identifier
Generate json dumped report for coveralls api.
def open(self, user=None, repo=None): webbrowser.open(self.format_path(repo, namespace=user, rw=False))
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier false
Open the URL of a repository in the user's browser
async def put(self, key, value, *args): self._db[key] = value await self.save()
module function_definition identifier parameters identifier identifier identifier list_splat_pattern identifier block expression_statement assignment subscript attribute identifier identifier identifier identifier expression_statement await call attribute identifier identifier argument_list
Edits a data entry.
def step(h1: Histogram1D, ax: Axes, **kwargs): show_stats = kwargs.pop("show_stats", False) show_values = kwargs.pop("show_values", False) density = kwargs.pop("density", False) cumulative = kwargs.pop("cumulative", False) value_format = kwargs.pop("value_format", None) text_kwargs = pop_kwargs_with_prefix("text_", kwargs) kwargs["label"] = kwargs.get("label", h1.name) data = get_data(h1, cumulative=cumulative, density=density) _apply_xy_lims(ax, h1, data, kwargs) _add_ticks(ax, h1, kwargs) _add_labels(ax, h1, kwargs) ax.step(h1.numpy_bins, np.concatenate([data[:1], data]), **kwargs) if show_stats: _add_stats_box(h1, ax, stats=show_stats) if show_values: _add_values(ax, h1, data, value_format=value_format, **text_kwargs)
module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end false expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end false expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end false expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end false expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end none expression_statement assignment identifier call identifier argument_list string string_start string_content string_end identifier 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 attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call identifier argument_list identifier identifier identifier identifier expression_statement call identifier argument_list identifier identifier identifier expression_statement call identifier argument_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list list subscript identifier slice integer identifier dictionary_splat identifier if_statement identifier block expression_statement call identifier argument_list identifier identifier keyword_argument identifier identifier if_statement identifier block expression_statement call identifier argument_list identifier identifier identifier keyword_argument identifier identifier dictionary_splat identifier
Step line-plot of 1D histogram.
def _repr_html_(self): nbreset = f'<style>{css_nbreset}</style>' resources = ''.join(map(str, self.resources)) return f'<div>{nbreset}{resources}<div class="hrepr">{self}</div></div>'
module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_content interpolation identifier string_content string_end expression_statement assignment identifier call attribute string string_start string_end identifier argument_list call identifier argument_list identifier attribute identifier identifier return_statement string string_start string_content interpolation identifier interpolation identifier string_content interpolation identifier string_content string_end
Jupyter Notebook hook to print this element as HTML.
def valid_substitution(strlen, index): values = index[0] return all([strlen > i for i in values])
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript identifier integer return_statement call identifier argument_list list_comprehension comparison_operator identifier identifier for_in_clause identifier identifier
skip performing substitutions that are outside the bounds of the string
def admin_url(model, url, object_id=None): opts = model._meta url = "admin:%s_%s_%s" % (opts.app_label, opts.object_name.lower(), url) args = () if object_id is not None: args = (object_id,) return reverse(url, args=args)
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier binary_operator string string_start string_content string_end tuple attribute identifier identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier tuple if_statement comparison_operator identifier none block expression_statement assignment identifier tuple identifier return_statement call identifier argument_list identifier keyword_argument identifier identifier
Returns the URL for the given model and admin url name.
def addImg(self, img): self.img = imread(img, 'gray', 'uint8') didFindCorners, corners = self.method() self.opts['foundPattern'].append(didFindCorners) if didFindCorners: self.findCount += 1 self.objpoints.append(self.objp) self.opts['imgPoints'].append(corners) return didFindCorners
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list expression_statement call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list identifier if_statement identifier block expression_statement augmented_assignment attribute identifier identifier integer expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list identifier return_statement identifier
add one chessboard image for detection lens distortion
def wkhtmltopdf_args_mapping(data): mapping = { 'cookies': 'cookie', 'custom-headers': 'custom-header', 'run-scripts': 'run-script' } return {mapping.get(k, k): v for k, v in data.items()}
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end return_statement dictionary_comprehension pair call attribute identifier identifier argument_list identifier identifier identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list
fix our names to wkhtmltopdf's args
def _css_background(self, **kwargs): img_1x, img_2x, _ = self._get_renditions(kwargs) tmpl = 'background-image: url("{s1x}");' if img_1x != img_2x: image_set = 'image-set(url("{s1x}") 1x, url("{s2x}") 2x)' tmpl += 'background-image: {ss};background-image: -webkit-{ss};'.format( ss=image_set) return tmpl.format(s1x=img_1x, s2x=img_2x)
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment pattern_list identifier identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier string string_start string_content string_end if_statement comparison_operator identifier identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement augmented_assignment identifier call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier
Get the CSS specifiers for this as a hidpi-capable background image
def authentication_url(self): params = { 'client_id': self.client_id, 'response_type': self.type, 'redirect_uri': self.callback_url } return AUTHENTICATION_URL + "?" + urlencode(params)
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier return_statement binary_operator binary_operator identifier string string_start string_content string_end call identifier argument_list identifier
Redirect your users to here to authenticate them.
def album_to_ref(album): name = '' for artist in album.artists: if len(name) > 0: name += ', ' name += artist.name if (len(name)) > 0: name += ' - ' if album.name: name += album.name else: name += 'Unknown Album' return Ref.directory(uri=album.uri, name=name)
module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_end for_statement identifier attribute identifier identifier block if_statement comparison_operator call identifier argument_list identifier integer block expression_statement augmented_assignment identifier string string_start string_content string_end expression_statement augmented_assignment identifier attribute identifier identifier if_statement comparison_operator parenthesized_expression call identifier argument_list identifier integer block expression_statement augmented_assignment identifier string string_start string_content string_end if_statement attribute identifier identifier block expression_statement augmented_assignment identifier attribute identifier identifier else_clause block expression_statement augmented_assignment identifier string string_start string_content string_end return_statement call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier
Convert a mopidy album to a mopidy ref.
def pulse(self): new_b_value = self.gpio_b.is_active new_a_value = self.gpio_a.is_active value = self.table_values.value(new_b_value, new_a_value, self.old_b_value, self.old_a_value) self.old_b_value = new_b_value self.old_a_value = new_a_value if value != 0: self.when_rotated(value)
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier if_statement comparison_operator identifier integer block expression_statement call attribute identifier identifier argument_list identifier
Calls when_rotated callback if detected changes
def cio_open(cinfo, src=None): argtypes = [ctypes.POINTER(CommonStructType), ctypes.c_char_p, ctypes.c_int] OPENJPEG.opj_cio_open.argtypes = argtypes OPENJPEG.opj_cio_open.restype = ctypes.POINTER(CioType) if src is None: length = 0 else: length = len(src) cio = OPENJPEG.opj_cio_open(ctypes.cast(cinfo, ctypes.POINTER(CommonStructType)), src, length) return cio
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier list call attribute identifier identifier argument_list identifier attribute identifier identifier attribute identifier identifier expression_statement assignment attribute attribute identifier identifier identifier identifier expression_statement assignment attribute attribute identifier identifier identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement assignment identifier integer else_clause block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier identifier identifier return_statement identifier
Wrapper for openjpeg library function opj_cio_open.
def handle_read(repo, **kwargs): log.info('read: %s %s' %(repo, kwargs)) if type(repo) in [unicode, str]: return {'name': 'Repo', 'desc': 'Welcome to Grit', 'comment': ''} else: return repo.serialize()
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier if_statement comparison_operator call identifier argument_list identifier list identifier identifier block return_statement dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_end else_clause block return_statement call attribute identifier identifier argument_list
handles reading repo information
def expand_families(self, stmts): new_stmts = [] for stmt in stmts: families_list = [] for ag in stmt.agent_list(): ag_children = self.get_children(ag) if len(ag_children) == 0: families_list.append([ag]) else: families_list.append(ag_children) for ag_combo in itertools.product(*families_list): child_agents = [] for ag_entry in ag_combo: if ag_entry is None or isinstance(ag_entry, Agent): new_agent = ag_entry elif isinstance(ag_entry, tuple): ag_ns, ag_id = ag_entry new_agent = _agent_from_ns_id(ag_ns, ag_id) else: raise Exception('Unrecognized agent entry type.') child_agents.append(new_agent) new_stmt = deepcopy(stmt) new_stmt.set_agent_list(child_agents) new_stmts.append(new_stmt) return new_stmts
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier list for_statement identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator call identifier argument_list identifier integer block expression_statement call attribute identifier identifier argument_list list identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier for_statement identifier call attribute identifier identifier argument_list list_splat identifier block expression_statement assignment identifier list for_statement identifier identifier block if_statement boolean_operator comparison_operator identifier none call identifier argument_list identifier identifier block expression_statement assignment identifier identifier elif_clause call identifier argument_list identifier identifier block expression_statement assignment pattern_list identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier else_clause block raise_statement call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Generate statements by expanding members of families and complexes.
def com(self): if self._com is None: self._com = np.mean(self.pmts.pos, axis=0) return self._com
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier keyword_argument identifier integer return_statement attribute identifier identifier
Center of mass, calculated from the mean of the PMT positions
def sitemap_index(request): sitemaps = [] with db_connect() as db_connection: with db_connection.cursor() as cursor: cursor.execute( ) for author, revised in cursor.fetchall(): sitemaps.append(Sitemap(url=request.route_url( 'sitemap', from_id=author), lastmod=revised)) si = SitemapIndex(sitemaps=sitemaps) resp = request.response resp.status = '200 OK' resp.content_type = 'text/xml' resp.body = si() return resp
module function_definition identifier parameters identifier block expression_statement assignment identifier list with_statement with_clause with_item as_pattern call identifier argument_list as_pattern_target identifier block with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list call identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier call identifier argument_list return_statement identifier
Return a sitemap index xml file for search engines.
def makeSer(segID, N, CA, C, O, geo): CA_CB_length=geo.CA_CB_length C_CA_CB_angle=geo.C_CA_CB_angle N_C_CA_CB_diangle=geo.N_C_CA_CB_diangle CB_OG_length=geo.CB_OG_length CA_CB_OG_angle=geo.CA_CB_OG_angle N_CA_CB_OG_diangle=geo.N_CA_CB_OG_diangle carbon_b= calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle, N_C_CA_CB_diangle) CB= Atom("CB", carbon_b, 0.0 , 1.0, " "," CB", 0,"C") oxygen_g= calculateCoordinates(N, CA, CB, CB_OG_length, CA_CB_OG_angle, N_CA_CB_OG_diangle) OG= Atom("OG", oxygen_g, 0.0, 1.0, " ", " OG", 0, "O") res= Residue((' ', segID, ' '), "SER", ' ') res.add(N) res.add(CA) res.add(C) res.add(O) res.add(CB) res.add(OG) return res
module function_definition identifier parameters identifier identifier identifier identifier identifier 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 expression_statement assignment identifier call identifier argument_list identifier identifier identifier identifier identifier identifier expression_statement assignment identifier call identifier argument_list string string_start string_content string_end identifier float float string string_start string_content string_end string string_start string_content string_end integer string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier identifier identifier identifier identifier identifier expression_statement assignment identifier call identifier argument_list string string_start string_content string_end identifier float float string string_start string_content string_end string string_start string_content string_end integer string string_start string_content string_end expression_statement assignment identifier call identifier argument_list tuple string string_start string_content string_end identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Creates a Serine residue
def make_skiplist(*args, use_fallback=False): sl = fallback.Skiplist if use_fallback else Skiplist return sl(*args)
module function_definition identifier parameters list_splat_pattern identifier default_parameter identifier false block expression_statement assignment identifier conditional_expression attribute identifier identifier identifier identifier return_statement call identifier argument_list list_splat identifier
Create a new skiplist
def read_inquiry_mode(sock): old_filter = sock.getsockopt( bluez.SOL_HCI, bluez.HCI_FILTER, 14) flt = bluez.hci_filter_new() opcode = bluez.cmd_opcode_pack(bluez.OGF_HOST_CTL, bluez.OCF_READ_INQUIRY_MODE) bluez.hci_filter_set_ptype(flt, bluez.HCI_EVENT_PKT) bluez.hci_filter_set_event(flt, bluez.EVT_CMD_COMPLETE); bluez.hci_filter_set_opcode(flt, opcode) sock.setsockopt( bluez.SOL_HCI, bluez.HCI_FILTER, flt ) bluez.hci_send_cmd(sock, bluez.OGF_HOST_CTL, bluez.OCF_READ_INQUIRY_MODE ) pkt = sock.recv(255) status,mode = struct.unpack("xxxxxxBB", pkt) if status != 0: mode = -1 sock.setsockopt( bluez.SOL_HCI, bluez.HCI_FILTER, old_filter ) return mode
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list integer expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement comparison_operator identifier integer block expression_statement assignment identifier unary_operator integer expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier identifier return_statement identifier
returns the current mode, or -1 on failure
def args(self): arglist = [] for k, v in six.iteritems(self.requires_hadoop()): arglist.append('--' + k) arglist.extend([t.output().path for t in flatten(v)]) arglist.extend(['--output', self.output()]) arglist.extend(self.job_args()) return arglist
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list list_comprehension attribute call attribute identifier identifier argument_list identifier for_in_clause identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list list string string_start string_content string_end call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list return_statement identifier
Returns an array of args to pass to the job.
def create_file(self): src = self.get_current_path() name, status = QtWidgets.QInputDialog.getText( self.tree_view, _('Create new file'), _('File name:'), QtWidgets.QLineEdit.Normal, '') if status: fatal_names = ['.', '..', os.sep] for i in fatal_names: if i == name: QtWidgets.QMessageBox.critical( self.tree_view, _("Error"), _("Wrong directory name")) return if os.path.isfile(src): src = os.path.dirname(src) path = os.path.join(src, name) try: with open(path, 'w'): pass except OSError as e: QtWidgets.QMessageBox.warning( self.tree_view, _('Failed to create new file'), _('Failed to create file: "%s".\n\n%s') % (path, str(e))) else: self.tree_view.file_created.emit(os.path.normpath(path))
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier call identifier argument_list string string_start string_content string_end call identifier argument_list string string_start string_content string_end attribute attribute identifier identifier identifier string string_start string_end if_statement identifier block expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end attribute identifier identifier for_statement identifier identifier block if_statement comparison_operator identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier call identifier argument_list string string_start string_content string_end call identifier argument_list string string_start string_content string_end return_statement if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier try_statement block with_statement with_clause with_item call identifier argument_list identifier string string_start string_content string_end block pass_statement except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier call identifier argument_list string string_start string_content string_end binary_operator call identifier argument_list string string_start string_content escape_sequence escape_sequence string_end tuple identifier call identifier argument_list identifier else_clause block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier
Creates a file under the current directory.
def locate(self, path): return Zconfig(lib.zconfig_locate(self._as_parameter_, path), False)
module function_definition identifier parameters identifier identifier block return_statement call identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier identifier false
Find a config item along a path; leading slash is optional and ignored.
def multiply(self, number): return self.from_list([x * number for x in self.to_list()])
module function_definition identifier parameters identifier identifier block return_statement call attribute identifier identifier argument_list list_comprehension binary_operator identifier identifier for_in_clause identifier call attribute identifier identifier argument_list
Return a Vector as the product of the vector and a real number.
def _make_scatter_logfile_name(cls, key, linkname, job_config): logfile = job_config.get('logfile', "%s_%s_%s.log" % (cls.default_prefix_logfile, linkname, key)) job_config['logfile'] = logfile
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end binary_operator string string_start string_content string_end tuple attribute identifier identifier identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier
Hook to inster the name of a logfile into the input config
def _organize_variants(samples, batch_id): caller_names = [x["variantcaller"] for x in samples[0]["variants"]] calls = collections.defaultdict(list) for data in samples: for vrn in data["variants"]: calls[vrn["variantcaller"]].append(vrn["vrn_file"]) data = samples[0] vrn_files = [] for caller in caller_names: fnames = calls[caller] if len(fnames) == 1: vrn_files.append(fnames[0]) else: vrn_files.append(population.get_multisample_vcf(fnames, batch_id, caller, data)) return caller_names, vrn_files
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list_comprehension subscript identifier string string_start string_content string_end for_in_clause identifier subscript subscript identifier integer string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement identifier identifier block for_statement identifier subscript identifier string string_start string_content string_end block expression_statement call attribute subscript identifier subscript identifier string string_start string_content string_end identifier argument_list subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier subscript identifier identifier if_statement comparison_operator call identifier argument_list identifier integer block expression_statement call attribute identifier identifier argument_list subscript identifier integer else_clause block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier identifier identifier return_statement expression_list identifier identifier
Retrieve variant calls for all samples, merging batched samples into single VCF.
def watch_dir(path: str) -> None: _compile_exclude_patterns() if config.autoreload or config.debug: p = pathlib.Path(path) p.resolve() _add_watch_path(p)
module function_definition identifier parameters typed_parameter identifier type identifier type none block expression_statement call identifier argument_list if_statement boolean_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list expression_statement call identifier argument_list identifier
Add ``path`` to watch for autoreload.
def _permute_aux_specs(self): calc_aux_mapping = self._NAMES_SUITE_TO_CALC.copy() calc_aux_mapping[_OBJ_LIB_STR] = None [calc_aux_mapping.pop(core) for core in self._CORE_SPEC_NAMES] specs = self._get_aux_specs() for suite_name, calc_name in calc_aux_mapping.items(): specs[calc_name] = specs.pop(suite_name) return _permuted_dicts_of_specs(specs)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment subscript identifier identifier none expression_statement list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment subscript identifier identifier call attribute identifier identifier argument_list identifier return_statement call identifier argument_list identifier
Generate all permutations of the non-core specifications.
def read_dates_by_service_ids( path: str ) -> Dict[FrozenSet[str], FrozenSet[datetime.date]]: feed = load_raw_feed(path) return _dates_by_service_ids(feed)
module function_definition identifier parameters typed_parameter identifier type identifier type generic_type identifier type_parameter type generic_type identifier type_parameter type identifier type generic_type identifier type_parameter type attribute identifier identifier block expression_statement assignment identifier call identifier argument_list identifier return_statement call identifier argument_list identifier
Find dates with identical service
def patch_sys_version(): if '|' in sys.version: sys_version = sys.version.split('|') sys.version = ' '.join([sys_version[0].strip(), sys_version[-1].strip()])
module function_definition identifier parameters block if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute string string_start string_content string_end identifier argument_list list call attribute subscript identifier integer identifier argument_list call attribute subscript identifier unary_operator integer identifier argument_list
Remove Continuum copyright statement to avoid parsing errors in IDLE
def _convert_hex_str_to_int(val): if val is None: return None hex_num = int(val, 16) if hex_num > 0x7FFFFFFFFFFFFFFF: hex_num -= 0x10000000000000000 assert -9223372036854775808 <= hex_num <= 9223372036854775807 return hex_num
module function_definition identifier parameters identifier block if_statement comparison_operator identifier none block return_statement none expression_statement assignment identifier call identifier argument_list identifier integer if_statement comparison_operator identifier integer block expression_statement augmented_assignment identifier integer assert_statement comparison_operator unary_operator integer identifier integer return_statement identifier
Convert hexadecimal formatted ids to signed int64
def yum_search(packages): output = {} cmd = ['yum', 'search'] if isinstance(packages, six.string_types): cmd.append(packages) else: cmd.extend(packages) log("Searching for {}".format(packages)) result = subprocess.check_output(cmd) for package in list(packages): output[package] = package in result return output
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end if_statement call identifier argument_list identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement identifier call identifier argument_list identifier block expression_statement assignment subscript identifier identifier comparison_operator identifier identifier return_statement identifier
Search for a package.
def threadProfileCode(func, *args, **kwargs): 'Toplevel thread profile wrapper.' with ThreadProfiler(threading.current_thread()) as prof: try: prof.thread.status = threadProfileCode.__wrapped__(func, *args, **kwargs) except EscapeException as e: prof.thread.status = e
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement string string_start string_content string_end with_statement with_clause with_item as_pattern call identifier argument_list call attribute identifier identifier argument_list as_pattern_target identifier block try_statement block expression_statement assignment attribute attribute identifier identifier identifier call attribute identifier identifier argument_list identifier list_splat identifier dictionary_splat identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement assignment attribute attribute identifier identifier identifier identifier
Toplevel thread profile wrapper.
def _dasd_reverse_conversion(cls, val, **kwargs): if val is not None: if val.upper() == 'ADMINISTRATORS': return '0' elif val.upper() == 'ADMINISTRATORS AND POWER USERS': return '1' elif val.upper() == 'ADMINISTRATORS AND INTERACTIVE USERS': return '2' elif val.upper() == 'NOT DEFINED': return '9999' else: return 'Invalid Value' else: return 'Not Defined'
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block if_statement comparison_operator identifier none block if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end block return_statement string string_start string_content string_end elif_clause comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end block return_statement string string_start string_content string_end elif_clause comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end block return_statement string string_start string_content string_end elif_clause comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end block return_statement string string_start string_content string_end else_clause block return_statement string string_start string_content string_end else_clause block return_statement string string_start string_content string_end
converts DASD String values to the reg_sz value
def _sanity_check_coerce_type_outside_of_fold(ir_blocks): is_in_fold = False for first_block, second_block in pairwise(ir_blocks): if isinstance(first_block, Fold): is_in_fold = True if not is_in_fold and isinstance(first_block, CoerceType): if not isinstance(second_block, (MarkLocation, Filter)): raise AssertionError(u'Expected MarkLocation or Filter after CoerceType, ' u'but none was found: {}'.format(ir_blocks)) if isinstance(second_block, Unfold): is_in_fold = False
module function_definition identifier parameters identifier block expression_statement assignment identifier false for_statement pattern_list identifier identifier call identifier argument_list identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier true if_statement boolean_operator not_operator identifier call identifier argument_list identifier identifier block if_statement not_operator call identifier argument_list identifier tuple identifier identifier block raise_statement call identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list identifier if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier false
Ensure that CoerceType not in a @fold are followed by a MarkLocation or Filter block.
def functionFactory(in_code, name, defaults, globals_, imports): def generatedFunction(): pass generatedFunction.__code__ = marshal.loads(in_code) generatedFunction.__name__ = name generatedFunction.__defaults = defaults generatedFunction.__globals__.update(pickle.loads(globals_)) for key, value in imports.items(): imported_module = __import__(value) scoop.logger.debug("Dynamically loaded module {0}".format(value)) generatedFunction.__globals__.update({key: imported_module}) return generatedFunction
module function_definition identifier parameters identifier identifier identifier identifier identifier block function_definition identifier parameters block pass_statement expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list dictionary pair identifier identifier return_statement identifier
Creates a function at runtime using binary compiled inCode
def forward_state(self, sequence, state=None): if state is None: state = self.zero_state(sequence.size(0)) data = self.input_block(sequence) state_outputs = [] for idx in range(len(self.recurrent_layers)): layer_length = self.recurrent_layers[idx].state_dim current_state = state[:, :, :layer_length] state = state[:, :, layer_length:] data, new_h = self.recurrent_layers[idx](data, current_state) if self.dropout_layers: data = self.dropout_layers[idx](data) state_outputs.append(new_h) output_data = self.output_activation(self.output_layer(data)) concatenated_hidden_output = torch.cat(state_outputs, dim=2) return output_data, concatenated_hidden_output
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier list for_statement identifier call identifier argument_list call identifier argument_list attribute identifier identifier block expression_statement assignment identifier attribute subscript attribute identifier identifier identifier identifier expression_statement assignment identifier subscript identifier slice slice slice identifier expression_statement assignment identifier subscript identifier slice slice slice identifier expression_statement assignment pattern_list identifier identifier call subscript attribute identifier identifier identifier argument_list identifier identifier if_statement attribute identifier identifier block expression_statement assignment identifier call subscript attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier integer return_statement expression_list identifier identifier
Forward propagate a sequence through the network accounting for the state
def _is_at_qry_end(self, nucmer_hit): hit_coords = nucmer_hit.qry_coords() return hit_coords.end >= nucmer_hit.qry_length - self.qry_end_tolerance
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list return_statement comparison_operator attribute identifier identifier binary_operator attribute identifier identifier attribute identifier identifier
Returns True iff the hit is "close enough" to the end of the query sequence
def collect_metrics(local_evaluator=None, remote_evaluators=[], timeout_seconds=180): episodes, num_dropped = collect_episodes( local_evaluator, remote_evaluators, timeout_seconds=timeout_seconds) metrics = summarize_episodes(episodes, episodes, num_dropped) return metrics
module function_definition identifier parameters default_parameter identifier none default_parameter identifier list default_parameter identifier integer block expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier identifier keyword_argument identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier return_statement identifier
Gathers episode metrics from PolicyEvaluator instances.
def request_headers(self, request): headers = {} allow_origin = self.allow_origin(request) if allow_origin: headers = dict_filter({ 'Access-Control-Allow-Origin': allow_origin, 'Access-Control-Allow-Credentials': {True: 'true', False: 'false'}.get(self.allow_credentials), 'Access-Control-Expose-Headers': ', '.join(self.expose_headers) if self.expose_headers else None, }) return headers
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement assignment identifier call identifier argument_list dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end call attribute dictionary pair true string string_start string_content string_end pair false string string_start string_content string_end identifier argument_list attribute identifier identifier pair string string_start string_content string_end conditional_expression call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier attribute identifier identifier none return_statement identifier
Generate standard request headers
def generate_checks(fact): yield TypeCheck(type(fact)) fact_captured = False for key, value in fact.items(): if (isinstance(key, str) and key.startswith('__') and key.endswith('__')): if key == '__bind__': yield FactCapture(value) fact_captured = True else: yield FeatureCheck(key, value) else: yield FeatureCheck(key, value) if not fact_captured: yield FactCapture("__pattern_%s__" % id(fact))
module function_definition identifier parameters identifier block expression_statement yield call identifier argument_list call identifier argument_list identifier expression_statement assignment identifier false for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement parenthesized_expression boolean_operator boolean_operator call identifier argument_list identifier identifier 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 if_statement comparison_operator identifier string string_start string_content string_end block expression_statement yield call identifier argument_list identifier expression_statement assignment identifier true else_clause block expression_statement yield call identifier argument_list identifier identifier else_clause block expression_statement yield call identifier argument_list identifier identifier if_statement not_operator identifier block expression_statement yield call identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier
Given a fact, generate a list of Check objects for checking it.
def target_to_ipv4_short(target): splitted = target.split('-') if len(splitted) != 2: return None try: start_packed = inet_pton(socket.AF_INET, splitted[0]) end_value = int(splitted[1]) except (socket.error, ValueError): return None start_value = int(binascii.hexlify(bytes(start_packed[3])), 16) if end_value < 0 or end_value > 255 or end_value < start_value: return None end_packed = start_packed[0:3] + struct.pack('B', end_value) return ipv4_range_to_list(start_packed, end_packed)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator call identifier argument_list identifier integer block return_statement none try_statement block expression_statement assignment identifier call identifier argument_list attribute identifier identifier subscript identifier integer expression_statement assignment identifier call identifier argument_list subscript identifier integer except_clause tuple attribute identifier identifier identifier block return_statement none expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list call identifier argument_list subscript identifier integer integer if_statement boolean_operator boolean_operator comparison_operator identifier integer comparison_operator identifier integer comparison_operator identifier identifier block return_statement none expression_statement assignment identifier binary_operator subscript identifier slice integer integer call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement call identifier argument_list identifier identifier
Attempt to return a IPv4 short range list from a target string.
def format_rst(self): res = '' num_cols = len(self.header) col_width = 25 for _ in range(num_cols): res += ''.join(['=' for _ in range(col_width - 1)]) + ' ' res += '\n' for c in self.header: res += c.ljust(col_width) res += '\n' for _ in range(num_cols): res += ''.join(['=' for _ in range(col_width - 1)]) + ' ' res += '\n' for row in self.arr: for c in row: res += self.force_to_string(c).ljust(col_width) res += '\n' for _ in range(num_cols): res += ''.join(['=' for _ in range(col_width - 1)]) + ' ' res += '\n' return res
module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_end expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier integer for_statement identifier call identifier argument_list identifier block expression_statement augmented_assignment identifier binary_operator call attribute string string_start string_end identifier argument_list list_comprehension string string_start string_content string_end for_in_clause identifier call identifier argument_list binary_operator identifier integer string string_start string_content string_end expression_statement augmented_assignment identifier string string_start string_content escape_sequence string_end for_statement identifier attribute identifier identifier block expression_statement augmented_assignment identifier call attribute identifier identifier argument_list identifier expression_statement augmented_assignment identifier string string_start string_content escape_sequence string_end for_statement identifier call identifier argument_list identifier block expression_statement augmented_assignment identifier binary_operator call attribute string string_start string_end identifier argument_list list_comprehension string string_start string_content string_end for_in_clause identifier call identifier argument_list binary_operator identifier integer string string_start string_content string_end expression_statement augmented_assignment identifier string string_start string_content escape_sequence string_end for_statement identifier attribute identifier identifier block for_statement identifier identifier block expression_statement augmented_assignment identifier call attribute call attribute identifier identifier argument_list identifier identifier argument_list identifier expression_statement augmented_assignment identifier string string_start string_content escape_sequence string_end for_statement identifier call identifier argument_list identifier block expression_statement augmented_assignment identifier binary_operator call attribute string string_start string_end identifier argument_list list_comprehension string string_start string_content string_end for_in_clause identifier call identifier argument_list binary_operator identifier integer string string_start string_content string_end expression_statement augmented_assignment identifier string string_start string_content escape_sequence string_end return_statement identifier
return table in RST format
def delete_network_subname(self, sub_name): try: body = {} net_list = self.neutronclient.list_networks(body=body) for net in net_list: if net.get('name').find(sub_name) != -1: self.delete_network_all_subnets(net.get('net_id')) except Exception as exc: LOG.error("Failed to get network by subname %(name)s, " "Exc %(exc)s", {'name': sub_name, 'exc': str(exc)})
module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment identifier dictionary expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier for_statement identifier identifier block if_statement comparison_operator call attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier argument_list identifier unary_operator integer block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end call identifier argument_list identifier
Delete the network by part of its name, use with caution.
def uniform(self, key, min_value=0., max_value=1.): return min_value + self._random(key) * (max_value - min_value)
module function_definition identifier parameters identifier identifier default_parameter identifier float default_parameter identifier float block return_statement binary_operator identifier binary_operator call attribute identifier identifier argument_list identifier parenthesized_expression binary_operator identifier identifier
Returns a random number between min_value and max_value
def _calc_strain(self, loc_input, loc_layer, motion, *args): strain_max = self._calc_strain_max(loc_input, loc_layer, motion, *args) return self.strain_ratio * strain_max
module function_definition identifier parameters identifier identifier identifier identifier list_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier list_splat identifier return_statement binary_operator attribute identifier identifier identifier
Compute the strain used for iterations of material properties.
def functions(self): return [v for v in self.globals.values() if isinstance(v, values.Function)]
module function_definition identifier parameters identifier block return_statement list_comprehension identifier for_in_clause identifier call attribute attribute identifier identifier identifier argument_list if_clause call identifier argument_list identifier attribute identifier identifier
A list of functions declared or defined in this module.
def add_tenant_to_flavor(request, flavor, tenant): return _nova.novaclient(request).flavor_access.add_tenant_access( flavor=flavor, tenant=tenant)
module function_definition identifier parameters identifier identifier identifier block return_statement call attribute attribute call attribute identifier identifier argument_list identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier
Add a tenant to the given flavor access list.
def paramsarraybounds(self): bounds = [] for (i, param) in self._index_to_param.items(): if isinstance(param, str): bounds.append(self.model.PARAMLIMITS[param]) elif isinstance(param, tuple): bounds.append(self.model.PARAMLIMITS[param[0]]) else: raise ValueError("Invalid param type") bounds = [(tup[0] + ALMOST_ZERO, tup[1] - ALMOST_ZERO) for tup in bounds] assert len(bounds) == len(self._index_to_param) return tuple(bounds)
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement tuple_pattern identifier identifier call attribute attribute identifier identifier identifier argument_list block if_statement call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list subscript attribute attribute identifier identifier identifier identifier elif_clause call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list subscript attribute attribute identifier identifier identifier subscript identifier integer else_clause block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier list_comprehension tuple binary_operator subscript identifier integer identifier binary_operator subscript identifier integer identifier for_in_clause identifier identifier assert_statement comparison_operator call identifier argument_list identifier call identifier argument_list attribute identifier identifier return_statement call identifier argument_list identifier
Bounds for parameters in `paramsarray`.
def _append_pairs(new_pairs): desired_pairs = restore_pairs() or [] desired_pairs += new_pairs print("Adding {} new pairs, queue has {} pairs".format(len(new_pairs), len(desired_pairs))) save_pairs(desired_pairs)
module function_definition identifier parameters identifier block expression_statement assignment identifier boolean_operator call identifier argument_list list expression_statement augmented_assignment identifier identifier expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier call identifier argument_list identifier expression_statement call identifier argument_list identifier
Load the pairlist, add new stuff, save it out
def _add_minimization_vars(self): self._z = self._prob.namespace(self._model.reactions, lower=0) v = self._v.set(self._model.reactions) z = self._z.set(self._model.reactions) self._prob.add_linear_constraints(z >= v, v >= -z)
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier keyword_argument identifier integer expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list comparison_operator identifier identifier comparison_operator identifier unary_operator identifier
Add variables and constraints for L1 norm minimization.
def _find_usage_subnets(self): subnet_to_az = {} subnets = defaultdict(int) for subnet in self.conn.describe_subnets()['Subnets']: subnets[subnet['VpcId']] += 1 subnet_to_az[subnet['SubnetId']] = subnet['AvailabilityZone'] for vpc_id in subnets: self.limits['Subnets per VPC']._add_current_usage( subnets[vpc_id], aws_type='AWS::EC2::VPC', resource_id=vpc_id ) return subnet_to_az
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary expression_statement assignment identifier call identifier argument_list identifier for_statement identifier subscript call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block expression_statement augmented_assignment subscript identifier subscript identifier string string_start string_content string_end integer expression_statement assignment subscript identifier subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end for_statement identifier identifier block expression_statement call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list subscript identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier return_statement identifier
find usage for Subnets; return dict of SubnetId to AZ
async def jsk_vc_pause(self, ctx: commands.Context): voice = ctx.guild.voice_client if voice.is_paused(): return await ctx.send("Audio is already paused.") voice.pause() await ctx.send(f"Paused audio in {voice.channel.name}.")
module function_definition identifier parameters identifier typed_parameter identifier type attribute identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier if_statement call attribute identifier identifier argument_list block return_statement await call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list expression_statement await call attribute identifier identifier argument_list string string_start string_content interpolation attribute attribute identifier identifier identifier string_content string_end
Pauses a running audio source, if there is one.
def _queue_processor(self)->None: "Processes queued up write requests asynchronously to Tensorboard." while not self.stop_request.isSet(): while not self.queue.empty(): if self.stop_request.isSet(): return request = self.queue.get() request.write() sleep(0.2)
module function_definition identifier parameters identifier type none block expression_statement string string_start string_content string_end while_statement not_operator call attribute attribute identifier identifier identifier argument_list block while_statement not_operator call attribute attribute identifier identifier identifier argument_list block if_statement call attribute attribute identifier identifier identifier argument_list block return_statement expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call identifier argument_list float
Processes queued up write requests asynchronously to Tensorboard.
def _get_token(): username = __opts__.get('rallydev', {}).get('username', None) password = __opts__.get('rallydev', {}).get('password', None) path = 'https://rally1.rallydev.com/slm/webservice/v2.0/security/authorize' result = salt.utils.http.query( path, decode=True, decode_type='json', text=True, status=True, username=username, password=password, cookies=True, persist_session=True, opts=__opts__, ) if 'dict' not in result: return None return result['dict']['OperationResult']['SecurityToken']
module function_definition identifier parameters block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list string string_start string_content string_end dictionary identifier argument_list string string_start string_content string_end none expression_statement assignment identifier call attribute call attribute identifier identifier argument_list string string_start string_content string_end dictionary identifier argument_list string string_start string_content string_end none expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier keyword_argument identifier true keyword_argument identifier string string_start string_content string_end keyword_argument identifier true keyword_argument identifier true keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier true keyword_argument identifier true keyword_argument identifier identifier if_statement comparison_operator string string_start string_content string_end identifier block return_statement none return_statement subscript subscript subscript identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end
Get an auth token
def _cached_request(self, base_url, client_id, client_secret, parameters, **kwargs): key = (base_url, client_id, tuple(parameters.items())) cached = self._cache.get(key, {}) if not cached.get('access_token') or self._expired(cached): cached = yield self._request(base_url, client_id, client_secret, parameters, **kwargs) self._cache[key] = cached self.purge_cache() logging.debug('Using a cached token: %s', cached.get('access_token')) raise Return(cached)
module function_definition identifier parameters identifier identifier identifier identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier tuple identifier identifier call identifier argument_list call attribute identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier dictionary if_statement boolean_operator not_operator call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list identifier block expression_statement assignment identifier yield call attribute identifier identifier argument_list identifier identifier identifier identifier dictionary_splat identifier expression_statement assignment subscript attribute identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement 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 raise_statement call identifier argument_list identifier
Cache the token request and use cached responses if available
def generate_token(self): response = self._make_request() self.auth = response self.token = response['token']
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end
Make request in API to generate a token.
def ext_pillar(minion_id, pillar, conf, nesting_key=None): comps = conf.split() paths = [comp for comp in comps if comp.startswith('path=')] if not paths: log.error('"%s" is not a valid Vault ext_pillar config', conf) return {} vault_pillar = {} try: path = paths[0].replace('path=', '') path = path.format(**{'minion': minion_id}) url = 'v1/{0}'.format(path) response = __utils__['vault.make_request']('GET', url) if response.status_code == 200: vault_pillar = response.json().get('data', {}) else: log.info('Vault secret not found for: %s', path) except KeyError: log.error('No such path in Vault: %s', path) if nesting_key: vault_pillar = {nesting_key: vault_pillar} return vault_pillar
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier list_comprehension identifier for_in_clause identifier identifier if_clause call attribute identifier identifier argument_list string string_start string_content string_end if_statement not_operator identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement dictionary expression_statement assignment identifier dictionary try_statement block expression_statement assignment identifier call attribute subscript identifier integer identifier argument_list string string_start string_content string_end string string_start string_end expression_statement assignment identifier call attribute identifier identifier argument_list dictionary_splat dictionary pair string string_start string_content string_end identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier call subscript identifier string string_start string_content string_end argument_list string string_start string_content string_end identifier if_statement comparison_operator attribute identifier identifier integer block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list string string_start string_content string_end dictionary else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement identifier block expression_statement assignment identifier dictionary pair identifier identifier return_statement identifier
Get pillar data from Vault for the configuration ``conf``.
def pre_init_process(self): db.connections.close_all() BackgroundProcess.objects.filter(pk=self.process_id).update( pid=self.pid, last_update=now(), running_since=now(), done=False, failed=False, message='init process..', ) [signal.signal(s, signal.SIG_DFL) for s in self.SIGNALS] [signal.signal(s, self.signal) for s in self.SIGNALS]
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier call identifier argument_list keyword_argument identifier call identifier argument_list keyword_argument identifier false keyword_argument identifier false keyword_argument identifier string string_start string_content string_end expression_statement list_comprehension call attribute identifier identifier argument_list identifier attribute identifier identifier for_in_clause identifier attribute identifier identifier expression_statement list_comprehension call attribute identifier identifier argument_list identifier attribute identifier identifier for_in_clause identifier attribute identifier identifier
will be executed after process fork
async def _wait_execute(self, address, command, args, kw): conn = await self.acquire(command, args) try: return (await conn.execute(command, *args, **kw)) finally: self.release(conn)
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier await call attribute identifier identifier argument_list identifier identifier try_statement block return_statement parenthesized_expression await call attribute identifier identifier argument_list identifier list_splat identifier dictionary_splat identifier finally_clause block expression_statement call attribute identifier identifier argument_list identifier
Acquire connection and execute command.
def _attr_display(value, html_element): if value == 'block': html_element.display = Display.block elif value == 'none': html_element.display = Display.none else: html_element.display = Display.inline
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier attribute identifier identifier elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier attribute identifier identifier else_clause block expression_statement assignment attribute identifier identifier attribute identifier identifier
Set the display value
def write_file(self, target_path, html): logger.debug("Building to {}{}".format(self.fs_name, target_path)) with self.fs.open(smart_text(target_path), 'wb') as outfile: outfile.write(six.binary_type(html)) outfile.close()
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier identifier with_statement with_clause with_item as_pattern call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list
Writes out the provided HTML to the provided path.
def getApplications(self): res = [] for f in self.features: if isinstance(f, Feature) and f.prop == "disk.0.applications": res.append(FeaturesApp(f.value.features)) return res
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier attribute identifier identifier block if_statement boolean_operator call identifier argument_list identifier identifier comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list call identifier argument_list attribute attribute identifier identifier identifier return_statement identifier
Return a list of Application with the specified apps in this system.
def byPromissor(self, ID): res = [] for direction in self.table: if ID in direction[1]: res.append(direction) return res
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list for_statement identifier attribute identifier identifier block if_statement comparison_operator identifier subscript identifier integer block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Returns all directions to a promissor.
def OnExitSelectionMode(self, event): self.grid.sel_mode_cursor = None self.grid.EnableDragGridSize(True) self.grid.EnableEditing(True)
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute attribute identifier identifier identifier none expression_statement call attribute attribute identifier identifier identifier argument_list true expression_statement call attribute attribute identifier identifier identifier argument_list true
Event handler for leaving selection mode, enables cell edits
def render_as_text(self, limit=None): lines = traceback.format_exception(self.exc_type, self.exc_value, self.frames[0], limit=limit) return ''.join(lines).rstrip()
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier subscript attribute identifier identifier integer keyword_argument identifier identifier return_statement call attribute call attribute string string_start string_end identifier argument_list identifier identifier argument_list
Return a string with the traceback.
async def on_shutdown(self): await self._unregister_subscriptions() self._accepting = False for (ws, _) in self._subscribers: await ws.close(code=aiohttp.WSCloseCode.GOING_AWAY, message='Server shutdown')
module function_definition identifier parameters identifier block expression_statement await call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier false for_statement tuple_pattern identifier identifier attribute identifier identifier block expression_statement await call attribute identifier identifier argument_list keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier string string_start string_content string_end
Cleans up any outstanding subscriptions.
def __doQuery(self, query, format, convert): self.__getFormat(format) self.sparql.setQuery(query) if convert: results = self.sparql.query().convert() else: results = self.sparql.query() return results
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier if_statement identifier block expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list else_clause block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list return_statement identifier
Inner method that does the actual query
def gnupg_home(): if 'GNUPGHOME' in os.environ: gnupghome = os.environ['GNUPGHOME'] if not os.path.isdir(gnupghome): raise CryptoritoError("Invalid GNUPGHOME directory") return ["--homedir", gnupghome] else: return []
module function_definition identifier parameters block if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block raise_statement call identifier argument_list string string_start string_content string_end return_statement list string string_start string_content string_end identifier else_clause block return_statement list
Returns appropriate arguments if GNUPGHOME is set
def parse_devices(self): devices = [] for device in self._channel_dict["devices"]: devices.append(Device(device, self._is_sixteen_bit, self._ignore_list)) return devices
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier subscript attribute identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier attribute identifier identifier attribute identifier identifier return_statement identifier
Creates an array of Device objects from the channel
def defadj(self, singular, plural): self.checkpat(singular) self.checkpatplural(plural) self.pl_adj_user_defined.extend((singular, plural)) return 1
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list tuple identifier identifier return_statement integer
Set the adjective plural of singular to plural.
def pycbc_compile_function(code,arg_names,local_dict,global_dict, module_dir, compiler='', verbose=1, support_code=None, headers=None, customize=None, type_converters=None, auto_downcast=1, **kw): headers = [] if headers is None else headers lockfile_dir = os.environ['PYTHONCOMPILED'] lockfile_name = os.path.join(lockfile_dir, 'code_lockfile') logging.info("attempting to aquire lock '%s' for " "compiling code" % lockfile_name) if not os.path.exists(lockfile_dir): os.makedirs(lockfile_dir) lockfile = open(lockfile_name, 'w') fcntl.lockf(lockfile, fcntl.LOCK_EX) logging.info("we have aquired the lock") func = _compile_function(code,arg_names, local_dict, global_dict, module_dir, compiler, verbose, support_code, headers, customize, type_converters, auto_downcast, **kw) fcntl.lockf(lockfile, fcntl.LOCK_UN) logging.info("the lock has been released") return func
module function_definition identifier parameters identifier identifier identifier identifier identifier default_parameter identifier string string_start string_end default_parameter identifier integer default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier integer dictionary_splat_pattern identifier block expression_statement assignment identifier conditional_expression list comparison_operator identifier none identifier expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end identifier if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list 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 identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier dictionary_splat identifier expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier
Dummy wrapper around scipy weave compile to implement file locking
def compute_gas_limit_bounds(parent: BlockHeader) -> Tuple[int, int]: boundary_range = parent.gas_limit // GAS_LIMIT_ADJUSTMENT_FACTOR upper_bound = parent.gas_limit + boundary_range lower_bound = max(GAS_LIMIT_MINIMUM, parent.gas_limit - boundary_range) return lower_bound, upper_bound
module function_definition identifier parameters typed_parameter identifier type identifier type generic_type identifier type_parameter type identifier type identifier block expression_statement assignment identifier binary_operator attribute identifier identifier identifier expression_statement assignment identifier binary_operator attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier binary_operator attribute identifier identifier identifier return_statement expression_list identifier identifier
Compute the boundaries for the block gas limit based on the parent block.
def delete(self, tweet_id): c = self.connection.cursor() try: tweet = c.execute("SELECT id, message, previous_tweet, next_tweet from tweets WHERE id=?", (tweet_id,)).next() except StopIteration: raise ValueError("No tweets were found with that ID") c.execute("UPDATE tweets set next_tweet=? WHERE id=?", (tweet[3], tweet[2])) c.execute("UPDATE tweets set previous_tweet=? WHERE id=?", (tweet[2], tweet[3])) if tweet[3] is None: c.execute("UPDATE tweetlist SET tweet=? WHERE label='last_tweet'", (tweet[2],)) if tweet[2] is None: c.execute("UPDATE tweetlist SET tweet=? WHERE label='first_tweet'", (tweet[3],)) c.execute("DELETE from tweets WHERE id=?", (tweet_id,)) self.connection.commit() c.close()
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list try_statement block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list string string_start string_content string_end tuple identifier identifier argument_list except_clause identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end tuple subscript identifier integer subscript identifier integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end tuple subscript identifier integer subscript identifier integer if_statement comparison_operator subscript identifier integer none block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end tuple subscript identifier integer if_statement comparison_operator subscript identifier integer none block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end tuple subscript identifier integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end tuple identifier expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list
Deletes a tweet from the list with the given id
def print_step_table(self, dataset_number=None): dataset_number = self._validate_dataset_number(dataset_number) if dataset_number is None: self._report_empty_dataset() return st = self.datasets[dataset_number].step_table print(st)
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list return_statement expression_statement assignment identifier attribute subscript attribute identifier identifier identifier identifier expression_statement call identifier argument_list identifier
Print the step table.
def recommend_for_record(self, record_id, depth=4, num_reco=10): data = calc_scores_for_node(self._graph, record_id, depth, num_reco) return data.Node.tolist(), data.Score.tolist()
module function_definition identifier parameters identifier identifier default_parameter identifier integer default_parameter identifier integer block expression_statement assignment identifier call identifier argument_list attribute identifier identifier identifier identifier identifier return_statement expression_list call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list
Calculate recommendations for record.
def _create_user(ctx): username, passhash = _get_credentials(ctx.obj['username'], ctx.obj['password'], ctx.obj['db']) if ctx.obj['db'].objectmodels['user'].count({'name': username}) > 0: raise KeyError() new_user = ctx.obj['db'].objectmodels['user']({ 'uuid': str(uuid4()), 'created': std_now() }) new_user.name = username new_user.passhash = passhash return new_user
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end if_statement comparison_operator call attribute subscript attribute subscript attribute identifier identifier string string_start string_content string_end identifier string string_start string_content string_end identifier argument_list dictionary pair string string_start string_content string_end identifier integer block raise_statement call identifier argument_list expression_statement assignment identifier call subscript attribute subscript attribute identifier identifier string string_start string_content string_end identifier string string_start string_content string_end argument_list dictionary pair string string_start string_content string_end call identifier argument_list call identifier argument_list pair string string_start string_content string_end call identifier argument_list expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier return_statement identifier
Internal method to create a normal user
def _q(self, number, precision='.00001'): if np.isinf(number): return np.nan else: return D(D(number).quantize(D(precision)))
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end block if_statement call attribute identifier identifier argument_list identifier block return_statement attribute identifier identifier else_clause block return_statement call identifier argument_list call attribute call identifier argument_list identifier identifier argument_list call identifier argument_list identifier
quantiztion of BSSEval values
def default_freq(**indexer): freq = 'AS-JAN' if indexer: if 'DJF' in indexer.values(): freq = 'AS-DEC' if 'month' in indexer and sorted(indexer.values()) != indexer.values(): raise (NotImplementedError) return freq
module function_definition identifier parameters dictionary_splat_pattern identifier block expression_statement assignment identifier string string_start string_content string_end if_statement identifier block if_statement comparison_operator string string_start string_content string_end call attribute identifier identifier argument_list block expression_statement assignment identifier string string_start string_content string_end if_statement boolean_operator comparison_operator string string_start string_content string_end identifier comparison_operator call identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list block raise_statement parenthesized_expression identifier return_statement identifier
Return the default frequency.
def build_from_bases(bases, classdict, attr, attr_dict): output = OrderedDict() output_keys = set() all_bases = [] for base in reversed(bases): if base is not object and isinstance(base, PropertyMetaclass): output_keys = output_keys.union(getattr(base, attr)) for item in reversed(base.__mro__): if item is object or not isinstance(item, PropertyMetaclass): continue if item not in all_bases: all_bases.append(item) for base in all_bases: for key, val in iteritems(getattr(base, attr)): if key in base.__dict__ and key in output_keys: output.update({key: val}) for key in classdict: if key in output: output.pop(key) output.update(attr_dict) return output
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier list for_statement identifier call identifier argument_list identifier block if_statement boolean_operator comparison_operator identifier identifier call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list identifier identifier for_statement identifier call identifier argument_list attribute identifier identifier block if_statement boolean_operator comparison_operator identifier identifier not_operator call identifier argument_list identifier identifier block continue_statement if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier for_statement identifier identifier block for_statement pattern_list identifier identifier call identifier argument_list call identifier argument_list identifier identifier block if_statement boolean_operator comparison_operator identifier attribute identifier identifier comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list dictionary pair identifier identifier for_statement identifier identifier block if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Helper function to build private HasProperties attributes
def _remove_network(network): ret = {'name': network['Name'], 'changes': {}, 'result': False, 'comment': ''} errors = [] for cid in network['Containers']: try: cinfo = __salt__['docker.inspect_container'](cid) except CommandExecutionError: cname = cid else: cname = cinfo.get('Name', '').lstrip('/') try: __salt__['docker.disconnect_container_from_network'](cid, network['Name']) except CommandExecutionError as exc: errors = \ 'Failed to disconnect container \'{0}\' : {1}'.format( cname, exc ) else: ret['changes'].setdefault('disconnected', []).append(cname) if errors: ret['comment'] = '\n'.join(errors) return ret try: __salt__['docker.remove_network'](network['Name']) except CommandExecutionError as exc: ret['comment'] = 'Failed to remove network: {0}'.format(exc) else: ret['changes']['removed'] = True ret['result'] = True ret['comment'] = 'Removed network \'{0}\''.format(network['Name']) return ret
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end subscript identifier string string_start string_content string_end pair string string_start string_content string_end dictionary pair string string_start string_content string_end false pair string string_start string_content string_end string string_start string_end expression_statement assignment identifier list for_statement identifier subscript identifier string string_start string_content string_end block try_statement block expression_statement assignment identifier call subscript identifier string string_start string_content string_end argument_list identifier except_clause identifier block expression_statement assignment identifier identifier else_clause block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end identifier argument_list string string_start string_content string_end try_statement block expression_statement call subscript identifier string string_start string_content string_end argument_list identifier subscript identifier string string_start string_content string_end except_clause as_pattern identifier as_pattern_target identifier block expression_statement assignment identifier call attribute string string_start string_content escape_sequence escape_sequence string_end identifier argument_list identifier identifier else_clause block expression_statement call attribute call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end list identifier argument_list identifier if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier return_statement identifier try_statement block expression_statement call subscript identifier string string_start string_content string_end argument_list subscript identifier string string_start string_content string_end except_clause as_pattern identifier as_pattern_target identifier block expression_statement assignment subscript identifier string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list identifier else_clause block expression_statement assignment subscript subscript identifier string string_start string_content string_end string string_start string_content string_end true expression_statement assignment subscript identifier string string_start string_content string_end true expression_statement assignment subscript identifier string string_start string_content string_end call attribute string string_start string_content escape_sequence escape_sequence string_end identifier argument_list subscript identifier string string_start string_content string_end return_statement identifier
Remove network, including all connected containers
def run(self): self.print_message("\nBeginning database replacement process.\n") if self.args.source_settings: settings = self.parse_db_settings(self.args.source_settings) self.initialize_db_args(settings, 'source') if self.args.settings: settings = self.parse_db_settings(self.args.settings) self.initialize_db_args(settings, 'destination') if self.args.capture: self.capture_heroku_database() file_url = self.args.url if self.args.source_app: self.print_message("Sourcing data from backup for Heroku app '%s'" % self.args.source_app) file_url = self.get_file_url_for_heroku_app(self.args.source_app) if self.args.destination_app: self.replace_heroku_db(file_url) elif self.databases['destination']['name']: self.replace_postgres_db(file_url) self.print_message("\nDone.\n\nDon't forget to update the Django Site entry if necessary!")
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence escape_sequence string_end if_statement attribute attribute identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier string string_start string_content string_end if_statement attribute attribute identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier string string_start string_content string_end if_statement attribute attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier attribute attribute identifier identifier identifier if_statement attribute attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier if_statement attribute attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier elif_clause subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence escape_sequence escape_sequence string_end
Replace a database with the data from the specified source.
def ProcessRequest(self, method_config, request): if self.log_request: logging.info( 'Calling method %s with %s: %s', method_config.method_id, method_config.request_type_name, request) return request
module function_definition identifier parameters identifier identifier identifier block if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier attribute identifier identifier identifier return_statement identifier
Hook for pre-processing of requests.
def delete(self): super().delete() self.character.place.send(self.character.place, key=self.name, val=None)
module function_definition identifier parameters identifier block expression_statement call attribute call identifier argument_list identifier argument_list expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list attribute attribute identifier identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier none
Remove myself from the world model immediately.
def loads(string): d = _loads(string) for k, v in d.items(): FILTERS[dr.get_component(k) or k] = set(v)
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment subscript identifier boolean_operator call attribute identifier identifier argument_list identifier identifier call identifier argument_list identifier
Loads the filters dictionary given a string.
def _setbin_safe(self, binstring): binstring = tidy_input_string(binstring) binstring = binstring.replace('0b', '') self._setbin_unsafe(binstring)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end expression_statement call attribute identifier identifier argument_list identifier
Reset the bitstring to the value given in binstring.
def traverse_until_fixpoint(predicate, tree): old_tree = None tree = simplify(tree) while tree and old_tree != tree: old_tree = tree tree = tree.traverse(predicate) if not tree: return None tree = simplify(tree) return tree
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier none expression_statement assignment identifier call identifier argument_list identifier while_statement boolean_operator identifier comparison_operator identifier identifier block expression_statement assignment identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator identifier block return_statement none expression_statement assignment identifier call identifier argument_list identifier return_statement identifier
Traverses the tree again and again until it is not modified.
def same_content(ref_source, test_source, allow_removed_final_blank_line): if ref_source == test_source: return True if not allow_removed_final_blank_line: return False ref_source = ref_source.splitlines() test_source = test_source.splitlines() if not ref_source: return False if ref_source[:-1] != test_source: return False return _BLANK_LINE.match(ref_source[-1])
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator identifier identifier block return_statement true if_statement not_operator identifier block return_statement false expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list if_statement not_operator identifier block return_statement false if_statement comparison_operator subscript identifier slice unary_operator integer identifier block return_statement false return_statement call attribute identifier identifier argument_list subscript identifier unary_operator integer
Is the content of two cells the same, except for an optional final blank line?
def search_meta_tag(html_doc, prefix, code): regex = '<meta\s+(?:name=([\'\"]){0}\\1\s+content=([\'\"]){1}\\2|content=([\'\"]){1}\\3\s+name=([\'\"]){0}\\4)\s*/?>'.format(prefix, code) meta = re.compile(regex, flags=re.MULTILINE | re.IGNORECASE) m = meta.search(html_doc) if m: head = re.search(r'</head>', html_doc, flags=re.IGNORECASE) if head and m.start() < head.start(): return True return False
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute string string_start string_content escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence string_end identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier binary_operator attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier keyword_argument identifier attribute identifier identifier if_statement boolean_operator identifier comparison_operator call attribute identifier identifier argument_list call attribute identifier identifier argument_list block return_statement true return_statement false
Checks whether the html_doc contains a meta matching the prefix & code
def comments(case_id): text = request.form['text'] variant_id = request.form.get('variant_id') username = request.form.get('username') case_obj = app.db.case(case_id) app.db.add_comment(case_obj, text, variant_id=variant_id, username=username) return redirect(request.referrer)
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier return_statement call identifier argument_list attribute identifier identifier
Upload a new comment.
def open(cls, **kwargs): handle_iter = cls.iter_open(**kwargs) try: handle = six.next(handle_iter) except StopIteration: raise usb_exceptions.DeviceNotFoundError( 'Open failed with args: %s', kwargs) try: multiple_handle = six.next(handle_iter) except StopIteration: return handle handle.close() multiple_handle.close() raise usb_exceptions.MultipleInterfacesFoundError(kwargs)
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list dictionary_splat identifier try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause identifier block raise_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause identifier block return_statement identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list raise_statement call attribute identifier identifier argument_list identifier
See iter_open, but raises if multiple or no matches found.
def send(self, message): if not message or not self.protocol or not self.protocol.transport: return if not self.can_log: _LOGGER.debug('Sending %s', message.strip()) try: self.protocol.transport.write(message.encode()) except OSError as exc: _LOGGER.error( 'Failed writing to transport %s: %s', self.protocol.transport, exc) self.protocol.transport.close() self.protocol.conn_lost_callback()
module function_definition identifier parameters identifier identifier block if_statement boolean_operator boolean_operator not_operator identifier not_operator attribute identifier identifier not_operator attribute attribute identifier identifier identifier block return_statement if_statement not_operator attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list try_statement block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list call attribute identifier identifier argument_list 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 attribute attribute identifier identifier identifier identifier expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list
Write a message to the gateway.
def _draw_error_underline(self, ptx, pango_layout, start, stop): self.context.save() self.context.set_source_rgb(1.0, 0.0, 0.0) pit = pango_layout.get_iter() for i in xrange(start): pit.next_char() extents_list = [] for char_no in xrange(start, stop): char_extents = pit.get_char_extents() underline_pixel_extents = [ char_extents[0] / pango.SCALE, (char_extents[1] + char_extents[3]) / pango.SCALE - 2, char_extents[2] / pango.SCALE, 4, ] if extents_list: if extents_list[-1][1] == underline_pixel_extents[1]: extents_list[-1][2] = extents_list[-1][2] + \ underline_pixel_extents[2] else: extents_list.append(underline_pixel_extents) else: extents_list.append(underline_pixel_extents) pit.next_char() for extent in extents_list: pangocairo.show_error_underline(ptx, *extent) self.context.restore()
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list float float float expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier list for_statement identifier call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier list binary_operator subscript identifier integer attribute identifier identifier binary_operator binary_operator parenthesized_expression binary_operator subscript identifier integer subscript identifier integer attribute identifier identifier integer binary_operator subscript identifier integer attribute identifier identifier integer if_statement identifier block if_statement comparison_operator subscript subscript identifier unary_operator integer integer subscript identifier integer block expression_statement assignment subscript subscript identifier unary_operator integer integer binary_operator subscript subscript identifier unary_operator integer integer line_continuation subscript identifier integer else_clause block expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier list_splat identifier expression_statement call attribute attribute identifier identifier identifier argument_list
Draws an error underline
def getstr_data(self, name, vals): fld2val = self.get_fld2val(name, vals) return self.fmt.format(**fld2val)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier return_statement call attribute attribute identifier identifier identifier argument_list dictionary_splat identifier
Return stats data string in markdown style.
def _get_argument(self, argument_node): argument = FritzActionArgument() argument.name = argument_node.find(self.nodename('name')).text argument.direction = argument_node.find(self.nodename('direction')).text rsv = argument_node.find(self.nodename('relatedStateVariable')).text argument.data_type = self.state_variables.get(rsv, None) return argument
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment attribute identifier identifier attribute call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment attribute identifier identifier attribute call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier attribute call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list identifier none return_statement identifier
Returns a FritzActionArgument instance for the given argument_node.
def kwargs_as_assignments(call_node, parent): if not isinstance(call_node, ast.Call): raise TypeError('node must be an ast.Call') if len(call_node.args) > 0: raise ValueError('positional args not allowed') for keyword in call_node.keywords: dst_name = keyword.arg if dst_name.startswith('gl_'): target = [ast.Name(id=keyword.arg, ctx=ast.Load())] else: target = [ast.Attribute(value=parent, attr=keyword.arg, ctx=ast.Store())] yield NoDeclAssign(targets=target, value=keyword.value)
module function_definition identifier parameters identifier identifier block if_statement not_operator call identifier argument_list identifier attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator call identifier argument_list attribute identifier identifier integer block raise_statement call identifier argument_list string string_start string_content string_end for_statement identifier attribute identifier identifier block expression_statement assignment identifier attribute identifier identifier if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier list call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier call attribute identifier identifier argument_list else_clause block expression_statement assignment identifier list call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier call attribute identifier identifier argument_list expression_statement yield call identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier
Yield NoDeclAssign nodes from kwargs in a Call node.
def getResetsIndices(networkDataFile): try: with open(networkDataFile) as f: reader = csv.reader(f) next(reader, None) next(reader, None) resetIdx = next(reader).index("R") resets = [] for i, line in enumerate(reader): if int(line[resetIdx]) == 1: resets.append(i) return resets except IOError as e: print "Could not open the file {}.".format(networkDataFile) raise e
module function_definition identifier parameters identifier block try_statement block with_statement with_clause with_item as_pattern call identifier argument_list identifier as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list identifier none expression_statement call identifier argument_list identifier none expression_statement assignment identifier call attribute call identifier argument_list identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier list for_statement pattern_list identifier identifier call identifier argument_list identifier block if_statement comparison_operator call identifier argument_list subscript identifier identifier integer block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier except_clause as_pattern identifier as_pattern_target identifier block print_statement call attribute string string_start string_content string_end identifier argument_list identifier raise_statement identifier
Returns the indices at which the data sequences reset.
def push(self, metric_name=None, metric_value=None, volume=None): graphite_path = self.path_prefix graphite_path += '.' + self.device + '.' + 'volume' graphite_path += '.' + volume + '.' + metric_name metric = Metric(graphite_path, metric_value, precision=4, host=self.device) self.publish_metric(metric)
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier attribute identifier identifier expression_statement augmented_assignment identifier binary_operator binary_operator binary_operator string string_start string_content string_end attribute identifier identifier string string_start string_content string_end string string_start string_content string_end expression_statement augmented_assignment identifier binary_operator binary_operator binary_operator string string_start string_content string_end identifier string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list identifier identifier keyword_argument identifier integer keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier
Ship that shit off to graphite broski
def bySignificator(self, ID): res = [] for direction in self.table: if ID in direction[2]: res.append(direction) return res
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list for_statement identifier attribute identifier identifier block if_statement comparison_operator identifier subscript identifier integer block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Returns all directions to a significator.