code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def GetReportData(self, get_report_args, token=None): ret = rdf_report_plugins.ApiReportData( representation_type=RepresentationType.AUDIT_CHART, audit_chart=rdf_report_plugins.ApiAuditChartReportData( used_fields=self.USED_FIELDS)) ret.audit_chart.rows = _LoadAuditEvents( self.HANDLERS, get_report_args, transformers=[_ExtractClientIdFromPath], token=token) return ret
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier expression_statement assignment attribute attribute identifier identifier identifier call identifier argument_list attribute identifier identifier identifier keyword_argument identifier list identifier keyword_argument identifier identifier return_statement identifier
Filter the cron job approvals in the given timerange.
def _convert_partition(partition): csvfile = six.StringIO() writer = unicodecsv.writer(csvfile) headers = partition.datafile.headers if headers: writer.writerow(headers) for row in partition: writer.writerow([row[h] for h in headers]) csvfile.seek(0) ret = { 'package_id': partition.dataset.vid.lower(), 'url': 'http://example.com', 'revision_id': '', 'description': partition.description or '', 'format': 'text/csv', 'hash': '', 'name': partition.name, 'resource_type': '', 'mimetype': 'text/csv', 'mimetype_inner': '', 'webstore_url': '', 'cache_url': '', 'upload': csvfile } return ret
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier attribute attribute identifier identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list list_comprehension subscript identifier identifier for_in_clause identifier identifier expression_statement call attribute identifier identifier argument_list integer expression_statement assignment identifier dictionary pair string string_start string_content string_end call attribute attribute attribute identifier identifier identifier identifier argument_list pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_end pair string string_start string_content string_end boolean_operator attribute identifier identifier string string_start string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_end pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end string string_start string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_end pair string string_start string_content string_end string string_start string_end pair string string_start string_content string_end string string_start string_end pair string string_start string_content string_end identifier return_statement identifier
Converts partition to resource dict ready to save to CKAN.
def gen_bisz(src, dst): return ReilBuilder.build(ReilMnemonic.BISZ, src, ReilEmptyOperand(), dst)
module function_definition identifier parameters identifier identifier block return_statement call attribute identifier identifier argument_list attribute identifier identifier identifier call identifier argument_list identifier
Return a BISZ instruction.
def getBinaryData(self, name, channel=None): return self._getNodeData(name, self._BINARYNODE, channel)
module function_definition identifier parameters identifier identifier default_parameter identifier none block return_statement call attribute identifier identifier argument_list identifier attribute identifier identifier identifier
Returns a binary node
def gpg_version(): cmd = flatten([gnupg_bin(), "--version"]) output = stderr_output(cmd) output = output \ .split('\n')[0] \ .split(" ")[2] \ .split('.') return tuple([int(x) for x in output])
module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list list call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute subscript call attribute subscript call attribute identifier line_continuation identifier argument_list string string_start string_content escape_sequence string_end integer line_continuation identifier argument_list string string_start string_content string_end integer line_continuation identifier argument_list string string_start string_content string_end return_statement call identifier argument_list list_comprehension call identifier argument_list identifier for_in_clause identifier identifier
Returns the GPG version
def create(cls, mp, part_number, stream=None, **kwargs): if part_number < 0 or part_number > mp.last_part_number: raise MultipartInvalidPartNumber() with db.session.begin_nested(): obj = cls( multipart=mp, part_number=part_number, ) db.session.add(obj) if stream: obj.set_contents(stream, **kwargs) return obj
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none dictionary_splat_pattern identifier block if_statement boolean_operator comparison_operator identifier integer comparison_operator identifier attribute identifier identifier block raise_statement call identifier argument_list with_statement with_clause with_item call attribute attribute identifier identifier identifier argument_list block expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier dictionary_splat identifier return_statement identifier
Create a new part object in a multipart object.
def read(self, num_bytes): self.check_pyb() try: return self.pyb.serial.read(num_bytes) except (serial.serialutil.SerialException, TypeError): self.close() raise DeviceError('serial port %s closed' % self.dev_name_short)
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list try_statement block return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier except_clause tuple attribute attribute identifier identifier identifier identifier block expression_statement call attribute identifier identifier argument_list raise_statement call identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier
Reads data from the pyboard over the serial port.
def _is_inline_definition(arg): return isinstance(arg, dict) and len(arg) == 1 and isinstance(next(six.itervalues(arg)), list)
module function_definition identifier parameters identifier block return_statement boolean_operator boolean_operator call identifier argument_list identifier identifier comparison_operator call identifier argument_list identifier integer call identifier argument_list call identifier argument_list call attribute identifier identifier argument_list identifier identifier
Returns True, if arg is an inline definition of a statement.
def client_ident(self): return irc.client.NickMask.from_params( self.nick, self.user, self.server.servername)
module function_definition identifier parameters identifier block return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier attribute attribute identifier identifier identifier
Return the client identifier as included in many command replies.
def handle_netusb(self, message): needs_update = 0 if self._yamaha: if 'play_info_updated' in message: play_info = self.get_play_info() if play_info: new_media_status = MediaStatus(play_info, self._ip_address) if self._yamaha.media_status != new_media_status: self._yamaha.new_media_status(new_media_status) needs_update += 1 playback = play_info.get('playback') if playback == "play": new_status = STATE_PLAYING elif playback == "stop": new_status = STATE_IDLE elif playback == "pause": new_status = STATE_PAUSED else: new_status = STATE_UNKNOWN if self._yamaha.status is not new_status: _LOGGER.debug("playback: %s", new_status) self._yamaha.status = new_status needs_update += 1 return needs_update
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier integer if_statement attribute identifier identifier block if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement identifier block expression_statement assignment identifier call identifier argument_list identifier attribute identifier identifier if_statement comparison_operator attribute attribute identifier identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement augmented_assignment identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier identifier elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier identifier elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier identifier else_clause block expression_statement assignment identifier identifier if_statement comparison_operator attribute attribute identifier identifier identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment attribute attribute identifier identifier identifier identifier expression_statement augmented_assignment identifier integer return_statement identifier
Handles 'netusb' in message
def render(self, data, accepted_media_type=None, renderer_context=None): if data is None: return bytes() renderer_context = renderer_context or {} indent = self.get_indent(accepted_media_type, renderer_context) if indent is None: separators = SHORT_SEPARATORS if self.compact else LONG_SEPARATORS else: separators = INDENT_SEPARATORS ret = json.dumps( data, cls=self.encoder_class, indent=indent, ensure_ascii=self.ensure_ascii, separators=separators ) if isinstance(ret, six.text_type): ret = ret.replace('\u2028', '\\u2028').replace('\u2029', '\\u2029') return bytes(ret.encode('utf-8')) return ret
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none block if_statement comparison_operator identifier none block return_statement call identifier argument_list expression_statement assignment identifier boolean_operator identifier dictionary expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier conditional_expression identifier attribute identifier identifier identifier else_clause block expression_statement assignment identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier if_statement call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end string string_start string_content escape_sequence string_end identifier argument_list string string_start string_content escape_sequence string_end string string_start string_content escape_sequence string_end return_statement call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier
Render `data` into JSON, returning a bytestring.
def remove_user(self, name): user = self.get_user(name) users = self.get_users() users.remove(user)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier
Remove a user from kubeconfig.
def copy(self): result = copy.deepcopy(self) result._cache.clear() return result
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list return_statement identifier
Return a copy of the Primitive object.
def _getPageInfo(self, pno, what): if self.isClosed or self.isEncrypted: raise ValueError("operation illegal for closed / encrypted doc") val = _fitz.Document__getPageInfo(self, pno, what) x = [] for v in val: if v not in x: x.append(v) val = x return val
module function_definition identifier parameters identifier identifier identifier block if_statement boolean_operator attribute identifier identifier attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier expression_statement assignment identifier list for_statement identifier identifier block if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier identifier return_statement identifier
Show fonts or images used on a page.
def convert_to_dict(self): out_dict = {} out_dict["groupName"] = self.group_name out_dict["atomNameList"] = self.atom_name_list out_dict["elementList"] = self.element_list out_dict["bondOrderList"] = self.bond_order_list out_dict["bondAtomList"] = self.bond_atom_list out_dict["formalChargeList"] = self.charge_list out_dict["singleLetterCode"] = self.single_letter_code out_dict["chemCompType"] = self.group_type return out_dict
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier return_statement identifier
Convert the group object to an appropriate DICT
def _lbdvrpmllpmbb(self,*args,**kwargs): obs, ro, vo= self._parse_radec_kwargs(kwargs,dontpop=True) X,Y,Z,vX,vY,vZ= self._XYZvxvyvz(*args,**kwargs) bad_indx= (X == 0.)*(Y == 0.)*(Z == 0.) if True in bad_indx: X[bad_indx]+= ro/10000. return coords.rectgal_to_sphergal(X,Y,Z,vX,vY,vZ,degree=True)
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment pattern_list identifier identifier identifier call attribute identifier identifier argument_list identifier keyword_argument identifier true expression_statement assignment pattern_list identifier identifier identifier identifier identifier identifier call attribute identifier identifier argument_list list_splat identifier dictionary_splat identifier expression_statement assignment identifier binary_operator binary_operator parenthesized_expression comparison_operator identifier float parenthesized_expression comparison_operator identifier float parenthesized_expression comparison_operator identifier float if_statement comparison_operator true identifier block expression_statement augmented_assignment subscript identifier identifier binary_operator identifier float return_statement call attribute identifier identifier argument_list identifier identifier identifier identifier identifier identifier keyword_argument identifier true
Calculate l,b,d,vr,pmll,pmbb
def encode(self): reading = self.visible_readings[0] data = struct.pack("<BBHLLLL", 0, 0, reading.stream, self.origin, self.sent_timestamp, reading.raw_time, reading.value) return bytearray(data)
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript attribute identifier identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end integer integer attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier return_statement call identifier argument_list identifier
Turn this report into a serialized bytearray that could be decoded with a call to decode
def to_commit(obj): if obj.type == 'tag': obj = deref_tag(obj) if obj.type != "commit": raise ValueError("Cannot convert object %r to type commit" % obj) return obj
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier return_statement identifier
Convert the given object to a commit if possible and return it
def getset(self, key, value, *, encoding=_NOTSET): return self.execute(b'GETSET', key, value, encoding=encoding)
module function_definition identifier parameters identifier identifier identifier keyword_separator default_parameter identifier identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier keyword_argument identifier identifier
Set the string value of a key and return its old value.
def _post_filter(search, urlkwargs, definitions): filters, urlkwargs = _create_filter_dsl(urlkwargs, definitions) for filter_ in filters: search = search.post_filter(filter_) return (search, urlkwargs)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier identifier for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement tuple identifier identifier
Ingest post filter in query.
def translate(self, instruction): try: trans_instrs = self._translate(instruction) except Exception: self._log_translation_exception(instruction) raise TranslationError("Unknown error") return trans_instrs
module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list identifier raise_statement call identifier argument_list string string_start string_content string_end return_statement identifier
Return REIL representation of an instruction.
def save_existing_iam_env_vars(self): for i in ['AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY', 'AWS_SESSION_TOKEN']: if i in self.env_vars: self.env_vars['OLD_' + i] = self.env_vars[i]
module function_definition identifier parameters identifier block for_statement identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier binary_operator string string_start string_content string_end identifier subscript attribute identifier identifier identifier
Backup IAM environment variables for later restoration.
def _check_error(response): if (not response.ok) or (response.status_code != 200): raise Exception( response.json()['error'] + ': ' + response.json()['error_description'] )
module function_definition identifier parameters identifier block if_statement boolean_operator parenthesized_expression not_operator attribute identifier identifier parenthesized_expression comparison_operator attribute identifier identifier integer block raise_statement call identifier argument_list binary_operator binary_operator subscript call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end subscript call attribute identifier identifier argument_list string string_start string_content string_end
Raises an exception if the Spark Cloud returned an error.
def popitem(self): try: item = dict.popitem(self) return (item[0], item[1][0]) except KeyError, e: raise BadRequestKeyError(str(e))
module function_definition identifier parameters identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement tuple subscript identifier integer subscript subscript identifier integer integer except_clause identifier identifier block raise_statement call identifier argument_list call identifier argument_list identifier
Pop an item from the dict.
def _bisect_interval(a, b, fa, fb): if fa*fb > 0: raise ValueError("f(a) and f(b) must have different signs") root = 0.0 status = _ECONVERR if fa == 0: root = a status = _ECONVERGED if fb == 0: root = b status = _ECONVERGED return root, status
module function_definition identifier parameters identifier identifier identifier identifier block if_statement comparison_operator binary_operator identifier identifier integer block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier float expression_statement assignment identifier identifier if_statement comparison_operator identifier integer block expression_statement assignment identifier identifier expression_statement assignment identifier identifier if_statement comparison_operator identifier integer block expression_statement assignment identifier identifier expression_statement assignment identifier identifier return_statement expression_list identifier identifier
Conditional checks for intervals in methods involving bisection
def show(ctx, component): col = ctx.obj['col'] if col.count({'name': component}) > 1: log('More than one component configuration of this name! Try ' 'one of the uuids as argument. Get a list with "config ' 'list"') return if component is None: configurations = col.find() for configuration in configurations: log("%-15s : %s" % (configuration.name, configuration.uuid), emitter='MANAGE') else: configuration = col.find_one({'name': component}) if configuration is None: configuration = col.find_one({'uuid': component}) if configuration is None: log('No component with that name or uuid found.') return print(json.dumps(configuration.serializablefields(), indent=4))
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end if_statement comparison_operator call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end identifier integer block expression_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end return_statement if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier identifier block expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple attribute identifier identifier attribute identifier identifier keyword_argument identifier string string_start string_content string_end else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end identifier if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end identifier if_statement comparison_operator identifier none block expression_statement call identifier argument_list string string_start string_content string_end return_statement expression_statement call identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier integer
Show the stored, active configuration of a component.
def fit(self, X, y=None, **kwargs): self.estimator.fit(X, y, **kwargs) self.n_samples_ = X.shape[0] self.n_clusters_ = self.estimator.n_clusters labels = self.estimator.predict(X) self.silhouette_score_ = silhouette_score(X, labels) self.silhouette_samples_ = silhouette_samples(X, labels) self.draw(labels) return self
module function_definition identifier parameters identifier identifier default_parameter identifier none dictionary_splat_pattern identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier dictionary_splat identifier expression_statement assignment attribute identifier identifier subscript attribute identifier identifier integer expression_statement assignment attribute identifier identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier call identifier argument_list identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Fits the model and generates the silhouette visualization.
def generate_input_template(tool): template = yaml.comments.CommentedMap() for inp in realize_input_schema(tool.tool["inputs"], tool.schemaDefs): name = shortname(inp["id"]) value, comment = generate_example_input( inp['type'], inp.get('default', None)) template.insert(0, name, value, comment) return template
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list for_statement identifier call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier block expression_statement assignment identifier call identifier argument_list subscript identifier string string_start string_content string_end expression_statement assignment pattern_list identifier identifier call identifier argument_list subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end none expression_statement call attribute identifier identifier argument_list integer identifier identifier identifier return_statement identifier
Generate an example input object for the given CWL process.
def host_in_set (ip, hosts, nets): if ip in hosts: return True if is_valid_ipv4(ip): n = dq2num(ip) for net in nets: if dq_in_net(n, net): return True return False
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator identifier identifier block return_statement true if_statement call identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list identifier for_statement identifier identifier block if_statement call identifier argument_list identifier identifier block return_statement true return_statement false
Return True if given ip is in host or network list.
def mkconstraints(): constraints = [] for j in range(1, 10): vars = ["%s%d" % (i, j) for i in uppercase[:9]] constraints.extend((c, const_different) for c in combinations(vars, 2)) for i in uppercase[:9]: vars = ["%s%d" % (i, j) for j in range(1, 10)] constraints.extend((c, const_different) for c in combinations(vars, 2)) for b0 in ['ABC', 'DEF', 'GHI']: for b1 in [[1, 2, 3], [4, 5, 6], [7, 8, 9]]: vars = ["%s%d" % (i, j) for i in b0 for j in b1] l = list((c, const_different) for c in combinations(vars, 2)) constraints.extend(l) return constraints
module function_definition identifier parameters block expression_statement assignment identifier list for_statement identifier call identifier argument_list integer integer block expression_statement assignment identifier list_comprehension binary_operator string string_start string_content string_end tuple identifier identifier for_in_clause identifier subscript identifier slice integer expression_statement call attribute identifier identifier generator_expression tuple identifier identifier for_in_clause identifier call identifier argument_list identifier integer for_statement identifier subscript identifier slice integer block expression_statement assignment identifier list_comprehension binary_operator string string_start string_content string_end tuple identifier identifier for_in_clause identifier call identifier argument_list integer integer expression_statement call attribute identifier identifier generator_expression tuple identifier identifier for_in_clause identifier call identifier argument_list identifier integer for_statement identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block for_statement identifier list list integer integer integer list integer integer integer list integer integer integer block expression_statement assignment identifier list_comprehension binary_operator string string_start string_content string_end tuple identifier identifier for_in_clause identifier identifier for_in_clause identifier identifier expression_statement assignment identifier call identifier generator_expression tuple identifier identifier for_in_clause identifier call identifier argument_list identifier integer expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Make constraint list for binary constraint problem.
def run(self): hosts = self.inventory.list_hosts(self.pattern) if len(hosts) == 0: self.callbacks.on_no_hosts() return dict(contacted={}, dark={}) global multiprocessing_runner multiprocessing_runner = self results = None p = utils.plugins.action_loader.get(self.module_name, self) if p and getattr(p, 'BYPASS_HOST_LOOP', None): self.host_set = hosts result_data = self._executor(hosts[0]).result results = [ ReturnData(host=h, result=result_data, comm_ok=True) \ for h in hosts ] del self.host_set elif self.forks > 1: try: results = self._parallel_exec(hosts) except IOError, ie: print ie.errno if ie.errno == 32: raise errors.AnsibleError("interupted") raise else: results = [ self._executor(h) for h in hosts ] return self._partition_results(results)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier if_statement comparison_operator call identifier argument_list identifier integer block expression_statement call attribute attribute identifier identifier identifier argument_list return_statement call identifier argument_list keyword_argument identifier dictionary keyword_argument identifier dictionary global_statement identifier expression_statement assignment identifier identifier expression_statement assignment identifier none expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier identifier if_statement boolean_operator identifier call identifier argument_list identifier string string_start string_content string_end none block expression_statement assignment attribute identifier identifier identifier expression_statement assignment identifier attribute call attribute identifier identifier argument_list subscript identifier integer identifier expression_statement assignment identifier list_comprehension call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier true line_continuation for_in_clause identifier identifier delete_statement attribute identifier identifier elif_clause comparison_operator attribute identifier identifier integer block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause identifier identifier block print_statement attribute identifier identifier if_statement comparison_operator attribute identifier identifier integer block raise_statement call attribute identifier identifier argument_list string string_start string_content string_end raise_statement else_clause block expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier identifier return_statement call attribute identifier identifier argument_list identifier
xfer & run module on all matched hosts
def regex_lexer(regex_pat): if isinstance(regex_pat, str): regex_pat = re.compile(regex_pat) def f(inp_str, pos): m = regex_pat.match(inp_str, pos) return m.group() if m else None elif hasattr(regex_pat, 'match'): def f(inp_str, pos): m = regex_pat.match(inp_str, pos) return m.group() if m else None else: regex_pats = tuple(re.compile(e) for e in regex_pat) def f(inp_str, pos): for each_pat in regex_pats: m = each_pat.match(inp_str, pos) if m: return m.group() return f
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier return_statement conditional_expression call attribute identifier identifier argument_list identifier none elif_clause call identifier argument_list identifier string string_start string_content string_end block function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier return_statement conditional_expression call attribute identifier identifier argument_list identifier none else_clause block expression_statement assignment identifier call identifier generator_expression call attribute identifier identifier argument_list identifier for_in_clause identifier identifier function_definition identifier parameters identifier identifier block for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement identifier block return_statement call attribute identifier identifier argument_list return_statement identifier
generate token names' cache
def getCatalogPixels(self): filenames = self.config.getFilenames() nside_catalog = self.config.params['coords']['nside_catalog'] nside_pixel = self.config.params['coords']['nside_pixel'] superpix = ugali.utils.skymap.superpixel(self.pixels,nside_pixel,nside_catalog) superpix = np.unique(superpix) pixels = np.intersect1d(superpix, filenames['pix'].compressed()) return pixels
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier subscript subscript attribute attribute identifier identifier identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier subscript subscript attribute attribute identifier identifier identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list return_statement identifier
Return the catalog pixels spanned by this ROI.
def results_to_csv(query_name, **kwargs): query = get_result_set(query_name, **kwargs) result = query.result columns = list(result[0].keys()) data = [tuple(row.values()) for row in result] frame = tablib.Dataset() frame.headers = columns for row in data: frame.append(row) csvs = frame.export('csv') return csvs
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list identifier dictionary_splat identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list call attribute subscript identifier integer identifier argument_list expression_statement assignment identifier list_comprehension call identifier argument_list call attribute identifier identifier argument_list for_in_clause identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier
Generate CSV from result data
def _round_frac(x, precision): if not np.isfinite(x) or x == 0: return x else: frac, whole = np.modf(x) if whole == 0: digits = -int(np.floor(np.log10(abs(frac)))) - 1 + precision else: digits = precision return np.around(x, digits)
module function_definition identifier parameters identifier identifier block if_statement boolean_operator not_operator call attribute identifier identifier argument_list identifier comparison_operator identifier integer block return_statement identifier else_clause block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier integer block expression_statement assignment identifier binary_operator binary_operator unary_operator call identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list call identifier argument_list identifier integer identifier else_clause block expression_statement assignment identifier identifier return_statement call attribute identifier identifier argument_list identifier identifier
Round the fractional part of the given number
def _is_on_import_statement(self, offset): "Does this offset point to an import statement?" data = self.resource.read() bol = data.rfind("\n", 0, offset) + 1 eol = data.find("\n", 0, bol) if eol == -1: eol = len(data) line = data[bol:eol] line = line.strip() if line.startswith("import ") or line.startswith("from "): return True else: return False
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end integer identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end integer identifier if_statement comparison_operator identifier unary_operator integer block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier subscript identifier slice identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement boolean_operator call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end block return_statement true else_clause block return_statement false
Does this offset point to an import statement?
def _validate_granttype(self, path, obj, _): errs = [] if not obj.implicit and not obj.authorization_code: errs.append('Either implicit or authorization_code should be defined.') return path, obj.__class__.__name__, errs
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier list if_statement boolean_operator not_operator attribute identifier identifier not_operator attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement expression_list identifier attribute attribute identifier identifier identifier identifier
make sure either implicit or authorization_code is defined
def metrics(self, name): return [ MetricStub( ensure_unicode(stub.name), stub.type, stub.value, normalize_tags(stub.tags), ensure_unicode(stub.hostname), ) for stub in self._metrics.get(to_string(name), []) ]
module function_definition identifier parameters identifier identifier block return_statement list_comprehension call identifier argument_list call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier call identifier argument_list attribute identifier identifier call identifier argument_list attribute identifier identifier for_in_clause identifier call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier list
Return the metrics received under the given name
def copyChar(len, out, val): ret = libxml2mod.xmlCopyChar(len, out, val) return ret
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier return_statement identifier
append the char value in the array
def untranslated_policy(self, default): return self.generator.settings.get(self.info.get('policy', None), default)
module function_definition identifier parameters identifier identifier block return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end none identifier
Get the policy for untranslated content
def convert_bboxes_to_albumentations(bboxes, source_format, rows, cols, check_validity=False): return [convert_bbox_to_albumentations(bbox, source_format, rows, cols, check_validity) for bbox in bboxes]
module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier false block return_statement list_comprehension call identifier argument_list identifier identifier identifier identifier identifier for_in_clause identifier identifier
Convert a list bounding boxes from a format specified in `source_format` to the format used by albumentations
def run_checked (self): self.start_time = time.time() self.setName("Status") wait_seconds = 1 first_wait = True while not self.stopped(wait_seconds): self.log_status() if first_wait: wait_seconds = self.wait_seconds first_wait = False
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier integer expression_statement assignment identifier true while_statement not_operator call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list if_statement identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier false
Print periodic status messages.
def render_koji(self): phase = 'prebuild_plugins' plugin = 'koji' if not self.dj.dock_json_has_plugin_conf(phase, plugin): return if self.spec.yum_repourls.value: logger.info("removing koji from request " "because there is yum repo specified") self.dj.remove_plugin(phase, plugin) elif not (self.spec.koji_target.value and self.spec.kojiroot.value and self.spec.kojihub.value): logger.info("removing koji from request as not specified") self.dj.remove_plugin(phase, plugin) else: self.dj.dock_json_set_arg(phase, plugin, "target", self.spec.koji_target.value) self.dj.dock_json_set_arg(phase, plugin, "root", self.spec.kojiroot.value) self.dj.dock_json_set_arg(phase, plugin, "hub", self.spec.kojihub.value) if self.spec.proxy.value: self.dj.dock_json_set_arg(phase, plugin, "proxy", self.spec.proxy.value)
module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier identifier block return_statement if_statement attribute attribute attribute identifier identifier identifier 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 expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier elif_clause not_operator parenthesized_expression boolean_operator boolean_operator attribute attribute attribute identifier identifier identifier identifier attribute attribute attribute identifier identifier identifier identifier attribute attribute attribute identifier identifier identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier string string_start string_content string_end attribute attribute attribute identifier identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier string string_start string_content string_end attribute attribute attribute identifier identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier string string_start string_content string_end attribute attribute attribute identifier identifier identifier identifier if_statement attribute attribute attribute identifier identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier string string_start string_content string_end attribute attribute attribute identifier identifier identifier identifier
if there is yum repo specified, don't pick stuff from koji
def perform(self): if self._file_size < self._SINGLE_UPLOAD_MAX: resource = "{0}{1}".format(self._DEFAULT_RESOURCE, self.bucket) response = self.__upload(resource, open(self._file_path, 'rb').read()) return response.headers['location'] else: response = self.__init_chunked_upload() min_chunk_size = int(response.headers['x-ton-min-chunk-size']) chunk_size = min_chunk_size * self._DEFAULT_CHUNK_SIZE location = response.headers['location'] f = open(self._file_path, 'rb') bytes_read = 0 while True: bytes = f.read(chunk_size) if not bytes: break bytes_start = bytes_read bytes_read += len(bytes) response = self.__upload_chunk(location, chunk_size, bytes, bytes_start, bytes_read) response_time = int(response.headers['x-response-time']) chunk_size = min_chunk_size * size(self._DEFAULT_CHUNK_SIZE, self._RESPONSE_TIME_MAX, response_time) f.close() return location.split("?")[0]
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier call attribute call identifier argument_list attribute identifier identifier string string_start string_content string_end identifier argument_list return_statement subscript attribute identifier identifier string string_start string_content string_end else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier binary_operator identifier attribute identifier identifier expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier integer while_statement true block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator identifier block break_statement expression_statement assignment identifier identifier expression_statement augmented_assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier identifier identifier expression_statement assignment identifier call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier binary_operator identifier call identifier argument_list attribute identifier identifier attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list return_statement subscript call attribute identifier identifier argument_list string string_start string_content string_end integer
Executes the current TONUpload object.
async def _end_clean(self): await self._timeout_watcher.clean() async def close_and_delete(container_id): try: await self._docker.remove_container(container_id) except: pass for container_id in self._containers_running: await close_and_delete(container_id) for container_id in self._student_containers_running: await close_and_delete(container_id)
module function_definition identifier parameters identifier block expression_statement await call attribute attribute identifier identifier identifier argument_list function_definition identifier parameters identifier block try_statement block expression_statement await call attribute attribute identifier identifier identifier argument_list identifier except_clause block pass_statement for_statement identifier attribute identifier identifier block expression_statement await call identifier argument_list identifier for_statement identifier attribute identifier identifier block expression_statement await call identifier argument_list identifier
Must be called when the agent is closing
async def __handle_ping(self, _ : Ping): self.__last_ping = time.time() await ZMQUtils.send(self.__backend_socket, Pong())
module function_definition identifier parameters identifier typed_parameter identifier type identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement await call attribute identifier identifier argument_list attribute identifier identifier call identifier argument_list
Handle a Ping message. Pong the backend
def default(self, value): self._default = value self._thumb = self._link_to_img()
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list
Set the default parameter and regenerate the thumbnail link.
def get(self, uri): if uri.startswith('cid:'): head, part = self.id_dict[uri[4:]] return StringIO.StringIO(part.getvalue()) if self.loc_dict.has_key(uri): head, part = self.loc_dict[uri] return StringIO.StringIO(part.getvalue()) return None
module function_definition identifier parameters identifier identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment pattern_list identifier identifier subscript attribute identifier identifier subscript identifier slice integer return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment pattern_list identifier identifier subscript attribute identifier identifier identifier return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list return_statement none
Get the content for the bodypart identified by the uri.
def _hour_angle_to_hours(times, hourangle, longitude, equation_of_time): naive_times = times.tz_localize(None) tzs = 1 / NS_PER_HR * ( naive_times.astype(np.int64) - times.astype(np.int64)) hours = (hourangle - longitude - equation_of_time / 4.) / 15. + 12. + tzs return np.asarray(hours)
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list none expression_statement assignment identifier binary_operator binary_operator integer identifier parenthesized_expression binary_operator call attribute identifier identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier binary_operator binary_operator binary_operator parenthesized_expression binary_operator binary_operator identifier identifier binary_operator identifier float float float identifier return_statement call attribute identifier identifier argument_list identifier
converts hour angles in degrees to hours as a numpy array
def plot_data(self): self.plt.plot(*self.fit.data, **self.options['data'])
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list list_splat attribute attribute identifier identifier identifier dictionary_splat subscript attribute identifier identifier string string_start string_content string_end
Add the data points to the plot.
def _GetChunk(self): found_ref = None for ref in self._blob_refs: if self._offset >= ref.offset and self._offset < (ref.offset + ref.size): found_ref = ref break if not found_ref: return None, None if self._current_ref != found_ref: self._current_ref = found_ref data = data_store.BLOBS.ReadBlobs([found_ref.blob_id]) self._current_chunk = data[found_ref.blob_id] return self._current_chunk, self._current_ref
module function_definition identifier parameters identifier block expression_statement assignment identifier none for_statement identifier attribute identifier identifier block if_statement boolean_operator comparison_operator attribute identifier identifier attribute identifier identifier comparison_operator attribute identifier identifier parenthesized_expression binary_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier identifier break_statement if_statement not_operator identifier block return_statement expression_list none none if_statement comparison_operator attribute identifier identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list list attribute identifier identifier expression_statement assignment attribute identifier identifier subscript identifier attribute identifier identifier return_statement expression_list attribute identifier identifier attribute identifier identifier
Fetches a chunk corresponding to the current offset.
def hasInfo(self): count = len([None for (fromUUID, size) in Diff.theKnownSizes[self.uuid].iteritems() if size is not None and fromUUID is not None ]) return count > 0
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list list_comprehension none for_in_clause tuple_pattern identifier identifier call attribute subscript attribute identifier identifier attribute identifier identifier identifier argument_list if_clause boolean_operator comparison_operator identifier none comparison_operator identifier none return_statement comparison_operator identifier integer
Will have information to write.
def _parse_tol(rtol,atol): if rtol is None: rtol= -12.*nu.log(10.) else: rtol= nu.log(rtol) if atol is None: atol= -12.*nu.log(10.) else: atol= nu.log(atol) return (rtol,atol)
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier none block expression_statement assignment identifier binary_operator unary_operator float call attribute identifier identifier argument_list float else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement assignment identifier binary_operator unary_operator float call attribute identifier identifier argument_list float else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement tuple identifier identifier
Parse the tolerance keywords
def scan(src): assert isinstance(src, (unicode_, bytes_)) try: nodes = STYLESHEET.parseString(src, parseAll=True) return nodes except ParseBaseException: err = sys.exc_info()[1] print(err.line, file=sys.stderr) print(" " * (err.column - 1) + "^", file=sys.stderr) print(err, file=sys.stderr) sys.exit(1)
module function_definition identifier parameters identifier block assert_statement call identifier argument_list identifier tuple identifier identifier try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier true return_statement identifier except_clause identifier block expression_statement assignment identifier subscript call attribute identifier identifier argument_list integer expression_statement call identifier argument_list attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement call identifier argument_list binary_operator binary_operator string string_start string_content string_end parenthesized_expression binary_operator attribute identifier identifier integer string string_start string_content string_end keyword_argument identifier attribute identifier identifier expression_statement call identifier argument_list identifier keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list integer
Scan scss from string and return nodes.
def fit_gaussian(x, y, yerr, p0): try: popt, pcov = curve_fit(gaussian, x, y, sigma=yerr, p0=p0, absolute_sigma=True) except RuntimeError: return [0],[0] return popt, pcov
module function_definition identifier parameters identifier identifier identifier identifier block try_statement block expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier true except_clause identifier block return_statement expression_list list integer list integer return_statement expression_list identifier identifier
Fit a Gaussian to the data
def to_dict(self): return {"name": self.table_name, "kind": self.table_kind, "data": [r.to_dict() for r in self]}
module function_definition identifier parameters identifier block return_statement dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end list_comprehension call attribute identifier identifier argument_list for_in_clause identifier identifier
Converts the table to a dict.
def generateRevision(self): revpath = self.sourcePath() if not os.path.exists(revpath): return revfile = os.path.join(revpath, self.revisionFilename()) mode = '' try: args = ['svn', 'info', revpath] proc = subprocess.Popen(args, stdout=subprocess.PIPE) mode = 'svn' except WindowsError: try: args = ['git', 'rev-parse', 'HEAD', revpath] proc = subprocess.Popen(args, stdout=subprocess.PIPE) mode = 'git' except WindowsError: return rev = None if mode == 'svn': for line in proc.stdout: data = re.match('^Revision: (\d+)', line) if data: rev = int(data.group(1)) break if rev is not None: try: f = open(revfile, 'w') f.write('__revision__ = {0}\n'.format(rev)) f.close() except IOError: pass
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block return_statement expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier call attribute identifier identifier argument_list expression_statement assignment identifier string string_start string_end try_statement block expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier expression_statement assignment identifier string string_start string_content string_end except_clause identifier block try_statement block expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier expression_statement assignment identifier string string_start string_content string_end except_clause identifier block return_statement expression_statement assignment identifier none if_statement comparison_operator identifier string string_start string_content string_end block for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement identifier block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list integer break_statement if_statement comparison_operator identifier none block try_statement block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list except_clause identifier block pass_statement
Generates the revision file for this builder.
def auth_edit(name, **kwargs): ctx = Context(**kwargs) ctx.timeout = None ctx.execute_action('auth:group:edit', **{ 'storage': ctx.repo.create_secure_service('storage'), 'name': name, })
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list dictionary_splat identifier expression_statement assignment attribute identifier identifier none expression_statement call attribute identifier identifier argument_list string string_start string_content string_end dictionary_splat dictionary pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end pair string string_start string_content string_end identifier
Interactively edits an authorization group.
def one_symbol_ops_str(self) -> str: return re.escape(''.join((key for key in self.ops.keys() if len(key) == 1)))
module function_definition identifier parameters identifier type identifier block return_statement call attribute identifier identifier argument_list call attribute string string_start string_end identifier argument_list generator_expression identifier for_in_clause identifier call attribute attribute identifier identifier identifier argument_list if_clause comparison_operator call identifier argument_list identifier integer
Regex-escaped string with all one-symbol operators
def serialize(graph: BELGraph, csv, sif, gsea, graphml, json, bel): if csv: log.info('Outputting CSV to %s', csv) to_csv(graph, csv) if sif: log.info('Outputting SIF to %s', sif) to_sif(graph, sif) if graphml: log.info('Outputting GraphML to %s', graphml) to_graphml(graph, graphml) if gsea: log.info('Outputting GRP to %s', gsea) to_gsea(graph, gsea) if json: log.info('Outputting JSON to %s', json) to_json_file(graph, json) if bel: log.info('Outputting BEL to %s', bel) to_bel(graph, bel)
module function_definition identifier parameters typed_parameter identifier type identifier identifier identifier identifier identifier identifier identifier block if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call identifier argument_list identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call identifier argument_list identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call identifier argument_list identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call identifier argument_list identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call identifier argument_list identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call identifier argument_list identifier identifier
Serialize a graph to various formats.
def selectfalse(table, field, complement=False): return select(table, field, lambda v: not bool(v), complement=complement)
module function_definition identifier parameters identifier identifier default_parameter identifier false block return_statement call identifier argument_list identifier identifier lambda lambda_parameters identifier not_operator call identifier argument_list identifier keyword_argument identifier identifier
Select rows where the given field evaluates `False`.
def sbesselh2(x, N): "Spherical Hankel of the second kind" jn = sbesselj(x, N) yn = sbessely(x, N) return jn - 1j * yn
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier return_statement binary_operator identifier binary_operator integer identifier
Spherical Hankel of the second kind
def _get_services(): serv = [] services = pyconnman.ConnManager().get_services() for path, _ in services: serv.append(six.text_type(path[len(SERVICE_PATH):])) return serv
module function_definition identifier parameters block expression_statement assignment identifier list expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list for_statement pattern_list identifier identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list subscript identifier slice call identifier argument_list identifier return_statement identifier
Returns a list with all connman services
def to_internal_value(self, data): if isinstance(data, dict) and isinstance(data.get('id', None), int): data = data['id'] elif isinstance(data, int): pass else: raise ValidationError("Contributor must be an integer or a dictionary with key 'id'") return self.Meta.model.objects.get(pk=data)
module function_definition identifier parameters identifier identifier block if_statement boolean_operator call identifier argument_list identifier identifier call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end none identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end elif_clause call identifier argument_list identifier identifier block pass_statement else_clause block raise_statement call identifier argument_list string string_start string_content string_end return_statement call attribute attribute attribute attribute identifier identifier identifier identifier identifier argument_list keyword_argument identifier identifier
Format the internal value.
def _get_corenlp_version(): "Return the corenlp version pointed at by CORENLP_HOME, or None" corenlp_home = os.environ.get("CORENLP_HOME") if corenlp_home: for fn in os.listdir(corenlp_home): m = re.match("stanford-corenlp-([\d.]+)-models.jar", fn) if m: return m.group(1)
module function_definition identifier parameters block expression_statement string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end if_statement identifier block for_statement identifier call attribute identifier identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement identifier block return_statement call attribute identifier identifier argument_list integer
Return the corenlp version pointed at by CORENLP_HOME, or None
def _init_repo(self): log.debug("initializing new Git Repo: {0}".format(self._engine_path)) if os.path.exists(self._engine_path): log.error("Path already exists! Aborting!") raise RuntimeError else: _logg_repo = git.Repo.init(path=self._engine_path, mkdir=True) record = "idid Logg repo initialized on {0}".format(today()) c = _logg_repo.index.commit(record) assert c.type == 'commit' log.info('Created git repo [{0}]'.format(self._engine_path)) return _logg_repo
module function_definition identifier parameters 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 if_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end raise_statement identifier else_clause block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier true expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list call identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier assert_statement comparison_operator attribute identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier return_statement identifier
create and initialize a new Git Repo
def prox_max(X, step, thresh=0): thresh_ = _step_gamma(step, thresh) above = X - thresh_ > 0 X[above] = thresh_ return X
module function_definition identifier parameters identifier identifier default_parameter identifier integer block expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier comparison_operator binary_operator identifier identifier integer expression_statement assignment subscript identifier identifier identifier return_statement identifier
Projection onto numbers below `thresh`
def _subsampling_sanity_check(self): dxs = np.array(self.codestream.segment[1].xrsiz) dys = np.array(self.codestream.segment[1].yrsiz) if np.any(dxs - dxs[0]) or np.any(dys - dys[0]): msg = ("The read_bands method should be used with the subsampling " "factors are different. " "\n\n{siz_segment}") msg = msg.format(siz_segment=str(self.codestream.segment[1])) raise IOError(msg)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute subscript attribute attribute identifier identifier identifier integer identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute subscript attribute attribute identifier identifier identifier integer identifier if_statement boolean_operator call attribute identifier identifier argument_list binary_operator identifier subscript identifier integer call attribute identifier identifier argument_list binary_operator identifier subscript identifier integer block expression_statement assignment identifier parenthesized_expression concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content escape_sequence escape_sequence string_end expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier call identifier argument_list subscript attribute attribute identifier identifier identifier integer raise_statement call identifier argument_list identifier
Check for differing subsample factors.
def _maybe_classify(self, y, k, cutoffs): rows, cols = y.shape if cutoffs is None: if self.fixed: mcyb = mc.Quantiles(y.flatten(), k=k) yb = mcyb.yb.reshape(y.shape) cutoffs = mcyb.bins k = len(cutoffs) return yb, cutoffs[:-1], k else: yb = np.array([mc.Quantiles(y[:, i], k=k).yb for i in np.arange(cols)]).transpose() return yb, None, k else: cutoffs = list(cutoffs) + [np.inf] cutoffs = np.array(cutoffs) yb = mc.User_Defined(y.flatten(), np.array(cutoffs)).yb.reshape( y.shape) k = len(cutoffs) return yb, cutoffs[:-1], k
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment pattern_list identifier identifier attribute identifier identifier if_statement comparison_operator identifier none block if_statement attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier return_statement expression_list identifier subscript identifier slice unary_operator integer identifier else_clause block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list list_comprehension attribute call attribute identifier identifier argument_list subscript identifier slice identifier keyword_argument identifier identifier identifier for_in_clause identifier call attribute identifier identifier argument_list identifier identifier argument_list return_statement expression_list identifier none identifier else_clause block expression_statement assignment identifier binary_operator call identifier argument_list identifier list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier return_statement expression_list identifier subscript identifier slice unary_operator integer identifier
Helper method for classifying continuous data.
def updateUi(self): index = self._slideshow.currentIndex() count = self._slideshow.count() self._previousButton.setVisible(index != 0) self._nextButton.setText('Finish' if index == count - 1 else 'Next') self.autoLayout()
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list comparison_operator identifier integer expression_statement call attribute attribute identifier identifier identifier argument_list conditional_expression string string_start string_content string_end comparison_operator identifier binary_operator identifier integer string string_start string_content string_end expression_statement call attribute identifier identifier argument_list
Updates the interface to show the selection buttons.
def _add_annots(self, layout, annots): if annots: for annot in resolve1(annots): annot = resolve1(annot) if annot.get('Rect') is not None: annot['bbox'] = annot.pop('Rect') annot = self._set_hwxy_attrs(annot) try: annot['URI'] = resolve1(annot['A'])['URI'] except KeyError: pass for k, v in six.iteritems(annot): if not isinstance(v, six.string_types): annot[k] = obj_to_string(v) elem = parser.makeelement('Annot', annot) layout.add(elem) return layout
module function_definition identifier parameters identifier identifier identifier block if_statement identifier block for_statement identifier call identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end none block expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier try_statement block expression_statement assignment subscript identifier string string_start string_content string_end subscript call identifier argument_list subscript identifier string string_start string_content string_end string string_start string_content string_end except_clause identifier block pass_statement for_statement pattern_list identifier identifier call attribute identifier identifier argument_list identifier block if_statement not_operator call identifier argument_list identifier attribute identifier identifier block expression_statement assignment subscript identifier identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Adds annotations to the layout object
def process(self, formdata=None, obj=None, data=None, **kwargs): self._obj = obj super(CommonFormMixin, self).process(formdata, obj, data, **kwargs)
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none dictionary_splat_pattern identifier block expression_statement assignment attribute identifier identifier identifier expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list identifier identifier identifier dictionary_splat identifier
Wrap the process method to store the current object instance
def ip_address(): s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.connect(("8.8.8.8", 53)) ip = s.getsockname()[0] s.close() return ip
module function_definition identifier parameters block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list tuple string string_start string_content string_end integer expression_statement assignment identifier subscript call attribute identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list return_statement identifier
Get the IP address used for public connections.
def aslist(generator): 'Function decorator to transform a generator into a list' def wrapper(*args, **kwargs): return list(generator(*args, **kwargs)) return wrapper
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block return_statement call identifier argument_list call identifier argument_list list_splat identifier dictionary_splat identifier return_statement identifier
Function decorator to transform a generator into a list
def toc(self): toc = [] stack = [toc] for entry in self.__toc: entry['sub'] = [] while entry['level'] < len(stack): stack.pop() while entry['level'] > len(stack): stack.append(stack[-1][-1]['sub']) stack[-1].append(entry) return toc
module function_definition identifier parameters identifier block expression_statement assignment identifier list expression_statement assignment identifier list identifier for_statement identifier attribute identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end list while_statement comparison_operator subscript identifier string string_start string_content string_end call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list while_statement comparison_operator subscript identifier string string_start string_content string_end call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list subscript subscript subscript identifier unary_operator integer unary_operator integer string string_start string_content string_end expression_statement call attribute subscript identifier unary_operator integer identifier argument_list identifier return_statement identifier
Smart getter for Table of Content list.
def populate_local_sch_cache(self, fw_dict): for fw_id in fw_dict: fw_data = fw_dict.get(fw_id) mgmt_ip = fw_data.get('fw_mgmt_ip') dev_status = fw_data.get('device_status') if dev_status == 'SUCCESS': new = True else: new = False if mgmt_ip is not None: drvr_dict, mgmt_ip = self.sched_obj.populate_fw_dev(fw_id, mgmt_ip, new) if drvr_dict is None or mgmt_ip is None: LOG.info("Pop cache for FW sch: drvr_dict or mgmt_ip " "is None")
module function_definition identifier parameters identifier identifier block for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier true else_clause block expression_statement assignment identifier false if_statement comparison_operator identifier none block expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier identifier identifier if_statement boolean_operator comparison_operator identifier none comparison_operator identifier none 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
Populate the local cache from FW DB after restart.
def _get_ipv4_from_binary(self, bin_addr): return socket.inet_ntop(socket.AF_INET, struct.pack("!L", bin_addr))
module function_definition identifier parameters identifier identifier block return_statement call attribute identifier identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier
Converts binary address to Ipv4 format.
def handler(event): def decorator(fn): def apply(cls): event.connect(fn, sender=cls) return cls fn.apply = apply return fn return decorator
module function_definition identifier parameters identifier block function_definition identifier parameters identifier block function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier return_statement identifier expression_statement assignment attribute identifier identifier identifier return_statement identifier return_statement identifier
Signal decorator to allow use of callback functions as class decorators.
def memoryCheck(vms_max_kb): safety_factor = 1.2 vms_max = vms_max_kb vms_gigs = vms_max / 1024 ** 2 buffer = safety_factor * vms_max buffer_gigs = buffer / 1024 ** 2 vm = psutil.virtual_memory() free_gigs = vm.available / 1024 ** 2 if vm.available < buffer: raise MemoryError('Running this requires quite a bit of memory ~ ' f'{vms_gigs:.2f}, you have {free_gigs:.2f} of the ' f'{buffer_gigs:.2f} needed')
module function_definition identifier parameters identifier block expression_statement assignment identifier float expression_statement assignment identifier identifier expression_statement assignment identifier binary_operator identifier binary_operator integer integer expression_statement assignment identifier binary_operator identifier identifier expression_statement assignment identifier binary_operator identifier binary_operator integer integer expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier binary_operator attribute identifier identifier binary_operator integer integer if_statement comparison_operator attribute identifier identifier identifier block raise_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start interpolation identifier format_specifier string_content interpolation identifier format_specifier string_content string_end string string_start interpolation identifier format_specifier string_content string_end
Lookup vms_max using getCurrentVMSKb
def idxterms(self): try: terms = listify(self._json.get("idxterms", {}).get('mainterm', [])) except AttributeError: return None try: return [d['$'] for d in terms] except AttributeError: return None
module function_definition identifier parameters identifier block try_statement block expression_statement assignment identifier call identifier argument_list call attribute call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end dictionary identifier argument_list string string_start string_content string_end list except_clause identifier block return_statement none try_statement block return_statement list_comprehension subscript identifier string string_start string_content string_end for_in_clause identifier identifier except_clause identifier block return_statement none
List of index terms.
def show_all_prs(self): for __, prs in self.collect_prs_info().items(): for pr_info in prs: logger.info( '{url} in state {state} ({merged})'.format(**pr_info) )
module function_definition identifier parameters identifier block for_statement pattern_list identifier identifier call attribute call attribute identifier identifier argument_list identifier argument_list block for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list dictionary_splat identifier
Log all PRs grouped by state.
def list_tools(self): tools = [] exists, sections = self.sections() if exists: for section in sections: options = {'section': section, 'built': None, 'version': None, 'repo': None, 'branch': None, 'name': None, 'groups': None, 'image_name': None} for option in list(options.keys()): exists, value = self.option(section, option) if exists: options[option] = value if 'core' not in options['groups'] and 'hidden' not in options['groups']: tools.append(options) return tools
module function_definition identifier parameters identifier block expression_statement assignment identifier list expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list if_statement identifier block for_statement identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end none pair string string_start string_content string_end none pair string string_start string_content string_end none pair string string_start string_content string_end none pair string string_start string_content string_end none pair string string_start string_content string_end none pair string string_start string_content string_end none for_statement identifier call identifier argument_list call attribute identifier identifier argument_list block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier identifier if_statement identifier block expression_statement assignment subscript identifier identifier identifier if_statement boolean_operator comparison_operator string string_start string_content string_end subscript identifier string string_start string_content string_end comparison_operator string string_start string_content string_end subscript identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Return list of tuples of all tools
def create_s3_session(): sess = requests.Session() retries = Retry(total=3, backoff_factor=.5, status_forcelist=[500, 502, 503, 504]) sess.mount('https://', HTTPAdapter(max_retries=retries)) return sess
module function_definition identifier parameters block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list keyword_argument identifier integer keyword_argument identifier float keyword_argument identifier list integer integer integer integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list keyword_argument identifier identifier return_statement identifier
Creates a session with automatic retries on 5xx errors.
def no_imls(self): return all(numpy.isnan(ls).any() for ls in self.imtls.values())
module function_definition identifier parameters identifier block return_statement call identifier generator_expression call attribute call attribute identifier identifier argument_list identifier identifier argument_list for_in_clause identifier call attribute attribute identifier identifier identifier argument_list
Return True if there are no intensity measure levels
def _txtinfo_to_python(self, data): self._format = 'txtinfo' lines = data.split('\n') try: start = lines.index('Table: Topology') + 2 except ValueError: raise ParserError('Unrecognized format') topology_lines = [line for line in lines[start:] if line] parsed_lines = [] for line in topology_lines: values = line.split(' ') parsed_lines.append({ 'source': values[0], 'target': values[1], 'cost': float(values[4]) }) return parsed_lines
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end try_statement block expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list string string_start string_content string_end integer except_clause identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier list_comprehension identifier for_in_clause identifier subscript identifier slice identifier if_clause identifier expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end subscript identifier integer pair string string_start string_content string_end subscript identifier integer pair string string_start string_content string_end call identifier argument_list subscript identifier integer return_statement identifier
Converts txtinfo format to python
def json(self): lines = [] for line in self.lines(): try: if len(line) == 1: lines.append(json.loads(line, strict=False)) else: lines.append(json.loads(line[1], strict=False)) except ValueError: pass return lines
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier call attribute identifier identifier argument_list block try_statement block if_statement comparison_operator call identifier argument_list identifier integer block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier false else_clause block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list subscript identifier integer keyword_argument identifier false except_clause identifier block pass_statement return_statement identifier
Return a list of JSON objects output by this service.
def _detect_sse3(self): "Does this compiler support SSE3 intrinsics?" self._print_support_start('SSE3') result = self.hasfunction('__m128 v; _mm_hadd_ps(v,v)', include='<pmmintrin.h>', extra_postargs=['-msse3']) self._print_support_end('SSE3', result) return result
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement identifier
Does this compiler support SSE3 intrinsics?
def create_db_schema(cls, cur, schema_name): create_schema_script = "CREATE SCHEMA {0} ;\n".format(schema_name) cur.execute(create_schema_script)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier
Create Postgres schema script and execute it on cursor
def capture_output(self, with_hook=True): self.hooked = '' def display_hook(obj): self.hooked += self.safe_better_repr(obj) self.last_obj = obj stdout, stderr = sys.stdout, sys.stderr if with_hook: d_hook = sys.displayhook sys.displayhook = display_hook sys.stdout, sys.stderr = StringIO(), StringIO() out, err = [], [] try: yield out, err finally: out.extend(sys.stdout.getvalue().splitlines()) err.extend(sys.stderr.getvalue().splitlines()) if with_hook: sys.displayhook = d_hook sys.stdout, sys.stderr = stdout, stderr
module function_definition identifier parameters identifier default_parameter identifier true block expression_statement assignment attribute identifier identifier string string_start string_end function_definition identifier parameters identifier block expression_statement augmented_assignment attribute identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment pattern_list identifier identifier expression_list attribute identifier identifier attribute identifier identifier if_statement identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment pattern_list attribute identifier identifier attribute identifier identifier expression_list call identifier argument_list call identifier argument_list expression_statement assignment pattern_list identifier identifier expression_list list list try_statement block expression_statement yield expression_list identifier identifier finally_clause block expression_statement call attribute identifier identifier argument_list call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list expression_statement call attribute identifier identifier argument_list call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list if_statement identifier block expression_statement assignment attribute identifier identifier identifier expression_statement assignment pattern_list attribute identifier identifier attribute identifier identifier expression_list identifier identifier
Steal stream output, return them in string, restore them
def show_position(self): pos = self.click_position dms = (mp_util.degrees_to_dms(pos[0]), mp_util.degrees_to_dms(pos[1])) msg = "Coordinates in WGS84\n" msg += "Decimal: %.6f %.6f\n" % (pos[0], pos[1]) msg += "DMS: %s %s\n" % (dms[0], dms[1]) msg += "Grid: %s\n" % mp_util.latlon_to_grid(pos) if self.logdir: logf = open(os.path.join(self.logdir, "positions.txt"), "a") logf.write("Position: %.6f %.6f at %s\n" % (pos[0], pos[1], time.ctime())) logf.close() posbox = MPMenuChildMessageDialog('Position', msg, font_size=32) posbox.show()
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier tuple call attribute identifier identifier argument_list subscript identifier integer call attribute identifier identifier argument_list subscript identifier integer expression_statement assignment identifier string string_start string_content escape_sequence string_end expression_statement augmented_assignment identifier binary_operator string string_start string_content escape_sequence string_end tuple subscript identifier integer subscript identifier integer expression_statement augmented_assignment identifier binary_operator string string_start string_content escape_sequence string_end tuple subscript identifier integer subscript identifier integer expression_statement augmented_assignment identifier binary_operator string string_start string_content escape_sequence string_end call attribute identifier identifier argument_list identifier if_statement attribute identifier identifier block expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list attribute identifier identifier string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end tuple subscript identifier integer subscript identifier integer call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list string string_start string_content string_end identifier keyword_argument identifier integer expression_statement call attribute identifier identifier argument_list
show map position click information
def installSite(self, siteStore, domain, publicURL, generateCert=True): certPath = siteStore.filesdir.child("server.pem") if generateCert and not certPath.exists(): certPath.setContent(self._createCert(domain, genSerial())) IOfferingTechnician(siteStore).installOffering(baseOffering) site = siteStore.findUnique(SiteConfiguration) site.hostname = domain installOn( TCPPort(store=siteStore, factory=site, portNumber=8080), siteStore) installOn( SSLPort(store=siteStore, factory=site, portNumber=8443, certificatePath=certPath), siteStore) shell = siteStore.findUnique(SecureShellConfiguration) installOn( TCPPort(store=siteStore, factory=shell, portNumber=8022), siteStore) fp = siteStore.findOrCreate(publicweb.FrontPage, prefixURL=u'') installOn(fp, siteStore)
module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier true block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end if_statement boolean_operator identifier not_operator call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier call identifier argument_list expression_statement call attribute call identifier argument_list identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier expression_statement call identifier argument_list call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier integer identifier expression_statement call identifier argument_list call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier integer keyword_argument identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier integer identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier string string_start string_end expression_statement call identifier argument_list identifier identifier
Create the necessary items to run an HTTP server and an SSH server.
def fill_phenotype_calls(self,phenotypes=None,inplace=False): if phenotypes is None: phenotypes = list(self['phenotype_label'].unique()) def _get_calls(label,phenos): d = dict([(x,0) for x in phenos]) if label!=label: return d d[label] = 1 return d if inplace: self['phenotype_calls'] = self.apply(lambda x: _get_calls(x['phenotype_label'],phenotypes),1) return fixed = self.copy() fixed['phenotype_calls'] = fixed.apply(lambda x: _get_calls(x['phenotype_label'],phenotypes),1) return fixed
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier false block if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list call attribute subscript identifier string string_start string_content string_end identifier argument_list function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list list_comprehension tuple identifier integer for_in_clause identifier identifier if_statement comparison_operator identifier identifier block return_statement identifier expression_statement assignment subscript identifier identifier integer return_statement identifier if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list lambda lambda_parameters identifier call identifier argument_list subscript identifier string string_start string_content string_end identifier integer return_statement expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list lambda lambda_parameters identifier call identifier argument_list subscript identifier string string_start string_content string_end identifier integer return_statement identifier
Set the phenotype_calls according to the phenotype names
def _derive_stereographic(): from sympy import symbols, atan2, acos, rot_axis1, rot_axis3, Matrix x_c, y_c, z_c, x, y, z = symbols('x_c y_c z_c x y z') around_z = atan2(x_c, y_c) around_x = acos(-z_c) v = Matrix([x, y, z]) xo, yo, zo = rot_axis1(around_x) * rot_axis3(-around_z) * v xp = xo / (1 - zo) yp = yo / (1 - zo) return xp, yp
module function_definition identifier parameters block import_from_statement dotted_name identifier dotted_name identifier dotted_name identifier dotted_name identifier dotted_name identifier dotted_name identifier dotted_name identifier expression_statement assignment pattern_list identifier identifier identifier identifier identifier identifier call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list unary_operator identifier expression_statement assignment identifier call identifier argument_list list identifier identifier identifier expression_statement assignment pattern_list identifier identifier identifier binary_operator binary_operator call identifier argument_list identifier call identifier argument_list unary_operator identifier identifier expression_statement assignment identifier binary_operator identifier parenthesized_expression binary_operator integer identifier expression_statement assignment identifier binary_operator identifier parenthesized_expression binary_operator integer identifier return_statement expression_list identifier identifier
Compute the formulae to cut-and-paste into the routine below.
def _value_data(self, value): return codecs.decode( codecs.encode(self.value_value(value)[1], 'base64'), 'utf8')
module function_definition identifier parameters identifier identifier block return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list subscript call attribute identifier identifier argument_list identifier integer string string_start string_content string_end string string_start string_content string_end
Parses binary and unidentified values.
def ft1file(self, **kwargs): kwargs_copy = self.base_dict.copy() kwargs_copy.update(**kwargs) kwargs_copy['dataset'] = kwargs.get('dataset', self.dataset(**kwargs)) self._replace_none(kwargs_copy) localpath = NameFactory.ft1file_format.format(**kwargs_copy) if kwargs.get('fullpath', False): return self.fullpath(localpath=localpath) return localpath
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list dictionary_splat 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 call attribute identifier identifier argument_list dictionary_splat identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list dictionary_splat identifier if_statement call attribute identifier identifier argument_list string string_start string_content string_end false block return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier return_statement identifier
return the name of the input ft1 file list
def extract(data, items, out_dir=None): if vcfutils.get_paired_phenotype(data): if len(items) == 1: germline_vcf = _remove_prioritization(data["vrn_file"], data, out_dir) germline_vcf = vcfutils.bgzip_and_index(germline_vcf, data["config"]) data["vrn_file_plus"] = {"germline": germline_vcf} return data
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement call attribute identifier identifier argument_list identifier block if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier call identifier argument_list subscript identifier string string_start string_content string_end identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier subscript identifier string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end dictionary pair string string_start string_content string_end identifier return_statement identifier
Extract germline calls for the given sample, if tumor only.
def plot(self, file_type): samples = self.mod_data[file_type] plot_title = file_types[file_type]['title'] plot_func = file_types[file_type]['plot_func'] plot_params = file_types[file_type]['plot_params'] return plot_func(samples, file_type, plot_title=plot_title, plot_params=plot_params)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier identifier expression_statement assignment identifier subscript subscript identifier identifier string string_start string_content string_end expression_statement assignment identifier subscript subscript identifier identifier string string_start string_content string_end expression_statement assignment identifier subscript subscript identifier identifier string string_start string_content string_end return_statement call identifier argument_list identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
Call file_type plotting function.
def unpickle_file(picklefile, **kwargs): with open(picklefile, 'rb') as f: return pickle.load(f, **kwargs)
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block return_statement call attribute identifier identifier argument_list identifier dictionary_splat identifier
Helper function to unpickle data from `picklefile`.
def node_created_handler(sender, **kwargs): if kwargs['created']: obj = kwargs['instance'] queryset = exclude_owner_of_node(obj) create_notifications.delay(**{ "users": queryset, "notification_model": Notification, "notification_type": "node_created", "related_object": obj })
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block if_statement subscript identifier string string_start string_content string_end block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list dictionary_splat dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end identifier
send notification when a new node is created according to users's settings
def _init_kws(self): if 'fmtgo' not in self.kws: self.kws['fmtgo'] = self.grprdflt.gosubdag.prt_attr['fmt'] + "\n" if 'fmtgo2' not in self.kws: self.kws['fmtgo2'] = self.grprdflt.gosubdag.prt_attr['fmt'] + "\n" if 'fmtgene' not in self.kws: if 'itemid2name' not in self.kws: self.kws['fmtgene'] = "{AART} {ID}\n" else: self.kws['fmtgene'] = "{AART} {ID} {NAME}\n" if 'fmtgene2' not in self.kws: self.kws['fmtgene2'] = self.kws['fmtgene']
module function_definition identifier parameters identifier block if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end binary_operator subscript attribute attribute attribute identifier identifier identifier identifier string string_start string_content string_end string string_start string_content escape_sequence string_end if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end binary_operator subscript attribute attribute attribute identifier identifier identifier identifier string string_start string_content string_end string string_start string_content escape_sequence string_end if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end string string_start string_content escape_sequence string_end else_clause block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end string string_start string_content escape_sequence string_end if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end
Fill default values for keyword args, if necessary.