code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def parse(cls, requester, entry): if not type(entry) is dict: return entry for key_to_parse, cls_to_parse in six.iteritems(cls.parser): if key_to_parse in entry: entry[key_to_parse] = cls_to_parse.parse( requester, entry[key_to_parse] ) return cls(requester, **entry)
module function_definition identifier parameters identifier identifier identifier block if_statement not_operator comparison_operator call identifier argument_list identifier identifier block return_statement identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list attribute identifier identifier block if_statement comparison_operator identifier identifier block expression_statement assignment subscript identifier identifier call attribute identifier identifier argument_list identifier subscript identifier identifier return_statement call identifier argument_list identifier dictionary_splat identifier
Turns a JSON object into a model instance.
def logout(self): from flask_login import logout_user, current_user if not current_user.is_authenticated: return True user = current_user events.logout_event.send(user) logout_user() app = current_app._get_current_object() identity_changed.send(app, identity=AnonymousIdentity()) return True
module function_definition identifier parameters identifier block import_from_statement dotted_name identifier dotted_name identifier dotted_name identifier if_statement not_operator attribute identifier identifier block return_statement true expression_statement assignment identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier call identifier argument_list return_statement true
Logout user and emit event.
def clean_limit(self): "Ensure given limit is less than default if defined" limit = self.cleaned_data.get('limit', None) if (settings.SELECTABLE_MAX_LIMIT is not None and (not limit or limit > settings.SELECTABLE_MAX_LIMIT)): limit = settings.SELECTABLE_MAX_LIMIT return limit
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end none if_statement parenthesized_expression boolean_operator comparison_operator attribute identifier identifier none parenthesized_expression boolean_operator not_operator identifier comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier attribute identifier identifier return_statement identifier
Ensure given limit is less than default if defined
def access_token(self): title = '%s.access_token' % self.__class__.__name__ from time import time import requests request_kwargs = { 'url': self.token_endpoint, 'data': { 'client_id': self.client_id, 'client_secret': self.client_secret, 'grant_type': 'client_credentials' } } try: current_time = time() response = requests.post(**request_kwargs) except Exception: if self.requests_handler: request_kwargs['method'] = 'POST' request_object = requests.Request(**request_kwargs) return self.requests_handler(request_object) else: raise response_details = self.response_handler.handle(response) if response_details['json']: self._access_token = response_details['json']['access_token'] expires_in = response_details['json']['expires_in'] self.expires_at = current_time + expires_in return self._access_token
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end attribute attribute identifier identifier identifier import_from_statement dotted_name identifier dotted_name identifier import_statement dotted_name identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end string string_start string_content string_end try_statement block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list dictionary_splat identifier except_clause identifier block if_statement attribute identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list dictionary_splat identifier return_statement call attribute identifier identifier argument_list identifier else_clause block raise_statement expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement subscript identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier subscript subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier subscript subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment attribute identifier identifier binary_operator identifier identifier return_statement attribute identifier identifier
a method to acquire an oauth access token
def dump_data(request): app_label = request.GET.get('app_label', []) if app_label: app_label = app_label.split(',') return dump_to_response(request, app_label=app_label, exclude=settings.SMUGGLER_EXCLUDE_LIST)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end list if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier
Exports data from whole project.
def define_options(default_conf): default = {} with open(default_conf, 'rb') as f: exec_in(native_str(f.read()), {}, default) for name, value in default.iteritems(): if name in options: setattr(options, name, value) else: define(name, value)
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary 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 identifier argument_list call identifier argument_list call attribute identifier identifier argument_list dictionary identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement comparison_operator identifier identifier block expression_statement call identifier argument_list identifier identifier identifier else_clause block expression_statement call identifier argument_list identifier identifier
Define the options from default.conf dynamically
def match_head(subject, pattern): if isinstance(pattern, Pattern): pattern = pattern.expression pattern_head = get_head(pattern) if pattern_head is None: return True if issubclass(pattern_head, OneIdentityOperation): return True subject_head = get_head(subject) assert subject_head is not None return issubclass(subject_head, pattern_head)
module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier none block return_statement true if_statement call identifier argument_list identifier identifier block return_statement true expression_statement assignment identifier call identifier argument_list identifier assert_statement comparison_operator identifier none return_statement call identifier argument_list identifier identifier
Checks if the head of subject matches the pattern's head.
def expand_region(tuple_of_s, a, b, start=0, stop=None): return tuple(expand_slice(s, a, b, start=start, stop=stop) for s in tuple_of_s)
module function_definition identifier parameters identifier identifier identifier default_parameter identifier integer default_parameter identifier none block return_statement call identifier generator_expression call identifier argument_list identifier identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier for_in_clause identifier identifier
Apply expend_slice on a tuple of slices
def initial_value(self, field_name: str = None): if self._meta.get_field(field_name).get_internal_type() == 'ForeignKey': if not field_name.endswith('_id'): field_name = field_name+'_id' attribute = self._diff_with_initial.get(field_name, None) if not attribute: return None return attribute[0]
module function_definition identifier parameters identifier typed_default_parameter identifier type identifier none block if_statement comparison_operator call attribute call attribute attribute identifier identifier identifier argument_list identifier identifier argument_list string string_start string_content string_end 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 identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier none if_statement not_operator identifier block return_statement none return_statement subscript identifier integer
Get initial value of field when model was instantiated.
def _library_check(self): try: output = yield from gns3server.utils.asyncio.subprocess_check_output("ldd", self._path) except (FileNotFoundError, subprocess.SubprocessError) as e: log.warn("Could not determine the shared library dependencies for {}: {}".format(self._path, e)) return p = re.compile("([\.\w]+)\s=>\s+not found") missing_libs = p.findall(output) if missing_libs: raise IOUError("The following shared library dependencies cannot be found for IOU image {}: {}".format(self._path, ", ".join(missing_libs)))
module function_definition identifier parameters identifier block try_statement block expression_statement assignment identifier yield call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end attribute identifier identifier except_clause as_pattern tuple identifier attribute identifier identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier identifier return_statement 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 identifier if_statement identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier call attribute string string_start string_content string_end identifier argument_list identifier
Checks for missing shared library dependencies in the IOU image.
def max_texture_limit(self): max_unit_array = (gl.GLint * 1)() gl.glGetIntegerv(gl.GL_MAX_TEXTURE_IMAGE_UNITS, max_unit_array) return max_unit_array[0]
module function_definition identifier parameters identifier block expression_statement assignment identifier call parenthesized_expression binary_operator attribute identifier identifier integer argument_list expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier return_statement subscript identifier integer
The maximum number of textures available for this graphic card's fragment shader.
def lock_account(self, minutes=30): period = datetime.timedelta(minutes=minutes) self.locked_until = datetime.datetime.utcnow() + period
module function_definition identifier parameters identifier default_parameter identifier integer block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier expression_statement assignment attribute identifier identifier binary_operator call attribute attribute identifier identifier identifier argument_list identifier
Lock user account for a period
def flatten(nested): flat_return = list() def __inner_flat(nested,flat): for i in nested: __inner_flat(i, flat) if isinstance(i, list) else flat.append(i) return flat __inner_flat(nested,flat_return) return flat_return
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list function_definition identifier parameters identifier identifier block for_statement identifier identifier block expression_statement conditional_expression call identifier argument_list identifier identifier call identifier argument_list identifier identifier call attribute identifier identifier argument_list identifier return_statement identifier expression_statement call identifier argument_list identifier identifier return_statement identifier
Return a flatten version of the nested argument
def refresh(self, include_fields=None, exclude_fields=None, extra_fields=None): r = self.bugzilla._getbug(self.bug_id, include_fields=include_fields, exclude_fields=exclude_fields, extra_fields=self._bug_fields + (extra_fields or [])) self._update_dict(r)
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier binary_operator attribute identifier identifier parenthesized_expression boolean_operator identifier list expression_statement call attribute identifier identifier argument_list identifier
Refresh the bug with the latest data from bugzilla
def _interp_function(self, y_ip1, y_i, t_ip1, t_i, imt_per): return y_i + (y_ip1 - y_i) / (t_ip1 - t_i) * (imt_per - t_i)
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block return_statement binary_operator identifier binary_operator binary_operator parenthesized_expression binary_operator identifier identifier parenthesized_expression binary_operator identifier identifier parenthesized_expression binary_operator identifier identifier
Generic interpolation function used in equation 19 of 2013 report.
def write_cache(self): doc = { '__format__': 1, 'dependencies': self._cache, } with open(self._cache_file, 'w') as f: json.dump(doc, f, sort_keys=True)
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end integer pair string string_start string_content string_end attribute identifier identifier with_statement with_clause with_item as_pattern call identifier argument_list attribute identifier identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier identifier keyword_argument identifier true
Writes the cache to disk as JSON.
def EncodeForCSV(x): "Encodes one value for CSV." k = x.encode('utf-8') if ',' in k or '"' in k: return '"%s"' % k.replace('"', '""') else: return k
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end 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 return_statement binary_operator string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end else_clause block return_statement identifier
Encodes one value for CSV.
def clean(): d = ['build', 'dist', 'scikits.audiolab.egg-info', HTML_DESTDIR, PDF_DESTDIR] for i in d: paver.path.path(i).rmtree() (paver.path.path('docs') / options.sphinx.builddir).rmtree()
module function_definition identifier parameters block expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier identifier for_statement identifier identifier block expression_statement call attribute call attribute attribute identifier identifier identifier argument_list identifier identifier argument_list expression_statement call attribute parenthesized_expression binary_operator call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end attribute attribute identifier identifier identifier identifier argument_list
Remove build, dist, egg-info garbage.
def refresh(self): self._screen.force_update() self._screen.refresh() self._update(1)
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list integer
Refresh the list and the screen
def _create_filter_by(self): filter_by = [] for name, values in request.args.copy().lists(): if name not in _SKIPPED_ARGUMENTS: column = _re_column_name.search(name).group(1) if column not in self._model_columns: continue for value in values: if name.endswith('_ne'): filter_by.append(name[:-3] + '!=' + value) elif name.endswith('_lte'): filter_by.append(name[:-4] + '<=' + value) elif name.endswith('_gte'): filter_by.append(name[:-4] + '>=' + value) elif name.endswith('_like'): filter_by.append(name[:-5] + '::like::%' + value + '%') else: filter_by.append(name.replace('__', '.') + '==' + value) filter_by += self._create_fulltext_query() return ','.join(filter_by)
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement pattern_list identifier identifier call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list block if_statement comparison_operator identifier identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier identifier argument_list integer if_statement comparison_operator identifier attribute identifier identifier block continue_statement for_statement identifier identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list binary_operator binary_operator subscript identifier slice unary_operator integer string string_start string_content string_end identifier elif_clause call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list binary_operator binary_operator subscript identifier slice unary_operator integer string string_start string_content string_end identifier elif_clause call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list binary_operator binary_operator subscript identifier slice unary_operator integer string string_start string_content string_end identifier elif_clause call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list binary_operator binary_operator binary_operator subscript identifier slice unary_operator integer string string_start string_content string_end identifier string string_start string_content string_end else_clause block expression_statement call attribute identifier identifier argument_list binary_operator binary_operator call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier expression_statement augmented_assignment identifier call attribute identifier identifier argument_list return_statement call attribute string string_start string_content string_end identifier argument_list identifier
Transform the json-server filter arguments to model-resource ones.
def create(self, name, data=None): return createPacket(self[name], data) if name in self else None
module function_definition identifier parameters identifier identifier default_parameter identifier none block return_statement conditional_expression call identifier argument_list subscript identifier identifier identifier comparison_operator identifier identifier none
Creates a new packet with the given definition and raw data.
def format_meta_lines(cls, meta, labels, offset, **kwargs): lines = [] name = meta['package_name'] if 'version' in meta: name += '-' + meta['version'] if 'custom_location' in kwargs: name += ' ({loc})'.format(loc=kwargs['custom_location']) lines.append(name) lines.append(len(name)*'=') lines.append('') lines.extend(meta['summary'].splitlines()) lines.append('') if meta.get('description', ''): lines.extend(meta['description'].splitlines()) lines.append('') data = [] for item in labels: if meta.get(item, '') != '': label = (cls._nice_strings[item] + ':').ljust(offset + 2) data.append(label + cls._format_field(meta[item])) lines.extend(data) return lines
module function_definition identifier parameters identifier identifier identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier list expression_statement assignment identifier subscript identifier string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement augmented_assignment identifier binary_operator string string_start string_content string_end subscript identifier string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement augmented_assignment identifier call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list binary_operator call identifier argument_list identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_end expression_statement call attribute identifier identifier argument_list call attribute subscript identifier string string_start string_content string_end identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_end if_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end block expression_statement call attribute identifier identifier argument_list call attribute subscript identifier string string_start string_content string_end identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_end expression_statement assignment identifier list for_statement identifier identifier block if_statement comparison_operator call attribute identifier identifier argument_list identifier string string_start string_end string string_start string_end block expression_statement assignment identifier call attribute parenthesized_expression binary_operator subscript attribute identifier identifier identifier string string_start string_content string_end identifier argument_list binary_operator identifier integer expression_statement call attribute identifier identifier argument_list binary_operator identifier call attribute identifier identifier argument_list subscript identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Return all information from a given meta dictionary in a list of lines
def validate(self): if self.stoichiometry_matrix.cols != self.propensities.rows: raise ValueError('There must be a column in stoichiometry matrix ' 'for each row in propensities matrix. ' 'S ({0.rows}x{0.cols}): {0!r} , ' 'propensities ({1.rows}x{1.cols}): {1!r}'.format(self.stoichiometry_matrix, self.propensities)) if self.stoichiometry_matrix.rows != len(self.species): raise ValueError('There must be a row in stoichiometry matrix for each variable. ' 'S ({0.rows}x{0.cols}): {0!r}, variables: {1!r}'.format(self.stoichiometry_matrix, self.species)) seen_free_symbols = set() parameters = set(self.parameters) species = set(self.species) intersection = parameters & species if intersection: raise ValueError("Some symbols are in both parameters and species lists") both = parameters | species for row in self.propensities: free_symbols = row.free_symbols free_symbols = free_symbols - seen_free_symbols for symbol in free_symbols: if symbol not in both: raise ValueError('Propensity {0!r} ' 'contains a free symbol {1!r} ' 'that is not in listed in parameters or species lists ' 'Parameters: {2!r}; ' 'Species: {3!r}'.format(row, symbol, self.parameters, self.species)) seen_free_symbols.update(free_symbols)
module function_definition identifier parameters identifier block if_statement comparison_operator attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier block raise_statement call identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier argument_list attribute identifier identifier attribute identifier identifier if_statement comparison_operator attribute attribute identifier identifier identifier call identifier argument_list attribute identifier identifier block raise_statement call identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier binary_operator identifier identifier if_statement identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier binary_operator identifier identifier for_statement identifier attribute identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier binary_operator identifier identifier for_statement identifier identifier block if_statement comparison_operator identifier identifier block raise_statement call identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier argument_list identifier identifier attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier
Validates whether the particular model is created properly
def dynacRepresentation(self): if self.plane.val == 'H': p = 0 elif self.plane.val == 'V': p = 1 return ['STEER', [[self.field_strength.val], [p]]]
module function_definition identifier parameters identifier block if_statement comparison_operator attribute attribute identifier identifier identifier string string_start string_content string_end block expression_statement assignment identifier integer elif_clause comparison_operator attribute attribute identifier identifier identifier string string_start string_content string_end block expression_statement assignment identifier integer return_statement list string string_start string_content string_end list list attribute attribute identifier identifier identifier list identifier
Return the Dynac representation of this steerer instance.
def batch_call(self, calls): req = self.protocol.create_batch_request() for call_args in calls: req.append(self.protocol.create_request(*call_args)) return self._send_and_handle_reply(req)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list list_splat identifier return_statement call attribute identifier identifier argument_list identifier
Experimental, use at your own peril.
def _extract_table_type(type): if isinstance(type, str): type = type.lower() if type[0:7] == 'binary': table_type = BINARY_TBL elif type[0:6] == 'ascii': table_type = ASCII_TBL else: raise ValueError( "table type string should begin with 'binary' or 'ascii' " "(case insensitive)") else: type = int(type) if type not in [BINARY_TBL, ASCII_TBL]: raise ValueError( "table type num should be BINARY_TBL (%d) or " "ASCII_TBL (%d)" % (BINARY_TBL, ASCII_TBL)) table_type = type return table_type
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator subscript identifier slice integer integer string string_start string_content string_end block expression_statement assignment identifier identifier elif_clause comparison_operator subscript identifier slice integer integer string string_start string_content string_end block expression_statement assignment identifier identifier else_clause block raise_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end else_clause block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier list identifier identifier block raise_statement call identifier argument_list binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end tuple identifier identifier expression_statement assignment identifier identifier return_statement identifier
Get the numerical table type
def detector_50_Cent(text): keywords = [ "50 Cent", "rap", "hip hop", "Curtis James Jackson III", "Curtis Jackson", "Eminem", "Dre", "Get Rich or Die Tryin'", "G-Unit", "Street King Immortal", "In da Club", "Interscope", ] num_keywords = sum(word in text for word in keywords) return ("50 Cent", float(num_keywords > 2))
module function_definition identifier parameters identifier block expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call identifier generator_expression comparison_operator identifier identifier for_in_clause identifier identifier return_statement tuple string string_start string_content string_end call identifier argument_list comparison_operator identifier integer
Determine whether 50 Cent is a topic.
def angle_between_vectors(x, y): first_step = abs(x[0] * y[0] + x[1] * y[1] + x[2] * y[2]) / ( np.sqrt(x[0]**2 + x[1]**2 + x[2]**2) * np.sqrt(y[0]**2 + y[1]**2 + y[2]**2)) second_step = np.arccos(first_step) return (second_step)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier binary_operator call identifier argument_list binary_operator binary_operator binary_operator subscript identifier integer subscript identifier integer binary_operator subscript identifier integer subscript identifier integer binary_operator subscript identifier integer subscript identifier integer parenthesized_expression binary_operator call attribute identifier identifier argument_list binary_operator binary_operator binary_operator subscript identifier integer integer binary_operator subscript identifier integer integer binary_operator subscript identifier integer integer call attribute identifier identifier argument_list binary_operator binary_operator binary_operator subscript identifier integer integer binary_operator subscript identifier integer integer binary_operator subscript identifier integer integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement parenthesized_expression identifier
Calculate the angle between two vectors x and y.
def process_status(self, helper, sess, check): if check == 'ntp_current_state': ntp_status_int = helper.get_snmp_value(sess, helper, self.oids['oid_ntp_current_state_int']) result = self.check_ntp_status(ntp_status_int) elif check == 'gps_mode': gps_status_int = helper.get_snmp_value(sess, helper, self.oids['oid_gps_mode_int']) result = self.check_gps_status(gps_status_int) else: return helper.update_status(helper, result)
module function_definition identifier parameters identifier identifier identifier identifier block if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier else_clause block return_statement expression_statement call attribute identifier identifier argument_list identifier identifier
get the snmp value, check the status and update the helper
def getTarget(self, iid): sql = 'select name, path from {} where _id=?'.format(self.TABLE_ITEMS) data = self.db.execute(sql, (iid,)).fetchone() if data: return {'name': data[0], 'path': data[1]} return None
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list identifier tuple identifier identifier argument_list if_statement identifier block return_statement dictionary pair string string_start string_content string_end subscript identifier integer pair string string_start string_content string_end subscript identifier integer return_statement none
Returns a dictionary containing information about a certain target
def script_exists(self, digest, *digests): return self.execute(b'SCRIPT', b'EXISTS', digest, *digests)
module function_definition identifier parameters identifier identifier list_splat_pattern identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier list_splat identifier
Check existence of scripts in the script cache.
def _config_section(config, section): path = os.path.join(config.get('config_path'), config.get('config_file')) conf = _config_ini(path) return conf.get(section)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier
Read the configuration file and return a section.
def add(self, domain_accession, domain_type, match_quality): self.matches[domain_type] = self.matches.get(domain_type, {}) self.matches[domain_type][domain_accession] = match_quality
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier call attribute attribute identifier identifier identifier argument_list identifier dictionary expression_statement assignment subscript subscript attribute identifier identifier identifier identifier identifier
match_quality should be a value between 0 and 1.
def sortJobs(jobTypes, options): longforms = {"med": "median", "ave": "average", "min": "min", "total": "total", "max": "max",} sortField = longforms[options.sortField] if (options.sortCategory == "time" or options.sortCategory == "clock" or options.sortCategory == "wait" or options.sortCategory == "memory" ): return sorted( jobTypes, key=lambda tag: getattr(tag, "%s_%s" % (sortField, options.sortCategory)), reverse=options.sortReverse) elif options.sortCategory == "alpha": return sorted( jobTypes, key=lambda tag: tag.name, reverse=options.sortReverse) elif options.sortCategory == "count": return sorted(jobTypes, key=lambda tag: tag.total_number, reverse=options.sortReverse)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end 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 expression_statement assignment identifier subscript identifier attribute identifier identifier if_statement parenthesized_expression boolean_operator boolean_operator boolean_operator comparison_operator attribute identifier identifier string string_start string_content string_end comparison_operator attribute identifier identifier string string_start string_content string_end comparison_operator attribute identifier identifier string string_start string_content string_end comparison_operator attribute identifier identifier string string_start string_content string_end block return_statement call identifier argument_list identifier keyword_argument identifier lambda lambda_parameters identifier call identifier argument_list identifier binary_operator string string_start string_content string_end tuple identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block return_statement call identifier argument_list identifier keyword_argument identifier lambda lambda_parameters identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block return_statement call identifier argument_list identifier keyword_argument identifier lambda lambda_parameters identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier
Return a jobTypes all sorted.
def _pca(x, k=2): "Compute PCA of `x` with `k` dimensions." x = x-torch.mean(x,0) U,S,V = torch.svd(x.t()) return torch.mm(x,U[:,:k])
module function_definition identifier parameters identifier default_parameter identifier integer block expression_statement string string_start string_content string_end expression_statement assignment identifier binary_operator identifier call attribute identifier identifier argument_list identifier integer expression_statement assignment pattern_list identifier identifier identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list return_statement call attribute identifier identifier argument_list identifier subscript identifier slice slice identifier
Compute PCA of `x` with `k` dimensions.
def clear_database(self) -> None: self._next_entity_id = 0 self._dead_entities.clear() self._components.clear() self._entities.clear() self.clear_cache()
module function_definition identifier parameters identifier type none block expression_statement assignment attribute identifier identifier integer expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list
Remove all Entities and Components from the World.
def cli(ctx, config_file, profile, endpoint_url, output, color, debug): config = Config(config_file) config.get_config_for_profle(profile) config.get_remote_config(endpoint_url) ctx.obj = config.options ctx.obj['output'] = output or config.options['output'] ctx.obj['color'] = color or os.environ.get('CLICOLOR', None) or config.options['color'] endpoint = endpoint_url or config.options['endpoint'] ctx.obj['client'] = Client( endpoint=endpoint, key=config.options['key'], token=get_token(endpoint), username=config.options.get('username', None), password=config.options.get('password', None), timeout=float(config.options['timeout']), ssl_verify=config.options['sslverify'], debug=debug or os.environ.get('DEBUG', None) or config.options['debug'] )
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end boolean_operator identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end boolean_operator boolean_operator identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end none subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier boolean_operator identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end call identifier argument_list keyword_argument identifier identifier keyword_argument identifier subscript attribute identifier identifier string string_start string_content string_end keyword_argument identifier call identifier argument_list identifier keyword_argument identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end none keyword_argument identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end none keyword_argument identifier call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end keyword_argument identifier subscript attribute identifier identifier string string_start string_content string_end keyword_argument identifier boolean_operator boolean_operator identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end none subscript attribute identifier identifier string string_start string_content string_end
Alerta client unified command-line tool.
def name_file(lane: int, flowcell: str, sample: str, read: int, undetermined: bool=False, date: dt.datetime=None, index: str=None) -> str: flowcell = f"{flowcell}-undetermined" if undetermined else flowcell date_str = date.strftime('%y%m%d') if date else '171015' index = index if index else 'XXXXXX' return f"{lane}_{date_str}_{flowcell}_{sample}_{index}_{read}.fastq.gz"
module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_default_parameter identifier type identifier false typed_default_parameter identifier type attribute identifier identifier none typed_default_parameter identifier type identifier none type identifier block expression_statement assignment identifier conditional_expression string string_start interpolation identifier string_content string_end identifier identifier expression_statement assignment identifier conditional_expression call attribute identifier identifier argument_list string string_start string_content string_end identifier string string_start string_content string_end expression_statement assignment identifier conditional_expression identifier identifier string string_start string_content string_end return_statement string string_start interpolation identifier string_content interpolation identifier string_content interpolation identifier string_content interpolation identifier string_content interpolation identifier string_content interpolation identifier string_content string_end
Name a FASTQ file following MIP conventions.
def git_hook(error=True): _, files_modified, _ = run("git diff-index --cached --name-only HEAD") options = parse_options() setup_logger(options) if sys.version_info >= (3,): candidates = [f.decode('utf-8') for f in files_modified] else: candidates = [str(f) for f in files_modified] if candidates: process_paths(options, candidates=candidates, error=error)
module function_definition identifier parameters default_parameter identifier true block expression_statement assignment pattern_list identifier identifier identifier call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list expression_statement call identifier argument_list identifier if_statement comparison_operator attribute identifier identifier tuple integer block expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list string string_start string_content string_end for_in_clause identifier identifier else_clause block expression_statement assignment identifier list_comprehension call identifier argument_list identifier for_in_clause identifier identifier if_statement identifier block expression_statement call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier
Run pylama after git commit.
def args(self): if self.space.has_basis or isinstance(self.label, SymbolicLabelBase): return (self.label, ) else: return (self.index, )
module function_definition identifier parameters identifier block if_statement boolean_operator attribute attribute identifier identifier identifier call identifier argument_list attribute identifier identifier identifier block return_statement tuple attribute identifier identifier else_clause block return_statement tuple attribute identifier identifier
Tuple containing `label_or_index` as its only element.
def getunzipped(username, repo, thedir): theurl = "https://github.com/" + username + "/" + repo + "/archive/master.zip" name = os.path.join(thedir, 'temp.zip') try: name = urllib.urlretrieve(theurl, name) name = os.path.join(thedir, 'temp.zip') except IOError as e: print("Can't retrieve %r to %r: %s" % (theurl, thedir, e)) return try: z = zipfile.ZipFile(name) except zipfile.error as e: print("Bad zipfile (from %r): %s" % (theurl, e)) return z.extractall(thedir) z.close() os.remove(name) copy_tree(os.path.join(thedir, repo + "-master"), thedir) shutil.rmtree(os.path.join(thedir, repo + "-master"))
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier binary_operator binary_operator binary_operator binary_operator string string_start string_content string_end identifier string string_start string_content string_end identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end except_clause as_pattern identifier as_pattern_target identifier block expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier identifier return_statement try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause as_pattern attribute identifier identifier as_pattern_target identifier block expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier return_statement expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier binary_operator identifier string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier binary_operator identifier string string_start string_content string_end
Downloads and unzips a zip file
def as_iframe(self, html_data): srcdoc = html_data.replace('"', "'") return ('<iframe id="{div_id}", srcdoc="{srcdoc}" style="width: {width}; ' 'height: {height};"></iframe>'.format( div_id=self.div_id, srcdoc=srcdoc, width=self.width, height=self.height))
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end return_statement parenthesized_expression call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier
Build the HTML representation for the mapviz.
def bidcollateral( ctx, collateral_symbol, collateral_amount, debt_symbol, debt_amount, account ): print_tx( ctx.bitshares.bid_collateral( Amount(collateral_amount, collateral_symbol), Amount(debt_amount, debt_symbol), account=account, ) )
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement call identifier argument_list call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier identifier call identifier argument_list identifier identifier keyword_argument identifier identifier
Bid for collateral in the settlement fund
def _setSkipRecords(self, skipRec): if type(skipRec) == int or (type(skipRec) == str and skipRec.isdigit()): self._skipRecords = skipRec else: raise FMError, 'Unsupported -skip value (not a number).'
module function_definition identifier parameters identifier identifier block if_statement boolean_operator comparison_operator call identifier argument_list identifier identifier parenthesized_expression boolean_operator comparison_operator call identifier argument_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment attribute identifier identifier identifier else_clause block raise_statement expression_list identifier string string_start string_content string_end
Specifies how many records to skip in the found set
def hmean_int(a, a_min=5778, a_max=1149851): from scipy.stats import hmean return int(round(hmean(np.clip(a, a_min, a_max))))
module function_definition identifier parameters identifier default_parameter identifier integer default_parameter identifier integer block import_from_statement dotted_name identifier identifier dotted_name identifier return_statement call identifier argument_list call identifier argument_list call identifier argument_list call attribute identifier identifier argument_list identifier identifier identifier
Harmonic mean of an array, returns the closest int
def format_ubuntu_dialog(df): s = '' for i, record in df.iterrows(): statement = list(split_turns(record.Context))[-1] reply = list(split_turns(record.Utterance))[-1] s += 'Statement: {}\n'.format(statement) s += 'Reply: {}\n\n'.format(reply) return s
module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_end for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment identifier subscript call identifier argument_list call identifier argument_list attribute identifier identifier unary_operator integer expression_statement assignment identifier subscript call identifier argument_list call identifier argument_list attribute identifier identifier unary_operator integer expression_statement augmented_assignment identifier call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier expression_statement augmented_assignment identifier call attribute string string_start string_content escape_sequence escape_sequence string_end identifier argument_list identifier return_statement identifier
Print statements paired with replies, formatted for easy review
def GetLocalU2FInterface(origin=socket.gethostname()): hid_transports = hidtransport.DiscoverLocalHIDU2FDevices() for t in hid_transports: try: return U2FInterface(security_key=hardware.SecurityKey(transport=t), origin=origin) except errors.UnsupportedVersionException: pass raise errors.NoDeviceFoundError()
module function_definition identifier parameters default_parameter identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier identifier block try_statement block return_statement call identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier except_clause attribute identifier identifier block pass_statement raise_statement call attribute identifier identifier argument_list
Obtains a U2FInterface for the first valid local U2FHID device found.
def sum(self, axis): axis = self.get_axis_number(axis) if self.dimensions == 2: new_hist = Hist1d else: new_hist = Histdd return new_hist.from_histogram(np.sum(self.histogram, axis=axis), bin_edges=itemgetter(*self.other_axes(axis))(self.bin_edges), axis_names=self.axis_names_without(axis))
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator attribute identifier identifier integer block expression_statement assignment identifier identifier else_clause block expression_statement assignment identifier identifier return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier call call identifier argument_list list_splat call attribute identifier identifier argument_list identifier argument_list attribute identifier identifier keyword_argument identifier call attribute identifier identifier argument_list identifier
Sums all data along axis, returns d-1 dimensional histogram
def work(): with rq.Connection(create_connection()): worker = rq.Worker(list(map(rq.Queue, listen))) worker.work()
module function_definition identifier parameters block with_statement with_clause with_item call attribute identifier identifier argument_list call identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list call identifier argument_list attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list
Start an rq worker on the connection provided by create_connection.
def md5_of_file(abspath): chunk_size = 1024 * 1024 m = hashlib.md5() with open(abspath, "rb") as f: while True: data = f.read(chunk_size) if not data: break m.update(data) return m.hexdigest()
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator integer integer expression_statement assignment identifier call attribute identifier identifier argument_list 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 while_statement true block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator identifier block break_statement expression_statement call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list
Md5 value of a file.
def segment_radii(neurites, neurite_type=NeuriteType.all): def _seg_radii(sec): pts = sec.points[:, COLS.R] return np.divide(np.add(pts[:-1], pts[1:]), 2.0) return map_segments(_seg_radii, neurites, neurite_type)
module function_definition identifier parameters identifier default_parameter identifier attribute identifier identifier block function_definition identifier parameters identifier block expression_statement assignment identifier subscript attribute identifier identifier slice attribute identifier identifier return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list subscript identifier slice unary_operator integer subscript identifier slice integer float return_statement call identifier argument_list identifier identifier identifier
arithmetic mean of the radii of the points in segments in a collection of neurites
def _join_partner(self, partner: Address): try: self.api.channel_open( self.registry_address, self.token_address, partner, ) except DuplicatedChannelError: pass total_deposit = self._initial_funding_per_partner if total_deposit == 0: return try: self.api.set_total_channel_deposit( registry_address=self.registry_address, token_address=self.token_address, partner_address=partner, total_deposit=total_deposit, ) except InvalidDBData: raise except RECOVERABLE_ERRORS: log.info( 'Deposit failed', node=pex(self.raiden.address), partner=pex(partner), ) except RaidenUnrecoverableError: should_crash = ( self.raiden.config['environment_type'] != Environment.PRODUCTION or self.raiden.config['unrecoverable_error_should_crash'] ) if should_crash: raise log.critical( 'Deposit failed', node=pex(self.raiden.address), partner=pex(partner), )
module function_definition identifier parameters identifier typed_parameter identifier type identifier block try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier identifier except_clause identifier block pass_statement expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier integer block return_statement try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier except_clause identifier block raise_statement except_clause identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier call identifier argument_list attribute attribute identifier identifier identifier keyword_argument identifier call identifier argument_list identifier except_clause identifier block expression_statement assignment identifier parenthesized_expression boolean_operator comparison_operator subscript attribute attribute identifier identifier identifier string string_start string_content string_end attribute identifier identifier subscript attribute attribute identifier identifier identifier string string_start string_content string_end if_statement identifier block raise_statement expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier call identifier argument_list attribute attribute identifier identifier identifier keyword_argument identifier call identifier argument_list identifier
Ensure a channel exists with partner and is funded in our side
def push_design_documents(self, design_path): for db_name in os.listdir(design_path): if db_name.startswith("__") or db_name.startswith("."): continue db_path = os.path.join(design_path, db_name) doc = self._folder_to_dict(db_path) doc_id = "_design/openag" doc["_id"] = doc_id db = self[db_name] if doc_id in db: old_doc = db[doc_id] doc["_rev"] = old_doc["_rev"] if doc == old_doc: continue db[doc_id] = doc
module function_definition identifier parameters identifier identifier block for_statement identifier call attribute identifier identifier argument_list identifier block if_statement boolean_operator call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end block continue_statement expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment identifier subscript identifier identifier if_statement comparison_operator identifier identifier block expression_statement assignment identifier subscript identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end if_statement comparison_operator identifier identifier block continue_statement expression_statement assignment subscript identifier identifier identifier
Push the design documents stored in `design_path` to the server
def multipart(body, content_length=0, **header_params): header_params.setdefault('CONTENT-LENGTH', content_length) if header_params and 'boundary' in header_params: if type(header_params['boundary']) is str: header_params['boundary'] = header_params['boundary'].encode() form = parse_multipart((body.stream if hasattr(body, 'stream') else body), header_params) for key, value in form.items(): if type(value) is list and len(value) is 1: form[key] = value[0] return form
module function_definition identifier parameters identifier default_parameter identifier integer dictionary_splat_pattern identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement boolean_operator identifier comparison_operator string string_start string_content string_end identifier block if_statement comparison_operator call identifier argument_list subscript identifier string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end call attribute subscript identifier string string_start string_content string_end identifier argument_list expression_statement assignment identifier call identifier argument_list parenthesized_expression conditional_expression attribute identifier identifier call identifier argument_list identifier string string_start string_content string_end identifier identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement boolean_operator comparison_operator call identifier argument_list identifier identifier comparison_operator call identifier argument_list identifier integer block expression_statement assignment subscript identifier identifier subscript identifier integer return_statement identifier
Converts multipart form data into native Python objects
def on_load(target: "EncryptableMixin", context): decrypt, plaintext = decrypt_instance(target) if decrypt: target.plaintext = plaintext
module function_definition identifier parameters typed_parameter identifier type string string_start string_content string_end identifier block expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier if_statement identifier block expression_statement assignment attribute identifier identifier identifier
Intercept SQLAlchemy's instance load event.
def _filter_nodes(superclass, all_nodes=_all_nodes): node_names = (node.__name__ for node in all_nodes if issubclass(node, superclass)) return frozenset(node_names)
module function_definition identifier parameters identifier default_parameter identifier identifier block expression_statement assignment identifier generator_expression attribute identifier identifier for_in_clause identifier identifier if_clause call identifier argument_list identifier identifier return_statement call identifier argument_list identifier
Filter out AST nodes that are subclasses of ``superclass``.
def _from_dict(cls, _dict): args = {} if 'key' in _dict: args['key'] = _dict.get('key') if 'matching_results' in _dict: args['matching_results'] = _dict.get('matching_results') if 'aggregations' in _dict: args['aggregations'] = [ QueryAggregation._from_dict(x) for x in (_dict.get('aggregations')) ] return cls(**args)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier parenthesized_expression call attribute identifier identifier argument_list string string_start string_content string_end return_statement call identifier argument_list dictionary_splat identifier
Initialize a AggregationResult object from a json dictionary.
def _get_users_of_group(config, group): if not group: return set() fas = fmn.rules.utils.get_fas(config) return fmn.rules.utils.get_user_of_group(config, fas, group)
module function_definition identifier parameters identifier identifier block if_statement not_operator identifier block return_statement call identifier argument_list expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier identifier identifier
Utility to query fas for users of a group.
def _send(self): self.queue.submit() self.queue_max_timestamp = int(time.time() + self.queue_max_interval) self.current_n_measurements = 0
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier call identifier argument_list binary_operator call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier integer
Send data to Librato.
def _update_subscribers(self, val): self._value = val for callback in self._observer_callbacks: callback(self._address, self._group, val)
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier identifier for_statement identifier attribute identifier identifier block expression_statement call identifier argument_list attribute identifier identifier attribute identifier identifier identifier
Save state value and notify listeners of the change.
def fix_all(override_debug=False, override_all=False): fix_base(True) fix_builtins(override_debug) fix_subprocess(override_debug, override_all) return True
module function_definition identifier parameters default_parameter identifier false default_parameter identifier false block expression_statement call identifier argument_list true expression_statement call identifier argument_list identifier expression_statement call identifier argument_list identifier identifier return_statement true
Activate the full compatibility.
def finalize(self): print('{} default sprite names found:'.format(self.total_default)) for name in self.list_default: print(name)
module function_definition identifier parameters identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier for_statement identifier attribute identifier identifier block expression_statement call identifier argument_list identifier
Output the default sprite names found in the project.
def find_default_container(builder, default_container=None, use_biocontainers=None, ): if not default_container and use_biocontainers: default_container = get_container_from_software_requirements( use_biocontainers, builder) return default_container
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block if_statement boolean_operator not_operator identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier return_statement identifier
Default finder for default containers.
def filter_infinity(self): mask = self.coordinates[:, 2] > self.coordinates[:, 2].min() coords = self.coordinates[mask] colors = self.colors[mask] return PointCloud(coords, colors)
module function_definition identifier parameters identifier block expression_statement assignment identifier comparison_operator subscript attribute identifier identifier slice integer call attribute subscript attribute identifier identifier slice integer identifier argument_list expression_statement assignment identifier subscript attribute identifier identifier identifier expression_statement assignment identifier subscript attribute identifier identifier identifier return_statement call identifier argument_list identifier identifier
Filter infinite distances from ``PointCloud.``
def config_function(self, token): match = token["match"] function = match.group(2).lower() param = match.group(3) or "" value_type = match.group(6) or "auto" param = param.replace(r"\)", ")") CONFIG_FUNCTIONS = { "base64": self.make_function_value_private, "env": self.make_value_from_env, "hide": self.make_function_value_private, "shell": self.make_value_from_shell, } return CONFIG_FUNCTIONS[function](param, value_type, function)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute call attribute identifier identifier argument_list integer identifier argument_list expression_statement assignment identifier boolean_operator call attribute identifier identifier argument_list integer string string_start string_end expression_statement assignment identifier boolean_operator call attribute identifier identifier argument_list integer 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 dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier return_statement call subscript identifier identifier argument_list identifier identifier identifier
Process a config function from a token
def complement(self): self.check() for key in CMAOptions.defaults(): if key not in self: self[key] = CMAOptions.defaults()[key] return self
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list for_statement identifier call attribute identifier identifier argument_list block if_statement comparison_operator identifier identifier block expression_statement assignment subscript identifier identifier subscript call attribute identifier identifier argument_list identifier return_statement identifier
add all missing options with their default values
def _get_search_text(self, cli): if self.preview_search(cli) and cli.buffers[self.search_buffer_name].text: return cli.buffers[self.search_buffer_name].text else: return self.get_search_state(cli).text
module function_definition identifier parameters identifier identifier block if_statement boolean_operator call attribute identifier identifier argument_list identifier attribute subscript attribute identifier identifier attribute identifier identifier identifier block return_statement attribute subscript attribute identifier identifier attribute identifier identifier identifier else_clause block return_statement attribute call attribute identifier identifier argument_list identifier identifier
The text we are searching for.
def deregister_listener(self, member_uuid, listener): self._casts[str(member_uuid)]['listeners'].remove(listener)
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute subscript subscript attribute identifier identifier call identifier argument_list identifier string string_start string_content string_end identifier argument_list identifier
Deregister listener for audio group changes of cast uuid.
def reload(self): if time.time() - self.updated > self.ttl: self.force_reload()
module function_definition identifier parameters identifier block if_statement comparison_operator binary_operator call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list
Reload catalog if sufficient time has passed
def _from_dict(cls, _dict): args = {} if 'feedback' in _dict: args['feedback'] = [ GetFeedback._from_dict(x) for x in (_dict.get('feedback')) ] return cls(**args)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier parenthesized_expression call attribute identifier identifier argument_list string string_start string_content string_end return_statement call identifier argument_list dictionary_splat identifier
Initialize a FeedbackList object from a json dictionary.
def __init(self): params = { "f" : "json" } json_dict = self._get(url=self._url, param_dict=params, securityHandler=self._securityHandler, proxy_url=self._proxy_url, proxy_port=self._proxy_port) attributes = [attr for attr in dir(self) if not attr.startswith('__') and \ not attr.startswith('_')] for k,v in json_dict.items(): if k in attributes: setattr(self, "_"+ k, json_dict[k]) else: print( k, " - attribute not implemented in RouteNetworkLayer.") del k,v
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement assignment identifier list_comprehension identifier for_in_clause identifier call identifier argument_list identifier if_clause boolean_operator not_operator call attribute identifier identifier argument_list string string_start string_content string_end line_continuation not_operator call attribute identifier identifier argument_list string string_start string_content string_end for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement comparison_operator identifier identifier block expression_statement call identifier argument_list identifier binary_operator string string_start string_content string_end identifier subscript identifier identifier else_clause block expression_statement call identifier argument_list identifier string string_start string_content string_end delete_statement expression_list identifier identifier
initializes all the properties
def exit(self, exit_code): self.inhibit_autoret = True self.state.options.discard(o.AST_DEPS) self.state.options.discard(o.AUTO_REFS) if isinstance(exit_code, int): exit_code = self.state.solver.BVV(exit_code, self.state.arch.bits) self.state.history.add_event('terminate', exit_code=exit_code) self.successors.add_successor(self.state, self.state.regs.ip, self.state.solver.true, 'Ijk_Exit')
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier true expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier attribute attribute attribute identifier identifier identifier identifier expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier attribute attribute attribute identifier identifier identifier identifier attribute attribute attribute identifier identifier identifier identifier string string_start string_content string_end
Add an exit representing terminating the program.
def main(): filename = pmag.get_named_arg('-f') if not filename: return with open(filename, 'rb+') as f: content = f.read() f.seek(0) f.write(content.replace(b'\r', b'')) f.truncate()
module function_definition identifier parameters block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement not_operator identifier block return_statement 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 assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end string string_start string_end expression_statement call attribute identifier identifier argument_list
Take out dos problem characters from any file
def assemble_cx(): if request.method == 'OPTIONS': return {} response = request.body.read().decode('utf-8') body = json.loads(response) stmts_json = body.get('statements') stmts = stmts_from_json(stmts_json) ca = CxAssembler(stmts) model_str = ca.make_model() res = {'model': model_str} return res
module function_definition identifier parameters block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block return_statement dictionary expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier return_statement identifier
Assemble INDRA Statements and return CX network json.
def open_magnet(self): if sys.platform.startswith('linux'): subprocess.Popen(['xdg-open', self.magnet], stdout=subprocess.PIPE, stderr=subprocess.PIPE) elif sys.platform.startswith('win32'): os.startfile(self.magnet) elif sys.platform.startswith('cygwin'): os.startfile(self.magnet) elif sys.platform.startswith('darwin'): subprocess.Popen(['open', self.magnet], stdout=subprocess.PIPE, stderr=subprocess.PIPE) else: subprocess.Popen(['xdg-open', self.magnet], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
module function_definition identifier parameters identifier block if_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list list string string_start string_content string_end attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier elif_clause call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list attribute identifier identifier elif_clause call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list attribute identifier identifier elif_clause call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list list string string_start string_content string_end attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list list string string_start string_content string_end attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier
Open magnet according to os.
def getSkeletalTrackingLevel(self, action): fn = self.function_table.getSkeletalTrackingLevel pSkeletalTrackingLevel = EVRSkeletalTrackingLevel() result = fn(action, byref(pSkeletalTrackingLevel)) return result, pSkeletalTrackingLevel
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call identifier argument_list identifier call identifier argument_list identifier return_statement expression_list identifier identifier
Reads the level of accuracy to which the controller is able to track the user to recreate a skeletal pose
def add_threadlocal(self, **values): with self._lock: self._ensure_threadlocal() self._tpayload.context.update(**values)
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block with_statement with_clause with_item attribute identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list dictionary_splat identifier
Add `values` to current thread's logging context
def response_handler(msg: Dict[str, str]) -> None: from wdom.document import getElementByWdomId id = msg['id'] elm = getElementByWdomId(id) if elm: elm.on_response(msg) else: logger.warning('No such element: wdom_id={}'.format(id))
module function_definition identifier parameters typed_parameter identifier type generic_type identifier type_parameter type identifier type identifier type none block import_from_statement dotted_name identifier identifier dotted_name identifier expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier
Handle response sent by browser.
def init_domain_ledger(self): if self.config.primaryStorage is None: genesis_txn_initiator = GenesisTxnInitiatorFromFile( self.genesis_dir, self.config.domainTransactionsFile) return Ledger( CompactMerkleTree( hashStore=self.getHashStore('domain')), dataDir=self.dataLocation, fileName=self.config.domainTransactionsFile, ensureDurability=self.config.EnsureLedgerDurability, genesis_txn_initiator=genesis_txn_initiator) else: return initStorage(self.config.primaryStorage, name=self.name + NODE_PRIMARY_STORAGE_SUFFIX, dataDir=self.dataLocation, config=self.config)
module function_definition identifier parameters identifier block if_statement comparison_operator attribute attribute identifier identifier identifier none block expression_statement assignment identifier call identifier argument_list attribute identifier identifier attribute attribute identifier identifier identifier return_statement call identifier argument_list call identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier identifier else_clause block return_statement call identifier argument_list attribute attribute identifier identifier identifier keyword_argument identifier binary_operator attribute identifier identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier
This is usually an implementation of Ledger
def chassis(self): self._check_session() status, data = self._rest.get_request('chassis') return data
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end return_statement identifier
Get list of chassis known to test session.
def createSections(self): self.soma = h.Section(name='soma', cell=self) self.dend = h.Section(name='dend', cell=self)
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier
Create the sections of the cell.
def initializePage(self): tree = self.uiStructureTREE tree.blockSignals(True) tree.setUpdatesEnabled(False) self.uiStructureTREE.clear() xstruct = self.scaffold().structure() self._structure = xstruct for xentry in xstruct: XScaffoldElementItem(tree, xentry) tree.blockSignals(False) tree.setUpdatesEnabled(True)
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list true expression_statement call attribute identifier identifier argument_list false expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list expression_statement assignment attribute identifier identifier identifier for_statement identifier identifier block expression_statement call identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list false expression_statement call attribute identifier identifier argument_list true
Initializes the page based on the current structure information.
def remove_accents(value): search = 'ΆΈΉΊΌΎΏάέήίόύώΪϊΐϋΰ' replace = 'ΑΕΗΙΟΥΩαεηιουωΙιιυυ' def replace_accented_character(match): matched = match.group(0) if matched in search: return replace[search.find(matched)] return matched return re.sub(r'[{0}]+'.format(search), replace_accented_character, value)
module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list integer if_statement comparison_operator identifier identifier block return_statement subscript identifier call attribute identifier identifier argument_list identifier return_statement identifier return_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier identifier
Remove accents from characters in the given string.
def _safe_path(filepath, can_be_cwl=False): if filepath in {'.gitignore', '.gitattributes'}: return False if filepath.startswith('.renku'): if can_be_cwl and filepath.endswith('.cwl'): return True return False return True
module function_definition identifier parameters identifier default_parameter identifier false block if_statement comparison_operator identifier set string string_start string_content string_end string string_start string_content string_end block return_statement false if_statement call attribute identifier identifier argument_list string string_start string_content string_end block if_statement boolean_operator identifier call attribute identifier identifier argument_list string string_start string_content string_end block return_statement true return_statement false return_statement true
Check if the path should be used in output.
def iter_parsed_values(self, field: Field) -> Iterable[Tuple[str, Any]]: for key, func in self.parsers.items(): value = func(field) if not value: continue yield key, value
module function_definition identifier parameters identifier typed_parameter identifier type identifier type generic_type identifier type_parameter type generic_type identifier type_parameter type identifier type identifier block for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block expression_statement assignment identifier call identifier argument_list identifier if_statement not_operator identifier block continue_statement expression_statement yield expression_list identifier identifier
Walk the dictionary of parsers and emit all non-null values.
def absolute(value): try: return abs(valid_numeric(value)) except (ValueError, TypeError): try: return abs(value) except Exception: return ''
module function_definition identifier parameters identifier block try_statement block return_statement call identifier argument_list call identifier argument_list identifier except_clause tuple identifier identifier block try_statement block return_statement call identifier argument_list identifier except_clause identifier block return_statement string string_start string_end
Return the absolute value.
def refract(alt_degrees, temperature_C, pressure_mbar): alt = alt_degrees while True: alt1 = alt alt = alt_degrees + refraction(alt, temperature_C, pressure_mbar) converged = abs(alt - alt1) <= 3.0e-5 if converged.all(): break return alt
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier identifier while_statement true block expression_statement assignment identifier identifier expression_statement assignment identifier binary_operator identifier call identifier argument_list identifier identifier identifier expression_statement assignment identifier comparison_operator call identifier argument_list binary_operator identifier identifier float if_statement call attribute identifier identifier argument_list block break_statement return_statement identifier
Given an unrefracted `alt` determine where it will appear in the sky.
def models_from_model(model, include_related=False, exclude=None): if exclude is None: exclude = set() if model and model not in exclude: exclude.add(model) if isinstance(model, ModelType) and not model._meta.abstract: yield model if include_related: exclude.add(model) for field in model._meta.fields: if hasattr(field, 'relmodel'): through = getattr(field, 'through', None) for rmodel in (field.relmodel, field.model, through): for m in models_from_model( rmodel, include_related=include_related, exclude=exclude): yield m for manytomany in model._meta.manytomany: related = getattr(model, manytomany) for m in models_from_model(related.model, include_related=include_related, exclude=exclude): yield m elif not isinstance(model, ModelType) and isclass(model): yield model
module function_definition identifier parameters identifier default_parameter identifier false default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list if_statement boolean_operator identifier comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier if_statement boolean_operator call identifier argument_list identifier identifier not_operator attribute attribute identifier identifier identifier block expression_statement yield identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier for_statement identifier attribute attribute identifier identifier identifier block if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end none for_statement identifier tuple attribute identifier identifier attribute identifier identifier identifier block for_statement identifier call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier block expression_statement yield identifier for_statement identifier attribute attribute identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier for_statement identifier call identifier argument_list attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier block expression_statement yield identifier elif_clause boolean_operator not_operator call identifier argument_list identifier identifier call identifier argument_list identifier block expression_statement yield identifier
Generator of all model in model.
def mk_kwargs(cls, kwargs): ret = {} kws = ['row_factory', 'body', 'parent'] for k in kws: if k in kwargs: ret[k] = kwargs.pop(k) return ret
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end for_statement identifier identifier block if_statement comparison_operator identifier identifier block expression_statement assignment subscript identifier identifier call attribute identifier identifier argument_list identifier return_statement identifier
Pop recognized arguments from a keyword list.
def loadFromFile(self, filename): file = open(filename, 'rb') try: wsdl = self.loadFromStream(file) finally: file.close() return wsdl
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier finally_clause block expression_statement call attribute identifier identifier argument_list return_statement identifier
Return a WSDL instance loaded from the given file.
def logout(request): request.response.headers.extend(forget(request)) return {'redirect': request.POST.get('came_from', '/')}
module function_definition identifier parameters identifier block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list call identifier argument_list identifier return_statement dictionary pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end
View to forget the user
def serverDirectories(self): directs = [] url = self._url + "/directories" params = { "f" : "json" } res = self._get(url=url, param_dict=params, securityHandler=self._securityHandler, proxy_url=self._proxy_url, proxy_port=self._proxy_port) for direct in res['directories']: directs.append( ServerDirectory(url=url + "/%s" % direct["name"], securityHandler=self._securityHandler, proxy_url=self._proxy_url, proxy_port=self._proxy_port, initialize=True)) return directs
module function_definition identifier parameters identifier block expression_statement assignment identifier list 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 string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier for_statement identifier subscript identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list call identifier argument_list keyword_argument identifier binary_operator identifier binary_operator string string_start string_content string_end subscript identifier 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 keyword_argument identifier true return_statement identifier
returns the server directory object in a list
def flatten(items,enter=lambda x:isinstance(x, list)): for x in items: if enter(x): yield from flatten(x) else: yield x
module function_definition identifier parameters identifier default_parameter identifier lambda lambda_parameters identifier call identifier argument_list identifier identifier block for_statement identifier identifier block if_statement call identifier argument_list identifier block expression_statement yield call identifier argument_list identifier else_clause block expression_statement yield identifier
Yield items from any nested iterable; see REF.
def visit_Name(self, node, store_as_param=False, **kwargs): if store_as_param or node.ctx == 'param': self.symbols.declare_parameter(node.name) elif node.ctx == 'store': self.symbols.store(node.name) elif node.ctx == 'load': self.symbols.load(node.name)
module function_definition identifier parameters identifier identifier default_parameter identifier false dictionary_splat_pattern identifier block if_statement boolean_operator identifier comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier
All assignments to names go through this function.
def _BuildHttpRoutingMap(self, router_cls): if not issubclass(router_cls, api_call_router.ApiCallRouter): raise ValueError("Router has to be an instance of ApiCallRouter.") routing_map = routing.Map() for _, metadata in iteritems(router_cls.GetAnnotatedMethods()): for http_method, path, unused_options in metadata.http_methods: routing_map.add( routing.Rule(path, methods=[http_method], endpoint=metadata)) routing_map.add( routing.Rule( path.replace("/api/", "/api/v2/"), methods=[http_method], endpoint=metadata)) return routing_map
module function_definition identifier parameters identifier identifier block if_statement not_operator call identifier argument_list identifier attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list for_statement pattern_list identifier identifier call identifier argument_list call attribute identifier identifier argument_list block for_statement pattern_list identifier identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier list identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier list identifier keyword_argument identifier identifier return_statement identifier
Builds a werkzeug routing map out of a given router class.
def _getMessage(session, txid): while True: if txid in session.messages: msg = session.messages[txid] del session.messages[txid] return msg else: try: nextMessage = session.queue.get(timeout=100) except queue.Empty: continue if 'txid' in nextMessage: session.messages[nextMessage['txid']] = nextMessage else: logger.info("message with no txid: %s" % nextMessage)
module function_definition identifier parameters identifier identifier block while_statement true block if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier identifier delete_statement subscript attribute identifier identifier identifier return_statement identifier else_clause block try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier integer except_clause attribute identifier identifier block continue_statement if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript attribute identifier identifier subscript identifier string string_start string_content string_end identifier else_clause block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier
Getting message associated with txid
def find_binary(self, binary): if os.path.exists(binary): return binary binary_name = os.path.basename(binary) search_paths = os.environ['PATH'].split(':') default_paths = [ '/usr/bin', '/bin' '/usr/local/bin', '/usr/sbin', '/sbin' '/usr/local/sbin', ] for path in default_paths: if path not in search_paths: search_paths.append(path) for path in search_paths: if os.path.isdir(path): filename = os.path.join(path, binary_name) if os.path.exists(filename): return filename return binary
module function_definition identifier parameters identifier identifier block if_statement call attribute attribute identifier identifier identifier argument_list identifier block return_statement identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end expression_statement assignment identifier list string string_start string_content string_end concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end concatenated_string string string_start string_content string_end string string_start string_content string_end for_statement identifier identifier block if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier for_statement identifier identifier block if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier if_statement call attribute attribute identifier identifier identifier argument_list identifier block return_statement identifier return_statement identifier
Scan and return the first path to a binary that we can find
def listen(self): self.validate_listeners() with ARBITRATOR.condition: while self.connected: ARBITRATOR.condition.wait() if not self.run_queues(): break
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list with_statement with_clause with_item attribute identifier identifier block while_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list if_statement not_operator call attribute identifier identifier argument_list block break_statement
Listen for changes in all registered listeners.
def evaluate_single_config( hparams, sampling_temp, max_num_noops, agent_model_dir, eval_fn=_eval_fn_with_learner ): tf.logging.info("Evaluating metric %s", get_metric_name( sampling_temp, max_num_noops, clipped=False )) eval_hparams = trainer_lib.create_hparams(hparams.base_algo_params) env = setup_env( hparams, batch_size=hparams.eval_batch_size, max_num_noops=max_num_noops, rl_env_max_episode_steps=hparams.eval_rl_env_max_episode_steps, env_name=hparams.rl_env_name) env.start_new_epoch(0) eval_fn(env, hparams, eval_hparams, agent_model_dir, sampling_temp) rollouts = env.current_epoch_rollouts() env.close() return tuple( compute_mean_reward(rollouts, clipped) for clipped in (True, False) )
module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end call identifier argument_list identifier identifier keyword_argument identifier false expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list integer expression_statement call identifier argument_list identifier identifier identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list return_statement call identifier generator_expression call identifier argument_list identifier identifier for_in_clause identifier tuple true false
Evaluate the PPO agent in the real environment.
def bounds_handler(ctx, param, value): retval = from_like_context(ctx, param, value) if retval is None and value is not None: try: value = value.strip(", []") retval = tuple(float(x) for x in re.split(r"[,\s]+", value)) assert len(retval) == 4 return retval except Exception: raise click.BadParameter( "{0!r} is not a valid bounding box representation".format(value) ) else: return retval
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier identifier if_statement boolean_operator comparison_operator identifier none comparison_operator identifier none block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier generator_expression call identifier argument_list identifier for_in_clause identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier assert_statement comparison_operator call identifier argument_list identifier integer return_statement identifier except_clause identifier block raise_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier else_clause block return_statement identifier
Handle different forms of bounds.