code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def list_pools(self, retrieve_all=True, **_params): return self.list('pools', self.pools_path, retrieve_all, **_params)
module function_definition identifier parameters identifier default_parameter identifier true dictionary_splat_pattern identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier identifier dictionary_splat identifier
Fetches a list of all load balancer pools for a project.
def cli(obj): client = obj['client'] status = client.mgmt_status() now = datetime.fromtimestamp(int(status['time']) / 1000.0) uptime = datetime(1, 1, 1) + timedelta(seconds=int(status['uptime']) / 1000.0) click.echo('{} up {} days {:02d}:{:02d}'.format( now.strftime('%H:%M'), uptime.day - 1, uptime.hour, uptime.minute ))
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator call identifier argument_list subscript identifier string string_start string_content string_end float expression_statement assignment identifier binary_operator call identifier argument_list integer integer integer call identifier argument_list keyword_argument identifier binary_operator call identifier argument_list subscript identifier string string_start string_content string_end float expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end binary_operator attribute identifier identifier integer attribute identifier identifier attribute identifier identifier
Display API server uptime in days, hours.
def resources(self): resources = [] for endpoint in self.endpoints: resource_type = endpoint.Meta.resource_type table = endpoint.Meta.table url = endpoint.name resources.append((resource_type, {'table': table, 'url': url})) return resources
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier attribute identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list tuple identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier return_statement identifier
Return list of all registered resources.
def filter(self, names): names = list_strings(names) fnames = [] for f in names: for pat in self.pats: if fnmatch.fnmatch(f, pat): fnames.append(f) return fnames
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier list for_statement identifier identifier block for_statement identifier attribute identifier identifier block if_statement call attribute identifier identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Returns a list with the names matching the pattern.
def nt(graph): from rdflib import ConjunctiveGraph from rdflib.plugin import register, Parser register('json-ld', Parser, 'rdflib_jsonld.parser', 'JsonLDParser') click.echo( ConjunctiveGraph().parse( data=_jsonld(graph, 'expand'), format='json-ld', ).serialize(format='nt') )
module function_definition identifier parameters identifier block import_from_statement dotted_name identifier dotted_name identifier import_from_statement dotted_name identifier identifier dotted_name identifier dotted_name identifier expression_statement call identifier argument_list string string_start string_content string_end identifier string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call attribute call attribute call identifier argument_list identifier argument_list keyword_argument identifier call identifier argument_list identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end identifier argument_list keyword_argument identifier string string_start string_content string_end
Format graph as n-tuples.
def dms2dd(d,m,s): if d < 0: sign = -1 else: sign = 1 dd = sign * (int(abs(d)) + float(m) / 60 + float(s) / 3600) return dd
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator identifier integer block expression_statement assignment identifier unary_operator integer else_clause block expression_statement assignment identifier integer expression_statement assignment identifier binary_operator identifier parenthesized_expression binary_operator binary_operator call identifier argument_list call identifier argument_list identifier binary_operator call identifier argument_list identifier integer binary_operator call identifier argument_list identifier integer return_statement identifier
Convert degrees, minutes, seconds to decimal degrees
def dump_database(id): log("Generating a backup of the database on Heroku...") dump_filename = "data.dump" data_directory = "data" dump_dir = os.path.join(data_directory, id) if not os.path.exists(dump_dir): os.makedirs(dump_dir) subprocess.call("heroku pg:backups capture --app " + id, shell=True) backup_url = subprocess.check_output( "heroku pg:backups public-url --app " + id, shell=True) backup_url = backup_url.replace('"', '').rstrip() backup_url = re.search("https:.*", backup_url).group(0) print(backup_url) log("Downloading the backup...") dump_path = os.path.join(dump_dir, dump_filename) with open(dump_path, 'wb') as file: subprocess.call(['curl', '-o', dump_path, backup_url], stdout=file) return dump_path
module function_definition identifier parameters identifier block expression_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier keyword_argument identifier true expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier keyword_argument identifier true expression_statement assignment identifier call attribute call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end identifier argument_list expression_statement assignment identifier call attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier argument_list integer expression_statement call identifier argument_list identifier expression_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier 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 list string string_start string_content string_end string string_start string_content string_end identifier identifier keyword_argument identifier identifier return_statement identifier
Backup the Postgres database locally.
def read_local_manifest(self): manifest = file_or_default(self.get_full_file_path(self.manifest_file), { 'format_version' : 2, 'root' : '/', 'have_revision' : 'root', 'files' : {}}, json.loads) if 'format_version' not in manifest or manifest['format_version'] < 2: raise SystemExit('Please update the client manifest format') return manifest
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier dictionary pair string string_start string_content string_end integer pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end dictionary attribute identifier identifier if_statement boolean_operator comparison_operator string string_start string_content string_end identifier comparison_operator subscript identifier string string_start string_content string_end integer block raise_statement call identifier argument_list string string_start string_content string_end return_statement identifier
Read the file manifest, or create a new one if there isn't one already
def badge(pipeline_id): if not pipeline_id.startswith('./'): pipeline_id = './' + pipeline_id pipeline_status = status.get(pipeline_id) status_color = 'lightgray' if pipeline_status.pipeline_details: status_text = pipeline_status.state().lower() last_execution = pipeline_status.get_last_execution() success = last_execution.success if last_execution else None if success is True: stats = last_execution.stats if last_execution else None record_count = stats.get('count_of_rows') if record_count is not None: status_text += ' (%d records)' % record_count status_color = 'brightgreen' elif success is False: status_color = 'red' else: status_text = "not found" return _make_badge_response('pipeline', status_text, status_color)
module function_definition identifier parameters identifier block if_statement not_operator call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier string string_start string_content string_end if_statement attribute identifier identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier conditional_expression attribute identifier identifier identifier none if_statement comparison_operator identifier true block expression_statement assignment identifier conditional_expression attribute identifier identifier identifier none expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier none block expression_statement augmented_assignment identifier binary_operator string string_start string_content string_end identifier expression_statement assignment identifier string string_start string_content string_end elif_clause comparison_operator identifier false 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 return_statement call identifier argument_list string string_start string_content string_end identifier identifier
An individual pipeline status
def search_string(self): self.__normalize() tmpl_source = unicode(open(self.tmpl_file).read()) compiler = Compiler() template = compiler.compile(tmpl_source) out = template(self) if not out: return False out = ''.join(out) out = re.sub('\n', '', out) out = re.sub('\s{3,}', ' ', out) out = re.sub(',\s*([}\\]])', '\\1', out) out = re.sub('([{\\[}\\]])(,?)\s*([{\\[}\\]])', '\\1\\2\\3', out) out = re.sub('\s*([{\\[\\]}:,])\s*', '\\1', out) return out
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list call attribute call identifier argument_list attribute identifier identifier identifier argument_list expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier if_statement not_operator identifier block return_statement false expression_statement assignment identifier call attribute string string_start string_end identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end string string_start string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end string string_start string_content escape_sequence string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content escape_sequence escape_sequence escape_sequence escape_sequence string_end string string_start string_content escape_sequence escape_sequence escape_sequence string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content escape_sequence escape_sequence string_end string string_start string_content escape_sequence string_end identifier return_statement identifier
Returns the JSON string that LendingClub expects for it's search
def crl(self): revoked_certs = self.get_revoked_certs() crl = crypto.CRL() now_str = timezone.now().strftime(generalized_time) for cert in revoked_certs: revoked = crypto.Revoked() revoked.set_serial(bytes_compat(cert.serial_number)) revoked.set_reason(b'unspecified') revoked.set_rev_date(bytes_compat(now_str)) crl.add_revoked(revoked) return crl.export(self.x509, self.pkey, days=1, digest=b'sha256')
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 expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list identifier for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list call identifier argument_list attribute 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 call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier keyword_argument identifier integer keyword_argument identifier string string_start string_content string_end
Returns up to date CRL of this CA
def _pypi_head_package(dependency): if dependency.specs: _, version = dependency.specs[0] url = BASE_PYPI_URL_WITH_VERSION.format(name=dependency.project_name, version=version) else: url = BASE_PYPI_URL.format(name=dependency.project_name) logger.debug("Doing HEAD requests against %s", url) req = request.Request(url, method='HEAD') try: response = request.urlopen(req) except HTTPError as http_error: if http_error.code == HTTP_STATUS_NOT_FOUND: return False else: raise if response.status == HTTP_STATUS_OK: logger.debug("%r exists in PyPI.", dependency) return True else: logger.warning("Got a (unexpected) HTTP_STATUS=%r and reason=%r checking if %r exists", response.status, response.reason, dependency) return True
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement assignment pattern_list identifier identifier subscript attribute identifier identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block if_statement comparison_operator attribute identifier identifier identifier block return_statement false else_clause block raise_statement if_statement comparison_operator attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement true else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier attribute identifier identifier identifier return_statement true
Hit pypi with a http HEAD to check if pkg_name exists.
def _create_cached_iter(self): for scn in self._scene_gen: self._scene_cache.append(scn) yield scn
module function_definition identifier parameters identifier block for_statement identifier attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement yield identifier
Iterate over the provided scenes, caching them for later.
def _make_path(self, path, name): if not os.path.exists(path): os.mkdirs(path) if os.path.isdir(path) : return os.path.join(path, name) return path
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 if_statement call attribute attribute identifier identifier identifier argument_list identifier block return_statement call attribute attribute identifier identifier identifier argument_list identifier identifier return_statement identifier
Makes directories as needed
def dump_map(file: TextIO = sys.stdout) -> None: pp = pprint.PrettyPrinter(indent=4, stream=file) print("Type map: ", file=file) pp.pprint(TYPE_MAP)
module function_definition identifier parameters typed_default_parameter identifier type identifier attribute identifier identifier type none block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier integer keyword_argument identifier identifier expression_statement call identifier argument_list string string_start string_content string_end keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier
Prints the JSON "registered types" map to the specified file.
def save_catalog(self, catalog_form, *args, **kwargs): if catalog_form.is_for_update(): return self.update_catalog(catalog_form, *args, **kwargs) else: return self.create_catalog(catalog_form, *args, **kwargs)
module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block if_statement call attribute identifier identifier argument_list block return_statement call attribute identifier identifier argument_list identifier list_splat identifier dictionary_splat identifier else_clause block return_statement call attribute identifier identifier argument_list identifier list_splat identifier dictionary_splat identifier
Pass through to provider CatalogAdminSession.update_catalog
def add_annotation(self, entity, annotation, value): url = self.base_path + 'term/add-annotation' data = {'tid': entity['id'], 'annotation_tid': annotation['id'], 'value': value, 'term_version': entity['version'], 'annotation_term_version': annotation['version']} return self.post(url, data)
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier binary_operator attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end subscript identifier string string_start string_content string_end pair string string_start string_content string_end subscript identifier string string_start string_content string_end pair string string_start string_content string_end identifier pair string string_start string_content string_end subscript identifier string string_start string_content string_end pair string string_start string_content string_end subscript identifier string string_start string_content string_end return_statement call attribute identifier identifier argument_list identifier identifier
Adds an annotation proprty to existing entity
def hook(self, name): def wrapper(func): self.hooks.add(name, func) return func return wrapper
module function_definition identifier parameters identifier identifier block function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier return_statement identifier return_statement identifier
Return a decorator that attaches a callback to a hook.
def _hm_send_msg(self, message): try: serial_message = message self.conn.write(serial_message) except serial.SerialTimeoutException: serror = "Write timeout error: \n" sys.stderr.write(serror) byteread = self.conn.read(159) datal = list(byteread) return datal
module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier except_clause attribute identifier identifier block expression_statement assignment identifier string string_start string_content escape_sequence string_end expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list integer expression_statement assignment identifier call identifier argument_list identifier return_statement identifier
This is the only interface to the serial connection.
def _prevent_core_dump(cls): try: resource.getrlimit(resource.RLIMIT_CORE) except ValueError: return else: resource.setrlimit(resource.RLIMIT_CORE, (0, 0))
module function_definition identifier parameters identifier block try_statement block expression_statement call attribute identifier identifier argument_list attribute identifier identifier except_clause identifier block return_statement else_clause block expression_statement call attribute identifier identifier argument_list attribute identifier identifier tuple integer integer
Prevent the process from generating a core dump.
def _recursive_matches(self, nodes, count): assert self.content is not None if count >= self.min: yield 0, {} if count < self.max: for alt in self.content: for c0, r0 in generate_matches(alt, nodes): for c1, r1 in self._recursive_matches(nodes[c0:], count+1): r = {} r.update(r0) r.update(r1) yield c0 + c1, r
module function_definition identifier parameters identifier identifier identifier block assert_statement comparison_operator attribute identifier identifier none if_statement comparison_operator identifier attribute identifier identifier block expression_statement yield expression_list integer dictionary if_statement comparison_operator identifier attribute identifier identifier block for_statement identifier attribute identifier identifier block for_statement pattern_list identifier identifier call identifier argument_list identifier identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list subscript identifier slice identifier binary_operator identifier integer block expression_statement assignment identifier dictionary expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement yield expression_list binary_operator identifier identifier identifier
Helper to recursively yield the matches.
def ConnectHandler(*args, **kwargs): if kwargs["device_type"] not in platforms: raise ValueError( "Unsupported device_type: " "currently supported platforms are: {}".format(platforms_str) ) ConnectionClass = ssh_dispatcher(kwargs["device_type"]) return ConnectionClass(*args, **kwargs)
module function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block if_statement comparison_operator subscript identifier string string_start string_content string_end identifier block raise_statement call identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier call identifier argument_list subscript identifier string string_start string_content string_end return_statement call identifier argument_list list_splat identifier dictionary_splat identifier
Factory function selects the proper class and creates object based on device_type.
def divide(n, m): avg = int(n / m) remain = n - m * avg data = list(itertools.repeat(avg, m)) for i in range(len(data)): if not remain: break data[i] += 1 remain -= 1 return data
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list binary_operator identifier identifier expression_statement assignment identifier binary_operator identifier binary_operator identifier identifier expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list identifier identifier for_statement identifier call identifier argument_list call identifier argument_list identifier block if_statement not_operator identifier block break_statement expression_statement augmented_assignment subscript identifier identifier integer expression_statement augmented_assignment identifier integer return_statement identifier
Divide integer n to m chunks
def delta(self, signature): "Generates delta for remote file via API using local file's signature." return self.api.post('path/sync/delta', self.path, signature=signature)
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end return_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end attribute identifier identifier keyword_argument identifier identifier
Generates delta for remote file via API using local file's signature.
def _renderBlockDevice(self, block_device, build): rendered_block_device = yield build.render(block_device) if rendered_block_device['volume_size'] is None: source_type = rendered_block_device['source_type'] source_uuid = rendered_block_device['uuid'] volume_size = self._determineVolumeSize(source_type, source_uuid) rendered_block_device['volume_size'] = volume_size return rendered_block_device
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier yield call attribute identifier identifier argument_list identifier if_statement comparison_operator subscript identifier string string_start string_content string_end none 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 identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier return_statement identifier
Render all of the block device's values.
def value(self): length = self._value.find(b'\x00') if length >= 0: return self._value[:length].decode('ascii') else: return self._value.decode('ascii')
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content escape_sequence string_end if_statement comparison_operator identifier integer block return_statement call attribute subscript attribute identifier identifier slice identifier identifier argument_list string string_start string_content string_end else_clause block return_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end
Field value as an ascii encoded string.
def state_reachable(subsystem): tpm = subsystem.tpm[..., subsystem.node_indices] test = tpm - np.array(subsystem.proper_state) if not np.any(np.logical_and(-1 < test, test < 1).all(-1)): raise exceptions.StateUnreachableError(subsystem.state)
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript attribute identifier identifier ellipsis attribute identifier identifier expression_statement assignment identifier binary_operator identifier call attribute identifier identifier argument_list attribute identifier identifier if_statement not_operator call attribute identifier identifier argument_list call attribute call attribute identifier identifier argument_list comparison_operator unary_operator integer identifier comparison_operator identifier integer identifier argument_list unary_operator integer block raise_statement call attribute identifier identifier argument_list attribute identifier identifier
Return whether a state can be reached according to the network's TPM.
def _structure_set(self, obj, cl): if is_bare(cl) or cl.__args__[0] is Any: return set(obj) else: elem_type = cl.__args__[0] return { self._structure_func.dispatch(elem_type)(e, elem_type) for e in obj }
module function_definition identifier parameters identifier identifier identifier block if_statement boolean_operator call identifier argument_list identifier comparison_operator subscript attribute identifier identifier integer identifier block return_statement call identifier argument_list identifier else_clause block expression_statement assignment identifier subscript attribute identifier identifier integer return_statement set_comprehension call call attribute attribute identifier identifier identifier argument_list identifier argument_list identifier identifier for_in_clause identifier identifier
Convert an iterable into a potentially generic set.
def next(self): if not hasattr(self, '_iter'): self._iter = self.readrow_as_dict() return self._iter.next()
module function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list return_statement call attribute attribute identifier identifier identifier argument_list
Retrieve the next row.
def sampling_volume_value(self): svi = self.pdx.SamplingVolume tli = self.pdx.TransmitLength return self._sampling_volume_value(svi, tli)
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier attribute attribute identifier identifier identifier return_statement call attribute identifier identifier argument_list identifier identifier
Returns the device samping volume value in m.
def _get_default_projection(cls): projected = [] neutral = [] omitted = False for name, field in cls.__fields__.items(): if field.project is None: neutral.append(name) elif field.project: projected.append(name) else: omitted = True if not projected and not omitted: return None elif not projected and omitted: projected = neutral return {field: True for field in projected}
module function_definition identifier parameters identifier block expression_statement assignment identifier list expression_statement assignment identifier list expression_statement assignment identifier false for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute identifier identifier argument_list identifier elif_clause attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment identifier true if_statement boolean_operator not_operator identifier not_operator identifier block return_statement none elif_clause boolean_operator not_operator identifier identifier block expression_statement assignment identifier identifier return_statement dictionary_comprehension pair identifier true for_in_clause identifier identifier
Construct the default projection document.
def AC(self): try: return self._AC except AttributeError: pass self._AC = [self.A, self.C] return self._AC
module function_definition identifier parameters identifier block try_statement block return_statement attribute identifier identifier except_clause identifier block pass_statement expression_statement assignment attribute identifier identifier list attribute identifier identifier attribute identifier identifier return_statement attribute identifier identifier
Vertices A and C, list.
def LabelValueTable(self, keys=None): keys = keys or self.superkey return super(CliTable, self).LabelValueTable(keys)
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier boolean_operator identifier attribute identifier identifier return_statement call attribute call identifier argument_list identifier identifier identifier argument_list identifier
Return LabelValue with FSM derived keys.
def print_help_fields(): def custom_manifold(): "named rTorrent custom attribute, e.g. 'custom_completion_target'" return ("custom_KEY", custom_manifold) def kind_manifold(): "file types that contribute at least N% to the item's total size" return ("kind_N", kind_manifold) print('') print("Fields are:") print("\n".join([" %-21s %s" % (name, field.__doc__) for name, field in sorted(engine.FieldDefinition.FIELDS.items() + [ custom_manifold(), kind_manifold(), ]) ])) print('') print("Format specifiers are:") print("\n".join([" %-21s %s" % (name, doc) for name, doc in sorted(formatting.OutputMapping.formatter_help()) ])) print('') print("Append format specifiers using a '.' to field names in '-o' lists,\n" "e.g. 'size.sz' or 'completed.raw.delta'.")
module function_definition identifier parameters block function_definition identifier parameters block expression_statement string string_start string_content string_end return_statement tuple string string_start string_content string_end identifier function_definition identifier parameters block expression_statement string string_start string_content string_end return_statement tuple string string_start string_content string_end identifier expression_statement call identifier argument_list string string_start string_end expression_statement call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list list_comprehension binary_operator string string_start string_content string_end tuple identifier attribute identifier identifier for_in_clause pattern_list identifier identifier call identifier argument_list binary_operator call attribute attribute attribute identifier identifier identifier identifier argument_list list call identifier argument_list call identifier argument_list expression_statement call identifier argument_list string string_start string_end expression_statement call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list list_comprehension binary_operator string string_start string_content string_end tuple identifier identifier for_in_clause pattern_list identifier identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list expression_statement call identifier argument_list string string_start string_end expression_statement call identifier argument_list concatenated_string string string_start string_content escape_sequence string_end string string_start string_content string_end
Print help about fields and field formatters.
def manifest_parse(self, path): print("fw: parsing manifests") content = open(path).read() return json.loads(content)
module function_definition identifier parameters identifier identifier block expression_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute call identifier argument_list identifier identifier argument_list return_statement call attribute identifier identifier argument_list identifier
parse manifest at path, return JSON object
def _parse_read_preference(options): if 'read_preference' in options: return options['read_preference'] name = options.get('readpreference', 'primary') mode = read_pref_mode_from_name(name) tags = options.get('readpreferencetags') max_staleness = options.get('maxstalenessseconds', -1) return make_read_preference(mode, tags, max_staleness)
module function_definition identifier parameters identifier block if_statement comparison_operator string string_start string_content string_end identifier block return_statement subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier 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 unary_operator integer return_statement call identifier argument_list identifier identifier identifier
Parse read preference options.
def competence(stochastic): if stochastic.dtype in bool_dtypes: return 2 elif isinstance(stochastic, distributions.Bernoulli): return 2 elif (isinstance(stochastic, distributions.Categorical) and (len(stochastic.parents['p'])==2)): return 2 else: return 0
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier identifier block return_statement integer elif_clause call identifier argument_list identifier attribute identifier identifier block return_statement integer elif_clause parenthesized_expression boolean_operator call identifier argument_list identifier attribute identifier identifier parenthesized_expression comparison_operator call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end integer block return_statement integer else_clause block return_statement integer
The competence function for Binary One-At-A-Time Metropolis
def interface_lookup(interfaces, hwaddr, address_type): for interface in interfaces.values(): if interface.get('hwaddr') == hwaddr: for address in interface.get('addrs'): if address.get('type') == address_type: return address.get('addr')
module function_definition identifier parameters identifier identifier identifier block for_statement identifier call attribute identifier identifier argument_list block if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end identifier block for_statement identifier call attribute identifier identifier argument_list string string_start string_content string_end block if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end
Search the address within the interface list.
def unsubscribe(self, socket_id, channel): con = self._get_connection(socket_id, create=False) if con is not None: con.subscriptions.discard(channel) try: self.subscriptions[channel].discard(socket_id) except KeyError: pass
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier false if_statement comparison_operator identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list identifier try_statement block expression_statement call attribute subscript attribute identifier identifier identifier identifier argument_list identifier except_clause identifier block pass_statement
Unsubscribes a socket from a channel.
def reload_all_plugins(self, *args): for manifest in self._manifests[:]: if self.get_plugin(manifest["name"]) is not None: self.reload_plugin(manifest["name"], *args)
module function_definition identifier parameters identifier list_splat_pattern identifier block for_statement identifier subscript attribute identifier identifier slice block if_statement comparison_operator call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end none block expression_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end list_splat identifier
Reloads all initialized plugins
def ignore(mapping): if isinstance(mapping, Mapping): return AsDict(mapping) elif isinstance(mapping, list): return [ignore(item) for item in mapping] return mapping
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block return_statement call identifier argument_list identifier elif_clause call identifier argument_list identifier identifier block return_statement list_comprehension call identifier argument_list identifier for_in_clause identifier identifier return_statement identifier
Use ignore to prevent a mapping from being mapped to a namedtuple.
def read_piezo_tensor(self): header_pattern = r"PIEZOELECTRIC TENSOR for field in x, y, " \ r"z\s+\(C/m\^2\)\s+([X-Z][X-Z]\s+)+\-+" row_pattern = r"[x-z]\s+" + r"\s+".join([r"(\-*[\.\d]+)"] * 6) footer_pattern = r"BORN EFFECTIVE" pt_table = self.read_table_pattern(header_pattern, row_pattern, footer_pattern, postprocess=float) self.data["piezo_tensor"] = pt_table
module function_definition identifier parameters identifier block expression_statement assignment identifier concatenated_string string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier binary_operator string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list binary_operator list string string_start string_content string_end integer expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier keyword_argument identifier identifier expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end identifier
Parse the piezo tensor data
def fromConfigFile(filename = DEFAULT_CONFIG_FILE): parser = SafeConfigParser() section = 'fenixedu' parser.read(filename) client_id = parser.get(section, 'client_id') redirect_uri = parser.get(section, 'redirect_uri') client_secret = parser.get(section, 'client_secret') base_url = parser.get(section, 'base_url') api_endpoint = parser.get(section, 'api_endpoint') api_version = parser.get(section, 'api_version') return FenixEduConfiguration(client_id = client_id, redirect_uri = redirect_uri, client_secret = client_secret, base_url = base_url, api_endpoint = api_endpoint, api_version = api_version)
module function_definition identifier parameters default_parameter identifier identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end return_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
Read settings from configuration file
def extract_summary(obj): try: doc = inspect.getdoc(obj).split("\n") except AttributeError: doc = '' while doc and not doc[0].strip(): doc.pop(0) for i, piece in enumerate(doc): if not piece.strip(): doc = doc[:i] break sentences = periods_re.split(" ".join(doc)) if len(sentences) == 1: summary = sentences[0].strip() else: summary = '' state_machine = RSTStateMachine(state_classes, 'Body') while sentences: summary += sentences.pop(0) + '.' node = new_document('') node.reporter = NullReporter('', 999, 4) node.settings.pep_references = None node.settings.rfc_references = None state_machine.run([summary], node) if not node.traverse(nodes.system_message): break return summary
module function_definition identifier parameters identifier block try_statement block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier identifier argument_list string string_start string_content escape_sequence string_end except_clause identifier block expression_statement assignment identifier string string_start string_end while_statement boolean_operator identifier not_operator call attribute subscript identifier integer identifier argument_list block expression_statement call attribute identifier identifier argument_list integer for_statement pattern_list identifier identifier call identifier argument_list identifier block if_statement not_operator call attribute identifier identifier argument_list block expression_statement assignment identifier subscript identifier slice identifier break_statement expression_statement assignment identifier call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier call attribute subscript identifier integer identifier argument_list else_clause block expression_statement assignment identifier string string_start string_end expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end while_statement identifier block expression_statement augmented_assignment identifier binary_operator call attribute identifier identifier argument_list integer string string_start string_content string_end expression_statement assignment identifier call identifier argument_list string string_start string_end expression_statement assignment attribute identifier identifier call identifier argument_list string string_start string_end integer integer expression_statement assignment attribute attribute identifier identifier identifier none expression_statement assignment attribute attribute identifier identifier identifier none expression_statement call attribute identifier identifier argument_list list identifier identifier if_statement not_operator call attribute identifier identifier argument_list attribute identifier identifier block break_statement return_statement identifier
Extract summary from docstring.
def list_address_scopes(self, retrieve_all=True, **_params): return self.list('address_scopes', self.address_scopes_path, retrieve_all, **_params)
module function_definition identifier parameters identifier default_parameter identifier true dictionary_splat_pattern identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier identifier dictionary_splat identifier
Fetches a list of all address scopes for a project.
def _github_ssh_key_exists(cls): remote_keys = map(lambda k: k._key, cls._user.get_keys()) found = False pubkey_files = glob.glob(os.path.expanduser('~/.ssh/*.pub')) for rk in remote_keys: for pkf in pubkey_files: local_key = io.open(pkf, encoding='utf-8').read() rkval = rk if isinstance(rk, six.string_types) else rk.value if rkval in local_key: found = True break return found
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list lambda lambda_parameters identifier attribute identifier identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier false expression_statement assignment identifier call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end for_statement identifier identifier block for_statement identifier identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end identifier argument_list expression_statement assignment identifier conditional_expression identifier call identifier argument_list identifier attribute identifier identifier attribute identifier identifier if_statement comparison_operator identifier identifier block expression_statement assignment identifier true break_statement return_statement identifier
Returns True if any key on Github matches a local key, else False.
def translate_sbml_reaction(entry, new_id, compartment_map, compound_map): new_entry = DictReactionEntry(entry, id=new_id) if new_entry.equation is not None: compounds = [] for compound, value in new_entry.equation.compounds: compartment = compartment_map.get( compound.compartment, compound.compartment) new_compound = compound.translate( lambda name: compound_map.get(name, name)).in_compartment( compartment) compounds.append((new_compound, value)) new_entry.equation = Reaction( new_entry.equation.direction, compounds) for key, value in iteritems(parse_xhtml_reaction_notes(entry)): if key not in new_entry.properties: new_entry.properties[key] = value return new_entry
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier list for_statement pattern_list identifier identifier attribute attribute identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list lambda lambda_parameters identifier call attribute identifier identifier argument_list identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list tuple identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list attribute attribute identifier identifier identifier identifier for_statement pattern_list identifier identifier call identifier argument_list call identifier argument_list identifier block if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier identifier return_statement identifier
Translate SBML reaction entry.
def copy(self): new_dict = IDict(std=self._std) new_dict.update(self.store) return new_dict
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier return_statement identifier
Return a copy of ourself.
def pack_chunk(tag, data): to_check = tag + data return (struct.pack(b"!I", len(data)) + to_check + struct.pack(b"!I", zlib.crc32(to_check) & 0xFFFFFFFF))
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier binary_operator identifier identifier return_statement parenthesized_expression binary_operator binary_operator call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end binary_operator call attribute identifier identifier argument_list identifier integer
Pack a PNG chunk for serializing to disk
def registerTrailingStop(self, tickerId, orderId=0, quantity=1, lastPrice=0, trailPercent=100., trailAmount=0., parentId=0, **kwargs): ticksize = self.contractDetails(tickerId)["m_minTick"] trailingStop = self.trailingStops[tickerId] = { "orderId": orderId, "parentId": parentId, "lastPrice": lastPrice, "trailAmount": trailAmount, "trailPercent": trailPercent, "quantity": quantity, "ticksize": ticksize } return trailingStop
module function_definition identifier parameters identifier identifier default_parameter identifier integer default_parameter identifier integer default_parameter identifier integer default_parameter identifier float default_parameter identifier float default_parameter identifier integer dictionary_splat_pattern identifier block expression_statement assignment identifier subscript call attribute identifier identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier assignment subscript attribute identifier identifier identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier return_statement identifier
adds trailing stop to monitor list
def _handle_no_candidates(self): if self.dom is not None and len(self.dom): dom = prep_article(self.dom) dom = build_base_document(dom, self._return_fragment) return self._remove_orphans( dom.get_element_by_id("readabilityBody")) else: logger.info("No document to use.") return build_error_document(self._return_fragment)
module function_definition identifier parameters identifier block if_statement boolean_operator comparison_operator attribute identifier identifier none call identifier argument_list attribute identifier identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier attribute identifier identifier return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement call identifier argument_list attribute identifier identifier
If we fail to find a good candidate we need to find something else.
def bytes_to_c_array(data): chars = [ "'{}'".format(encode_escape(i)) for i in decode_escape(data) ] return ', '.join(chars) + ', 0'
module function_definition identifier parameters identifier block expression_statement assignment identifier list_comprehension call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier for_in_clause identifier call identifier argument_list identifier return_statement binary_operator call attribute string string_start string_content string_end identifier argument_list identifier string string_start string_content string_end
Make a C array using the given string.
def clear_all(self): for urlpath in self._metadata.keys(): self.clear_cache(urlpath) if not os.path.isdir(self._cache_dir): return for subdir in os.listdir(self._cache_dir): try: fn = posixpath.join(self._cache_dir, subdir) if os.path.isdir(fn): shutil.rmtree(fn) if os.path.isfile(fn): os.remove(fn) except (OSError, IOError) as e: logger.warning(str(e))
module function_definition identifier parameters identifier block for_statement identifier call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier if_statement not_operator call attribute attribute identifier identifier identifier argument_list attribute identifier identifier block return_statement for_statement identifier call attribute identifier identifier argument_list attribute identifier identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier identifier if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier except_clause as_pattern tuple identifier identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier
Clears all cache and metadata.
def _print_command(self, cmd): text = helpers.repr_bytes(cmd) self.outf.write(text) if not text.endswith(b'\n'): self.outf.write(b'\n')
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier if_statement not_operator call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content escape_sequence string_end
Wrapper to avoid adding unnecessary blank lines.
def send_method_request(self, method: str, method_params: dict) -> dict: url = '/'.join((self.METHOD_URL, method)) method_params['v'] = self.API_VERSION if self._access_token: method_params['access_token'] = self._access_token response = self.post(url, method_params, timeout=10) response.raise_for_status() return json.loads(response.text)
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type identifier type identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list tuple attribute identifier identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier if_statement attribute identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier keyword_argument identifier integer expression_statement call attribute identifier identifier argument_list return_statement call attribute identifier identifier argument_list attribute identifier identifier
Sends user-defined method and method params
def updateButtonText(self, lst): axis_txt = '' for e in lst: axis_txt += '%d,' % (e+1) self.SetLabel("Axes: %s" % axis_txt[:-1])
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier string string_start string_end for_statement identifier identifier block expression_statement augmented_assignment identifier binary_operator string string_start string_content string_end parenthesized_expression binary_operator identifier integer expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end subscript identifier slice unary_operator integer
Update the list of selected axes in the menu button
def resolve(self, client): resolve_method = getattr(client, snake_case(self.link_type)) if self.link_type == 'Space': return resolve_method() else: return resolve_method(self.id)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier call identifier argument_list attribute identifier identifier if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block return_statement call identifier argument_list else_clause block return_statement call identifier argument_list attribute identifier identifier
Resolves Link to a specific Resource
def _extract_number_of_taxa(self): n_taxa = dict() for i in self.seq_records: if i.gene_code not in n_taxa: n_taxa[i.gene_code] = 0 n_taxa[i.gene_code] += 1 number_taxa = sorted([i for i in n_taxa.values()], reverse=True)[0] self.number_taxa = str(number_taxa)
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list for_statement identifier attribute identifier identifier block if_statement comparison_operator attribute identifier identifier identifier block expression_statement assignment subscript identifier attribute identifier identifier integer expression_statement augmented_assignment subscript identifier attribute identifier identifier integer expression_statement assignment identifier subscript call identifier argument_list list_comprehension identifier for_in_clause identifier call attribute identifier identifier argument_list keyword_argument identifier true integer expression_statement assignment attribute identifier identifier call identifier argument_list identifier
sets `self.number_taxa` to the number of taxa as string
def user_has_email(username): user = api.user.get(username=username) if not user.getProperty("email"): msg = _( "This user doesn't have an email associated " "with their account." ) raise Invalid(msg) return True
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier if_statement not_operator call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end raise_statement call identifier argument_list identifier return_statement true
make sure, that given user has an email associated
def prepare(self, engine, mode, items) -> None: self.tx_id = str(uuid.uuid4()).replace("-", "") self.engine = engine self.mode = mode self.items = items self._prepare_request()
module function_definition identifier parameters identifier identifier identifier identifier type none block expression_statement assignment attribute identifier identifier call attribute call identifier argument_list call attribute identifier identifier argument_list identifier argument_list string string_start string_content string_end string string_start string_end expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list
Create a unique transaction id and dumps the items into a cached request object.
def save_optimizer_for_phase(phase): with open(make_optimizer_pickle_path(phase), "w+b") as f: f.write(pickle.dumps(phase.optimizer))
module function_definition identifier parameters identifier block 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 call attribute identifier identifier argument_list attribute identifier identifier
Save the optimizer associated with the phase as a pickle
def _calculate_day_cost(self, plan, period): plan_pricings = plan.planpricing_set.order_by('-pricing__period').select_related('pricing') selected_pricing = None for plan_pricing in plan_pricings: selected_pricing = plan_pricing if plan_pricing.pricing.period <= period: break if selected_pricing: return (selected_pricing.price / selected_pricing.pricing.period).quantize(Decimal('1.00')) raise ValueError('Plan %s has no pricings.' % plan)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier argument_list string string_start string_content string_end expression_statement assignment identifier none for_statement identifier identifier block expression_statement assignment identifier identifier if_statement comparison_operator attribute attribute identifier identifier identifier identifier block break_statement if_statement identifier block return_statement call attribute parenthesized_expression binary_operator attribute identifier identifier attribute attribute identifier identifier identifier identifier argument_list call identifier argument_list string string_start string_content string_end raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier
Finds most fitted plan pricing for a given period, and calculate day cost
def impute_data(self,x): imp = Imputer(missing_values='NaN', strategy='mean', axis=0) return imp.fit_transform(x)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier integer return_statement call attribute identifier identifier argument_list identifier
Imputes data set containing Nan values
def _get_dotgraphs(self, hdrgo, usrgos, pltargs, go2parentids): gosubdagplotnts = self._get_gosubdagplotnts(hdrgo, usrgos, pltargs, go2parentids) dotstrs = [obj.get_dotstr() for obj in gosubdagplotnts] return dotstrs
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier identifier expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list for_in_clause identifier identifier return_statement identifier
Get a GO DAG in a dot-language string for a single Group of user GOs.
def _symbol_in(self, symbol, name): lsymbol = symbol.lower() lname = name.lower() return lsymbol == lname[:len(symbol)] or "_" + lsymbol in lname
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list return_statement boolean_operator comparison_operator identifier subscript identifier slice call identifier argument_list identifier comparison_operator binary_operator string string_start string_content string_end identifier identifier
Checks whether the specified symbol is part of the name for completion.
def _any_source_silent(sources): return np.any(np.all(np.sum( sources, axis=tuple(range(2, sources.ndim))) == 0, axis=1))
module function_definition identifier parameters identifier block return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list comparison_operator call attribute identifier identifier argument_list identifier keyword_argument identifier call identifier argument_list call identifier argument_list integer attribute identifier identifier integer keyword_argument identifier integer
Returns true if the parameter sources has any silent first dimensions
def _update_port_group_info(self, switches=None): if switches is None: switches = self._switches.keys() for switch_ip in switches: client = self._switches.get(switch_ip) ret = self._run_eos_cmds(['show interfaces'], client) if not ret or len(ret) == 0: LOG.warning("Unable to retrieve interface info for %s", switch_ip) continue intf_info = ret[0] self._port_group_info[switch_ip] = intf_info.get('interfaces', {})
module function_definition identifier parameters identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list for_statement identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list list string string_start string_content string_end identifier if_statement boolean_operator not_operator identifier comparison_operator call identifier argument_list identifier integer block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier continue_statement expression_statement assignment identifier subscript identifier integer expression_statement assignment subscript attribute identifier identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end dictionary
Refresh data on switch interfaces' port group membership
def prepare_recently_opened_state_machines_list_for_storage(self): from rafcon.gui.singleton import global_gui_config num = global_gui_config.get_config_value('NUMBER_OF_RECENT_OPENED_STATE_MACHINES_STORED') state_machine_paths = self.get_config_value('recently_opened_state_machines', []) self.set_config_value('recently_opened_state_machines', state_machine_paths[:num])
module function_definition identifier parameters identifier block import_from_statement dotted_name identifier identifier identifier dotted_name identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end subscript identifier slice identifier
Reduce number of paths in the recent opened state machines to limit from gui config
def reload(self): enum = self._enum if not enum: return self.clear() if not self.isRequired(): self.addItem('') if self.sortByKey(): self.addItems(sorted(enum.keys())) else: items = enum.items() items.sort(key = lambda x: x[1]) self.addItems(map(lambda x: x[0], items))
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier if_statement not_operator identifier block return_statement expression_statement call attribute identifier identifier argument_list if_statement not_operator call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list string string_start string_end if_statement call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list call identifier argument_list call attribute identifier identifier argument_list else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list keyword_argument identifier lambda lambda_parameters identifier subscript identifier integer expression_statement call attribute identifier identifier argument_list call identifier argument_list lambda lambda_parameters identifier subscript identifier integer identifier
Reloads the contents for this box.
def _trim_config(self, b_config, mod, key): if isinstance(b_config[mod], list): self._remove_list_item(b_config[mod], key) elif isinstance(b_config[mod], dict): b_config[mod].pop(key) return b_config
module function_definition identifier parameters identifier identifier identifier identifier block if_statement call identifier argument_list subscript identifier identifier identifier block expression_statement call attribute identifier identifier argument_list subscript identifier identifier identifier elif_clause call identifier argument_list subscript identifier identifier identifier block expression_statement call attribute subscript identifier identifier identifier argument_list identifier return_statement identifier
Take a beacon configuration and strip out the interval bits
def _is_significant(change, significance): try: a = float(change['from']) b = float(change['to']) except ValueError: return True return abs(a - b) > 10 ** (-significance)
module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment identifier call identifier argument_list subscript identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list subscript identifier string string_start string_content string_end except_clause identifier block return_statement true return_statement comparison_operator call identifier argument_list binary_operator identifier identifier binary_operator integer parenthesized_expression unary_operator identifier
Return True if a change is genuinely significant given our tolerance.
def addField(self, field) : if field.lower() in self.legend : raise ValueError("%s is already in the legend" % field.lower()) self.legend[field.lower()] = len(self.legend) if len(self.strLegend) > 0 : self.strLegend += self.separator + field else : self.strLegend += field
module function_definition identifier parameters identifier identifier block if_statement comparison_operator call attribute identifier identifier argument_list attribute identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end call attribute identifier identifier argument_list expression_statement assignment subscript attribute identifier identifier call attribute identifier identifier argument_list call identifier argument_list attribute identifier identifier if_statement comparison_operator call identifier argument_list attribute identifier identifier integer block expression_statement augmented_assignment attribute identifier identifier binary_operator attribute identifier identifier identifier else_clause block expression_statement augmented_assignment attribute identifier identifier identifier
add a filed to the legend
def setPgConfigOptions(**kwargs): for key, value in kwargs.items(): logger.debug("Setting PyQtGraph config option: {} = {}".format(key, value)) pg.setConfigOptions(**kwargs)
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 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 dictionary_splat identifier
Sets the PyQtGraph config options and emits a log message
def throw_if_bad_response(response): try: response.raise_for_status() except RequestException: try: msg = 'Response code: {}; response body:\n{}'.format(response.status_code, json.dumps(response.json(), indent=2)) raise CerberusClientException(msg) except ValueError: msg = 'Response code: {}; response body:\n{}'.format(response.status_code, response.text) raise CerberusClientException(msg)
module function_definition identifier parameters identifier block try_statement block expression_statement call attribute identifier identifier argument_list except_clause identifier block try_statement block expression_statement assignment identifier call attribute string string_start string_content escape_sequence string_end identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier integer raise_statement call identifier argument_list identifier except_clause identifier block expression_statement assignment identifier call attribute string string_start string_content escape_sequence string_end identifier argument_list attribute identifier identifier attribute identifier identifier raise_statement call identifier argument_list identifier
Throw an exception if the Cerberus response is not successful.
def remove_eoc_marker(self, text, next_text): if self.cell_marker_start: return text if self.is_code() and text[-1] == self.comment + ' -': if not next_text or next_text[0].startswith(self.comment + ' + {'): text = text[:-1] if self.lines_to_end_of_cell_marker and (self.lines_to_next_cell is None or self.lines_to_end_of_cell_marker > self.lines_to_next_cell): self.lines_to_next_cell = self.lines_to_end_of_cell_marker else: blank_lines = self.lines_to_end_of_cell_marker if blank_lines is None: blank_lines = pep8_lines_between_cells(text[:-1], next_text, self.ext) blank_lines = 0 if blank_lines < 2 else 2 text = text[:-1] + [''] * blank_lines + text[-1:] return text
module function_definition identifier parameters identifier identifier identifier block if_statement attribute identifier identifier block return_statement identifier if_statement boolean_operator call attribute identifier identifier argument_list comparison_operator subscript identifier unary_operator integer binary_operator attribute identifier identifier string string_start string_content string_end block if_statement boolean_operator not_operator identifier call attribute subscript identifier integer identifier argument_list binary_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier subscript identifier slice unary_operator integer if_statement boolean_operator attribute identifier identifier parenthesized_expression boolean_operator comparison_operator attribute identifier identifier none comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier attribute identifier identifier else_clause block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list subscript identifier slice unary_operator integer identifier attribute identifier identifier expression_statement assignment identifier conditional_expression integer comparison_operator identifier integer integer expression_statement assignment identifier binary_operator binary_operator subscript identifier slice unary_operator integer binary_operator list string string_start string_end identifier subscript identifier slice unary_operator integer return_statement identifier
Remove end of cell marker when next cell has an explicit start marker
def _get_stats(self, url, instance): self.log.debug('Fetching Couchbase stats at url: {}'.format(url)) ssl_verify = instance.get('ssl_verify', True) timeout = float(instance.get('timeout', DEFAULT_TIMEOUT)) auth = None if 'user' in instance and 'password' in instance: auth = (instance['user'], instance['password']) r = requests.get(url, auth=auth, verify=ssl_verify, headers=headers(self.agentConfig), timeout=timeout) r.raise_for_status() return r.json()
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end true expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier none if_statement 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 tuple subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier call identifier argument_list attribute identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list return_statement call attribute identifier identifier argument_list
Hit a given URL and return the parsed json.
def fmt_iso(timestamp): try: return fmt.iso_datetime(timestamp) except (ValueError, TypeError): return "N/A".rjust(len(fmt.iso_datetime(0)))
module function_definition identifier parameters identifier block try_statement block return_statement call attribute identifier identifier argument_list identifier except_clause tuple identifier identifier block return_statement call attribute string string_start string_content string_end identifier argument_list call identifier argument_list call attribute identifier identifier argument_list integer
Format a UNIX timestamp to an ISO datetime string.
def _resolve_call(self, table, column='', value='', **kwargs): if not column: return self.catalog(table) elif not value: return self.catalog(table, column) column = column.upper() value = str(value).upper() data = self.call_api(table, column, value, **kwargs) if isinstance(data, dict): data = data.values()[0] return data
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_end default_parameter identifier string string_start string_end dictionary_splat_pattern identifier block if_statement not_operator identifier block return_statement call attribute identifier identifier argument_list identifier elif_clause not_operator identifier block return_statement call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute call identifier argument_list identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier dictionary_splat identifier if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier subscript call attribute identifier identifier argument_list integer return_statement identifier
Internal method to resolve the API wrapper call.
def all_models(self, alphabet: _Alphabet) -> Set[PLInterpretation]: all_possible_interpretations = alphabet.powerset().symbols all_models = set() for i in all_possible_interpretations: current_interpretation = PLInterpretation(i) if self.truth(current_interpretation): all_models.add(current_interpretation) self._all_models = all_models return all_models
module function_definition identifier parameters identifier typed_parameter identifier type identifier type generic_type identifier type_parameter type identifier block expression_statement assignment identifier attribute call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier return_statement identifier
Find all the possible interpretations given a set of symbols
def cut_gmail_quote(html_message): gmail_quote = cssselect('div.gmail_quote', html_message) if gmail_quote and (gmail_quote[0].text is None or not RE_FWD.match(gmail_quote[0].text)): gmail_quote[0].getparent().remove(gmail_quote[0]) return True
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end identifier if_statement boolean_operator identifier parenthesized_expression boolean_operator comparison_operator attribute subscript identifier integer identifier none not_operator call attribute identifier identifier argument_list attribute subscript identifier integer identifier block expression_statement call attribute call attribute subscript identifier integer identifier argument_list identifier argument_list subscript identifier integer return_statement true
Cuts the outermost block element with class gmail_quote.
def _filter_closest(self, lat, lon, stations): current_location = (lat, lon) closest = None closest_distance = None for station in stations: station_loc = (station.latitude, station.longitude) station_distance = distance.distance(current_location, station_loc).km if not closest or station_distance < closest_distance: closest = station closest_distance = station_distance return closest
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier tuple identifier identifier expression_statement assignment identifier none expression_statement assignment identifier none for_statement identifier identifier block expression_statement assignment identifier tuple attribute identifier identifier attribute identifier identifier expression_statement assignment identifier attribute call attribute identifier identifier argument_list identifier identifier identifier if_statement boolean_operator not_operator identifier comparison_operator identifier identifier block expression_statement assignment identifier identifier expression_statement assignment identifier identifier return_statement identifier
Helper to filter the closest station to a given location.
def stream_download(url, target_path, verbose=False): response = requests.get(url, stream=True) handle = open(target_path, "wb") if verbose: print("Beginning streaming download of %s" % url) start = datetime.now() try: content_length = int(response.headers['Content-Length']) content_MB = content_length/1048576.0 print("Total file size: %.2f MB" % content_MB) except KeyError: pass for chunk in response.iter_content(chunk_size=512): if chunk: handle.write(chunk) if verbose: print( "Download completed to %s in %s" % (target_path, datetime.now() - start))
module function_definition identifier parameters identifier identifier default_parameter identifier false block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier true expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end if_statement identifier block expression_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list try_statement block expression_statement assignment identifier call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier binary_operator identifier float expression_statement call identifier argument_list binary_operator string string_start string_content string_end identifier except_clause identifier block pass_statement for_statement identifier call attribute identifier identifier argument_list keyword_argument identifier integer block if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier binary_operator call attribute identifier identifier argument_list identifier
Download a large file without loading it into memory.
def __init_keystone_session_v2(self, check=False): from keystoneauth1 import loading as keystone_v2 loader = keystone_v2.get_plugin_loader('password') auth = loader.load_from_options( auth_url=self._os_auth_url, username=self._os_username, password=self._os_password, project_name=self._os_tenant_name, ) sess = keystoneauth1.session.Session(auth=auth, verify=self._os_cacert) if check: log.debug("Checking that Keystone API v2 session works...") try: nova = nova_client.Client(self._compute_api_version, session=sess, cacert=self._os_cacert) nova.flavors.list() except keystoneauth1.exceptions.NotFound as err: log.warning("Creating Keystone v2 session failed: %s", err) return None except keystoneauth1.exceptions.ClientException as err: log.error("OpenStack server rejected request (likely configuration error?): %s", err) return None log.info("Using Keystone API v2 session to authenticate to OpenStack") return sess
module function_definition identifier parameters identifier default_parameter identifier false block import_from_statement dotted_name identifier aliased_import dotted_name identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list except_clause as_pattern attribute attribute identifier identifier identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement none except_clause as_pattern attribute attribute identifier identifier identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement none expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier
Create and return a session object using Keystone API v2.
def wp_is_loiter(self, i): loiter_cmds = [mavutil.mavlink.MAV_CMD_NAV_LOITER_UNLIM, mavutil.mavlink.MAV_CMD_NAV_LOITER_TURNS, mavutil.mavlink.MAV_CMD_NAV_LOITER_TIME, mavutil.mavlink.MAV_CMD_NAV_LOITER_TO_ALT] if (self.wpoints[i].command in loiter_cmds): return True return False
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier if_statement parenthesized_expression comparison_operator attribute subscript attribute identifier identifier identifier identifier identifier block return_statement true return_statement false
return true if waypoint is a loiter waypoint
def output(self, out_file): self.out_file = out_file out_file.write('event: ns : Nanoseconds\n') out_file.write('events: ns\n') self._output_summary() for entry in sorted(self.entries, key=_entry_sort_key): self._output_entry(entry)
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end expression_statement call attribute identifier identifier argument_list for_statement identifier call identifier argument_list attribute identifier identifier keyword_argument identifier identifier block expression_statement call attribute identifier identifier argument_list identifier
Write the converted entries to out_file
def filter_records(root, head, update, filters=()): root, head, update = freeze(root), freeze(head), freeze(update) for filter_ in filters: root, head, update = filter_(root, head, update) return thaw(root), thaw(head), thaw(update)
module function_definition identifier parameters identifier identifier identifier default_parameter identifier tuple block expression_statement assignment pattern_list identifier identifier identifier expression_list call identifier argument_list identifier call identifier argument_list identifier call identifier argument_list identifier for_statement identifier identifier block expression_statement assignment pattern_list identifier identifier identifier call identifier argument_list identifier identifier identifier return_statement expression_list call identifier argument_list identifier call identifier argument_list identifier call identifier argument_list identifier
Apply the filters to the records.
def update_cognito_triggers(self): if self.cognito: user_pool = self.cognito.get('user_pool') triggers = self.cognito.get('triggers', []) lambda_configs = set() for trigger in triggers: lambda_configs.add(trigger['source'].split('_')[0]) self.zappa.update_cognito(self.lambda_name, user_pool, lambda_configs, self.lambda_arn)
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end list expression_statement assignment identifier call identifier argument_list for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list subscript call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end integer expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier identifier attribute identifier identifier
Update any cognito triggers
def _set_random_data(self): rdata = self._load_response('random') rdata = rdata['query']['random'][0] pageid = rdata.get('id') title = rdata.get('title') self.data.update({'pageid': pageid, 'title': title})
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier subscript subscript subscript identifier string string_start string_content string_end string string_start string_content string_end integer 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 expression_statement call attribute attribute identifier identifier identifier argument_list dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier
sets page data from random request
def verify_password(self, password): if self.password is None: return False from boiler.user.util.passlib import passlib_context return passlib_context.verify(str(password), self.password)
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier none block return_statement false import_from_statement dotted_name identifier identifier identifier identifier dotted_name identifier return_statement call attribute identifier identifier argument_list call identifier argument_list identifier attribute identifier identifier
Verify a given string for being valid password
def condition_from_code(condcode): if condcode in __BRCONDITIONS: cond_data = __BRCONDITIONS[condcode] return {CONDCODE: condcode, CONDITION: cond_data[0], DETAILED: cond_data[1], EXACT: cond_data[2], EXACTNL: cond_data[3], } return None
module function_definition identifier parameters identifier block if_statement comparison_operator identifier identifier block expression_statement assignment identifier subscript identifier identifier return_statement dictionary pair identifier identifier pair identifier subscript identifier integer pair identifier subscript identifier integer pair identifier subscript identifier integer pair identifier subscript identifier integer return_statement none
Get the condition name from the condition code.
def unstash_index(self, sync=False, branch=None): stash_list = self.git_exec(['stash', 'list'], no_verbose=True) if branch is None: branch = self.get_current_branch_name() for stash in stash_list.splitlines(): verb = 'syncing' if sync else 'switching' if ( (('Legit' in stash) and ('On {0}:'.format(branch) in stash) and (verb in stash) ) or (('GitHub' in stash) and ('On {0}:'.format(branch) in stash) and (verb in stash) ) ): return stash[7]
module function_definition identifier parameters identifier default_parameter identifier false default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier true if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier call attribute identifier identifier argument_list block expression_statement assignment identifier conditional_expression string string_start string_content string_end identifier string string_start string_content string_end if_statement parenthesized_expression boolean_operator parenthesized_expression boolean_operator boolean_operator parenthesized_expression comparison_operator string string_start string_content string_end identifier parenthesized_expression comparison_operator call attribute string string_start string_content string_end identifier argument_list identifier identifier parenthesized_expression comparison_operator identifier identifier parenthesized_expression boolean_operator boolean_operator parenthesized_expression comparison_operator string string_start string_content string_end identifier parenthesized_expression comparison_operator call attribute string string_start string_content string_end identifier argument_list identifier identifier parenthesized_expression comparison_operator identifier identifier block return_statement subscript identifier integer
Returns an unstash index if one is available.
def posts(self): rev = int(self.db.get('site:rev')) if rev != self.revision: self.reload_site() return self._posts
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list return_statement attribute identifier identifier
Get posts, reloading the site if needed.
def parse(content, *args, **kwargs): global MECAB_PYTHON3 if 'mecab_loc' not in kwargs and MECAB_PYTHON3 and 'MeCab' in globals(): return MeCab.Tagger(*args).parse(content) else: return run_mecab_process(content, *args, **kwargs)
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block global_statement identifier if_statement boolean_operator boolean_operator comparison_operator string string_start string_content string_end identifier identifier comparison_operator string string_start string_content string_end call identifier argument_list block return_statement call attribute call attribute identifier identifier argument_list list_splat identifier identifier argument_list identifier else_clause block return_statement call identifier argument_list identifier list_splat identifier dictionary_splat identifier
Use mecab-python3 by default to parse JP text. Fall back to mecab binary app if needed
def _format_filename(self, prefix, year, week): return "{}{}_{}-{}.csv".format(self.base_path, prefix, year, week)
module function_definition identifier parameters identifier identifier identifier identifier block return_statement call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier identifier identifier identifier
Construct the file name based on the path and options.
def _check_rest_version(self, version): version = str(version) if version not in self.supported_rest_versions: msg = "Library is incompatible with REST API version {0}" raise ValueError(msg.format(version)) array_rest_versions = self._list_available_rest_versions() if version not in array_rest_versions: msg = "Array is incompatible with REST API version {0}" raise ValueError(msg.format(version)) return LooseVersion(version)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier string string_start string_content string_end raise_statement call identifier argument_list call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier identifier block expression_statement assignment identifier string string_start string_content string_end raise_statement call identifier argument_list call attribute identifier identifier argument_list identifier return_statement call identifier argument_list identifier
Validate a REST API version is supported by the library and target array.
def header(self, method, client='htmlshark'): return {'token': self._request_token(method, client), 'privacy': 0, 'uuid': self.session.user, 'clientRevision': grooveshark.const.CLIENTS[client]['version'], 'session': self.session.session, 'client': client, 'country': self.session.country}
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end block return_statement dictionary pair string string_start string_content string_end call attribute identifier identifier argument_list identifier identifier pair string string_start string_content string_end integer pair string string_start string_content string_end attribute attribute identifier identifier identifier pair string string_start string_content string_end subscript subscript attribute attribute identifier identifier identifier identifier string string_start string_content string_end pair string string_start string_content string_end attribute attribute identifier identifier identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end attribute attribute identifier identifier identifier
generates Grooveshark API Json header
def create_environment_dict(overrides): result = os.environ.copy() result.update(overrides or {}) return result
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list boolean_operator identifier dictionary return_statement identifier
Create and return a copy of os.environ with the specified overrides
def reset(self): self._count = 0 self._sum = float(0) self._min = float('inf') self._max = float(0)
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier call identifier argument_list integer expression_statement assignment attribute identifier identifier call identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier call identifier argument_list integer
Reset the time statistics data for the operation.
def _send(self, **kwargs): if kwargs.get("dest_addr_long") is not None: self.zb.remote_at(**kwargs) else: self.zb.at(**kwargs)
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end none block expression_statement call attribute attribute identifier identifier identifier argument_list dictionary_splat identifier else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list dictionary_splat identifier
Send a frame to either the local ZigBee or a remote device.
def open(self, print_matlab_welcome=False): if self.process and not self.process.returncode: raise MatlabConnectionError('Matlab(TM) process is still active. Use close to ' 'close it') self.process = subprocess.Popen( [self.matlab_process_path, '-nojvm', '-nodesktop'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) flags = fcntl.fcntl(self.process.stdout, fcntl.F_GETFL) fcntl.fcntl(self.process.stdout, fcntl.F_SETFL, flags| os.O_NONBLOCK) if print_matlab_welcome: self._sync_output() else: self._sync_output(None)
module function_definition identifier parameters identifier default_parameter identifier false block if_statement boolean_operator attribute identifier identifier not_operator attribute attribute identifier identifier identifier block raise_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list list attribute identifier identifier string string_start string_content string_end string string_start string_content string_end keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute attribute identifier identifier identifier attribute identifier identifier binary_operator identifier attribute identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list else_clause block expression_statement call attribute identifier identifier argument_list none
Opens the matlab process.