code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def match_string(pattern, search_string): rexobj = REX(pattern, None) rexpatstr = reformat_pattern(pattern) rexpat = re.compile(rexpatstr) rexobj.rex_patternstr = rexpatstr rexobj.rex_pattern = rexpat line_count = 1 for line in search_string.splitlines(): line = line.strip() mobj = rexpat.match(line) if mobj: populate_resobj(rexobj, mobj, line_count) line_count += 1 return rexobj
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier none expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment identifier integer for_statement identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement call identifier argument_list identifier identifier identifier expression_statement augmented_assignment identifier integer return_statement identifier
Match a pattern in a string
def upload_gunicorn_conf(command='gunicorn', app_name=None, template_name=None, context=None): app_name = app_name or command default = {'app_name': app_name, 'command': command} context = context or {} default.update(context) template_name = template_name or [u'supervisor/%s.conf' % command, u'supervisor/gunicorn.conf'] upload_supervisor_app_conf(app_name=app_name, template_name=template_name, context=default)
module function_definition identifier parameters default_parameter identifier string string_start string_content string_end default_parameter identifier none default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier boolean_operator identifier identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier expression_statement assignment identifier boolean_operator identifier dictionary expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier boolean_operator identifier list binary_operator string string_start string_content string_end identifier string string_start string_content string_end expression_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
Upload Supervisor configuration for a gunicorn server.
def remove_targets(self, type, kept=None): if kept is None: kept = [ i for i, x in enumerate(self._targets) if not isinstance(x, type) ] if len(kept) == len(self._targets): return self self._targets = [self._targets[x] for x in kept] self._labels = [self._labels[x] for x in kept] if not self._groups: return self index_map = { o_idx: n_idx for n_idx, o_idx in zip(range(len(self._targets)), kept) } kept = set(kept) for idx, grp in enumerate(self._groups): self._groups[idx] = _sos_group( [index_map[x] for x in grp._indexes if x in kept], [y for x, y in zip(grp._indexes, grp._labels) if x in kept ]).set(**grp._dict) return self
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier list_comprehension identifier for_in_clause pattern_list identifier identifier call identifier argument_list attribute identifier identifier if_clause not_operator call identifier argument_list identifier identifier if_statement comparison_operator call identifier argument_list identifier call identifier argument_list attribute identifier identifier block return_statement identifier expression_statement assignment attribute identifier identifier list_comprehension subscript attribute identifier identifier identifier for_in_clause identifier identifier expression_statement assignment attribute identifier identifier list_comprehension subscript attribute identifier identifier identifier for_in_clause identifier identifier if_statement not_operator attribute identifier identifier block return_statement identifier expression_statement assignment identifier dictionary_comprehension pair identifier identifier for_in_clause pattern_list identifier identifier call identifier argument_list call identifier argument_list call identifier argument_list attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier call attribute call identifier argument_list list_comprehension subscript identifier identifier for_in_clause identifier attribute identifier identifier if_clause comparison_operator identifier identifier list_comprehension identifier for_in_clause pattern_list identifier identifier call identifier argument_list attribute identifier identifier attribute identifier identifier if_clause comparison_operator identifier identifier identifier argument_list dictionary_splat attribute identifier identifier return_statement identifier
Remove targets of certain type
def get(app, name): backend = get_all(app).get(name) if not backend: msg = 'Harvest backend "{0}" is not registered'.format(name) raise EntrypointError(msg) return backend
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute call identifier argument_list identifier identifier argument_list identifier if_statement not_operator identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier raise_statement call identifier argument_list identifier return_statement identifier
Get a backend given its name
def collect_cmd(self, args, ret): from dvc.command.daemon import CmdDaemonAnalytics assert isinstance(ret, int) or ret is None if ret is not None: self.info[self.PARAM_CMD_RETURN_CODE] = ret if args is not None and hasattr(args, "func"): assert args.func != CmdDaemonAnalytics self.info[self.PARAM_CMD_CLASS] = args.func.__name__
module function_definition identifier parameters identifier identifier identifier block import_from_statement dotted_name identifier identifier identifier dotted_name identifier assert_statement boolean_operator call identifier argument_list identifier identifier comparison_operator identifier none if_statement comparison_operator identifier none block expression_statement assignment subscript attribute identifier identifier attribute identifier identifier identifier if_statement boolean_operator comparison_operator identifier none call identifier argument_list identifier string string_start string_content string_end block assert_statement comparison_operator attribute identifier identifier identifier expression_statement assignment subscript attribute identifier identifier attribute identifier identifier attribute attribute identifier identifier identifier
Collect analytics info from a CLI command.
def _cldf2lexstat( dataset, segments='segments', transcription='value', row='parameter_id', col='language_id'): D = _cldf2wld(dataset) return lingpy.LexStat(D, segments=segments, transcription=transcription, row=row, col=col)
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
Read LexStat object from cldf dataset.
def delete(self, request, pzone_pk, operation_pk): try: operation = PZoneOperation.objects.get(pk=operation_pk) except PZoneOperation.DoesNotExist: raise Http404("Cannot find given operation.") operation.delete() return Response("", 204)
module function_definition identifier parameters identifier identifier identifier identifier block try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier except_clause attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list return_statement call identifier argument_list string string_start string_end integer
Remove an operation from the given pzone.
async def unmount(self): self._data = await self._handler.unmount( system_id=self.node.system_id, id=self.id)
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier await call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier attribute identifier identifier
Unmount this block device.
def salt_master(project, target, module, args=None, kwargs=None): client = project.cluster.head.ssh_client cmd = ['salt'] cmd.extend(generate_salt_cmd(target, module, args, kwargs)) cmd.append('--timeout=300') cmd.append('--state-output=mixed') cmd = ' '.join(cmd) output = client.exec_command(cmd, sudo=True) if output['exit_code'] == 0: return output['stdout'] else: return output['stderr']
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier attribute attribute attribute identifier identifier identifier identifier expression_statement assignment identifier list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier true if_statement comparison_operator subscript identifier string string_start string_content string_end integer block return_statement subscript identifier string string_start string_content string_end else_clause block return_statement subscript identifier string string_start string_content string_end
Execute a `salt` command in the head node
def _submit_bundle(cmd_args, app): sac = streamsx.rest.StreamingAnalyticsConnection(service_name=cmd_args.service_name) sas = sac.get_streaming_analytics() sr = sas.submit_job(bundle=app.app, job_config=app.cfg[ctx.ConfigParams.JOB_CONFIG]) if 'exception' in sr: rc = 1 elif 'status_code' in sr: try: rc = 0 if int(sr['status_code'] == 200) else 1 except: rc = 1 elif 'id' in sr or 'jobId' in sr: rc = 0 sr['return_code'] = rc return sr
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier subscript attribute identifier identifier attribute attribute identifier identifier identifier if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier integer elif_clause comparison_operator string string_start string_content string_end identifier block try_statement block expression_statement assignment identifier conditional_expression integer call identifier argument_list comparison_operator subscript identifier string string_start string_content string_end integer integer except_clause block expression_statement assignment identifier integer elif_clause boolean_operator comparison_operator string string_start string_content string_end identifier comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier integer expression_statement assignment subscript identifier string string_start string_content string_end identifier return_statement identifier
Submit an existing bundle to the service
def join(self, iterable): before = [] chunks = [] for i, s in enumerate(iterable): chunks.extend(before) before = self.chunks if isinstance(s, FmtStr): chunks.extend(s.chunks) elif isinstance(s, (bytes, unicode)): chunks.extend(fmtstr(s).chunks) else: raise TypeError("expected str or FmtStr, %r found" % type(s)) return FmtStr(*chunks)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list expression_statement assignment identifier list for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier attribute identifier identifier if_statement call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier elif_clause call identifier argument_list identifier tuple identifier identifier block expression_statement call attribute identifier identifier argument_list attribute call identifier argument_list identifier identifier else_clause block raise_statement call identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier return_statement call identifier argument_list list_splat identifier
Joins an iterable yielding strings or FmtStrs with self as separator
def func_interpolate_na(interpolator, x, y, **kwargs): out = y.copy() nans = pd.isnull(y) nonans = ~nans n_nans = nans.sum() if n_nans == 0 or n_nans == len(y): return y f = interpolator(x[nonans], y[nonans], **kwargs) out[nans] = f(x[nans]) return out
module function_definition identifier parameters identifier identifier identifier dictionary_splat_pattern 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 unary_operator identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement boolean_operator comparison_operator identifier integer comparison_operator identifier call identifier argument_list identifier block return_statement identifier expression_statement assignment identifier call identifier argument_list subscript identifier identifier subscript identifier identifier dictionary_splat identifier expression_statement assignment subscript identifier identifier call identifier argument_list subscript identifier identifier return_statement identifier
helper function to apply interpolation along 1 dimension
def _percolate_query(index, doc_type, percolator_doc_type, document): if ES_VERSION[0] in (2, 5): results = current_search_client.percolate( index=index, doc_type=doc_type, allow_no_indices=True, ignore_unavailable=True, body={'doc': document} ) return results['matches'] elif ES_VERSION[0] == 6: results = current_search_client.search( index=index, doc_type=percolator_doc_type, allow_no_indices=True, ignore_unavailable=True, body={ 'query': { 'percolate': { 'field': 'query', 'document_type': percolator_doc_type, 'document': document, } } } ) return results['hits']['hits']
module function_definition identifier parameters identifier identifier identifier identifier block if_statement comparison_operator subscript identifier integer tuple integer integer block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier true keyword_argument identifier true keyword_argument identifier dictionary pair string string_start string_content string_end identifier return_statement subscript identifier string string_start string_content string_end elif_clause comparison_operator subscript identifier integer integer block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier true keyword_argument identifier true keyword_argument identifier dictionary pair string string_start string_content string_end dictionary pair string string_start string_content string_end dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier return_statement subscript subscript identifier string string_start string_content string_end string string_start string_content string_end
Get results for a percolate query.
def autodiscover(): global _RACE_PROTECTION if _RACE_PROTECTION: return _RACE_PROTECTION = True try: return filter(None, [find_related_module(app, 'tasks') for app in settings.INSTALLED_APPS]) finally: _RACE_PROTECTION = False
module function_definition identifier parameters block global_statement identifier if_statement identifier block return_statement expression_statement assignment identifier true try_statement block return_statement call identifier argument_list none list_comprehension call identifier argument_list identifier string string_start string_content string_end for_in_clause identifier attribute identifier identifier finally_clause block expression_statement assignment identifier false
Include tasks for all applications in ``INSTALLED_APPS``.
def _get_cursor(self): _options = self._get_options() conn = MySQLdb.connect(host=_options['host'], user=_options['user'], passwd=_options['pass'], db=_options['db'], port=_options['port'], ssl=_options['ssl']) cursor = conn.cursor() try: yield cursor except MySQLdb.DatabaseError as err: log.exception('Error in ext_pillar MySQL: %s', err.args) finally: conn.close()
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 keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list try_statement block expression_statement yield identifier except_clause as_pattern attribute identifier identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier finally_clause block expression_statement call attribute identifier identifier argument_list
Yield a MySQL cursor
def ProcessLegacyClient(self, ping, client): labels = self._GetClientLabelsList(client) system = client.Get(client.Schema.SYSTEM, "Unknown") uname = client.Get(client.Schema.UNAME, "Unknown") self._Process(labels, ping, system, uname)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier identifier identifier identifier
Update counters for system, version and release attributes.
def decode(self, poll_interval, buf=None): if buf is None: buf = self.receive(poll_interval) if buf is None: return None return decode_network_packet(buf)
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block return_statement none return_statement call identifier argument_list identifier
Decodes a given buffer or the next received packet.
def by_name(self): return {key.split(preferences_settings.SECTION_KEY_SEPARATOR)[-1]: value for key, value in self.all().items()}
module function_definition identifier parameters identifier block return_statement dictionary_comprehension pair subscript call attribute identifier identifier argument_list attribute identifier identifier unary_operator integer identifier for_in_clause pattern_list identifier identifier call attribute call attribute identifier identifier argument_list identifier argument_list
Return a dictionary with preferences identifiers and values, but without the section name in the identifier
def order_mod( x, m ): if m <= 1: return 0 assert gcd( x, m ) == 1 z = x result = 1 while z != 1: z = ( z * x ) % m result = result + 1 return result
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier integer block return_statement integer assert_statement comparison_operator call identifier argument_list identifier identifier integer expression_statement assignment identifier identifier expression_statement assignment identifier integer while_statement comparison_operator identifier integer block expression_statement assignment identifier binary_operator parenthesized_expression binary_operator identifier identifier identifier expression_statement assignment identifier binary_operator identifier integer return_statement identifier
Return the order of x in the multiplicative group mod m.
def make_label(loss, key): algo, rate, mu, half, reg = key slots, args = ['{:.3f}', '{}', 'm={:.3f}'], [loss, algo, mu] if algo in 'SGD NAG RMSProp Adam ESGD'.split(): slots.append('lr={:.2e}') args.append(rate) if algo in 'RMSProp ADADELTA ESGD'.split(): slots.append('rmsh={}') args.append(half) slots.append('rmsr={:.2e}') args.append(reg) return ' '.join(slots).format(*args)
module function_definition identifier parameters identifier identifier block expression_statement assignment pattern_list identifier identifier identifier identifier identifier identifier expression_statement assignment pattern_list identifier identifier expression_list list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end list identifier identifier identifier if_statement comparison_operator identifier call attribute string string_start string_content string_end identifier argument_list block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier call attribute string string_start string_content string_end identifier argument_list block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier return_statement call attribute call attribute string string_start string_content string_end identifier argument_list identifier identifier argument_list list_splat identifier
Create a legend label for an optimization run.
def save(self): for server, conf in self.servers.iteritems(): self._add_index_server() for conf_k, conf_v in conf.iteritems(): if not self.conf.has_section(server): self.conf.add_section(server) self.conf.set(server, conf_k, conf_v) with open(self.rc_file, 'wb') as configfile: self.conf.write(configfile) self.conf.read(self.rc_file)
module function_definition identifier parameters identifier block for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier identifier with_statement with_clause with_item as_pattern call identifier argument_list attribute identifier identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier
Saves pypirc file with new configuration information.
def great_circle_Npoints(lonlat1r, lonlat2r, N): ratio = np.linspace(0.0,1.0, N).reshape(-1,1) xyz1 = lonlat2xyz(lonlat1r[0], lonlat1r[1]) xyz2 = lonlat2xyz(lonlat2r[0], lonlat2r[1]) mids = ratio * xyz2 + (1.0-ratio) * xyz1 norm = np.sqrt((mids**2).sum(axis=1)) xyzN = mids / norm.reshape(-1,1) lonlatN = xyz2lonlat( xyzN[:,0], xyzN[:,1], xyzN[:,2]) return lonlatN
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list float float identifier identifier argument_list unary_operator integer integer expression_statement assignment identifier call identifier argument_list subscript identifier integer subscript identifier integer expression_statement assignment identifier call identifier argument_list subscript identifier integer subscript identifier integer expression_statement assignment identifier binary_operator binary_operator identifier identifier binary_operator parenthesized_expression binary_operator float identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute parenthesized_expression binary_operator identifier integer identifier argument_list keyword_argument identifier integer expression_statement assignment identifier binary_operator identifier call attribute identifier identifier argument_list unary_operator integer integer expression_statement assignment identifier call identifier argument_list subscript identifier slice integer subscript identifier slice integer subscript identifier slice integer return_statement identifier
N points along the line joining lonlat1 and lonlat2
def _max(ctx, *number): if len(number) == 0: raise ValueError("Wrong number of arguments") result = conversions.to_decimal(number[0], ctx) for arg in number[1:]: arg = conversions.to_decimal(arg, ctx) if arg > result: result = arg return result
module function_definition identifier parameters identifier list_splat_pattern identifier block if_statement comparison_operator call identifier argument_list identifier integer block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier integer identifier for_statement identifier subscript identifier slice integer block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement comparison_operator identifier identifier block expression_statement assignment identifier identifier return_statement identifier
Returns the maximum value of all arguments
def _from_dict(cls, _dict): args = {} if 'entities' in _dict: args['entities'] = [ QueryEntitiesEntity._from_dict(x) for x in (_dict.get('entities')) ] return cls(**args)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier parenthesized_expression call attribute identifier identifier argument_list string string_start string_content string_end return_statement call identifier argument_list dictionary_splat identifier
Initialize a QueryRelationsArgument object from a json dictionary.
def _element_format(self, occur): if occur: occ = occur else: occ = self.occur if occ == 1: if hasattr(self, "default"): self.attr["nma:default"] = self.default else: self.attr["nma:implicit"] = "true" middle = self._chorder() if self.rng_children() else "<empty/>%s" fmt = (self.start_tag() + self.serialize_annots().replace("%", "%%") + middle + self.end_tag()) if (occ == 2 or self.parent.name == "choice" or self.parent.name == "case" and len(self.parent.children) == 1): return fmt else: return "<optional>" + fmt + "</optional>"
module function_definition identifier parameters identifier identifier block if_statement identifier block expression_statement assignment identifier identifier else_clause block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier integer block if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier else_clause block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier conditional_expression call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier parenthesized_expression binary_operator binary_operator binary_operator call attribute identifier identifier argument_list call attribute call attribute identifier identifier argument_list identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier call attribute identifier identifier argument_list if_statement parenthesized_expression boolean_operator boolean_operator comparison_operator identifier integer comparison_operator attribute attribute identifier identifier identifier string string_start string_content string_end boolean_operator comparison_operator attribute attribute identifier identifier identifier string string_start string_content string_end comparison_operator call identifier argument_list attribute attribute identifier identifier identifier integer block return_statement identifier else_clause block return_statement binary_operator binary_operator string string_start string_content string_end identifier string string_start string_content string_end
Return the serialization format for an element node.
def handle_password(user, password): if password is None: try: password = keyring.get_password("yagmail", user) except NameError as e: print( "'keyring' cannot be loaded. Try 'pip install keyring' or continue without. See https://github.com/kootenpv/yagmail" ) raise e if password is None: import getpass password = getpass.getpass("Password for <{0}>: ".format(user)) answer = "" while answer != "y" and answer != "n": prompt_string = "Save username and password in keyring? [y/n]: " try: answer = raw_input(prompt_string).strip() except NameError: answer = input(prompt_string).strip() if answer == "y": register(user, password) return password
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier none block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call identifier argument_list string string_start string_content string_end raise_statement identifier if_statement comparison_operator identifier none block import_statement dotted_name identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier string string_start string_end while_statement boolean_operator comparison_operator identifier string string_start string_content string_end comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end try_statement block expression_statement assignment identifier call attribute call identifier argument_list identifier identifier argument_list except_clause identifier block expression_statement assignment identifier call attribute call identifier argument_list identifier identifier argument_list if_statement comparison_operator identifier string string_start string_content string_end block expression_statement call identifier argument_list identifier identifier return_statement identifier
Handles getting the password
def _get_unmanaged_files(self, managed, system_all): m_files, m_dirs, m_links = managed s_files, s_dirs, s_links = system_all return (sorted(list(set(s_files).difference(m_files))), sorted(list(set(s_dirs).difference(m_dirs))), sorted(list(set(s_links).difference(m_links))))
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment pattern_list identifier identifier identifier identifier expression_statement assignment pattern_list identifier identifier identifier identifier return_statement tuple call identifier argument_list call identifier argument_list call attribute call identifier argument_list identifier identifier argument_list identifier call identifier argument_list call identifier argument_list call attribute call identifier argument_list identifier identifier argument_list identifier call identifier argument_list call identifier argument_list call attribute call identifier argument_list identifier identifier argument_list identifier
Get the intersection between all files and managed files.
def print_meter_record(file_path, rows=5): m = nr.read_nem_file(file_path) print('Header:', m.header) print('Transactions:', m.transactions) for nmi in m.readings: for channel in m.readings[nmi]: print(nmi, 'Channel', channel) for reading in m.readings[nmi][channel][-rows:]: print('', reading)
module function_definition identifier parameters identifier default_parameter identifier integer block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call identifier argument_list string string_start string_content string_end attribute identifier identifier for_statement identifier attribute identifier identifier block for_statement identifier subscript attribute identifier identifier identifier block expression_statement call identifier argument_list identifier string string_start string_content string_end identifier for_statement identifier subscript subscript subscript attribute identifier identifier identifier identifier slice unary_operator identifier block expression_statement call identifier argument_list string string_start string_end identifier
Output readings for specified number of rows to console
def earth_accel(RAW_IMU,ATTITUDE): r = rotation(ATTITUDE) accel = Vector3(RAW_IMU.xacc, RAW_IMU.yacc, RAW_IMU.zacc) * 9.81 * 0.001 return r * accel
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier binary_operator binary_operator call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier float float return_statement binary_operator identifier identifier
return earth frame acceleration vector
def FDR_BH(self, p): p = np.asfarray(p) by_descend = p.argsort()[::-1] by_orig = by_descend.argsort() steps = float(len(p)) / np.arange(len(p), 0, -1) q = np.minimum(1, np.minimum.accumulate(steps * p[by_descend])) return q[by_orig]
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier subscript call attribute identifier identifier argument_list slice unary_operator integer expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier binary_operator call identifier argument_list call identifier argument_list identifier call attribute identifier identifier argument_list call identifier argument_list identifier integer unary_operator integer expression_statement assignment identifier call attribute identifier identifier argument_list integer call attribute attribute identifier identifier identifier argument_list binary_operator identifier subscript identifier identifier return_statement subscript identifier identifier
Benjamini-Hochberg p-value correction for multiple hypothesis testing.
def isfile(self, relpath): if self.isignored(relpath): return False return self._isfile_raw(relpath)
module function_definition identifier parameters identifier identifier block if_statement call attribute identifier identifier argument_list identifier block return_statement false return_statement call attribute identifier identifier argument_list identifier
Returns True if path is a file and is not ignored.
def from_context(cls, ctx, config_paths=None, project=None): if ctx.obj is None: ctx.obj = Bunch() ctx.obj.cfg = cls(ctx.info_name, config_paths, project=project) return ctx.obj.cfg
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier call identifier argument_list expression_statement assignment attribute attribute identifier identifier identifier call identifier argument_list attribute identifier identifier identifier keyword_argument identifier identifier return_statement attribute attribute identifier identifier identifier
Create a configuration object, and initialize the Click context with it.
def rt(nu, size=None): return rnormal(0, 1, size) / np.sqrt(rchi2(nu, size) / nu)
module function_definition identifier parameters identifier default_parameter identifier none block return_statement binary_operator call identifier argument_list integer integer identifier call attribute identifier identifier argument_list binary_operator call identifier argument_list identifier identifier identifier
Student's t random variates.
def objective_value(self): if self._f is None: raise RuntimeError("Problem has not been optimized yet") if self.direction == "max": return -self._f + self.offset else: return self._f + self.offset
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block raise_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block return_statement binary_operator unary_operator attribute identifier identifier attribute identifier identifier else_clause block return_statement binary_operator attribute identifier identifier attribute identifier identifier
Returns the optimal objective value
def write_length_and_key(fp, value): written = write_fmt(fp, 'I', 0 if value in _TERMS else len(value)) written += write_bytes(fp, value) return written
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end conditional_expression integer comparison_operator identifier identifier call identifier argument_list identifier expression_statement augmented_assignment identifier call identifier argument_list identifier identifier return_statement identifier
Helper to write descriptor key.
def info(): installation_path = os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir)) click.echo("colin {} {}".format(__version__, installation_path)) click.echo("colin-cli {}\n".format(os.path.realpath(__file__))) rpm_installed = is_rpm_installed() click.echo(get_version_msg_from_the_cmd(package_name="podman", use_rpm=rpm_installed)) click.echo(get_version_msg_from_the_cmd(package_name="skopeo", use_rpm=rpm_installed)) click.echo(get_version_msg_from_the_cmd(package_name="ostree", use_rpm=rpm_installed, max_lines_of_the_output=3))
module function_definition identifier parameters block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier attribute attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list call identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier integer
Show info about colin and its dependencies.
def layers_to_solr(self, layers): layers_dict_list = [] layers_success_ids = [] layers_errors_ids = [] for layer in layers: layer_dict, message = layer2dict(layer) if not layer_dict: layers_errors_ids.append([layer.id, message]) LOGGER.error(message) else: layers_dict_list.append(layer_dict) layers_success_ids.append(layer.id) layers_json = json.dumps(layers_dict_list) try: url_solr_update = '%s/solr/hypermap/update/json/docs' % SEARCH_URL headers = {"content-type": "application/json"} params = {"commitWithin": 1500} requests.post(url_solr_update, data=layers_json, params=params, headers=headers) LOGGER.info('Solr synced for the given layers') except Exception: message = "Error saving solr records: %s" % sys.exc_info()[1] layers_errors_ids.append([-1, message]) LOGGER.error(message) return False, layers_errors_ids return True, layers_errors_ids
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list expression_statement assignment identifier list expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier if_statement not_operator identifier block expression_statement call attribute identifier identifier argument_list list attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier try_statement block expression_statement assignment identifier binary_operator string string_start string_content string_end identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end integer expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end except_clause identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end subscript call attribute identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list list unary_operator integer identifier expression_statement call attribute identifier identifier argument_list identifier return_statement expression_list false identifier return_statement expression_list true identifier
Sync n layers in Solr.
def ensure_text(str_or_bytes, encoding='utf-8'): if not isinstance(str_or_bytes, six.text_type): return str_or_bytes.decode(encoding) return str_or_bytes
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block if_statement not_operator call identifier argument_list identifier attribute identifier identifier block return_statement call attribute identifier identifier argument_list identifier return_statement identifier
Ensures an input is a string, decoding if it is bytes.
def tag(message): release_ver = versioning.current() message = message or 'v{} release'.format(release_ver) with conf.within_proj_dir(): log.info("Creating release tag") git.tag( author=git.latest_commit().author, name='v{}'.format(release_ver), message=message, )
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier boolean_operator identifier call attribute string string_start string_content string_end identifier argument_list identifier with_statement with_clause with_item call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list keyword_argument identifier attribute call attribute identifier identifier argument_list identifier keyword_argument identifier call attribute string string_start string_content string_end identifier argument_list identifier keyword_argument identifier identifier
Tag the current commit with the current version.
def _make_plus_helper(obj, fields): new_obj = {} for key, value in obj.items(): if key in fields or key.startswith('_'): if fields.get(key): if isinstance(value, list): value = [_make_plus_helper(item, fields[key]) for item in value] new_obj[key] = value else: new_obj['+%s' % key] = value return new_obj
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement boolean_operator comparison_operator identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end block if_statement call attribute identifier identifier argument_list identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier list_comprehension call identifier argument_list identifier subscript identifier identifier for_in_clause identifier identifier expression_statement assignment subscript identifier identifier identifier else_clause block expression_statement assignment subscript identifier binary_operator string string_start string_content string_end identifier identifier return_statement identifier
add a + prefix to any fields in obj that aren't in fields
def addReference(self, reference): id_ = reference.getId() self._referenceIdMap[id_] = reference self._referenceNameMap[reference.getLocalId()] = reference self._referenceIds.append(id_)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment subscript attribute identifier identifier identifier identifier expression_statement assignment subscript attribute identifier identifier call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Adds the specified reference to this ReferenceSet.
def download(self, path): service_get_resp = requests.get(self.location, cookies={"session": self.session}) payload = service_get_resp.json() download_get_resp = requests.get(payload["content"]) with open(path, "wb") as config_file: config_file.write(download_get_resp.content)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier dictionary pair string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier
downloads a config resource to the path
def capitalized_words_percent(s): s = to_unicode(s, precise=True) words = re.split('\s', s) words = [w for w in words if w.strip()] words = [w for w in words if len(w) > 2] capitalized_words_counter = 0 valid_words_counter = 0 for word in words: if not INVALID_WORD_START.match(word): valid_words_counter += 1 if word[0].isupper() and not word[1].isupper(): capitalized_words_counter += 1 if valid_words_counter > 0 and len(words) > 1: return 100 * float(capitalized_words_counter) / valid_words_counter return 0
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier true expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier list_comprehension identifier for_in_clause identifier identifier if_clause call attribute identifier identifier argument_list expression_statement assignment identifier list_comprehension identifier for_in_clause identifier identifier if_clause comparison_operator call identifier argument_list identifier integer expression_statement assignment identifier integer expression_statement assignment identifier integer for_statement identifier identifier block if_statement not_operator call attribute identifier identifier argument_list identifier block expression_statement augmented_assignment identifier integer if_statement boolean_operator call attribute subscript identifier integer identifier argument_list not_operator call attribute subscript identifier integer identifier argument_list block expression_statement augmented_assignment identifier integer if_statement boolean_operator comparison_operator identifier integer comparison_operator call identifier argument_list identifier integer block return_statement binary_operator binary_operator integer call identifier argument_list identifier identifier return_statement integer
Returns capitalized words percent.
def _reorder(string, salt): len_salt = len(salt) if len_salt != 0: string = list(string) index, integer_sum = 0, 0 for i in range(len(string) - 1, 0, -1): integer = ord(salt[index]) integer_sum += integer j = (integer + index + integer_sum) % i string[i], string[j] = string[j], string[i] index = (index + 1) % len_salt string = ''.join(string) return string
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier integer block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment pattern_list identifier identifier expression_list integer integer for_statement identifier call identifier argument_list binary_operator call identifier argument_list identifier integer integer unary_operator integer block expression_statement assignment identifier call identifier argument_list subscript identifier identifier expression_statement augmented_assignment identifier identifier expression_statement assignment identifier binary_operator parenthesized_expression binary_operator binary_operator identifier identifier identifier identifier expression_statement assignment pattern_list subscript identifier identifier subscript identifier identifier expression_list subscript identifier identifier subscript identifier identifier expression_statement assignment identifier binary_operator parenthesized_expression binary_operator identifier integer identifier expression_statement assignment identifier call attribute string string_start string_end identifier argument_list identifier return_statement identifier
Reorders `string` according to `salt`.
def _sumDiceRolls(self, rollList): if isinstance(rollList, RollList): self.rolls.append(rollList) return rollList.sum() else: return rollList
module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list else_clause block return_statement identifier
convert from dice roll structure to a single integer result
def join_sentences(string1, string2, glue='.'): "concatenate two sentences together with punctuation glue" if not string1 or string1 == '': return string2 if not string2 or string2 == '': return string1 new_string = string1.rstrip() if not new_string.endswith(glue): new_string += glue new_string += ' ' + string2.lstrip() return new_string
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end block expression_statement string string_start string_content string_end if_statement boolean_operator not_operator identifier comparison_operator identifier string string_start string_end block return_statement identifier if_statement boolean_operator not_operator identifier comparison_operator identifier string string_start string_end block return_statement identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement not_operator call attribute identifier identifier argument_list identifier block expression_statement augmented_assignment identifier identifier expression_statement augmented_assignment identifier binary_operator string string_start string_content string_end call attribute identifier identifier argument_list return_statement identifier
concatenate two sentences together with punctuation glue
def read_count(self, space, start, end): read_counts = 0 for read in self._bam.fetch(space, start, end): read_counts += 1 return self._normalize(read_counts, self._total)
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier integer for_statement identifier call attribute attribute identifier identifier identifier argument_list identifier identifier identifier block expression_statement augmented_assignment identifier integer return_statement call attribute identifier identifier argument_list identifier attribute identifier identifier
Retrieve the normalized read count in the provided region.
def getChemicalPotential(self, solution): if isinstance(solution, Solution): solution = solution.getSolution() self.mu = self.solver.chemicalPotential(solution) return self.mu
module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list identifier return_statement attribute identifier identifier
Call solver in order to calculate chemical potential.
def cli_char(name, tibiadata, json): name = " ".join(name) char = _fetch_and_parse(Character.get_url, Character.from_content, Character.get_url_tibiadata, Character.from_tibiadata, tibiadata, name) if json and char: print(char.to_json(indent=2)) return print(get_character_string(char))
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier identifier identifier if_statement boolean_operator identifier identifier block expression_statement call identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier integer return_statement expression_statement call identifier argument_list call identifier argument_list identifier
Displays information about a Tibia character.
def value(self): if self.root.stale: self.root.update(self.root.now, None) return self._value
module function_definition identifier parameters identifier block if_statement attribute attribute identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier none return_statement attribute identifier identifier
Current value of the Node
def tables(subjects=None, pastDays=None, include_inactive=False, lang=DEFAULT_LANGUAGE): request = Request('tables', subjects=subjects, pastDays=pastDays, includeInactive=include_inactive, lang=lang) return (Table(table, lang=lang) for table in request.json)
module function_definition identifier parameters default_parameter identifier none default_parameter identifier none default_parameter identifier false default_parameter identifier identifier block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier return_statement generator_expression call identifier argument_list identifier keyword_argument identifier identifier for_in_clause identifier attribute identifier identifier
Find tables placed under given subjects.
def register(self, bucket, name_or_func, func=None): assert bucket in self, 'Bucket %s is unknown' % bucket if func is None and hasattr(name_or_func, '__name__'): name = name_or_func.__name__ func = name_or_func elif func: name = name_or_func if name in self[bucket]: raise AlreadyRegistered('The function %s is already registered' % name) self[bucket][name] = func
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none block assert_statement comparison_operator identifier identifier binary_operator string string_start string_content string_end identifier if_statement boolean_operator comparison_operator identifier none call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier identifier elif_clause identifier block expression_statement assignment identifier identifier if_statement comparison_operator identifier subscript identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment subscript subscript identifier identifier identifier identifier
Add a function to the registry by name
def peak_load(self): peak_load = pd.Series(self.consumption).mul(pd.Series( self.grid.network.config['peakload_consumption_ratio']).astype( float), fill_value=0) return peak_load
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list attribute identifier identifier identifier argument_list call attribute call attribute identifier identifier argument_list subscript attribute attribute attribute identifier identifier identifier identifier string string_start string_content string_end identifier argument_list identifier keyword_argument identifier integer return_statement identifier
Get sectoral peak load
def btc_tx_witness_strip( tx_serialized ): if not btc_tx_is_segwit(tx_serialized): return tx_serialized tx = btc_tx_deserialize(tx_serialized) for inp in tx['ins']: del inp['witness_script'] tx_stripped = btc_tx_serialize(tx) return tx_stripped
module function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list identifier block return_statement identifier expression_statement assignment identifier call identifier argument_list identifier for_statement identifier subscript identifier string string_start string_content string_end block delete_statement subscript identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier return_statement identifier
Strip the witness information from a serialized transaction
def place(self): self.place_children() self.canvas.append(self.parent.canvas, float(self.left), float(self.top))
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier call identifier argument_list attribute identifier identifier call identifier argument_list attribute identifier identifier
Place this container's canvas onto the parent container's canvas.
def refresh_content(self, order=None, name=None): order = order or self.content.order url = name or self.content.name if order == 'ignore': order = None with self.term.loader('Refreshing page'): self.content = SubmissionContent.from_url( self.reddit, url, self.term.loader, order=order, max_comment_cols=self.config['max_comment_cols']) if not self.term.loader.exception: self.nav = Navigator(self.content.get, page_index=-1)
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier boolean_operator identifier attribute attribute identifier identifier identifier expression_statement assignment identifier boolean_operator identifier attribute attribute identifier identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier none with_statement with_clause with_item call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier identifier attribute attribute identifier identifier identifier keyword_argument identifier identifier keyword_argument identifier subscript attribute identifier identifier string string_start string_content string_end if_statement not_operator attribute attribute attribute identifier identifier identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list attribute attribute identifier identifier identifier keyword_argument identifier unary_operator integer
Re-download comments and reset the page index
def _check_rev_dict(tree, ebt): ebs = defaultdict(dict) for edge in ebt.values(): source_id = edge['@source'] edge_id = edge['@id'] ebs[source_id][edge_id] = edge assert ebs == tree['edgeBySourceId']
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier for_statement identifier call attribute identifier identifier argument_list block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment subscript subscript identifier identifier identifier identifier assert_statement comparison_operator identifier subscript identifier string string_start string_content string_end
Verifyies that `ebt` is the inverse of the `edgeBySourceId` data member of `tree`
def render_to_response(self, *args, **kwargs): if self.request.path != self.object.get_absolute_url(): return HttpResponseRedirect(self.object.get_absolute_url()) return super(TalkView, self).render_to_response(*args, **kwargs)
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block if_statement comparison_operator attribute attribute identifier identifier identifier call attribute attribute identifier identifier identifier argument_list block return_statement call identifier argument_list call attribute attribute identifier identifier identifier argument_list return_statement call attribute call identifier argument_list identifier identifier identifier argument_list list_splat identifier dictionary_splat identifier
Canonicalize the URL if the slug changed
def _lookup_vultrid(which_key, availkey, keyname): if DETAILS == {}: _cache_provider_details() which_key = six.text_type(which_key) try: return DETAILS[availkey][which_key][keyname] except KeyError: return False
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator identifier dictionary block expression_statement call identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier try_statement block return_statement subscript subscript subscript identifier identifier identifier identifier except_clause identifier block return_statement false
Helper function to retrieve a Vultr ID
def _module_callers(parser, modname, result): if modname in result: return module = parser.get(modname) mresult = {} if module is not None: for xname, xinst in module.executables(): _exec_callers(xinst, mresult) result[modname] = mresult for depkey in module.dependencies: depmod = depkey.split('.')[0].lower() _module_callers(parser, depmod, result)
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator identifier identifier block return_statement expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier dictionary if_statement comparison_operator identifier none block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement call identifier argument_list identifier identifier expression_statement assignment subscript identifier identifier identifier for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute subscript call attribute identifier identifier argument_list string string_start string_content string_end integer identifier argument_list expression_statement call identifier argument_list identifier identifier identifier
Adds any calls to executables contained in the specified module.
def concretize(self, **kwargs): lengths = [self.state.solver.eval(x[1], **kwargs) for x in self.content] kwargs['cast_to'] = bytes return [b'' if i == 0 else self.state.solver.eval(x[0][i*self.state.arch.byte_width-1:], **kwargs) for i, x in zip(lengths, self.content)]
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier list_comprehension call attribute attribute attribute identifier identifier identifier identifier argument_list subscript identifier integer dictionary_splat identifier for_in_clause identifier attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier return_statement list_comprehension conditional_expression string string_start string_end comparison_operator identifier integer call attribute attribute attribute identifier identifier identifier identifier argument_list subscript subscript identifier integer slice binary_operator binary_operator identifier attribute attribute attribute identifier identifier identifier identifier integer dictionary_splat identifier for_in_clause pattern_list identifier identifier call identifier argument_list identifier attribute identifier identifier
Returns a list of the packets read or written as bytestrings.
def _update_data_out(self, data, dtype): try: self.data_out.update({dtype: data}) except AttributeError: self.data_out = {dtype: data}
module function_definition identifier parameters identifier identifier identifier block try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list dictionary pair identifier identifier except_clause identifier block expression_statement assignment attribute identifier identifier dictionary pair identifier identifier
Append the data of the given dtype_out to the data_out attr.
def send(colors, cache_dir=CACHE_DIR, to_send=True, vte_fix=False): if OS == "Darwin": tty_pattern = "/dev/ttys00[0-9]*" else: tty_pattern = "/dev/pts/[0-9]*" sequences = create_sequences(colors, vte_fix) if to_send: for term in glob.glob(tty_pattern): util.save_file(sequences, term) util.save_file(sequences, os.path.join(cache_dir, "sequences")) logging.info("Set terminal colors.")
module function_definition identifier parameters identifier default_parameter identifier identifier default_parameter identifier true default_parameter identifier false block if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end else_clause block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier identifier if_statement identifier block for_statement identifier call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end
Send colors to all open terminals.
def generate_gml(username, nodes, edges, cache=False): node_content = "" for i in range(len(nodes)): node_id = "\t\tid %d\n" % (i + 1) node_label = "\t\tlabel \"%s\"\n" % (nodes[i]) node_content += format_node(node_id, node_label) edge_content = "" for i in range(len(edges)): edge = edges[i] edge_source = "\t\tsource %d\n" % (nodes.index(edge[0]) + 1) edge_target = "\t\ttarget %d\n" % (nodes.index(edge[1]) + 1) edge_content += format_edge(edge_source, edge_target) content = format_content(node_content, edge_content) with open(username_to_file(username), 'w') as f: f.write(content) if cache: cache_file(username_to_file(username))
module function_definition identifier parameters identifier identifier identifier default_parameter identifier false block expression_statement assignment identifier string string_start string_end for_statement identifier call identifier argument_list call identifier argument_list identifier block expression_statement assignment identifier binary_operator string string_start string_content escape_sequence escape_sequence escape_sequence string_end parenthesized_expression binary_operator identifier integer expression_statement assignment identifier binary_operator string string_start string_content escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence string_end parenthesized_expression subscript identifier identifier expression_statement augmented_assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier string string_start string_end for_statement identifier call identifier argument_list call identifier argument_list identifier block expression_statement assignment identifier subscript identifier identifier expression_statement assignment identifier binary_operator string string_start string_content escape_sequence escape_sequence escape_sequence string_end parenthesized_expression binary_operator call attribute identifier identifier argument_list subscript identifier integer integer expression_statement assignment identifier binary_operator string string_start string_content escape_sequence escape_sequence escape_sequence string_end parenthesized_expression binary_operator call attribute identifier identifier argument_list subscript identifier integer integer expression_statement augmented_assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier with_statement with_clause with_item as_pattern call identifier argument_list call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement call identifier argument_list call identifier argument_list identifier
Generate a GML format file representing the given graph attributes
def invoke(self): unitdata.kv().flush() subprocess.check_call([self._filepath, '--invoke', self._test_output], env=os.environ)
module function_definition identifier parameters identifier block expression_statement call attribute call attribute identifier identifier argument_list identifier argument_list expression_statement call attribute identifier identifier argument_list list attribute identifier identifier string string_start string_content string_end attribute identifier identifier keyword_argument identifier attribute identifier identifier
Call the external handler to be invoked.
def com_google_fonts_check_name_match_familyname_fullfont(ttFont): from fontbakery.utils import get_name_entry_strings familyname = get_name_entry_strings(ttFont, NameID.FONT_FAMILY_NAME) fullfontname = get_name_entry_strings(ttFont, NameID.FULL_FONT_NAME) if len(familyname) == 0: yield FAIL, Message("no-font-family-name", ("Font lacks a NameID.FONT_FAMILY_NAME" " entry in the 'name' table.")) elif len(fullfontname) == 0: yield FAIL, Message("no-full-font-name", ("Font lacks a NameID.FULL_FONT_NAME" " entry in the 'name' table.")) else: fullfontname = fullfontname[0] familyname = familyname[0] if not fullfontname.startswith(familyname): yield FAIL, Message( "does-not", (" On the 'name' table, the full font name" " (NameID {} - FULL_FONT_NAME: '{}')" " does not begin with font family name" " (NameID {} - FONT_FAMILY_NAME:" " '{}')".format(NameID.FULL_FONT_NAME, familyname, NameID.FONT_FAMILY_NAME, fullfontname))) else: yield PASS, "Full font name begins with the font family name."
module function_definition identifier parameters identifier block import_from_statement dotted_name identifier identifier dotted_name identifier expression_statement assignment identifier call identifier argument_list identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier attribute identifier identifier if_statement comparison_operator call identifier argument_list identifier integer block expression_statement yield expression_list identifier call identifier argument_list string string_start string_content string_end parenthesized_expression concatenated_string string string_start string_content string_end string string_start string_content string_end elif_clause comparison_operator call identifier argument_list identifier integer block expression_statement yield expression_list identifier call identifier argument_list string string_start string_content string_end parenthesized_expression concatenated_string string string_start string_content string_end string string_start string_content string_end else_clause block expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier subscript identifier integer if_statement not_operator call attribute identifier identifier argument_list identifier block expression_statement yield expression_list identifier call identifier argument_list string string_start string_content string_end parenthesized_expression call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier argument_list attribute identifier identifier identifier attribute identifier identifier identifier else_clause block expression_statement yield expression_list identifier string string_start string_content string_end
Does full font name begin with the font family name?
def resolve_dependencies(self): self._concatenate_inner(True) self._concatenate_inner(False) self._insert_breaklines()
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list true expression_statement call attribute identifier identifier argument_list false expression_statement call attribute identifier identifier argument_list
Resolves chunk dependency by concatenating them.
def show_keypair(kwargs=None, call=None): if call != 'function': log.error( 'The show_keypair function must be called with -f or --function.' ) return False if not kwargs: kwargs = {} if 'keyname' not in kwargs: log.error('A keyname is required.') return False keypairs = list_keypairs(call='function') keyid = keypairs[kwargs['keyname']]['id'] log.debug('Key ID is %s', keyid) details = query(method='account/keys', command=keyid) return details
module function_definition identifier parameters default_parameter identifier none default_parameter identifier none block if_statement comparison_operator identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement false if_statement not_operator identifier block expression_statement assignment identifier dictionary if_statement comparison_operator string string_start string_content string_end identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement false expression_statement assignment identifier call identifier argument_list keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier subscript subscript identifier subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier return_statement identifier
Show the details of an SSH keypair
def handle_new_events(self, events): for event in events: self.events.append( self.create_event_object( event[0], event[1], int(event[2])))
module function_definition identifier parameters identifier identifier block for_statement identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list subscript identifier integer subscript identifier integer call identifier argument_list subscript identifier integer
Add each new events to the event queue.
def statement(self): return (self.assignment ^ self.expression) + Suppress( self.syntax.terminator)
module function_definition identifier parameters identifier block return_statement binary_operator parenthesized_expression binary_operator attribute identifier identifier attribute identifier identifier call identifier argument_list attribute attribute identifier identifier identifier
A terminated relational algebra statement.
def flatten(self): ls = [self.output] ls.extend(self.state) return ls
module function_definition identifier parameters identifier block expression_statement assignment identifier list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier return_statement identifier
Create a flattened version by putting output first and then states.
def _transfer_str(self, conn, tmp, name, data): if type(data) == dict: data = utils.jsonify(data) afd, afile = tempfile.mkstemp() afo = os.fdopen(afd, 'w') try: afo.write(data.encode('utf8')) except: raise errors.AnsibleError("failure encoding into utf-8") afo.flush() afo.close() remote = os.path.join(tmp, name) try: conn.put_file(afile, remote) finally: os.unlink(afile) return remote
module function_definition identifier parameters identifier identifier identifier identifier identifier block if_statement comparison_operator call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end try_statement block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end except_clause block raise_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier try_statement block expression_statement call attribute identifier identifier argument_list identifier identifier finally_clause block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
transfer string to remote file
def _get_auth(username, password): if username and password: return requests.auth.HTTPBasicAuth(username, password) else: return None
module function_definition identifier parameters identifier identifier block if_statement boolean_operator identifier identifier block return_statement call attribute attribute identifier identifier identifier argument_list identifier identifier else_clause block return_statement none
Returns the HTTP auth header
def write(self): with open(self.path, 'w') as file_: file_.write(self.content)
module function_definition identifier parameters identifier block with_statement with_clause with_item as_pattern call identifier argument_list attribute identifier identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier
Write content back to file.
def make_local_dirs(dl_dir, dl_inputs, keep_subdirs): if not os.path.isdir(dl_dir): os.makedirs(dl_dir) print('Created local base download directory: %s' % dl_dir) if keep_subdirs: dl_dirs = set([os.path.join(dl_dir, d[1]) for d in dl_inputs]) for d in dl_dirs: if not os.path.isdir(d): os.makedirs(d) return
module function_definition identifier parameters identifier identifier identifier block if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list binary_operator string string_start string_content string_end identifier if_statement identifier block expression_statement assignment identifier call identifier argument_list list_comprehension call attribute attribute identifier identifier identifier argument_list identifier subscript identifier integer for_in_clause identifier identifier for_statement identifier identifier block if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement
Make any required local directories to prepare for downloading
def save_cfg_vals_to_git_cfg(**cfg_map): for cfg_key_suffix, cfg_val in cfg_map.items(): cfg_key = f'cherry-picker.{cfg_key_suffix.replace("_", "-")}' cmd = "git", "config", "--local", cfg_key, cfg_val subprocess.check_call(cmd, stderr=subprocess.STDOUT)
module function_definition identifier parameters dictionary_splat_pattern identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment identifier string string_start string_content interpolation call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end string_end expression_statement assignment identifier expression_list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier identifier expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier
Save a set of options into Git config.
def _set_size_code(self): if not self._op.startswith(self.SIZE): self._size_code = None return if len(self._op) == len(self.SIZE): self._size_code = self.SZ_EQ else: suffix = self._op[len(self.SIZE):] self._size_code = self.SZ_MAPPING.get(suffix, None) if self._size_code is None: raise ValueError('invalid "{}" suffix "{}"'.format(self.SIZE, suffix))
module function_definition identifier parameters identifier block if_statement not_operator call attribute attribute identifier identifier identifier argument_list attribute identifier identifier block expression_statement assignment attribute identifier identifier none return_statement if_statement comparison_operator call identifier argument_list attribute identifier identifier call identifier argument_list attribute identifier identifier block expression_statement assignment attribute identifier identifier attribute identifier identifier else_clause block expression_statement assignment identifier subscript attribute identifier identifier slice call identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list identifier none if_statement comparison_operator attribute identifier identifier none block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier identifier
Set the code for a size operation.
def delete(self, filename): self._failed_atoms.clear() self.clear() self.save(filename, padding=lambda x: 0)
module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier lambda lambda_parameters identifier integer
Remove the metadata from the given filename.
def from_cn(cls, common_name): result_cn = [(cert['id'], [cert['cn']] + cert['altnames']) for cert in cls.list({'status': ['pending', 'valid'], 'items_per_page': 500, 'cn': common_name})] result_alt = [(cert['id'], [cert['cn']] + cert['altnames']) for cert in cls.list({'status': ['pending', 'valid'], 'items_per_page': 500, 'altname': common_name})] result = result_cn + result_alt ret = {} for id_, fqdns in result: for fqdn in fqdns: ret.setdefault(fqdn, []).append(id_) cert_id = ret.get(common_name) if not cert_id: return return cert_id
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list_comprehension tuple subscript identifier string string_start string_content string_end binary_operator list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end for_in_clause identifier call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end list string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end integer pair string string_start string_content string_end identifier expression_statement assignment identifier list_comprehension tuple subscript identifier string string_start string_content string_end binary_operator list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end for_in_clause identifier call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end list string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end integer pair string string_start string_content string_end identifier expression_statement assignment identifier binary_operator identifier identifier expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier identifier block for_statement identifier identifier block expression_statement call attribute call attribute identifier identifier argument_list identifier list identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator identifier block return_statement return_statement identifier
Retrieve a certificate by its common name.
def path_iter(self, include_self=True): if include_self: node = self else: node = self.parent while node is not None: yield node node = node.parent
module function_definition identifier parameters identifier default_parameter identifier true block if_statement identifier block expression_statement assignment identifier identifier else_clause block expression_statement assignment identifier attribute identifier identifier while_statement comparison_operator identifier none block expression_statement yield identifier expression_statement assignment identifier attribute identifier identifier
Yields back the path from this node to the root node.
def find_tag(match: str, strict: bool, directory: str): with suppress(CalledProcessError): echo(git.find_tag(match, strict=strict, git_dir=directory))
module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier block with_statement with_clause with_item call identifier argument_list identifier block expression_statement call identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier
Find tag for git repository.
def sync_readmes(): print("syncing README") with open("README.md", 'r') as reader: file_text = reader.read() with open("README", 'w') as writer: writer.write(file_text)
module function_definition identifier parameters block expression_statement call identifier argument_list string string_start string_content string_end with_statement with_clause with_item as_pattern call identifier argument_list string string_start string_content string_end string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list with_statement with_clause with_item as_pattern call identifier argument_list string string_start string_content string_end string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier
just copies README.md into README for pypi documentation
def _collectAxisPoints(self): for l, (value, deltaName) in self.items(): location = Location(l) name = location.isOnAxis() if name is not None and name is not False: if name not in self._axes: self._axes[name] = [] if l not in self._axes[name]: self._axes[name].append(l) return self._axes
module function_definition identifier parameters identifier block for_statement pattern_list identifier tuple_pattern identifier identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement boolean_operator comparison_operator identifier none comparison_operator identifier false block if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier list if_statement comparison_operator identifier subscript attribute identifier identifier identifier block expression_statement call attribute subscript attribute identifier identifier identifier identifier argument_list identifier return_statement attribute identifier identifier
Return a dictionary with all on-axis locations.
def find_generator_as_statement(node): return ( isinstance(node, ast.Expr) and isinstance(node.value, ast.GeneratorExp) )
module function_definition identifier parameters identifier block return_statement parenthesized_expression boolean_operator call identifier argument_list identifier attribute identifier identifier call identifier argument_list attribute identifier identifier attribute identifier identifier
Finds a generator as a statement
def endpoint_is_activated(endpoint_id, until, absolute_time): client = get_client() res = client.endpoint_get_activation_requirements(endpoint_id) def fail(deadline=None): exp_string = "" if deadline is not None: exp_string = " or will expire within {} seconds".format(deadline) message = "The endpoint is not activated{}.\n\n".format( exp_string ) + activation_requirements_help_text(res, endpoint_id) formatted_print(res, simple_text=message) click.get_current_context().exit(1) def success(msg, *format_params): formatted_print(res, simple_text=(msg.format(endpoint_id, *format_params))) click.get_current_context().exit(0) if res["expires_in"] == -1: success("{} does not require activation") if until is None: if res.active_until(0): success("{} is activated") fail() if res.active_until(until, relative_time=not absolute_time): success("{} will be active for at least {} seconds", until) else: fail(deadline=until)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier function_definition identifier parameters default_parameter identifier none block expression_statement assignment identifier string string_start string_end if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier binary_operator call attribute string string_start string_content escape_sequence escape_sequence string_end identifier argument_list identifier call identifier argument_list identifier identifier expression_statement call identifier argument_list identifier keyword_argument identifier identifier expression_statement call attribute call attribute identifier identifier argument_list identifier argument_list integer function_definition identifier parameters identifier list_splat_pattern identifier block expression_statement call identifier argument_list identifier keyword_argument identifier parenthesized_expression call attribute identifier identifier argument_list identifier list_splat identifier expression_statement call attribute call attribute identifier identifier argument_list identifier argument_list integer if_statement comparison_operator subscript identifier string string_start string_content string_end unary_operator integer block expression_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier none block if_statement call attribute identifier identifier argument_list integer block expression_statement call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list if_statement call attribute identifier identifier argument_list identifier keyword_argument identifier not_operator identifier block expression_statement call identifier argument_list string string_start string_content string_end identifier else_clause block expression_statement call identifier argument_list keyword_argument identifier identifier
Executor for `globus endpoint is-activated`
def check_hints(self, reply): try: f_ind = reply.index("hints") l_ind = reply.rindex("hints") except Exception: fail_reason = vdp_const.hints_failure_reason % (reply) LOG.error("%s", fail_reason) return False, fail_reason if f_ind != l_ind: fail_reason = vdp_const.multiple_hints_failure_reason % (reply) LOG.error("%s", fail_reason) return False, fail_reason try: hints_compl = reply.partition("hints")[2] hints_val = reply.partition("hints")[2][0:4] len_hints = int(hints_val) hints_val = hints_compl[4:4 + len_hints] hints = int(hints_val) if hints != 0: fail_reason = vdp_const.nonzero_hints_failure % (hints) return False, fail_reason except ValueError: fail_reason = vdp_const.format_failure_reason % (reply) LOG.error("%s", fail_reason) return False, fail_reason return True, None
module function_definition identifier parameters identifier identifier block try_statement block 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 except_clause identifier block expression_statement assignment identifier binary_operator attribute identifier identifier parenthesized_expression identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement expression_list false identifier if_statement comparison_operator identifier identifier block expression_statement assignment identifier binary_operator attribute identifier identifier parenthesized_expression identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement expression_list false identifier try_statement block expression_statement assignment identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end integer expression_statement assignment identifier subscript subscript call attribute identifier identifier argument_list string string_start string_content string_end integer slice integer integer expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier subscript identifier slice integer binary_operator integer identifier expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier integer block expression_statement assignment identifier binary_operator attribute identifier identifier parenthesized_expression identifier return_statement expression_list false identifier except_clause identifier block expression_statement assignment identifier binary_operator attribute identifier identifier parenthesized_expression identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement expression_list false identifier return_statement expression_list true none
Parse the hints to check for errors.
def _get_output(algorithm, iport=0, iconnection=0, oport=0, active_scalar=None, active_scalar_field='point'): ido = algorithm.GetInputDataObject(iport, iconnection) data = wrap(algorithm.GetOutputDataObject(oport)) data.copy_meta_from(ido) if active_scalar is not None: data.set_active_scalar(active_scalar, preference=active_scalar_field) return data
module function_definition identifier parameters identifier default_parameter identifier integer default_parameter identifier integer default_parameter identifier integer default_parameter identifier none default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier return_statement identifier
A helper to get the algorithm's output and copy input's vtki meta info
def compute_update_ratio(weight_tensors, before_weights, after_weights): deltas = [after - before for after, before in zip(after_weights, before_weights)] delta_norms = [np.linalg.norm(d.ravel()) for d in deltas] weight_norms = [np.linalg.norm(w.ravel()) for w in before_weights] ratios = [d / w for d, w in zip(delta_norms, weight_norms)] all_summaries = [ tf.Summary.Value(tag='update_ratios/' + tensor.name, simple_value=ratio) for tensor, ratio in zip(weight_tensors, ratios)] return tf.Summary(value=all_summaries)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier list_comprehension binary_operator identifier identifier for_in_clause pattern_list identifier identifier call identifier argument_list identifier identifier expression_statement assignment identifier list_comprehension call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list for_in_clause identifier identifier expression_statement assignment identifier list_comprehension call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list for_in_clause identifier identifier expression_statement assignment identifier list_comprehension binary_operator identifier identifier for_in_clause pattern_list identifier identifier call identifier argument_list identifier identifier expression_statement assignment identifier list_comprehension call attribute attribute identifier identifier identifier argument_list keyword_argument identifier binary_operator string string_start string_content string_end attribute identifier identifier keyword_argument identifier identifier for_in_clause pattern_list identifier identifier call identifier argument_list identifier identifier return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier
Compute the ratio of gradient norm to weight norm.
def register(self, x, graph=False): if graph: from inspect import signature parameters = list(signature(x).parameters) required_parameters = {"plugins", "services", "strategy"} assert ( len(parameters) > 0 and parameters[0] == "graph" ), 'First parameter of a graph api function must be "graph".' assert ( required_parameters.intersection(parameters) == required_parameters ), "Graph api functions must define the following parameters: " + ", ".join(sorted(required_parameters)) self.__all__.append(get_name(x)) return x
module function_definition identifier parameters identifier identifier default_parameter identifier false block if_statement identifier block import_from_statement dotted_name identifier dotted_name identifier expression_statement assignment identifier call identifier argument_list attribute call identifier argument_list identifier identifier expression_statement assignment identifier set string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end assert_statement parenthesized_expression boolean_operator comparison_operator call identifier argument_list identifier integer comparison_operator subscript identifier integer string string_start string_content string_end string string_start string_content string_end assert_statement parenthesized_expression comparison_operator call attribute identifier identifier argument_list identifier identifier binary_operator string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier return_statement identifier
Register a function as being part of an API, then returns the original function.
def _scale(self): if self._scale_to_box: scale = 100.0 / self.mesh.scale else: scale = 1.0 return scale
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement assignment identifier binary_operator float attribute attribute identifier identifier identifier else_clause block expression_statement assignment identifier float return_statement identifier
Scaling factor for precision.
def _get_value(self, entity): value = super(_ClassKeyProperty, self)._get_value(entity) if not value: value = entity._class_key() self._store_value(entity, value) return value
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute call identifier argument_list identifier identifier identifier argument_list identifier if_statement not_operator identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier identifier return_statement identifier
Compute and store a default value if necessary.
def new(self): new_dashboard = models.Dashboard( dashboard_title='[ untitled dashboard ]', owners=[g.user], ) db.session.add(new_dashboard) db.session.commit() return redirect(f'/superset/dashboard/{new_dashboard.id}/?edit=true')
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list return_statement call identifier argument_list string string_start string_content interpolation attribute identifier identifier string_content string_end
Creates a new, blank dashboard and redirects to it in edit mode
def preload_pages(): try: _add_url_rule([page.url for page in Page.query.all()]) except Exception: current_app.logger.warn('Pages were not loaded.') raise
module function_definition identifier parameters block try_statement block expression_statement call identifier argument_list list_comprehension attribute identifier identifier for_in_clause identifier call attribute attribute identifier identifier identifier argument_list except_clause identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end raise_statement
Register all pages before the first application request.
def buffer(self, byte_offset=0): contents = self.ptr.contents ptr = addressof(contents.buffer.contents) + byte_offset length = contents.length * 4 - byte_offset return buffer((c_char * length).from_address(ptr).raw) \ if length else None
module function_definition identifier parameters identifier default_parameter identifier integer block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier binary_operator call identifier argument_list attribute attribute identifier identifier identifier identifier expression_statement assignment identifier binary_operator binary_operator attribute identifier identifier integer identifier return_statement conditional_expression call identifier argument_list attribute call attribute parenthesized_expression binary_operator identifier identifier identifier argument_list identifier identifier line_continuation identifier none
Get a copy of the map buffer
def _get_swig_version(env, swig): swig = env.subst(swig) pipe = SCons.Action._subproc(env, SCons.Util.CLVar(swig) + ['-version'], stdin = 'devnull', stderr = 'devnull', stdout = subprocess.PIPE) if pipe.wait() != 0: return out = SCons.Util.to_str(pipe.stdout.read()) match = re.search('SWIG Version\s+(\S+).*', out, re.MULTILINE) if match: if verbose: print("Version is:%s"%match.group(1)) return match.group(1) else: if verbose: print("Unable to detect version: [%s]"%out)
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 attribute identifier identifier identifier argument_list identifier binary_operator call attribute attribute identifier identifier identifier argument_list identifier list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier attribute identifier identifier if_statement comparison_operator call attribute identifier identifier argument_list integer block return_statement expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier attribute identifier identifier if_statement identifier block if_statement identifier block expression_statement call identifier argument_list binary_operator string string_start string_content string_end call attribute identifier identifier argument_list integer return_statement call attribute identifier identifier argument_list integer else_clause block if_statement identifier block expression_statement call identifier argument_list binary_operator string string_start string_content string_end identifier
Run the SWIG command line tool to get and return the version number
def reference_image_path(cls, project, location, product, reference_image): return google.api_core.path_template.expand( "projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}", project=project, location=location, product=product, reference_image=reference_image, )
module function_definition identifier parameters identifier identifier identifier identifier identifier block return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
Return a fully-qualified reference_image string.
def _action_enabled(self, event, action): event_actions = self._aconfig.get(event) if event_actions is None: return True if event_actions is False: return False return action in event_actions
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator identifier none block return_statement true if_statement comparison_operator identifier false block return_statement false return_statement comparison_operator identifier identifier
Check if an action for a notification is enabled.
def _function_handler(function, args, kwargs, future): future.set_running_or_notify_cancel() try: result = function(*args, **kwargs) except BaseException as error: error.traceback = format_exc() future.set_exception(error) else: future.set_result(result)
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement call attribute identifier identifier argument_list try_statement block expression_statement assignment identifier call identifier argument_list list_splat identifier dictionary_splat identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement assignment attribute identifier identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier
Runs the actual function in separate thread and returns its result.
def stopWater(self, dev_id): path = 'device/stop_water' payload = {'id': dev_id} return self.rachio.put(path, payload)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier identifier
Stop all watering on device.
def strip_punctuation_space(value): "Strip excess whitespace prior to punctuation." def strip_punctuation(string): replacement_list = ( (' .', '.'), (' :', ':'), ('( ', '('), (' )', ')'), ) for match, replacement in replacement_list: string = string.replace(match, replacement) return string if value == None: return None if type(value) == list: return [strip_punctuation(v) for v in value] return strip_punctuation(value)
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end function_definition identifier parameters identifier block expression_statement assignment identifier tuple tuple string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end for_statement pattern_list identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier return_statement identifier if_statement comparison_operator identifier none block return_statement none if_statement comparison_operator call identifier argument_list identifier identifier block return_statement list_comprehension call identifier argument_list identifier for_in_clause identifier identifier return_statement call identifier argument_list identifier
Strip excess whitespace prior to punctuation.