code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def find_ge(self, item): 'Return first item with a key >= equal to item. Raise ValueError if not found' k = self._key(item) i = bisect_left(self._keys, k) if i != len(self): return self._items[i] raise ValueError('No item found with key at or above: %r' % (k,))
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier identifier if_statement comparison_operator identifier call identifier argument_list identifier block return_statement subscript attribute identifier identifier identifier raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier
Return first item with a key >= equal to item. Raise ValueError if not found
def stdin_to_vobject(self, lines): cal = iCalendar() for event in self._parse_remind('-', lines)['-'].values(): self._gen_vevent(event, cal.add('vevent')) return cal
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list for_statement identifier call attribute subscript call attribute identifier identifier argument_list string string_start string_content string_end identifier string string_start string_content string_end identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier
Return iCal object of the Remind commands in lines
def filter_contour(imageFile, opFile): im = Image.open(imageFile) im1 = im.filter(ImageFilter.CONTOUR) im1.save(opFile)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier
convert an image by applying a contour
def _parse_attribute( self, element, attribute, state ): parsed_value = self._default attribute_value = element.get(attribute, None) if attribute_value is not None: parsed_value = self._parser_func(attribute_value, state) elif self.required: state.raise_error( MissingValue, 'Missing required attribute "{}" on element "{}"'.format( self._attribute, element.tag ) ) return parsed_value
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier none if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier elif_clause attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier attribute identifier identifier return_statement identifier
Parse the primitive value within the XML element's attribute.
def create_option_pool(self): return OptionPool( self.networkapi_url, self.user, self.password, self.user_ldap)
module function_definition identifier parameters identifier block return_statement call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier
Get an instance of option_pool services facade.
def export(self, out_filename): with zipfile.ZipFile(out_filename, 'w', zipfile.ZIP_DEFLATED) as arc: id_list = list(self.get_thread_info()) for num, my_info in enumerate(id_list): logging.info('Working on item %i : %s', num, my_info['number']) my_thread = GitHubCommentThread( self.gh_info.owner, self.gh_info.realm, my_info['title'], self.gh_info.user, self.gh_info.token, thread_id=my_info['number']) csec = my_thread.get_comment_section() cdict = [item.to_dict() for item in csec.comments] my_json = json.dumps(cdict) arc.writestr('%i__%s' % (my_info['number'], my_info['title']), my_json)
module function_definition identifier parameters identifier identifier block with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list identifier string string_start string_content string_end attribute identifier identifier as_pattern_target identifier block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier subscript identifier string string_start string_content string_end attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier keyword_argument identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list for_in_clause identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end identifier
Export desired threads as a zipfile to out_filename.
def documents(cls, filter=None, **kwargs): documents = [cls(document) for document in cls.find(filter, **kwargs)] return [document for document in documents if document.document]
module function_definition identifier parameters identifier default_parameter identifier none dictionary_splat_pattern identifier block expression_statement assignment identifier list_comprehension call identifier argument_list identifier for_in_clause identifier call attribute identifier identifier argument_list identifier dictionary_splat identifier return_statement list_comprehension identifier for_in_clause identifier identifier if_clause attribute identifier identifier
Returns a list of Documents if any document is filtered
def handle_purge(environ, start_response): from utils import is_valid_security, get_cached_files from settings import DEBUG server = environ['SERVER_NAME'] try: request_uri = get_path(environ) path_and_query = request_uri.lstrip("/") query_string = environ.get('QUERY_STRING', '') if is_valid_security('PURGE', query_string): cached_files = get_cached_files(path_and_query, server) for i in cached_files: try: os.remove(i) except OSError as e: return do_500(environ, start_response, e.message) start_response("204 No Content", []) return [] else: return do_405(environ, start_response) except Http404 as e: return do_404(environ, start_response, e.message, DEBUG)
module function_definition identifier parameters identifier identifier block import_from_statement dotted_name identifier dotted_name identifier dotted_name identifier import_from_statement dotted_name identifier dotted_name identifier expression_statement assignment identifier subscript identifier string string_start string_content string_end try_statement block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end if_statement call identifier argument_list string string_start string_content string_end identifier block expression_statement assignment identifier call identifier argument_list identifier identifier for_statement identifier identifier block try_statement block expression_statement call attribute identifier identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block return_statement call identifier argument_list identifier identifier attribute identifier identifier expression_statement call identifier argument_list string string_start string_content string_end list return_statement list else_clause block return_statement call identifier argument_list identifier identifier except_clause as_pattern identifier as_pattern_target identifier block return_statement call identifier argument_list identifier identifier attribute identifier identifier identifier
Handle a PURGE request.
def disconnect(self): self.__stop_timer() for event in self.__in_flight.values(): event.set() self.__mqtt.disconnect() thread = threading.Thread(target=self.__mqtt.loop_stop) thread.daemon = True thread.start() thread.join(4)
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list for_statement identifier call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier attribute attribute identifier identifier identifier expression_statement assignment attribute identifier identifier true expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list integer
Disconnects from the MQTT server
async def run_checks(self): async for check in self.fsm.health_check(): yield check async for check in self.self_check(): yield check for check in MiddlewareManager.health_check(): yield check
module function_definition identifier parameters identifier block for_statement identifier call attribute attribute identifier identifier identifier argument_list block expression_statement yield identifier for_statement identifier call attribute identifier identifier argument_list block expression_statement yield identifier for_statement identifier call attribute identifier identifier argument_list block expression_statement yield identifier
Run checks on itself and on the FSM
def cublasZtpsv(handle, uplo, trans, diag, n, AP, x, incx): status = _libcublas.cublasZtpsv_v2(handle, _CUBLAS_FILL_MODE[uplo], _CUBLAS_OP[trans], _CUBLAS_DIAG[diag], n, int(AP), int(x), incx) cublasCheckStatus(status)
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier subscript identifier identifier subscript identifier identifier subscript identifier identifier identifier call identifier argument_list identifier call identifier argument_list identifier identifier expression_statement call identifier argument_list identifier
Solve complex triangular-packed system with one right-hand size.
def run_with_werkzeug(self, **options): threaded = self.threads is not None and (self.threads > 0) self.app.run( host=self.host, port=self.port, debug=self.debug, threaded=threaded, **options )
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier boolean_operator comparison_operator attribute identifier identifier none parenthesized_expression comparison_operator attribute identifier identifier integer 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 attribute identifier identifier keyword_argument identifier identifier dictionary_splat identifier
Run with werkzeug simple wsgi container.
def staking_leaderboard(round_num=0, tournament=1): click.echo(prettify(napi.get_staking_leaderboard(tournament=tournament, round_num=round_num)))
module function_definition identifier parameters default_parameter identifier integer default_parameter identifier integer block expression_statement call attribute identifier identifier argument_list call identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier
Retrieves the staking competition leaderboard for the given round.
def pubmed_citation(args=sys.argv[1:], out=sys.stdout): parser = argparse.ArgumentParser( description='Get a citation using a PubMed ID or PubMed URL') parser.add_argument('query', help='PubMed ID or PubMed URL') parser.add_argument( '-m', '--mini', action='store_true', help='get mini citation') parser.add_argument( '-e', '--email', action='store', help='set user email', default='') args = parser.parse_args(args=args) lookup = PubMedLookup(args.query, args.email) publication = Publication(lookup, resolve_doi=False) if args.mini: out.write(publication.cite_mini() + '\n') else: out.write(publication.cite() + '\n')
module function_definition identifier parameters default_parameter identifier subscript attribute identifier identifier slice integer default_parameter identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_end expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier false if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end else_clause block expression_statement call attribute identifier identifier argument_list binary_operator call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end
Get a citation via the command line using a PubMed ID or PubMed URL
def newest(self): if self._order_by == 'newest': return self.first if self._order_by == 'oldest': return self.last return max(self.entries, key=lambda x: (x.date, x.id))
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block return_statement attribute identifier identifier if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block return_statement attribute identifier identifier return_statement call identifier argument_list attribute identifier identifier keyword_argument identifier lambda lambda_parameters identifier tuple attribute identifier identifier attribute identifier identifier
Gets the newest entry in the view, regardless of sort order
def _fit_bmr_model(self, X, y): self.f_bmr = BayesMinimumRiskClassifier() X_bmr = self.predict_proba(X) self.f_bmr.fit(y, X_bmr) return self
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier return_statement identifier
Private function used to fit the BayesMinimumRisk model.
def to_match(self): self.validate() mark_name, field_name = self.location.get_location_name() validate_safe_string(mark_name) validate_safe_string(field_name) return u'%s.%s' % (mark_name, field_name)
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 expression_statement call identifier argument_list identifier expression_statement call identifier argument_list identifier return_statement binary_operator string string_start string_content string_end tuple identifier identifier
Return a unicode object with the MATCH representation of this GlobalContextField.
def V_(x, requires_grad=False, volatile=False): return create_variable(x, volatile=volatile, requires_grad=requires_grad)
module function_definition identifier parameters identifier default_parameter identifier false default_parameter identifier false block return_statement call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier
equivalent to create_variable, which creates a pytorch tensor
def disbatch(self): ret = [] for low in self.lowstate: if not self._verify_client(low): return if self.token is not None and 'token' not in low: low['token'] = self.token if not (('token' in low) or ('username' in low and 'password' in low and 'eauth' in low)): ret.append('Failed to authenticate') break try: chunk_ret = yield getattr(self, '_disbatch_{0}'.format(low['client']))(low) ret.append(chunk_ret) except (AuthenticationError, AuthorizationError, EauthAuthenticationError): ret.append('Failed to authenticate') break except Exception as ex: ret.append('Unexpected exception while handling request: {0}'.format(ex)) log.error('Unexpected exception while handling request:', exc_info=True) if not self._finished: self.write(self.serialize({'return': ret})) self.finish()
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier attribute identifier identifier block if_statement not_operator call attribute identifier identifier argument_list identifier block return_statement if_statement boolean_operator comparison_operator attribute identifier identifier none comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier if_statement not_operator parenthesized_expression boolean_operator parenthesized_expression comparison_operator string string_start string_content string_end identifier parenthesized_expression boolean_operator boolean_operator comparison_operator string string_start string_content string_end identifier comparison_operator string string_start string_content string_end identifier comparison_operator string string_start string_content string_end identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end break_statement try_statement block expression_statement assignment identifier yield call call identifier argument_list identifier call attribute string string_start string_content string_end identifier argument_list subscript identifier string string_start string_content string_end argument_list identifier expression_statement call attribute identifier identifier argument_list identifier except_clause tuple identifier identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end break_statement except_clause as_pattern 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 identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier true if_statement not_operator attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list
Disbatch all lowstates to the appropriate clients
def create_api_deployment(self): try: self.client.create_deployment(restApiId=self.api_id, stageName=self.env) self.log.info('Created a deployment resource.') except botocore.exceptions.ClientError as error: error_code = error.response['Error']['Code'] if error_code == 'TooManyRequestsException': self.log.debug('Retrying. We have hit api limit.') else: self.log.debug('Retrying. We received %s.', error_code)
module function_definition identifier parameters identifier block 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 expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end except_clause as_pattern attribute attribute identifier identifier identifier as_pattern_target identifier block expression_statement assignment identifier subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end if_statement comparison_operator identifier string string_start string_content string_end block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier
Create API deployment of ENV name.
def thumbnail_source_for_display_item(self, ui, display_item: DisplayItem.DisplayItem) -> ThumbnailSource: with self.__lock: thumbnail_source = self.__thumbnail_sources.get(display_item) if not thumbnail_source: thumbnail_source = ThumbnailSource(ui, display_item) self.__thumbnail_sources[display_item] = thumbnail_source def will_delete(thumbnail_source): del self.__thumbnail_sources[thumbnail_source._display_item] thumbnail_source._on_will_delete = will_delete else: assert thumbnail_source._ui == ui return thumbnail_source.add_ref()
module function_definition identifier parameters identifier identifier typed_parameter identifier type attribute identifier identifier type identifier block with_statement with_clause with_item attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement not_operator identifier block expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier function_definition identifier parameters identifier block delete_statement subscript attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier identifier else_clause block assert_statement comparison_operator attribute identifier identifier identifier return_statement call attribute identifier identifier argument_list
Returned ThumbnailSource must be closed.
def _create_union_types_specification(schema_graph, graphql_types, hidden_classes, base_name): def types_spec(): return [ graphql_types[x] for x in sorted(list(schema_graph.get_subclass_set(base_name))) if x not in hidden_classes ] return types_spec
module function_definition identifier parameters identifier identifier identifier identifier block function_definition identifier parameters block return_statement list_comprehension subscript identifier identifier for_in_clause identifier call identifier argument_list call identifier argument_list call attribute identifier identifier argument_list identifier if_clause comparison_operator identifier identifier return_statement identifier
Return a function that gives the types in the union type rooted at base_name.
def Parse(self, stat, file_object, knowledge_base): _, _ = stat, knowledge_base field_parser = NtpdFieldParser() for line in field_parser.ParseEntries( utils.ReadFileBytesAsUnicode(file_object)): field_parser.ParseLine(line) yield rdf_config_file.NtpConfig( config=field_parser.config, server=field_parser.keyed.get("server"), restrict=field_parser.keyed.get("restrict"), fudge=field_parser.keyed.get("fudge"), trap=field_parser.keyed.get("trap"), peer=field_parser.keyed.get("peer"), broadcast=field_parser.keyed.get("broadcast"), manycastclient=field_parser.keyed.get("manycastclient"))
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment pattern_list identifier identifier expression_list identifier identifier expression_statement assignment identifier call identifier argument_list for_statement identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement yield call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end
Parse a ntp config into rdf.
def sky2px(wcs,ra,dec,dra,ddec,cell, beam): dra = beam if dra<beam else dra ddec = beam if ddec<beam else ddec offsetDec = int((ddec/2.)/cell) offsetRA = int((dra/2.)/cell) if offsetDec%2==1: offsetDec += 1 if offsetRA%2==1: offsetRA += 1 raPix,decPix = map(int, wcs.wcs2pix(ra,dec)) return np.array([raPix-offsetRA,raPix+offsetRA,decPix-offsetDec,decPix+offsetDec])
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier conditional_expression identifier comparison_operator identifier identifier identifier expression_statement assignment identifier conditional_expression identifier comparison_operator identifier identifier identifier expression_statement assignment identifier call identifier argument_list binary_operator parenthesized_expression binary_operator identifier float identifier expression_statement assignment identifier call identifier argument_list binary_operator parenthesized_expression binary_operator identifier float identifier if_statement comparison_operator binary_operator identifier integer integer block expression_statement augmented_assignment identifier integer if_statement comparison_operator binary_operator identifier integer integer block expression_statement augmented_assignment identifier integer expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier call attribute identifier identifier argument_list identifier identifier return_statement call attribute identifier identifier argument_list list binary_operator identifier identifier binary_operator identifier identifier binary_operator identifier identifier binary_operator identifier identifier
convert a sky region to pixel positions
def recordlookup(table, key, dictionary=None): if dictionary is None: dictionary = dict() it = iter(table) hdr = next(it) flds = list(map(text_type, hdr)) keyindices = asindices(hdr, key) assert len(keyindices) > 0, 'no key selected' getkey = operator.itemgetter(*keyindices) for row in it: k = getkey(row) rec = Record(row, flds) if k in dictionary: l = dictionary[k] l.append(rec) dictionary[k] = l else: dictionary[k] = [rec] return dictionary
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier assert_statement comparison_operator call identifier argument_list identifier integer string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list list_splat identifier for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier identifier if_statement comparison_operator identifier identifier block expression_statement assignment identifier subscript identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment subscript identifier identifier identifier else_clause block expression_statement assignment subscript identifier identifier list identifier return_statement identifier
Load a dictionary with data from the given table, mapping to record objects.
def _normalize_batch(b:Tuple[Tensor,Tensor], mean:FloatTensor, std:FloatTensor, do_x:bool=True, do_y:bool=False)->Tuple[Tensor,Tensor]: "`b` = `x`,`y` - normalize `x` array of imgs and `do_y` optionally `y`." x,y = b mean,std = mean.to(x.device),std.to(x.device) if do_x: x = normalize(x,mean,std) if do_y and len(y.shape) == 4: y = normalize(y,mean,std) return x,y
module function_definition identifier parameters typed_parameter identifier type generic_type identifier type_parameter type identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_default_parameter identifier type identifier true typed_default_parameter identifier type identifier false type generic_type identifier type_parameter type identifier type identifier block expression_statement string string_start string_content string_end expression_statement assignment pattern_list identifier identifier identifier expression_statement assignment pattern_list identifier identifier expression_list call attribute identifier identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier if_statement identifier block expression_statement assignment identifier call identifier argument_list identifier identifier identifier if_statement boolean_operator identifier comparison_operator call identifier argument_list attribute identifier identifier integer block expression_statement assignment identifier call identifier argument_list identifier identifier identifier return_statement expression_list identifier identifier
`b` = `x`,`y` - normalize `x` array of imgs and `do_y` optionally `y`.
def _geom_points(geom): if geom['type'] == 'Point': yield tuple(geom['coordinates']) elif geom['type'] in ('MultiPoint', 'LineString'): for position in geom['coordinates']: yield tuple(position) else: raise InvalidFeatureError( "Unsupported geometry type:{0}".format(geom['type']))
module function_definition identifier parameters identifier block if_statement comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end block expression_statement yield call identifier argument_list subscript identifier string string_start string_content string_end elif_clause comparison_operator subscript identifier string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end block for_statement identifier subscript identifier string string_start string_content string_end block expression_statement yield call identifier argument_list identifier else_clause block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list subscript identifier string string_start string_content string_end
GeoJSON geometry to a sequence of point tuples
def printSequences(x, formatString="%d"): [seqLen, numElements] = x.shape for i in range(seqLen): s = "" for j in range(numElements): s += formatString % x[i][j] print s
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment list_pattern identifier identifier attribute identifier identifier for_statement identifier call identifier argument_list identifier block expression_statement assignment identifier string string_start string_end for_statement identifier call identifier argument_list identifier block expression_statement augmented_assignment identifier binary_operator identifier subscript subscript identifier identifier identifier print_statement identifier
Print a bunch of sequences stored in a 2D numpy array.
async def _get_tshark_process(self, packet_count=None, stdin=None): if self.use_json: output_type = 'json' if not tshark_supports_json(self.tshark_path): raise TSharkVersionException("JSON only supported on Wireshark >= 2.2.0") else: output_type = 'psml' if self._only_summaries else 'pdml' parameters = [self._get_tshark_path(), '-l', '-n', '-T', output_type] + \ self.get_parameters(packet_count=packet_count) self._log.debug('Creating TShark subprocess with parameters: ' + ' '.join(parameters)) self._log.debug('Executable: %s' % parameters[0]) tshark_process = await asyncio.create_subprocess_exec(*parameters, stdout=subprocess.PIPE, stderr=self._stderr_output(), stdin=stdin) self._created_new_process(parameters, tshark_process) return tshark_process
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block if_statement attribute identifier identifier block expression_statement assignment identifier string string_start string_content string_end if_statement not_operator call identifier argument_list attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end else_clause block expression_statement assignment identifier conditional_expression string string_start string_content string_end attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier binary_operator list 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 line_continuation call attribute identifier identifier argument_list keyword_argument identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end subscript identifier integer expression_statement assignment identifier await call attribute identifier identifier argument_list list_splat identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier call attribute identifier identifier argument_list keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier return_statement identifier
Returns a new tshark process with previously-set parameters.
def partition(self, ref=None, **kwargs): from .exc import NotFoundError from six import text_type if ref: for p in self.partitions: if (text_type(ref) == text_type(p.name) or text_type(ref) == text_type(p.id) or text_type(ref) == text_type(p.vid)): return p raise NotFoundError("Failed to find partition for ref '{}' in dataset '{}'".format(ref, self.name)) elif kwargs: from ..identity import PartitionNameQuery pnq = PartitionNameQuery(**kwargs) return self._find_orm
module function_definition identifier parameters identifier default_parameter identifier none dictionary_splat_pattern identifier block import_from_statement relative_import import_prefix dotted_name identifier dotted_name identifier import_from_statement dotted_name identifier dotted_name identifier if_statement identifier block for_statement identifier attribute identifier identifier block if_statement parenthesized_expression boolean_operator boolean_operator comparison_operator call identifier argument_list identifier call identifier argument_list attribute identifier identifier comparison_operator call identifier argument_list identifier call identifier argument_list attribute identifier identifier comparison_operator call identifier argument_list identifier call identifier argument_list attribute identifier identifier block return_statement identifier raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier attribute identifier identifier elif_clause identifier block import_from_statement relative_import import_prefix dotted_name identifier dotted_name identifier expression_statement assignment identifier call identifier argument_list dictionary_splat identifier return_statement attribute identifier identifier
Returns partition by ref.
def _validate_func_args(func, kwargs): args, varargs, varkw, defaults = inspect.getargspec(func) if set(kwargs.keys()) != set(args[1:]): raise TypeError("decorator kwargs do not match %s()'s kwargs" % func.__name__)
module function_definition identifier parameters identifier identifier block expression_statement assignment pattern_list identifier identifier identifier identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator call identifier argument_list call attribute identifier identifier argument_list call identifier argument_list subscript identifier slice integer block raise_statement call identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier
Validate decorator args when used to decorate a function.
def detect_port(port): socket_test = socket.socket(socket.AF_INET,socket.SOCK_STREAM) try: socket_test.connect(('127.0.0.1', int(port))) socket_test.close() return True except: return False
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier try_statement block expression_statement call attribute identifier identifier argument_list tuple string string_start string_content string_end call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list return_statement true except_clause block return_statement false
Detect if the port is used
def _pwr_optfcn(df, loc): I = _lambertw_i_from_v(df['r_sh'], df['r_s'], df['nNsVth'], df[loc], df['i_0'], df['i_l']) return I * df[loc]
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier identifier subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end return_statement binary_operator identifier subscript identifier identifier
Function to find power from ``i_from_v``.
def retrieve_layers(self, *args, **options): queryset = Q() if len(args) < 1: all_layers = Layer.objects.published().external() if options['exclude']: exclude_list = options['exclude'].replace(' ', '').split(',') return all_layers.exclude(slug__in=exclude_list) else: self.verbose('no layer specified, will retrieve all layers!') return all_layers for layer_slug in args: queryset = queryset | Q(slug=layer_slug) try: layer = Layer.objects.get(slug=layer_slug) if not layer.is_external: raise CommandError('Layer "%s" is not an external layer\n\r' % layer_slug) if not layer.is_published: raise CommandError('Layer "%s" is not published. Why are you trying to work on an unpublished layer?\n\r' % layer_slug) except Layer.DoesNotExist: raise CommandError('Layer "%s" does not exist\n\r' % layer_slug) return Layer.objects.published().external().select_related().filter(queryset)
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list if_statement subscript identifier string string_start string_content string_end block expression_statement assignment identifier call attribute call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end string string_start string_end identifier argument_list string string_start string_content string_end return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier for_statement identifier identifier block expression_statement assignment identifier binary_operator identifier call identifier argument_list keyword_argument identifier identifier try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier if_statement not_operator attribute identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content escape_sequence escape_sequence string_end identifier if_statement not_operator attribute identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content escape_sequence escape_sequence string_end identifier except_clause attribute identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content escape_sequence escape_sequence string_end identifier return_statement call attribute call attribute call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list identifier argument_list identifier argument_list identifier
Retrieve specified layers or all external layers if no layer specified.
def _set_line_indent(src, line, indent): if not indent: return line idt = [] for c in src: if c not in ['\t', ' ']: break idt.append(c) return ''.join(idt) + line.lstrip()
module function_definition identifier parameters identifier identifier identifier block if_statement not_operator identifier block return_statement identifier expression_statement assignment identifier list for_statement identifier identifier block if_statement comparison_operator identifier list string string_start string_content escape_sequence string_end string string_start string_content string_end block break_statement expression_statement call attribute identifier identifier argument_list identifier return_statement binary_operator call attribute string string_start string_end identifier argument_list identifier call attribute identifier identifier argument_list
Indent the line with the source line.
def _call_mount(self, volume, mountpoint, type=None, opts=""): if opts and not opts.endswith(','): opts += "," opts += 'loop,offset=' + str(volume.offset) + ',sizelimit=' + str(volume.size) cmd = ['mount', volume.get_raw_path(), mountpoint, '-o', opts] if not volume.disk.read_write: cmd[-1] += ',ro' if type is not None: cmd += ['-t', type] _util.check_output_(cmd, stderr=subprocess.STDOUT)
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none default_parameter identifier string string_start string_end block if_statement boolean_operator identifier not_operator call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement augmented_assignment identifier string string_start string_content string_end expression_statement augmented_assignment identifier binary_operator binary_operator binary_operator string string_start string_content string_end call identifier argument_list attribute identifier identifier string string_start string_content string_end call identifier argument_list attribute identifier identifier expression_statement assignment identifier list string string_start string_content string_end call attribute identifier identifier argument_list identifier string string_start string_content string_end identifier if_statement not_operator attribute attribute identifier identifier identifier block expression_statement augmented_assignment subscript identifier unary_operator integer string string_start string_content string_end if_statement comparison_operator identifier none block expression_statement augmented_assignment identifier list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier
Calls the mount command, specifying the mount type and mount options.
def draw_text(self, text:str, x:float, y:float, *, font_name:str, font_size:float, fill:Color) -> None: pass
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier keyword_separator typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier type none block pass_statement
Draws the given text at x,y.
def summary(self): return "\n".join([ "Transaction:", " When: " + self.date.strftime("%a %d %b %Y"), " Description: " + self.desc.replace('\n', ' '), " For amount: {}".format(self.amount), " From: {}".format( ", ".join(map(lambda x: x.account, self.src)) if self.src \ else "UNKNOWN" ), " To: {}".format( ", ".join(map(lambda x: x.account, self.dst)) if self.dst \ else "UNKNOWN" ), "" ])
module function_definition identifier parameters identifier block return_statement call attribute string string_start string_content escape_sequence string_end identifier argument_list list string string_start string_content string_end binary_operator string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end binary_operator string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list string string_start string_content escape_sequence string_end string string_start string_content string_end 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 conditional_expression call attribute string string_start string_content string_end identifier argument_list call identifier argument_list lambda lambda_parameters identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier line_continuation string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list conditional_expression call attribute string string_start string_content string_end identifier argument_list call identifier argument_list lambda lambda_parameters identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier line_continuation string string_start string_content string_end string string_start string_end
Return a string summary of transaction
def clear(self): self.log(u"Clearing cache...") for file_handler, file_info in self.cache.values(): self.log([u" Removing file '%s'", file_info]) gf.delete_file(file_handler, file_info) self._initialize_cache() self.log(u"Clearing cache... done")
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end
Clear the cache and remove all the files from disk.
def update_grid(self): info_map = self.ms_game.get_info_map() for i in xrange(self.ms_game.board_height): for j in xrange(self.ms_game.board_width): self.grid_wgs[(i, j)].info_label(info_map[i, j]) self.ctrl_wg.move_counter.display(self.ms_game.num_moves) if self.ms_game.game_status == 2: self.ctrl_wg.reset_button.setIcon(QtGui.QIcon(CONTINUE_PATH)) elif self.ms_game.game_status == 1: self.ctrl_wg.reset_button.setIcon(QtGui.QIcon(WIN_PATH)) self.timer.stop() elif self.ms_game.game_status == 0: self.ctrl_wg.reset_button.setIcon(QtGui.QIcon(LOSE_PATH)) self.timer.stop()
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list for_statement identifier call identifier argument_list attribute attribute identifier identifier identifier block for_statement identifier call identifier argument_list attribute attribute identifier identifier identifier block expression_statement call attribute subscript attribute identifier identifier tuple identifier identifier identifier argument_list subscript identifier identifier identifier expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list attribute attribute identifier identifier identifier if_statement comparison_operator attribute attribute identifier identifier identifier integer block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier elif_clause comparison_operator attribute attribute identifier identifier identifier integer block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list elif_clause comparison_operator attribute attribute identifier identifier identifier integer block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list
Update grid according to info map.
def commentmap(self, cache=True): if self.__commentmap is not None and cache==True: return self.__commentmap else: x = self.xml(src='word/comments.xml') d = Dict() if x is None: return d for comment in x.root.xpath("w:comment", namespaces=self.NS): id = comment.get("{%(w)s}id" % self.NS) typ = comment.get("{%(w)s}type" % self.NS) d[id] = Dict(id=id, type=typ, elem=comment) if cache==True: self.__commentmap = d return d
module function_definition identifier parameters identifier default_parameter identifier true block if_statement boolean_operator comparison_operator attribute identifier identifier none comparison_operator identifier true block return_statement attribute identifier identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list if_statement comparison_operator identifier none block return_statement identifier for_statement identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier expression_statement assignment subscript identifier identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier if_statement comparison_operator identifier true block expression_statement assignment attribute identifier identifier identifier return_statement identifier
return the comments from the docx, keyed to string id.
def browse_path(self, window): text = self.gui_helper.create_file_chooser_dialog("Choose project directory", self.path_window, name="Select") if text is not None: self.dir_name.set_text(text)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end attribute identifier identifier keyword_argument identifier string string_start string_content string_end if_statement comparison_operator identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Function opens the file chooser dialog for settings project dir
def GetUcsMethodMeta(classId, key): if classId in _MethodFactoryMeta: if key in _MethodFactoryMeta[classId]: return _MethodFactoryMeta[classId][key] return None
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier identifier block if_statement comparison_operator identifier subscript identifier identifier block return_statement subscript subscript identifier identifier identifier return_statement none
Methods returns the method meta of the ExternalMethod.
def to_code_array(self): state = None first_line = True self.pys_file.seek(0) for line in self.pys_file: if first_line: if line == "[Pyspread save file version]\n": first_line = False else: raise ValueError(_("File format unsupported.")) if line in self._section2reader: state = line elif state is not None: self._section2reader[state](line)
module function_definition identifier parameters identifier block expression_statement assignment identifier none expression_statement assignment identifier true expression_statement call attribute attribute identifier identifier identifier argument_list integer for_statement identifier attribute identifier identifier block if_statement identifier block if_statement comparison_operator identifier string string_start string_content escape_sequence string_end block expression_statement assignment identifier false else_clause block raise_statement call identifier argument_list call identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier identifier elif_clause comparison_operator identifier none block expression_statement call subscript attribute identifier identifier identifier argument_list identifier
Replaces everything in code_array from pys_file
def rootChild_resetPassword(self, req, webViewer): from xmantissa.signup import PasswordResetResource return PasswordResetResource(self.store)
module function_definition identifier parameters identifier identifier identifier block import_from_statement dotted_name identifier identifier dotted_name identifier return_statement call identifier argument_list attribute identifier identifier
Return a page which will allow the user to re-set their password.
def _list_format(self, occur): if self.keys: self.attr["nma:key"] = " ".join(self.keys) keys = ''.join([self.keymap[k].serialize(occur=2) for k in self.keys]) else: keys = "" if self.maxEl: self.attr["nma:max-elements"] = self.maxEl if int(self.minEl) == 0: ord_ = "zeroOrMore" else: ord_ = "oneOrMore" if int(self.minEl) > 1: self.attr["nma:min-elements"] = self.minEl middle = self._chorder() if self.rng_children() else "<empty/>%s" return ("<" + ord_ + ">" + self.start_tag("element") + (self.serialize_annots() + keys).replace("%", "%%") + middle + self.end_tag("element") + "</" + ord_ + ">")
module function_definition identifier parameters identifier identifier block if_statement attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute string string_start string_end identifier argument_list list_comprehension call attribute subscript attribute identifier identifier identifier identifier argument_list keyword_argument identifier integer for_in_clause identifier attribute identifier identifier else_clause block expression_statement assignment identifier string string_start string_end if_statement attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier if_statement comparison_operator call identifier argument_list attribute identifier identifier integer block expression_statement assignment identifier string string_start string_content string_end else_clause block expression_statement assignment identifier string string_start string_content string_end if_statement comparison_operator call identifier argument_list attribute identifier identifier integer block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier conditional_expression call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end return_statement parenthesized_expression binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator string string_start string_content string_end identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end call attribute parenthesized_expression binary_operator call attribute identifier identifier argument_list identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier string string_start string_content string_end
Return the serialization format for a _list_ node.
def add_size_info (self): if self.is_directory(): return filename = self.get_os_filename() self.size = fileutil.get_size(filename) self.modified = datetime.utcfromtimestamp(fileutil.get_mtime(filename))
module function_definition identifier parameters identifier block if_statement call attribute identifier identifier argument_list block return_statement expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier
Get size of file content and modification time from filename path.
def validate_empty_attributes(fully_qualified_name: str, spec: Dict[str, Any], *attributes: str) -> List[EmptyAttributeError]: return [ EmptyAttributeError(fully_qualified_name, spec, attribute) for attribute in attributes if not spec.get(attribute, None) ]
module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type generic_type identifier type_parameter type identifier type identifier typed_parameter list_splat_pattern identifier type identifier type generic_type identifier type_parameter type identifier block return_statement list_comprehension call identifier argument_list identifier identifier identifier for_in_clause identifier identifier if_clause not_operator call attribute identifier identifier argument_list identifier none
Validates to ensure that a set of attributes do not contain empty values
def normalize(s, replace_spaces=True): whitelist = (' -' + string.ascii_letters + string.digits) if type(s) == six.binary_type: s = six.text_type(s, 'utf-8', 'ignore') table = {} for ch in [ch for ch in s if ch not in whitelist]: if ch not in table: try: replacement = unicodedata.normalize('NFKD', ch)[0] if replacement in whitelist: table[ord(ch)] = replacement else: table[ord(ch)] = u'_' except: table[ord(ch)] = u'_' if replace_spaces: return s.translate(table).replace(u'_', u'').replace(' ', '_') else: return s.translate(table).replace(u'_', u'')
module function_definition identifier parameters identifier default_parameter identifier true block expression_statement assignment identifier parenthesized_expression binary_operator binary_operator string string_start string_content string_end attribute identifier identifier attribute identifier identifier if_statement comparison_operator call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier dictionary for_statement identifier list_comprehension identifier for_in_clause identifier identifier if_clause comparison_operator identifier identifier block if_statement comparison_operator identifier identifier block try_statement block expression_statement assignment identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end identifier integer if_statement comparison_operator identifier identifier block expression_statement assignment subscript identifier call identifier argument_list identifier identifier else_clause block expression_statement assignment subscript identifier call identifier argument_list identifier string string_start string_content string_end except_clause block expression_statement assignment subscript identifier call identifier argument_list identifier string string_start string_content string_end if_statement identifier block return_statement call attribute call attribute call attribute identifier identifier argument_list identifier identifier argument_list string string_start string_content string_end string string_start string_end identifier argument_list string string_start string_content string_end string string_start string_content string_end else_clause block return_statement call attribute call attribute identifier identifier argument_list identifier identifier argument_list string string_start string_content string_end string string_start string_end
Normalize non-ascii characters to their closest ascii counterparts
def content_break(self, el): should_break = False if self.type == 'odp': if el.name == 'page' and el.namespace and el.namespace == self.namespaces['draw']: should_break = True return should_break
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier false if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block if_statement boolean_operator boolean_operator comparison_operator attribute identifier identifier string string_start string_content string_end attribute identifier identifier comparison_operator attribute identifier identifier subscript attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier true return_statement identifier
Break on specified boundaries.
def listen_dataset_events(self, owner_id, project_id, dataset_id): if not self._user_id: raise AmigoCloudError(self.error_msg['logged_in_websockets']) url = '/users/%s/projects/%s/datasets/%s/start_websocket_session' response = self.get(url % (owner_id, project_id, dataset_id)) websocket_session = response['websocket_session'] auth_data = {'userid': self._user_id, 'datasetid': dataset_id, 'websocket_session': websocket_session} self.amigosocket.emit('authenticate', auth_data)
module function_definition identifier parameters identifier identifier identifier identifier block if_statement not_operator attribute identifier identifier block raise_statement call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator identifier tuple identifier identifier identifier expression_statement assignment identifier subscript identifier 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 identifier pair string string_start string_content string_end identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier
Authenticate to start using dataset events.
def _process_version_lines(self): if len(self._lines_seen["version"]) > 1: self._add_error(_("Multiple version lines appeared.")) elif self._lines_seen["version"][0] != 1: self._add_error(_("The version must be on the first line."))
module function_definition identifier parameters identifier block if_statement comparison_operator call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end integer block expression_statement call attribute identifier identifier argument_list call identifier argument_list string string_start string_content string_end elif_clause comparison_operator subscript subscript attribute identifier identifier string string_start string_content string_end integer integer block expression_statement call attribute identifier identifier argument_list call identifier argument_list string string_start string_content string_end
Process version line rules.
async def create(self, **kwargs): try: obj = self._meta.object_class() self.data.update(kwargs) await obj.deserialize(self.data) await obj.insert(db=self.db) return await obj.serialize() except Exception as ex: logger.exception(ex) raise BadRequest(ex)
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement await call attribute identifier identifier argument_list attribute identifier identifier expression_statement await call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier return_statement await call attribute identifier identifier argument_list except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier raise_statement call identifier argument_list identifier
Corresponds to POST request without a resource identifier, inserting a document into the database
def dispatch(self, *args, **kwargs): return super(GetAppListJsonView, self).dispatch(*args, **kwargs)
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block return_statement call attribute call identifier argument_list identifier identifier identifier argument_list list_splat identifier dictionary_splat identifier
Only staff members can access this view
def read_record(self, dtype, shape=1, byteorder=None): rec = numpy.rec try: record = rec.fromfile(self._fh, dtype, shape, byteorder=byteorder) except Exception: dtype = numpy.dtype(dtype) if shape is None: shape = self._size // dtype.itemsize size = product(sequence(shape)) * dtype.itemsize data = self._fh.read(size) record = rec.fromstring(data, dtype, shape, byteorder=byteorder) return record[0] if shape == 1 else record
module function_definition identifier parameters identifier identifier default_parameter identifier integer default_parameter identifier none block expression_statement assignment identifier attribute identifier identifier try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier identifier identifier keyword_argument identifier identifier except_clause identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement assignment identifier binary_operator attribute identifier identifier attribute identifier identifier expression_statement assignment identifier binary_operator call identifier argument_list call identifier argument_list identifier attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier keyword_argument identifier identifier return_statement conditional_expression subscript identifier integer comparison_operator identifier integer identifier
Return numpy record from file.
def webdriver_assert(self, assertion, failure_message='Failed Assertion'): try: assert assertion() is True except AssertionError: raise WebDriverAssertionException.WebDriverAssertionException(self.driver_wrapper, failure_message) return True
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end block try_statement block assert_statement comparison_operator call identifier argument_list true except_clause identifier block raise_statement call attribute identifier identifier argument_list attribute identifier identifier identifier return_statement true
Assert the assertion, but throw a WebDriverAssertionException if assertion fails
def save_loop(self): last_hash = hash(repr(self.hosts)) while self.running: eventlet.sleep(self.save_interval) next_hash = hash(repr(self.hosts)) if next_hash != last_hash: self.save() last_hash = next_hash
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list call identifier argument_list attribute identifier identifier while_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call identifier argument_list call identifier argument_list attribute identifier identifier if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier identifier
Saves the state if it has changed.
def pull(self): for item in self.input_stream: print('%s -' % item['timestamp'], end='') if item['transport']: print(item['transport']['type'], end='') packet_type = item['packet']['type'] print(packet_type, end='') packet = item['packet'] if packet_type in ['IP', 'IP6']: if 'src_domain' in packet: print('%s(%s) --> %s(%s)' % (net_utils.inet_to_str(packet['src']), packet['src_domain'], net_utils.inet_to_str(packet['dst']), packet['dst_domain']), end='') else: print('%s --> %s' % (net_utils.inet_to_str(packet['src']), net_utils.inet_to_str(packet['dst'])), end='') else: print(str(packet)) if item['application']: print('Application: %s' % item['application']['type'], end='') print(str(item['application']), end='') print()
module function_definition identifier parameters identifier block for_statement identifier attribute identifier identifier block expression_statement call identifier argument_list binary_operator string string_start string_content string_end subscript identifier string string_start string_content string_end keyword_argument identifier string string_start string_end if_statement subscript identifier string string_start string_content string_end block expression_statement call identifier argument_list subscript subscript identifier string string_start string_content string_end string string_start string_content string_end keyword_argument identifier string string_start 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 call identifier argument_list identifier keyword_argument identifier string string_start string_end expression_statement assignment identifier subscript identifier string string_start string_content string_end if_statement comparison_operator identifier list string string_start string_content string_end string string_start string_content string_end block if_statement comparison_operator string string_start string_content string_end identifier block expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end keyword_argument identifier string string_start string_end else_clause block expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end keyword_argument identifier string string_start string_end else_clause block expression_statement call identifier argument_list call identifier argument_list identifier if_statement subscript identifier string string_start string_content string_end block expression_statement call identifier argument_list binary_operator string string_start string_content string_end subscript subscript identifier string string_start string_content string_end string string_start string_content string_end keyword_argument identifier string string_start string_end expression_statement call identifier argument_list call identifier argument_list subscript identifier string string_start string_content string_end keyword_argument identifier string string_start string_end expression_statement call identifier argument_list
Print out summary information about each packet from the input_stream
def ability(cls, id_, name, function_type, ability_id, general_id=0): assert function_type in ABILITY_FUNCTIONS return cls(id_, name, ability_id, general_id, function_type, FUNCTION_TYPES[function_type], None)
module function_definition identifier parameters identifier identifier identifier identifier identifier default_parameter identifier integer block assert_statement comparison_operator identifier identifier return_statement call identifier argument_list identifier identifier identifier identifier identifier subscript identifier identifier none
Define a function represented as a game ability.
def secret_loader(self, callback): if not callback or not callable(callback): raise Exception("Please pass in a callable that loads secret keys") self.secret_loader_callback = callback return callback
module function_definition identifier parameters identifier identifier block if_statement boolean_operator not_operator identifier not_operator call identifier argument_list identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier identifier return_statement identifier
Decorate a method that receives a key id and returns a secret key
def _check_mapper(self, mapper): if not hasattr(mapper, 'parse') or not callable(mapper.parse): raise ValueError('mapper must implement parse()') if not hasattr(mapper, 'format') or not callable(mapper.format): raise ValueError('mapper must implement format()')
module function_definition identifier parameters identifier identifier block if_statement boolean_operator not_operator call identifier argument_list identifier string string_start string_content string_end not_operator call identifier argument_list attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement boolean_operator not_operator call identifier argument_list identifier string string_start string_content string_end not_operator call identifier argument_list attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end
Check that the mapper has valid signature.
def _filter_messages(messages, products=None, levels=None): if products is None: products = [] if levels is None: levels = [] segments = [] bounds = len(messages) for i, message in enumerate(messages): if (message[3] in products or len(products) == 0) and \ (message[4] in levels or len(levels) == 0): start = int(message[1]) if i == (bounds - 1): end = None else: end = int(messages[i+1][1]) segments.append((start, end)) return _join(segments)
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier list if_statement comparison_operator identifier none block expression_statement assignment identifier list expression_statement assignment identifier list expression_statement assignment identifier call identifier argument_list identifier for_statement pattern_list identifier identifier call identifier argument_list identifier block if_statement boolean_operator parenthesized_expression boolean_operator comparison_operator subscript identifier integer identifier comparison_operator call identifier argument_list identifier integer line_continuation parenthesized_expression boolean_operator comparison_operator subscript identifier integer identifier comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier call identifier argument_list subscript identifier integer if_statement comparison_operator identifier parenthesized_expression binary_operator identifier integer block expression_statement assignment identifier none else_clause block expression_statement assignment identifier call identifier argument_list subscript subscript identifier binary_operator identifier integer integer expression_statement call attribute identifier identifier argument_list tuple identifier identifier return_statement call identifier argument_list identifier
filter messages for desired products and levels.
def backup(path, name=None): from PyHardLinkBackup.phlb.phlb_main import backup backup(path, name)
module function_definition identifier parameters identifier default_parameter identifier none block import_from_statement dotted_name identifier identifier identifier dotted_name identifier expression_statement call identifier argument_list identifier identifier
Start a Backup run
def info(self, callback=None, **kwargs): self.client.fetch( self.mk_req('', method='GET', **kwargs), callback = callback )
module function_definition identifier parameters identifier default_parameter identifier none dictionary_splat_pattern identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_end keyword_argument identifier string string_start string_content string_end dictionary_splat identifier keyword_argument identifier identifier
Get the basic info from the current cluster.
def crud_url_name(model, action, prefix=None): if prefix is None: prefix = "" app_label = model._meta.app_label model_lower = model.__name__.lower() return '%s%s_%s_%s' % (prefix, app_label, model_lower, action)
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier string string_start string_end expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list return_statement binary_operator string string_start string_content string_end tuple identifier identifier identifier identifier
Returns url name for given model and action.
def _format_params(self, type_, params): if 'initial_state' in params: initial_state = params['initial_state'] if isinstance(initial_state, Mapping): initial_state_list = [3]*self.properties['num_qubits'] low = -1 if type_ == 'ising' else 0 for v, val in initial_state.items(): if val == 3: continue if val <= 0: initial_state_list[v] = low else: initial_state_list[v] = 1 params['initial_state'] = initial_state_list
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier binary_operator list integer subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier conditional_expression unary_operator integer comparison_operator identifier string string_start string_content string_end integer for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement comparison_operator identifier integer block continue_statement if_statement comparison_operator identifier integer block expression_statement assignment subscript identifier identifier identifier else_clause block expression_statement assignment subscript identifier identifier integer expression_statement assignment subscript identifier string string_start string_content string_end identifier
Reformat some of the parameters for sapi.
def root_dataset(self): ds = self.dataset(ROOT_CONFIG_NAME_V) ds._database = self return ds
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier return_statement identifier
Return the root dataset, which hold configuration values for the library
def can(self, event): return [t.new_state for t in self._transitions if t.event.equals(event)]
module function_definition identifier parameters identifier identifier block return_statement list_comprehension attribute identifier identifier for_in_clause identifier attribute identifier identifier if_clause call attribute attribute identifier identifier identifier argument_list identifier
returns a list of states that can result from processing this event
def create(spellchecker_cache_path): user_dictionary = os.path.join(os.getcwd(), "DICTIONARY") user_words = read_dictionary_file(user_dictionary) valid_words = Dictionary(valid_words_set(user_dictionary, user_words), "valid_words", [user_dictionary], spellchecker_cache_path) return (user_words, valid_words)
module function_definition identifier parameters 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 expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier identifier string string_start string_content string_end list identifier identifier return_statement tuple identifier identifier
Create a Dictionary at spellchecker_cache_path with valid words.
def ExceptionHook(exctype, value, tb): for line in traceback.format_exception_only(exctype, value): log.error(line.replace('\n', '')) for line in traceback.format_tb(tb): log.error(line.replace('\n', '')) sys.__excepthook__(exctype, value, tb)
module function_definition identifier parameters identifier identifier identifier block for_statement identifier call attribute identifier identifier argument_list identifier identifier block 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 for_statement identifier call attribute identifier identifier argument_list identifier block 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 identifier identifier identifier
A custom exception handler that logs errors to file.
def add(self, value): if self._disposed: raise ValueError( 'Cannot add value: this _WatchStore instance is already disposed') self._data.append(value) if hasattr(value, 'nbytes'): self._in_mem_bytes += value.nbytes self._ensure_bytes_limits()
module function_definition identifier parameters identifier identifier block if_statement attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list identifier if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement augmented_assignment attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list
Add a tensor the watch store.
def base_url(klass, space_id='', resource_id=None, environment_id=None, **kwargs): url = "spaces/{0}".format( space_id) if environment_id is not None: url = url = "{0}/environments/{1}".format(url, environment_id) url = "{0}/{1}".format( url, base_path_for(klass.__name__) ) if resource_id: url = "{0}/{1}".format(url, resource_id) return url
module function_definition identifier parameters identifier default_parameter identifier string string_start string_end default_parameter identifier none default_parameter identifier none dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement assignment identifier assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier call identifier argument_list attribute identifier identifier if_statement identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier identifier return_statement identifier
Returns the URI for the resource.
def exit_with_error(message): click.secho(message, err=True, bg='red', fg='white') sys.exit(0)
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier true keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list integer
Display formatted error message and exit call
def add_build_configuration_to_set( set_id=None, set_name=None, config_id=None, config_name=None): content = add_build_configuration_to_set_raw(set_id, set_name, config_id, config_name) if content: return utils.format_json(content)
module function_definition identifier parameters default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier call identifier argument_list identifier identifier identifier identifier if_statement identifier block return_statement call attribute identifier identifier argument_list identifier
Add a build configuration to an existing BuildConfigurationSet
def prepare_data_loader(args, dataset, vocab, test=False): dataset = dataset.transform(lambda s1, s2, label: (vocab(s1), vocab(s2), label), lazy=False) batchify_fn = btf.Tuple(btf.Pad(), btf.Pad(), btf.Stack(dtype='int32')) data_lengths = [max(len(d[0]), len(d[1])) for d in dataset] batch_sampler = nlp.data.FixedBucketSampler(lengths=data_lengths, batch_size=args.batch_size, shuffle=(not test)) data_loader = gluon.data.DataLoader(dataset=dataset, batch_sampler=batch_sampler, batchify_fn=batchify_fn) return data_loader
module function_definition identifier parameters identifier identifier identifier default_parameter identifier false block expression_statement assignment identifier call attribute identifier identifier argument_list lambda lambda_parameters identifier identifier identifier tuple call identifier argument_list identifier call identifier argument_list identifier identifier keyword_argument identifier false expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier list_comprehension call identifier argument_list call identifier argument_list subscript identifier integer call identifier argument_list subscript identifier integer for_in_clause identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier parenthesized_expression not_operator identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier return_statement identifier
Read data and build data loader.
def AddNoiseToLatLng(lat, lng): m_per_tenth_lat = Distance(lat, lng, lat + 0.1, lng) m_per_tenth_lng = Distance(lat, lng, lat, lng + 0.1) lat_per_100m = 1 / m_per_tenth_lat * 10 lng_per_100m = 1 / m_per_tenth_lng * 10 return (lat + (lat_per_100m * 5 * (random.random() * 2 - 1)), lng + (lng_per_100m * 5 * (random.random() * 2 - 1)))
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier binary_operator identifier float identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier binary_operator identifier float expression_statement assignment identifier binary_operator binary_operator integer identifier integer expression_statement assignment identifier binary_operator binary_operator integer identifier integer return_statement tuple binary_operator identifier parenthesized_expression binary_operator binary_operator identifier integer parenthesized_expression binary_operator binary_operator call attribute identifier identifier argument_list integer integer binary_operator identifier parenthesized_expression binary_operator binary_operator identifier integer parenthesized_expression binary_operator binary_operator call attribute identifier identifier argument_list integer integer
Add up to 500m of error to each coordinate of lat, lng.
def wait(self, log_file): "Wait until the process is ready." lines = map(self.log_line, self.filter_lines(self.get_lines(log_file))) return any( std.re.search(self.pattern, line) for line in lines )
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier return_statement call identifier generator_expression call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier for_in_clause identifier identifier
Wait until the process is ready.
def ExpireRules(self): rules = self.Get(self.Schema.RULES) new_rules = self.Schema.RULES() now = time.time() * 1e6 expired_session_ids = set() for rule in rules: if rule.expires > now: new_rules.Append(rule) else: for action in rule.actions: if action.hunt_id: expired_session_ids.add(action.hunt_id) if expired_session_ids: with data_store.DB.GetMutationPool() as pool: manager = queue_manager.QueueManager(token=self.token) manager.MultiNotifyQueue([ rdf_flows.GrrNotification(session_id=session_id) for session_id in expired_session_ids ], mutation_pool=pool) if len(new_rules) < len(rules): self.Set(self.Schema.RULES, new_rules) self.Flush()
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list float expression_statement assignment identifier call identifier argument_list for_statement identifier identifier block if_statement comparison_operator attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier else_clause block for_statement identifier attribute identifier identifier block if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier if_statement identifier block with_statement with_clause with_item as_pattern call attribute attribute identifier identifier identifier argument_list as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list list_comprehension call attribute identifier identifier argument_list keyword_argument identifier identifier for_in_clause identifier identifier keyword_argument identifier identifier if_statement comparison_operator call identifier argument_list identifier call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list attribute attribute identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list
Removes any rules with an expiration date in the past.
def encode(self, s): sentence = s tokens = sentence.strip().split() if self._replace_oov is not None: tokens = [t if t in self._token_to_id else self._replace_oov for t in tokens] ret = [self._token_to_id[tok] for tok in tokens] return ret[::-1] if self._reverse else ret
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier list_comprehension conditional_expression identifier comparison_operator identifier attribute identifier identifier attribute identifier identifier for_in_clause identifier identifier expression_statement assignment identifier list_comprehension subscript attribute identifier identifier identifier for_in_clause identifier identifier return_statement conditional_expression subscript identifier slice unary_operator integer attribute identifier identifier identifier
Converts a space-separated string of tokens to a list of ids.
def ast_to_headings(node): Heading = namedtuple('Heading', ['level', 'title']) level = None walker = node.walker() headings = [] event = walker.nxt() while event is not None: entering = event['entering'] node = event['node'] if node.t == 'Heading': if entering: level = node.level else: level = None elif level: if node.t != 'Text': raise Exception('Unexpected node {}, only text may be within a heading.'.format(node.t)) headings.append(Heading(level=level, title=node.literal)) event = walker.nxt() return headings
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier none expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier list expression_statement assignment identifier call attribute identifier identifier argument_list while_statement comparison_operator identifier none block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier string string_start string_content string_end if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block if_statement identifier block expression_statement assignment identifier attribute identifier identifier else_clause block expression_statement assignment identifier none elif_clause identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list return_statement identifier
Walks AST and returns a list of headings
def _format_help_dicts(help_dicts, display_defaults=False): help_strs = [] for help_dict in help_dicts: help_str = "%s (%s" % ( help_dict["var_name"], "Required" if help_dict["required"] else "Optional", ) if help_dict.get("default") and display_defaults: help_str += ", Default=%s)" % help_dict["default"] else: help_str += ")" if help_dict.get("help_str"): help_str += ": %s" % help_dict["help_str"] help_strs.append(help_str) return "\n".join(help_strs)
module function_definition identifier parameters identifier default_parameter identifier false block expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple subscript identifier string string_start string_content string_end conditional_expression string string_start string_content string_end subscript identifier string string_start string_content string_end string string_start string_content string_end if_statement boolean_operator call attribute identifier identifier argument_list 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 else_clause block expression_statement augmented_assignment identifier string string_start string_content string_end if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement augmented_assignment identifier binary_operator string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier return_statement call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier
Format the output of _generate_help_dicts into a str
def text_from_affiliation_elements(department, institution, city, country): "format an author affiliation from details" return ', '.join(element for element in [department, institution, city, country] if element)
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement string string_start string_content string_end return_statement call attribute string string_start string_content string_end identifier generator_expression identifier for_in_clause identifier list identifier identifier identifier identifier if_clause identifier
format an author affiliation from details
def run_with_pmids(model_path, pmids): from indra.tools.machine.machine import run_with_pmids_helper run_with_pmids_helper(model_path, pmids)
module function_definition identifier parameters identifier identifier block import_from_statement dotted_name identifier identifier identifier identifier dotted_name identifier expression_statement call identifier argument_list identifier identifier
Run with given list of PMIDs.
def annotate_gemini(data, retriever=None): r = dd.get_variation_resources(data) return all([r.get(k) and objectstore.file_exists_or_remote(r[k]) for k in ["exac", "gnomad_exome"]])
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement call identifier argument_list list_comprehension boolean_operator call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list subscript identifier identifier for_in_clause identifier list string string_start string_content string_end string string_start string_content string_end
Annotate with population calls if have data installed.
def _null_date(self): try: return self.__null_date except AttributeError: number_settings = self._target.getNumberFormatSettings() d = number_settings.getPropertyValue('NullDate') self.__null_date = datetime.datetime(d.Year, d.Month, d.Day) return self.__null_date
module function_definition identifier parameters identifier block try_statement block return_statement attribute identifier identifier except_clause identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier return_statement attribute identifier identifier
Returns date which is represented by a integer 0.
def checkConfig(): config_file_dir = os.path.join(cwd, "config.py") if os.path.exists(config_file_dir): print("Making a backup of your config file!") config_file_dir2 = os.path.join(cwd, "config.py.oldbak") copyfile(config_file_dir, config_file_dir2)
module function_definition identifier parameters block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end expression_statement call identifier argument_list identifier identifier
If the config.py file exists, back it up
def join(tokens, start, result): texts = [] if len(result) > 0: for e in result: for child in e.iter(): if child.text is not None: texts.append(child.text) return [E(result[0].tag, ' '.join(texts))]
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier list if_statement comparison_operator call identifier argument_list identifier integer block for_statement identifier identifier block for_statement identifier call attribute identifier identifier argument_list block if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute identifier identifier argument_list attribute identifier identifier return_statement list call identifier argument_list attribute subscript identifier integer identifier call attribute string string_start string_content string_end identifier argument_list identifier
Join tokens into a single string with spaces between.
def date_from_quarter(base_date, ordinal, year): interval = 3 month_start = interval * (ordinal - 1) if month_start < 0: month_start = 9 month_end = month_start + interval if month_start == 0: month_start = 1 return [ datetime(year, month_start, 1), datetime(year, month_end, calendar.monthrange(year, month_end)[1]) ]
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier integer expression_statement assignment identifier binary_operator identifier parenthesized_expression binary_operator identifier integer if_statement comparison_operator identifier integer block expression_statement assignment identifier integer expression_statement assignment identifier binary_operator identifier identifier if_statement comparison_operator identifier integer block expression_statement assignment identifier integer return_statement list call identifier argument_list identifier identifier integer call identifier argument_list identifier identifier subscript call attribute identifier identifier argument_list identifier identifier integer
Extract date from quarter of a year
def ret_list_minions(self): tgt = _tgt_set(self.tgt) return self._ret_minions(tgt.intersection)
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier return_statement call attribute identifier identifier argument_list attribute identifier identifier
Return minions that match via list
def visit_Starred(self, node: AST, dfltChaining: bool = True) -> str: with self.op_man(node): return f"*{self.visit(node.value)}"
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_default_parameter identifier type identifier true type identifier block with_statement with_clause with_item call attribute identifier identifier argument_list identifier block return_statement string string_start string_content interpolation call attribute identifier identifier argument_list attribute identifier identifier string_end
Return representation of starred expresssion.
def to_dict(self): return {name: {'value': self._process_value(str, value)} for name, value in self._ea_dict.items() if not (value is None or value == "" or value == [])}
module function_definition identifier parameters identifier block return_statement dictionary_comprehension pair identifier dictionary pair string string_start string_content string_end call attribute identifier identifier argument_list identifier identifier for_in_clause pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list if_clause not_operator parenthesized_expression boolean_operator boolean_operator comparison_operator identifier none comparison_operator identifier string string_start string_end comparison_operator identifier list
Converts extensible attributes into the format suitable for NIOS.
def handle_set_row(self): row = self.reader.int() logger.info(" -> row: %s", row) self.controller.row = row
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment attribute attribute identifier identifier identifier identifier
Read incoming row change from server
def url(self, key): return urlunparse((self.protocol, '%s:%s' % (self.domain, self.port), '%s/api/v1%s' % (self.prefix, URLS[key]), '', '', ''))
module function_definition identifier parameters identifier identifier block return_statement call identifier argument_list tuple attribute identifier identifier binary_operator string string_start string_content string_end tuple attribute identifier identifier attribute identifier identifier binary_operator string string_start string_content string_end tuple attribute identifier identifier subscript identifier identifier string string_start string_end string string_start string_end string string_start string_end
Creates a full URL to the API using urls dict
def wr_tsv(self, fout_tsv, goea_results, **kws): prt_flds = kws.get('prt_flds', self.get_prtflds_default(goea_results)) tsv_data = MgrNtGOEAs(goea_results).get_goea_nts_prt(prt_flds, **kws) RPT.wr_tsv(fout_tsv, tsv_data, **kws)
module function_definition identifier parameters identifier identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute call identifier argument_list identifier identifier argument_list identifier dictionary_splat identifier expression_statement call attribute identifier identifier argument_list identifier identifier dictionary_splat identifier
Write tab-separated table data to file
def upload_hub(hub, host, remote_dir, user=None, port=22, rsync_options=RSYNC_OPTIONS, staging=None): hub.render() if staging is None: staging = tempfile.mkdtemp() staging, linknames = stage_hub(hub, staging=staging) local_dir = os.path.join(staging) upload(host, user, local_dir=local_dir, remote_dir=remote_dir, rsync_options=rsync_options) return linknames
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none default_parameter identifier integer default_parameter identifier identifier default_parameter identifier none block expression_statement call attribute identifier identifier argument_list if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier keyword_argument identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement call identifier argument_list identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier return_statement identifier
Renders, stages, and uploads a hub.
def _check_type(name, obj, expected_type): if not isinstance(obj, expected_type): raise TypeError( '"%s" must be an a %s' % (name, expected_type.__name__) )
module function_definition identifier parameters identifier identifier identifier block if_statement not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier attribute identifier identifier
Raise a TypeError if object is not of expected type
def duration(label, stop_it=True, stop_at=None): if label not in labels: return None if "duration" in labels[label]: return Duration(labels[label]["duration"]) if stop_it: return stop(label, at=stop_at) else: return None
module function_definition identifier parameters identifier default_parameter identifier true default_parameter identifier none block if_statement comparison_operator identifier identifier block return_statement none if_statement comparison_operator string string_start string_content string_end subscript identifier identifier block return_statement call identifier argument_list subscript subscript identifier identifier string string_start string_content string_end if_statement identifier block return_statement call identifier argument_list identifier keyword_argument identifier identifier else_clause block return_statement none
Returns duration in seconds for label
def call(cmd, shell=True, cwd=None, universal_newlines=True, stderr=STDOUT): return Shell._run(call, cmd, shell=shell, cwd=cwd, stderr=stderr, universal_newlines=universal_newlines)
module function_definition identifier parameters identifier default_parameter identifier true default_parameter identifier none default_parameter identifier true default_parameter identifier identifier block return_statement call attribute identifier identifier argument_list identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
Just execute a specific command.
def _create_penwidth_combo(self): choices = map(unicode, xrange(12)) self.pen_width_combo = \ _widgets.PenWidthComboBox(self, choices=choices, style=wx.CB_READONLY, size=(50, -1)) self.pen_width_combo.SetToolTipString(_(u"Border width")) self.AddControl(self.pen_width_combo) self.Bind(wx.EVT_COMBOBOX, self.OnLineWidth, self.pen_width_combo)
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier call identifier argument_list integer expression_statement assignment attribute identifier identifier line_continuation call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier tuple integer unary_operator integer expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier
Create pen width combo box
def append(self, item): if len(self) == 0: self.index = 0 self.items.append(item)
module function_definition identifier parameters identifier identifier block if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment attribute identifier identifier integer expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Adds a new item to the end of the collection.