code
stringlengths
51
2.34k
sequence
stringlengths
1.16k
13.1k
docstring
stringlengths
11
171
def parsed_file(config_file): parser = ConfigParser(allow_no_value=True) parser.readfp(config_file) return parser
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parsed_file'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'confi...
Parse an ini-style config file.
def _post_json(self, instance, space=None, rel_path=None, extra_params=None): model = type(instance) if space is None and model not in (Space, Event): raise Exception( 'In general, `API._post_json` should always ' 'be called with a `space` argument.' ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_post_json'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12']}; {'id': '4', 'type': 'identifier', 'children'...
Base level method for updating data via the API
def on_task_done(self, task): task['status'] = self.taskdb.SUCCESS task['lastcrawltime'] = time.time() if 'schedule' in task: if task['schedule'].get('auto_recrawl') and 'age' in task['schedule']: task['status'] = self.taskdb.ACTIVE next_exetime = task...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'on_task_done'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
Called when a task is done and success, called by `on_task_status`
def _xfs_info_get_kv(serialized): if serialized.startswith("="): serialized = serialized[1:].strip() serialized = serialized.replace(" = ", "=*** ").replace(" =", "=") opt = [] for tkn in serialized.split(" "): if not opt or "=" in tkn: opt.append(tkn) else: ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_xfs_info_get_kv'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
Parse one line of the XFS info output.
def _id_for_pc(self, name): if not name in self.pc2id_lut: self.c.execute("INSERT INTO pcs (name) VALUES ( ? )", (name,)) self.pc2id_lut[name] = self.c.lastrowid self.id2pc_lut[self.c.lastrowid] = name return self.pc2id_lut[name]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_id_for_pc'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's...
Given the name of the PC, return the database identifier.
def _build_index(maf_strm, ref_spec): idx_strm = StringIO.StringIO() bound_iter = functools.partial(genome_alignment_iterator, reference_species=ref_spec) hash_func = JustInTimeGenomeAlignmentBlock.build_hash idx = IndexedFile(maf_strm, bound_iter, hash_func) idx.write_index(i...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_build_index'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
Build an index for a MAF genome alig file and return StringIO of it.
def default(cls): "Make the current foreground color the default." wAttributes = cls._get_text_attributes() wAttributes &= ~win32.FOREGROUND_MASK wAttributes |= win32.FOREGROUND_GREY wAttributes &= ~win32.FOREGROUND_INTENSITY cls._set_text_attributes(wAttributes)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'default'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'...
Make the current foreground color the default.
def stop_other_daemons(self): if self.smbd.running: self.smbd.stop() if self.nmbd.running: self.nmbd.stop()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'stop_other_daemons'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
Stop services already provided by main samba daemon
def link_text(cls): link = cls.__name__ if link.endswith('View'): link = link[:-4] return link
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'link_text'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; ...
Return link text for this view.
def _authenticate_x509(credentials, sock_info): query = SON([('authenticate', 1), ('mechanism', 'MONGODB-X509')]) if credentials.username is not None: query['user'] = credentials.username elif sock_info.max_wire_version < 5: raise ConfigurationError( "A username ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_authenticate_x509'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'va...
Authenticate using MONGODB-X509.
def _restore_coordinator(self): transport_info = self.device.get_current_transport_info() if transport_info is not None: if transport_info['current_transport_state'] == 'PLAYING': self.device.pause() self._restore_queue() if self.is_playing_queue and self.play...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_restore_coordinator'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
Do the coordinator-only part of the restore.
def toList(self): date = self.date() sign = '+' if date[0] >= 0 else '-' date[0] = abs(date[0]) return list(sign) + date
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'toList'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'...
Returns date as signed list.
def compute_hash(attributes, ignored_attributes=None): ignored_attributes = list(ignored_attributes) if ignored_attributes else [] tuple_attributes = _convert(attributes.copy(), ignored_attributes) hasher = hashlib.sha256(str(tuple_attributes).encode('utf-8', errors='ignore')) return hasher.hexdigest()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'compute_hash'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
Computes a hash code for the given dictionary that is safe for persistence round trips
def vector_to_word(vector): word = "" for vec in vector: word = word + int2char(vec) return word
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'vector_to_word'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 've...
Convert integer vectors to character vectors.
def controller_event(self, channel, contr_nr, contr_val): return self.midi_event(CONTROLLER, channel, contr_nr, contr_val)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'controller_event'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children':...
Return the bytes for a MIDI controller event.
def _parse_src_js_var(self, variable): src_url = 'http://115.com' r = self.http.get(src_url) soup = BeautifulSoup(r.content) scripts = [script.text for script in soup.find_all('script')] text = '\n'.join(scripts) pattern = "%s\s*=\s*(.*);" % (variable.upper()) m =...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_parse_src_js_var'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
Parse JavaScript variables in the source page
def execute_query(self, query, values): retval = self.cursor.execute(query, values) self.__close_db() return retval
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'execute_query'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'va...
Executes a query to the test_db and closes the connection afterwards.
def returnPorts(self): if self._gotPorts: map(portpicker.return_port, self.ports) self._gotPorts = False self.ports = []
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'returnPorts'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'...
deallocate specific ports on the current machine
def stopReceivingBoxes(self, reason): AMP.stopReceivingBoxes(self, reason) log.removeObserver(self._emit)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'stopReceivingBoxes'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'va...
Stop observing log events.
def _get_local_ref(region, ref_file, out_vcf_base): out_file = "{0}.fa".format(out_vcf_base) if not file_exists(out_file): with pysam.Fastafile(ref_file) as in_pysam: contig, start, end = region seq = in_pysam.fetch(contig, int(start), int(end)) with open(out_file, "w...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_local_ref'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'v...
Retrieve a local FASTA file corresponding to the specified region.
def avg(self): if len(self.values) > 0: return sum(self.values) / float(len(self.values)) else: return None
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'avg'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id'...
return the mean value
def _load_score(self): score = int(self.score_file.read()) self.score_file.seek(0, os.SEEK_SET) return score
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_load_score'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'...
Load the best score from file.
def create_permissions_from_tuples(model, codename_tpls): if codename_tpls: model_cls = django_apps.get_model(model) content_type = ContentType.objects.get_for_model(model_cls) for codename_tpl in codename_tpls: app_label, codename, name = get_from_codename_tuple( ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_permissions_from_tuples'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'childr...
Creates custom permissions on model "model".
def _clean(self): found_ids = {} nodes = [self._nodes[_node.Root.ID]] while nodes: node = nodes.pop() found_ids[node.id] = None nodes = nodes + node.children for node_id in self._nodes: if node_id in found_ids: continue ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_clean'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'...
Recursively check that all nodes are reachable.
def doc_dict(self): doc = { 'type': self.value_type, 'description': self.description, 'extended_description': self.details } return doc
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'doc_dict'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; ...
Generate the documentation for this field.
def dl_file(url, dest, chunk_size=6553): import urllib3 http = urllib3.PoolManager() r = http.request('GET', url, preload_content=False) with dest.open('wb') as out: while True: data = r.read(chunk_size) if data is None or len(data) == 0: break ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dl_file'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
Download `url` to `dest`
def node_insert_before(self, node, new_node): assert(not self.node_is_on_list(new_node)) assert(node is not new_node) prev = self.node_prev(node) assert(prev is not None) self.node_set_prev(node, new_node) self.node_set_next(new_node, node) self.node_set_prev(new_...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'node_insert_before'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': []...
Insert the new node before node.
def iteritems(self): sorted_data = sorted(self.data.iteritems(), self.cmp, self.key, self.reverse) for k,v in sorted_data: yield k,v
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'iteritems'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};...
Sort and then iterate the dictionary
def export_context(target_zip): from django_productline import utils context_file = tasks.get_context_path() return utils.create_or_append_to_zip(context_file, target_zip, 'context.json')
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'export_context'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ta...
Append context.json to target_zip
def authenticate(self, api_key): self._api_key = api_key self._session.auth = ('', self._api_key) return self._verify_api_key()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'authenticate'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
Logs user into Heroku with given api_key.
def object_to_json(obj): if isinstance(obj, (datetime.datetime, datetime.date, datetime.time)): return obj.isoformat() return str(obj)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'object_to_json'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ob...
Convert object that cannot be natively serialized by python to JSON representation.
def accept_line(event): " Accept the line regardless of where the cursor is. " b = event.current_buffer b.accept_action.validate_and_handle(event.cli, b)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'accept_line'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'event...
Accept the line regardless of where the cursor is.
def from_connections(cls, caption, connections): root = ET.Element('datasource', caption=caption, version='10.0', inline='true') outer_connection = ET.SubElement(root, 'connection') outer_connection.set('class', 'federated') named_conns = ET.SubElement(outer_connection, 'named-connection...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'from_connections'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], ...
Create a new Data Source give a list of Connections.
def contains_all(self, array): dtype = getattr(array, 'dtype', None) if dtype is None: dtype = np.result_type(*array) return is_real_dtype(dtype)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'contains_all'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
Test if `array` is an array of real numbers.
def command(state, args): args = parser.parse_args(args[1:]) aid = state.results.parse_aid(args.aid, default_key='db') query.update.reset(state.db, aid, args.episode)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'command'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'stat...
Reset anime watched episodes.
def _find_pair(self, protocol, remote_candidate): for pair in self._check_list: if (pair.protocol == protocol and pair.remote_candidate == remote_candidate): return pair return None
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_find_pair'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
Find a candidate pair in the check list.
def FromReadings(cls, uuid, readings, sent_timestamp=0): header = struct.pack("<BBHLLL", cls.ReportType, 0, len(readings)*16, uuid, sent_timestamp, 0) packed_readings = bytearray() for reading in readings: packed_reading = struct.pack("<HHLLL", reading.stream, 0, reading.reading_id, ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'FromReadings'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': []...
Generate a broadcast report from a list of readings and a uuid.
def find_comprehension_as_statement(node): return ( isinstance(node, ast.Expr) and isinstance(node.value, (ast.ListComp, ast.DictComp, ast.SetComp)) )
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_comprehension_as_statement'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children':...
Finds a comprehension as a statement
def _smooth_best_span_estimates(self): self._smoothed_best_spans = smoother.perform_smooth(self.x, self._best_span_at_each_point, MID_SPAN)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_smooth_best_span_estimates'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [],...
Apply a MID_SPAN smooth to the best span estimates at each observation.
def eof(): @Parser def eof_parser(text, index=0): if index >= len(text): return Value.success(index, None) else: return Value.failure(index, 'EOF') return eof_parser
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'eof'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '42']}; {'id': '5', 'type': '...
Parser EOF flag of a string.
def read_plain_byte_array(file_obj, count): return [file_obj.read(struct.unpack(b"<i", file_obj.read(4))[0]) for i in range(count)]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'read_plain_byte_array'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], ...
Read `count` byte arrays using the plain encoding.
def list(self, node, elem, module, path): nel, newm, path = self.sample_element(node, elem, module, path) if path is None: return for kn in node.i_key: self.node_handler.get(kn.keyword, self.ignore)( kn, nel, newm, path) self.process_children(node,...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'list'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'v...
Create sample entries of a list.
def fetch_entries(self): data = [] for row in self.get_rows(): if exceeded_limit(self.limit, len(data)): break entry = row.find_all('td') entry_dict = {} show = entry[0].string net = entry[1].string if not self._matc...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fetch_entries'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel...
Fetch data and parse it to build a list of cable entries.
def instances(self): ist = lib.EnvGetNextInstanceInClass(self._env, self._cls, ffi.NULL) while ist != ffi.NULL: yield Instance(self._env, ist) ist = lib.EnvGetNextInstanceInClass(self._env, self._cls, ist)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'instances'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};...
Iterate over the instances of the class.
def _make_mask(self, data, lon_str=LON_STR, lat_str=LAT_STR): mask = False for west, east, south, north in self.mask_bounds: if west < east: mask_lon = (data[lon_str] > west) & (data[lon_str] < east) else: mask_lon = (data[lon_str] < west) | (data[...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_make_mask'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], ...
Construct the mask that defines a region on a given data's grid.
def save_to_disk(self, filename_pattern=None): if not self._converter: raise RuntimeError( 'Must set _converter on subclass or via set_converter before calling ' 'save_to_disk.') pattern = filename_pattern or self._default_filename_pattern if not pattern: raise RuntimeError( ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'save_to_disk'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
Returns a callback to convert test record to proto and save to disk.
def _last(self, **spec): for record in self._entries(spec).order_by(orm.desc(model.Entry.local_date), orm.desc(model.Entry.id))[:1]: return entry.Entry(record) return None
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_last'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}...
Get the latest entry in this category, optionally including subcategories
def schedule(dev): for d in range(7): dev.query_schedule(d) for day in dev.schedule.values(): click.echo("Day %s, base temp: %s" % (day.day, day.base_temp)) current_hour = day.next_change_at for hour in day.hours: if current_hour == 0: continue click.echo(...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'schedule'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'dev'}; {...
Gets the schedule from the thermostat.
def register(self, name, path, plugin, description=None, final_words=None): if name in self.recipes.keys(): raise RecipeExistsException("Recipe %s was already registered by %s" % (name, self.recipes["name"].plugin.name)) self.recipes[name] = Recipe(nam...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'register'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '11']}; {'id': '4', 'type': 'identifier', 'childr...
Registers a new recipe.
def stop(self): self.prestop() if not self._graceful: self._graceful = True self.stream.stop_stream() self.audio.terminate() msg = 'Stopped' self.verbose_info(msg, log=False) if self.log: self.logging.info(msg) if self.collect: ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'stop'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id...
Stop the stream and terminate PyAudio
def download_api(branch=None) -> str: habitica_github_api = 'https://api.github.com/repos/HabitRPG/habitica' if not branch: branch = requests.get(habitica_github_api + '/releases/latest').json()['tag_name'] curl = local['curl']['-sL', habitica_github_api + '/tarball/{}'.format(branch)] tar = loc...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'download_api'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', ...
download API documentation from _branch_ of Habitica\'s repo on Github
def remove(self, username, user_api, filename=None, force=False): self.keys = API.__get_keys(filename) self.username = username user = user_api.find(username)[0] if not force: self.__confirm() for key in self.__delete_keys(): operation = {'sshPublicKey': [...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'remove'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10']}; {'id': '4', 'type': 'identifier', 'children': []...
Remove specified SSH public key from specified user.
def to_schema(self): types = set() generated_schemas = [] for schema_generator in self._schema_generators: generated_schema = schema_generator.to_schema() if len(generated_schema) == 1 and 'type' in generated_schema: types.add(generated_schema['type']) ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_schema'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};...
Convert the current schema to a `dict`.
def _get_all_refs(self, dep, handled_refs=None): if handled_refs is None: handled_refs = [dep] else: if dep in handled_refs: return [] res = [] if dep in self.future_values_key_item: res.extend( self.future_values_key_it...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_all_refs'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'va...
get al list of all dependencies for the given item "dep"
def _threaded_start(self): self.active = True self.thread = Thread(target=self._main_loop) self.thread.setDaemon(True) self.thread.start()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_threaded_start'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's...
Spawns a worker thread to do the expiration checks
def flatten(self, obj): return [self._serialize(f, obj) for f in self.fields]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'flatten'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self...
Return a list with the field values
def _value_validate(self, value, rnge, identifier="Given"): if value is not None and (value < rnge[0] or value > rnge[1]): raise ValueError('%s value must be between %d and %d.' % (identifier, rnge[0], rnge[1]))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_value_validate'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children':...
Make sure a value is within a given range
def build_traversal(self, traversal): rhs_label = ':' + traversal.target_class.__label__ lhs_ident = self.build_source(traversal.source) rhs_ident = traversal.name + rhs_label self._ast['return'] = traversal.name self._ast['result_class'] = traversal.target_class rel_iden...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'build_traversal'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
traverse a relationship from a node to a set of nodes
def _calculate_duration(start_time, finish_time): if not (start_time and finish_time): return 0 start = datetime.datetime.fromtimestamp(start_time) finish = datetime.datetime.fromtimestamp(finish_time) duration = finish - start decimals = float(("0." + str(duration.microseconds))) return...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_calculate_duration'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'v...
Calculates how long it took to execute the testcase.
def render_constants(): generate_file("constant_enums.pxi", cython_enums, pjoin(root, 'zmq', 'backend', 'cython')) generate_file("constants.pxi", constants_pyx, pjoin(root, 'zmq', 'backend', 'cython')) generate_file("zmq_constants.h", ifndefs, pjoin(root, 'zmq', 'utils'))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'render_constants'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '18', '31']}; {'...
render generated constant files from templates
def load_ipython_extension(ipython): from coconut import __coconut__ newvars = {} for var, val in vars(__coconut__).items(): if not var.startswith("__"): newvars[var] = val ipython.push(newvars) from coconut.convenience import cmd, parse, CoconutException from coconut.termina...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_ipython_extension'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
Loads Coconut as an IPython extension.
def D(self, ID, asp): obj = self.chart.getObject(ID).copy() obj.relocate(obj.lon - asp) ID = 'D_%s_%s' % (ID, asp) return self.G(ID, obj.lat, obj.lon)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'D'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'...
Returns the dexter aspect of an object.
def relpath(self, path): return os.path.relpath(path, start=self.path)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'relpath'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self...
Return a relative filepath to path from Dir path.
def invalidate_all(self): for fname in os.listdir(self.cache_path): if fname.startswith(self.func.__name__ + "."): os.remove(os.path.join(self.cache_path, fname))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'invalidate_all'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se...
Remove all files caching this function
def bundle(self, ref, capture_exceptions=False): from ..orm.exc import NotFoundError if isinstance(ref, Dataset): ds = ref else: try: ds = self._db.dataset(ref) except NotFoundError: ds = None if not ds: try:...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'bundle'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
Return a bundle build on a dataset, with the given vid or id reference
def btc_is_p2wsh_address( address ): wver, whash = segwit_addr_decode(address) if whash is None: return False if len(whash) != 32: return False return True
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'btc_is_p2wsh_address'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
Is the given address a p2wsh address?
def underscore(text): return UNDERSCORE[1].sub(r'\1_\2', UNDERSCORE[0].sub(r'\1_\2', text)).lower()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'underscore'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'text'}...
Converts text that may be camelcased into an underscored format
def _attach_endpoints(self): for name, value in inspect.getmembers(self): if inspect.isclass(value) and issubclass(value, self._Endpoint) and (value is not self._Endpoint): endpoint_instance = value(self.requester) setattr(self, endpoint_instance.endpoint_base, endpoi...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_attach_endpoints'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
Dynamically attaches endpoint callables to this client
def _chunks(l, ncols): assert isinstance(ncols, int), "ncols must be an integer" for i in range(0, len(l), ncols): yield l[i: i+ncols]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_chunks'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'l'};...
Yield successive n-sized chunks from list, l.
def write_close(self, code=None): return self.write(self.parser.close(code), opcode=0x8, encode=False)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'write_close'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
Write a close ``frame`` with ``code``.
def do_alarm_update(mc, args): fields = {} fields['alarm_id'] = args.id if args.state.upper() not in state_types: errmsg = ('Invalid state, not one of [' + ', '.join(state_types) + ']') print(errmsg) return fields['state'] = args.state fields...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'do_alarm_update'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
Update the alarm state.
def hide(cls): cls.el.style.display = "none" cls.overlay.hide() cls.bind()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'hide'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id'...
Hide the log interface.
def kinks(path, tol=1e-8): kink_list = [] for idx in range(len(path)): if idx == 0 and not path.isclosed(): continue try: u = path[(idx - 1) % len(path)].unit_tangent(1) v = path[idx].unit_tangent(0) u_dot_v = u.real*v.real + u.imag*v.imag ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'kinks'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'path'}...
returns indices of segments that start on a non-differentiable joint.
def sort(self, *args, **kwargs): self._list.sort(*args, **kwargs) for index, value in enumerate(self._list): self._dict[value] = index
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se...
Sort this setlist in place.
def xmlinfo(self, id): self._update_index() for package in self._index.findall('packages/package'): if package.get('id') == id: return package for collection in self._index.findall('collections/collection'): if collection.get('id') == id: return collection raise ValueError('P...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'xmlinfo'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self...
Return the XML info record for the given item
def _check_values(in_values): out_values = [] for value in in_values: out_values.append(value) return tuple(out_values)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_check_values'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'in_...
Check if values need to be converted before they get mogrify'd
def source(self, source): if isinstance(source, list): source = source[0] if len(source) > 0 else None self._source = source
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'source'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'...
When the source gets updated, update the select widget
def clean_bootstrap_builds(self, _args): if exists(join(self.ctx.build_dir, 'bootstrap_builds')): shutil.rmtree(join(self.ctx.build_dir, 'bootstrap_builds'))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'clean_bootstrap_builds'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [],...
Delete all the bootstrap builds.
def derive_fernet_key(input_key): hkdf = HKDF( algorithm=hashes.SHA256(), length=32, salt=salt, info=info, backend=backend, ) return base64.urlsafe_b64encode(hkdf.derive(force_bytes(input_key)))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'derive_fernet_key'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
Derive a 32-bit b64-encoded Fernet key from arbitrary input key.
def algorithms(self): if self._algorithms is None: uri = "/loadbalancers/algorithms" resp, body = self.method_get(uri) self._algorithms = [alg["name"] for alg in body["algorithms"]] return self._algorithms
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'algorithms'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}...
Returns a list of available load balancing algorithms.
def as_length(self, value): new_vec = self.copy() new_vec.length = value return new_vec
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'as_length'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se...
Return a new vector scaled to given length
def available_modes_with_ids(self): if not self._available_mode_ids: all_modes = FIXED_MODES.copy() self._available_mode_ids = all_modes modes = self.get_available_modes() try: if modes: simple_modes = dict( ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'available_modes_with_ids'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'v...
Return list of objects containing available mode name and id.
def load_dbf(self, shapefile_name): dbf_ext = 'dbf' try: self.dbf = open("%s.%s" % (shapefile_name, dbf_ext), "rb") except IOError: try: self.dbf = open("%s.%s" % (shapefile_name, dbf_ext.upper()), "rb") except IOError: ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_dbf'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel...
Attempts to load file with .dbf extension as both lower and upper case
def encode_params(params, **kwargs): cleaned = clean_params(params, **kwargs) return json.dumps(cleaned)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'encode_params'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
Clean and JSON-encode a dict of parameters.
def _enter_single_subdir(root_dir): current_cwd = os.getcwd() try: dest_dir = root_dir dir_list = os.listdir(root_dir) if len(dir_list) == 1: first = os.path.join(root_dir, dir_list[0]) if os.path.isdir(first): dest_dir = first else: ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_enter_single_subdir'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
if the given directory has just a single subdir, enter that
def content_bytes(self): get_message = \ self._communication.needle_positions.get_line_configuration_message return get_message(self._line_number)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'content_bytes'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel...
Return the start and stop needle.
def trigger(self, username, project, branch, **build_params): method = 'POST' url = ('/project/{username}/{project}/tree/{branch}?' 'circle-token={token}'.format( username=username, project=project, branch=branch, token=self.client.api_token)) ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'trigger'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': []...
Trigger new build and return a summary of the build.
def _split_column_and_labels(self, column_or_label): column = None if column_or_label is None else self._get_column(column_or_label) labels = [label for i, label in enumerate(self.labels) if column_or_label not in (i, label)] return column, labels
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_split_column_and_labels'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [...
Return the specified column and labels of other columns.
def _check_intersection(self, other): props = ["_callables_db", "_reverse_callables_db", "_modules_dict"] for prop in props: self_dict = getattr(self, prop) other_dict = getattr(other, prop) keys_self = set(self_dict.keys()) keys_other = set(other_dict.key...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_check_intersection'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'v...
Check that intersection of two objects has the same information.
def bind_download_buttons(cls): def on_click(ev): button_el = ev.target form_el = button_el.parent.parent.parent content = form_el.get(selector="textarea")[0].text suffix = form_el.name download_path = "as_file/%s.%s" % (cls.filename, suffix) ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'bind_download_buttons'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
Bind buttons to callbacks.
def layer_mapproxy(request, catalog_slug, layer_uuid, path_info): layer = get_object_or_404(Layer, uuid=layer_uuid, catalog__slug=catalog_slug) if layer.service.type == 'Hypermap:WorldMap': layer.service.url = layer.url mp, yaml_config = ge...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'layer_mapproxy'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [...
Get Layer with matching catalog and uuid
def processData(self, times, response, test_num, trace_num, rep_num): response = response * self._polarity if rep_num == 0: self.spike_counts = [] self.spike_latencies = [] self.spike_rates = [] fs = 1./(times[1] - times[0]) spike_times = spikestats.sp...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'processData'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': 'identifier', 'chil...
Calulate spike times from raw response data
def little_endian(self): if not self._ptr: raise BfdException("BFD not initialized") return _bfd.get_bfd_attribute(self._ptr, BfdAttributes.IS_LITTLE_ENDIAN)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'little_endian'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel...
Return the little_endian attribute of the BFD file being processed.
def delete_rows_csr(mat, indices): if not isinstance(mat, scipy.sparse.csr_matrix): raise ValueError("works only for CSR format -- use .tocsr() first") indices = list(indices) mask = np.ones(mat.shape[0], dtype=bool) mask[indices] = False return mat[mask]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'delete_rows_csr'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
Remove the rows denoted by ``indices`` form the CSR sparse matrix ``mat``.
def merge_with_default_options(self, config_opts): return dict(list(self.defaults.items()) + list(config_opts.items()))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'merge_with_default_options'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children':...
merge options from configuration file with the default options
def _extract_methods(self): service = self._service all_urls = set() urls_with_options = set() if not service.http: return for rule in service.http.rules: http_method, url = _detect_pattern_option(rule) if not url or not http_method or not rule...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_extract_methods'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
Obtains the methods used in the service.
def listen_for_updates(self): self.toredis.subscribe(self.group_pubsub, callback=self.callback)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'listen_for_updates'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
Attach a callback on the group pubsub
def send_message(message, pipe='public'): if pipe not in ['public', 'private']: raise ValueError('pipe argument can be only "public" or "private"') else: pipe = pipe.upper() pipe_path = PUBLIC_PIPE if pipe == 'PUBLIC' else PRIVATE_PIPE pipeout = open(pipe_path, 'a') pipeout.write('%s...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'send_message'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
writes message to pipe
def dumps(obj, **kwargs): t = type(obj) if obj is True: return u'true' elif obj is False: return u'false' elif obj == None: return u'null' elif t == type('') or t == type(u''): single = "'" in obj double = '"' in obj if single and double: r...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dumps'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'obj'};...
Serialize ``obj`` to a JSON5-formatted ``str``.
def output(self, data, context): if self.transform: if hasattr(self.transform, 'context'): self.transform.context = context data = self.transform(data) if hasattr(data, 'read'): data = data.read().decode('utf8') if data is not None: ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'output'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
Outputs the provided data using the transformations and output format specified for this CLI endpoint