code
stringlengths
51
2.34k
sequence
stringlengths
1.16k
13.1k
docstring
stringlengths
11
171
def fishers_method(pvals): pvals = np.asarray(pvals) degrees_of_freedom = 2 * pvals.size chisq_stat = np.sum(-2*np.log(pvals)) fishers_pval = stats.chi2.sf(chisq_stat, degrees_of_freedom) return fishers_pval
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fishers_method'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'pv...
Fisher's method for combining independent p-values.
def store_edges(self, edges): with open(self.get_path(OslomRunner.TMP_EDGES_FILE), "w") as writer: for edge in edges: writer.write("{}\t{}\t{}\n".format( self.id_remapper.get_int_id(edge[0]), self.id_remapper.get_int_id(edge[1]), ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'store_edges'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
Store the temporary network edges input file with re-mapped Ids.
def moveToPoint(self, xxx_todo_changeme2): (x,y) = xxx_todo_changeme2 self.set_x1(float(self.get_x1()) + float(x)) self.set_x2(float(self.get_x2()) + float(x)) self.set_y1(float(self.get_y1()) + float(y)) self.set_y2(float(self.get_y2()) + float(y))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'moveToPoint'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
Moves the line to the point x,y
def getin(m, path, default=None): keynotfound = ':com.gooey-project/not-found' result = reduce(lambda acc, val: acc.get(val, {keynotfound: None}), path, m) if isinstance(result, dict) and keynotfound in result: return default return result
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getin'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'm...
returns the value in a nested dict
def split_by_idxs(seq, idxs): last = 0 for idx in idxs: if not (-len(seq) <= idx < len(seq)): raise KeyError(f'Idx {idx} is out-of-bounds') yield seq[last:idx] last = idx yield seq[last:]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'split_by_idxs'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
A generator that returns sequence pieces, seperated by indexes specified in idxs.
def items(self): for key, task in self._tasks: if not (task and task.result): yield key, None else: yield key, json.loads(task.result)["payload"]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'items'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'i...
Yield the async reuslts for the context.
def clf(): Visualizer3D._scene = Scene(background_color=Visualizer3D._scene.background_color) Visualizer3D._scene.ambient_light = AmbientLight(color=[1.0, 1.0, 1.0], strength=1.0)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'clf'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '20']}; {'id': '5', 'type': '...
Clear the current figure
def aschannel(self) -> 'Channel': N = self.qubit_nb R = 4 tensor = bk.outer(self.tensor, self.H.tensor) tensor = bk.reshape(tensor, [2**N]*R) tensor = bk.transpose(tensor, [0, 3, 1, 2]) return Channel(tensor, self.qubits)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'aschannel'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se...
Converts a Gate into a Channel
def getlist(self, name: str, default: Any = None) -> List[Any]: return super().get(name, default)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14', '20']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getlist'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'v...
Return the entire list
def stop(self): try: self.running = False logger.info('Waiting tasks to finish...') self.queue.join() self.socket.close() logger.info('Exiting (C-Ctrl again to force it)...') except KeyboardInterrupt: logger.info('Forced.') ...
{'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 server and all its threads.
def parse_iscsiname(rule): parser = argparse.ArgumentParser() rules = shlex.split(rule) rules.pop(0) args = clean_args(vars(parser.parse_args(rules))) parser = None return args
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_iscsiname'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'r...
Parse the iscsiname line
def add_field(self, name, default_value=None): self._fields[name] = default_value def func(cluster): return self.get(name, cluster) setattr(self, name, func)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_field'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
Add a field with an optional default value.
def quick_search(limit, pretty, sort, **kw): req = search_req_from_opts(**kw) cl = clientv1() page_size = min(limit, 250) echo_json_response(call_and_wrap( cl.quick_search, req, page_size=page_size, sort=sort ), pretty, limit)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'quick_search'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [],...
Execute a quick search.
def to_gremlin(self): self.validate() if self.optional: operation = u'optional' else: operation = u'back' mark_name, _ = self.location.get_location_name() return u'{operation}({mark_name})'.format( operation=operation, mark_name=saf...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_gremlin'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}...
Return a unicode object with the Gremlin representation of this BasicBlock.
def _get_numeric_status(self, key): value = self._get_status(key) if value and any(i.isdigit() for i in value): return float(re.sub("[^0-9.]", "", value)) return None
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_numeric_status'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'v...
Extract the numeric value from the statuses object.
def create_dataclass_loader(cls, registry, field_getters): fields = cls.__dataclass_fields__ item_loaders = map(registry, map(attrgetter('type'), fields.values())) getters = map(field_getters.__getitem__, fields) loaders = list(starmap(compose, zip(item_loaders, getters))) def dloader(obj): ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_dataclass_loader'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children...
create a loader for a dataclass type
def _read_select_kqueue(k_queue): npipes = len(NonBlockingStreamReader._streams) kevents = [select.kevent(s.stream.fileno(), filter=select.KQ_FILTER_READ, flags=select.KQ_EV_ADD | select.KQ_EV_ENABLE) for s in NonBlocki...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_read_select_kqueue'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
Read PIPES using BSD Kqueue
def _addDataFile(self, filename): if filename.endswith('.ttl'): self._rdfGraph.parse(filename, format='n3') else: self._rdfGraph.parse(filename, format='xml')
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_addDataFile'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
Given a filename, add it to the graph
def update_last_backup_meta_data(self): self.meta['last_backup']['time'] = get_time_string_for_float(self.last_backup_time) self.meta['last_backup']['file_system_path'] = self._tmp_storage_path self.meta['last_backup']['marked_dirty'] = self.state_machine_model.state_machine.marked_dirty
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_last_backup_meta_data'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': []...
Update the auto backup meta data with internal recovery information
def initialize(self): mkdir_p(self.archive_path) mkdir_p(self.bin_path) mkdir_p(self.codebase_path) mkdir_p(self.input_basepath)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'initialize'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}...
Create the laboratory directories.
def create_keys_in(): keys = Group( Optional(Suppress("(")) + value + Optional(Suppress(",") + value) + Optional(Suppress(")")) ) return (Suppress(upkey("keys") + upkey("in")) + delimitedList(keys)).setResultsName( "keys_in" )
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_keys_in'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '38']}; {'id': '5'...
Create a grammer for the 'KEYS IN' clause used for queries
def add_stack_frame(self, stack_frame): if len(self.stack_frames) >= MAX_FRAMES: self.dropped_frames_count += 1 else: self.stack_frames.append(stack_frame.format_stack_frame_json())
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_stack_frame'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
Add StackFrame to frames list.
def copy(self): connection = self.connection del self.connection copied_query = deepcopy(self) copied_query.connection = connection self.connection = connection return copied_query
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'copy'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id...
Deeply copies everything in the query object except the connection object is shared
def isignored(self, relpath, directory=False): relpath = self._relpath_no_dot(relpath) if directory: relpath = self._append_trailing_slash(relpath) return self.ignore.match_file(relpath)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'isignored'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
Returns True if path matches pants ignore pattern.
def log_run(self): version = get_system_spec()['raiden'] cursor = self.conn.cursor() cursor.execute('INSERT INTO runs(raiden_version) VALUES (?)', [version]) self.maybe_commit()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'log_run'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {...
Log timestamp and raiden version to help with debugging
def getOverlayDualAnalogTransform(self, ulOverlay, eWhich): fn = self.function_table.getOverlayDualAnalogTransform pvCenter = HmdVector2_t() pfRadius = c_float() result = fn(ulOverlay, eWhich, byref(pvCenter), byref(pfRadius)) return result, pvCenter, pfRadius.value
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getOverlayDualAnalogTransform'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'ch...
Gets the analog input to Dual Analog coordinate scale for the specified overlay.
def _setup_eventloop(self): if os.name == 'nt': self.eventloop = asyncio.ProactorEventLoop() else: self.eventloop = asyncio.new_event_loop() asyncio.set_event_loop(self.eventloop) if os.name == 'posix' and isinstance(threading.current_thread(), threading._MainThre...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_setup_eventloop'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
Sets up a new eventloop as the current one according to the OS.
def _add_researcher_summary(samples, summary_yaml): by_researcher = collections.defaultdict(list) for data in (x[0] for x in samples): researcher = utils.get_in(data, ("upload", "researcher")) if researcher: by_researcher[researcher].append(data["description"]) out_by_researcher ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_add_researcher_summary'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': []...
Generate summary files per researcher if organized via a LIMS.
def send_status(self, payload): answer = {} data = [] if self.paused: answer['status'] = 'paused' else: answer['status'] = 'running' if len(self.queue) > 0: data = deepcopy(self.queue.queue) for key, item in data.items(): ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'send_status'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
Send the daemon status and the current queue for displaying.
def focusPrev(self, event): try: event.widget.tk_focusPrev().focus_set() except TypeError: name = event.widget.tk.call('tk_focusPrev', event.widget._w) event.widget._nametowidget(str(name)).focus_set()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'focusPrev'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se...
Set focus to previous item in sequence
def __summary(self): text = "Time: %s\n" % self.when text += "Comitter: %s\n" % self.editor inst = self.timemachine.presently if self.action_type == "dl": text += "Deleted %s\n" % inst._object_type_text() elif self.action_type == "cr": text += "Created %s\...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '__summary'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};...
A plaintext summary of the Action, useful for debugging.
def _confused_state(self, request: Request) -> Type[BaseState]: origin = request.register.get(Register.STATE) if origin in self._allowed_states: try: return import_class(origin) except (AttributeError, ImportError): pass return import_class...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_confused_state'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], ...
If we're confused, find which state to call.
def stamp_excerpt(kb_app: kb, sphinx_app: Sphinx, doctree: doctree): resources = sphinx_app.env.resources confdir = sphinx_app.confdir source = PurePath(doctree.attributes['source']) docname = str(source.relative_to(confdir)).split('.rst')[0] resource = resources....
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'stamp_excerpt'}; {'id': '3', 'type': 'parameters', 'children': ['4', '8', '12']}; {'id': '4', 'type': 'typed_parameter', 'children': ...
Walk the tree and extract excert into resource.excerpt
def replicate(ctx, args): slave = ClusterNode.from_uri(args.node) master = ClusterNode.from_uri(args.master) if not master.is_master(): ctx.abort("Node {!r} is not a master.".format(args.master)) try: slave.replicate(master.name) except redis.ResponseError as e: ctx.abort(str...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'replicate'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ct...
Make node to be the slave of a master.
def runctx(self, cmd, globals, locals): self.enable_by_count() try: exec(cmd, globals, locals) finally: self.disable_by_count() return self
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'runctx'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
Profile a single executable statement in the given namespaces.
def lazyfunc(func): closuremem_ = [{}] def wrapper(*args, **kwargs): mem = closuremem_[0] key = (repr(args), repr(kwargs)) try: return mem[key] except KeyError: mem[key] = func(*args, **kwargs) return mem[key] return wrapper
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'lazyfunc'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'func'}; ...
Returns a memcached version of a function
def return_on_initial_capital(capital, period_pl, leverage=None): if capital <= 0: raise ValueError('cost must be a positive number not %s' % capital) leverage = leverage or 1. eod = capital + (leverage * period_pl.cumsum()) ltd_rets = (eod / capital) - 1. dly_rets = ltd_rets dly_rets.il...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'return_on_initial_capital'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'childr...
Return the daily return series based on the capital
def backup_name(self, timestamp=None): suffix = datetime2string(coalesce(timestamp, datetime.now()), "%Y%m%d_%H%M%S") return File.add_suffix(self._filename, suffix)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'backup_name'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
RETURN A FILENAME THAT CAN SERVE AS A BACKUP FOR THIS FILE
def clear( self ): self.setCurrentLayer(None) self._layers = [] self._cache.clear() super(XNodeScene, self).clear()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'clear'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'i...
Clears the current scene of all the items and layers.
def _check_align(self): if not hasattr(self, "_align"): self._align = ["l"]*self._row_size if not hasattr(self, "_valign"): self._valign = ["t"]*self._row_size
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_check_align'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self...
Check if alignment has been specified, set default one if not
def run_cmd(call, cmd, *, echo=True, **kwargs): if echo: print('$> ' + ' '.join(map(pipes.quote, cmd))) return call(cmd, **kwargs)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run_cmd'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10']}; {'id': '4', 'type': 'identifier', 'children': [...
Run a command and echo it first
def decode_list(input_props, name): val_str = input_props.get(name, None) if val_str: return val_str.split(" ") return []
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'decode_list'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
Decodes a space-separated list
def return_buffer_contents(self, frame, force_unescaped=False): if not force_unescaped: if frame.eval_ctx.volatile: self.writeline('if context.eval_ctx.autoescape:') self.indent() self.writeline('return Markup(concat(%s))' % frame.buffer) ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'return_buffer_contents'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children'...
Return the buffer contents of the frame.
def _handle_ls(self): try: arg1 = self.argument(1) arg2 = self.argument(2) todos = [] if arg2 == 'to' or arg1 == 'before': number = arg1 if arg2 == 'to' else arg2 todo = self.todolist.todo(number) todos = self.todoli...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_handle_ls'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}...
Handles the ls subsubcommand.
def log_entries(self, time_zone='UTC', is_overview=False, include=None, fetch_all=True): endpoint = '/'.join((self.endpoint, self.id, 'log_entries')) query_params = { 'time_zone': time_zone, 'is_overview': json.dumps(is_overview), } if include:...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '17']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'log_entries'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14']}; {'id': '4', 'type': 'identifier', 'childre...
Query for log entries on an incident instance.
def FilePrinter(filename, mode='a', closing=True): path = os.path.abspath(os.path.expanduser(filename)) f = open(path, mode) return Printer(f, closing)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'FilePrinter'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
Opens the given file and returns a printer to it.
def _is_default(path, dest, name): subvol_id = __salt__['btrfs.subvolume_show'](path)[name]['subvolume id'] def_id = __salt__['btrfs.subvolume_get_default'](dest)['id'] return subvol_id == def_id
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_is_default'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
Check if the subvolume is the current default.
def _tool_from_string(name): known_tools = sorted(_known_tools.keys()) if name in known_tools: tool_fn = _known_tools[name] if isinstance(tool_fn, string_types): tool_fn = _known_tools[tool_fn] return tool_fn() else: matches, text = difflib.get_close_matches(name....
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_tool_from_string'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
Takes a string and returns a corresponding `Tool` instance.
def _get_management_client(self, client_class): try: client = get_client_from_auth_file( client_class, auth_path=self.service_account_file ) except ValueError as error: raise AzureCloudException( 'Service account file format is invalid:...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_management_client'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [],...
Return instance of resource management client.
def filter(self, p_todo_str, p_todo): return "|{:>3}| {}".format(self.todolist.number(p_todo), p_todo_str)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'filter'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
Prepends the number to the todo string.
def register(tag, end_tag=None): def register_function(function): tagmap[tag] = {'func': function, 'endtag': end_tag} if end_tag: tagmap['endtags'].append(end_tag) return function return register_function
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'register'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'tag...
Decorator for registering shortcode functions.
def for_all_targets(self, module, func, filter_func=None): for target in self.targets(module): if filter_func is None or filter_func(target): func(target)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'for_all_targets'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children':...
Call func once for all of the targets of this module.
def enable_notebook(): try: from IPython.core.getipython import get_ipython except ImportError: raise ImportError('This feature requires IPython 1.0+') ip = get_ipython() f = ip.display_formatter.formatters['text/html'] f.for_type(np.ndarray, _array_to_html)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'enable_notebook'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '22', '28', '38']...
Enable automatic visualization of NumPy arrays in the IPython Notebook.
def convert_dict_to_datetime(obj_map): converted_map = {} for key, value in obj_map.items(): if isinstance(value, dict) and 'tzinfo' in value.keys(): converted_map[key] = datetime.datetime(**value) elif isinstance(value, dict): converted_map[key] = convert_dict_to_datetim...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'convert_dict_to_datetime'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'v...
converts dictionary representations of datetime back to datetime obj
def quit(self, message=None): if message is None: message = 'Quit' if self.connected: self.send('QUIT', params=[message])
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'quit'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};...
Quit from the server.
def reconstruct_files(input_dir): input_dir = input_dir.rstrip('/') with nl.notify('Attempting to organize/reconstruct directory'): for r,ds,fs in os.walk(input_dir): for f in fs: if f[0]=='.': shutil.move(os.path.join(r,f),os.path.join(r,'i'+f)) n...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'reconstruct_files'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
sorts ``input_dir`` and tries to reconstruct the subdirectories found
def _put_file(self, file): post_params = { 'file_size': file.size, 'file_hash': file.md5hash(), 'content_type': self._get_content_type(file), } headers = self._request_headers('PUT', file.prefixed_name, post_params=post_params) with closing(HTTPConnect...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_put_file'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se...
Send PUT request to S3 with file contents
def distribute_libs(self, arch, src_dirs, wildcard='*', dest_dir="libs"): info('Copying libs') tgt_dir = join(dest_dir, arch.arch) ensure_dir(tgt_dir) for src_dir in src_dirs: for lib in glob.glob(join(src_dir, wildcard)): shprint(sh.cp, '-a', lib, tgt_dir)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'distribute_libs'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10']}; {'id': '4', 'type': 'identifier', 'chil...
Copy existing arch libs from build dirs to current dist dir.
def replace_emphasis(self, s, index = 0): e = self.emphasized[index] self.body[e[0]:e[1]] = [s] del self.emphasized[index]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'replace_emphasis'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], ...
replace the index'th emphasized text with s
def add_template(template, **kwargs): tmpl = Template() tmpl.name = template.name if template.description: tmpl.description = template.description if template.layout: tmpl.layout = get_layout_as_string(template.layout) db.DBSession.add(tmpl) if template.templatetypes 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': 'add_template'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
Add template and a type and typeattrs.
def md_options_to_metadata(options): metadata = parse_md_code_options(options) if metadata: language = metadata[0][0] for lang in _JUPYTER_LANGUAGES + ['julia', 'scheme', 'c++']: if language.lower() == lang.lower(): return lang, dict(metadata[1:]) return None, dic...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'md_options_to_metadata'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
Parse markdown options and return language and metadata
def load_styles(path_or_doc): if isinstance(path_or_doc, string_types): doc = load(path_or_doc) else: if isinstance(path_or_doc, ODFDocument): doc = path_or_doc._doc else: doc = path_or_doc assert isinstance(doc, OpenDocument), doc styles = {_style_nam...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_styles'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'path_...
Return a dictionary of all styles contained in an ODF document.
def _match_setters(self, query): q = query.decode('utf-8') for name, parser, response, error_response in self._setters: try: parsed = parser(q) logger.debug('Found response in setter of %s' % name) except ValueError: continue ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_match_setters'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
Try to find a match
def check_public_permissions(payload): allowed_public_permissions = ['view', 'add', 'download'] for perm_type in ['add', 'remove']: for perm in payload.get('public', {}).get(perm_type, []): if perm not in allowed_public_permissions: raise exceptions.PermissionDenied("Permissi...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_public_permissions'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'v...
Raise ``PermissionDenied`` if public permissions are too open.
def _rgb_randomize(x, channel:int=None, thresh:float=0.3): "Randomize one of the channels of the input image" if channel is None: channel = np.random.randint(0, x.shape[0] - 1) x[channel] = torch.rand(x.shape[1:]) * np.random.uniform(0, thresh) return x
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_rgb_randomize'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '10']}; {'id': '4', 'type': 'identifier', 'children': [], ...
Randomize one of the channels of the input image
def cwlout(key, valtype=None, extensions=None, fields=None, exclude=None): out = {"id": key} if valtype: out["type"] = valtype if fields: out["fields"] = fields if extensions: out["secondaryFiles"] = extensions if exclude: out["exclude"] = exclude return out
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '17']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cwlout'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14']}; {'id': '4', 'type': 'identifier', 'children': [...
Definition of an output variable, defining the type and associated secondary files.
def favicon(request): favicon = u"{}tree/images/favicon.ico".format(settings.STATIC_URL) try: from seo.models import MetaSite site = MetaSite.objects.get(default=True) return HttpResponseRedirect(site.favicon.url) except: return HttpResponseRedirect(favicon)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'favicon'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'request'}...
It returns favicon's location
def async_get_device(self, uid, fields='*'): return (yield from self._get('/pods/{}'.format(uid), fields=fields))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'async_get_device'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], ...
Get specific device by ID.
def get(args): html = args.H lang = args.l nowrap = args.n query = args.q silent = args.s title = args.t verbose = args.v wiki = args.w if query: qobj = WPToolsQuery(lang=lang, wiki=wiki) if title: return qobj.query(title) return qobj.random() ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id'...
invoke wptools and assemble selected output
def _py2java(sc, obj): if isinstance(obj, RDD): obj = _to_java_object_rdd(obj) elif isinstance(obj, DataFrame): obj = obj._jdf elif isinstance(obj, SparkContext): obj = obj._jsc elif isinstance(obj, list): obj = [_py2java(sc, x) for x in obj] elif isinstance(obj, Java...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_py2java'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sc'...
Convert Python object into Java
def _visible_in_diff(merge_result, context_lines=3): i = old_line = new_line = 0 while i < len(merge_result): line_or_conflict = merge_result[i] if isinstance(line_or_conflict, tuple): yield old_line, new_line, line_or_conflict old_line += len(line_or_conflict[0]) ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_visible_in_diff'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
Collects the set of lines that should be visible in a diff with a certain number of context lines
def _save_multi(data, file_name, sep=";"): logger.debug("saving multi") with open(file_name, "w", newline='') as f: logger.debug(f"{file_name} opened") writer = csv.writer(f, delimiter=sep) try: writer.writerows(itertools.zip_longest(*data)) except Exception as e: ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_save_multi'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
convenience function for storing data column-wise in a csv-file.
def includePoint(self, p): if not len(p) == 2: raise ValueError("bad sequ. length") self.x0, self.y0, self.x1, self.y1 = TOOLS._include_point_in_rect(self, p) return self
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'includePoint'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
Extend rectangle to include point p.
def close(self): target = self.prev if (self.is_current and self.prev != self) else None with switch_window(self._browser, self.name): self._browser.driver.close() if target is not None: target.is_current = True
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'close'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'i...
Close this window. If this window is active, switch to previous window
def parameters_as_string(self): params = ", ".join([ p.name for p in self.ordered_parameters ]) return params
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parameters_as_string'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
Returns a comma-separated list of the parameters in the executable definition.
def make_config(self, data: dict): self.validate_config(data) config_data = self.prepare_config(data) return config_data
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'make_config'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
Make a MIP config.
def cnxml_to_html(cnxml_source): source = _string2io(cnxml_source) xml = etree.parse(source) xml = _transform('cnxml-to-html5.xsl', xml, version='"{}"'.format(version)) xml = XHTML_MODULE_BODY_XPATH(xml) return etree.tostring(xml[0])
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cnxml_to_html'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cnx...
Transform the CNXML source to HTML
def withHeartbeater(cls, heartbeater): instance = cls(heartbeater) heartbeater.writeHeartbeat = instance.heartbeat return instance
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'withHeartbeater'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
Connect a SockJSProtocolMachine to its heartbeater.
def unsubscribe_all(self, callback=False): futures = ((f, r) for f, r in self._requests.items() if isinstance(r, Subscribe) and f not in self._pending_unsubscribes) if futures: for future, request in futures: if callback: ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'unsubscribe_all'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
Send an unsubscribe for all active subscriptions
def build_funding(award_groups): if not award_groups: return [] funding_awards = [] for award_groups_item in award_groups: for award_group_id, award_group in iteritems(award_groups_item): award = ea.FundingAward() award.award_group_id = award_group_id if a...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'build_funding'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'awa...
Given a funding data, format it
def _ordereddict2dict(input_ordered_dict): return salt.utils.json.loads(salt.utils.json.dumps(input_ordered_dict))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_ordereddict2dict'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
Convert ordered dictionary to a dictionary
def as_timedelta(cls, delta): if isinstance(delta, cls): return delta return cls(delta.days, delta.seconds, delta.microseconds)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'as_timedelta'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
Convert delta into a MyTimedelta object.
def transform(self, trans): clone = deepcopy(self) for n in clone.iter_sections(): n.points[:, 0:3] = trans(n.points[:, 0:3]) return clone
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'transform'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se...
Return a copy of this neurite with a 3D transformation applied
def encode(self, input_str): inputs = self.encoders["inputs"].encode(input_str) + [EOS_ID] batch_inputs = np.reshape(inputs, [1, -1, 1, 1]) return batch_inputs
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'encode'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'...
Input str to features dict, ready for inference.
def update_record(self, name, address, ttl=60): record_id = self._get_record(name) if record_id is None: return self._create_record(name, address, ttl) return self._update_record(record_id, name, address, ttl)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_record'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [...
Updates a record, creating it if not exists.
def commit(): session_token = request.headers['session_token'] repository = request.headers['repository'] current_user = have_authenticated_user(request.environ['REMOTE_ADDR'], repository, session_token) if current_user is False: return fail(user_auth_fail_msg) repository_path = config['repositor...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'commit'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '13', '21', '34', '44', '5...
Commit changes and release the write lock
def _get_aggregated_node_list(self, data): node_list = [] for node in data: local_addresses = [node['primary']] if 'secondary' in node: local_addresses += node['secondary'] node_list.append(local_addresses) return node_list
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_aggregated_node_list'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': ...
Returns list of main and secondary mac addresses.
def machine_info(): import psutil BYTES_IN_GIG = 1073741824.0 free_bytes = psutil.virtual_memory().total return [{"memory": float("%.1f" % (free_bytes / BYTES_IN_GIG)), "cores": multiprocessing.cpu_count(), "name": socket.gethostname()}]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'machine_info'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '8', '12', '22']}; {...
Retrieve core and memory information for the current machine.
def _build_gadgets(self, gadget_tree_root): node_list = self._build_gadgets_rec(gadget_tree_root) return [RawGadget(n) for n in node_list]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_build_gadgets'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
Return a gadgets list.
def add(self, callback_type, callback): with self.lock: self.callbacks[callback_type].append(callback)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel...
Add a new listener
def find_all_files(self): files = self.find_files() subrepo_files = ( posixpath.join(subrepo.location, filename) for subrepo in self.subrepos() for filename in subrepo.find_files() ) return itertools.chain(files, subrepo_files)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_all_files'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se...
Find files including those in subrepositories.
def inputindex(input): stats = {} countminmax = "SUM(count) AS count, MIN(day) AS first, MAX(day) AS last" tables = ("moves", "clicks", "scrolls") if "mouse" == input else ("keys", "combos") for table in tables: stats[table] = db.fetchone("counts", countminmax, type=table) stats[ta...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'inputindex'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'input'...
Handler for showing keyboard or mouse page with day and total links.
def add_record(self, record): rec = self.get_record(record._record_type, record.host) if rec: rec = record for i,r in enumerate(self._entries): if r._record_type == record._record_type \ and r.host == record.host: ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_record'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's...
Add or update a given DNS record
def _get_entry_link(self, entry): entry_link = None for link in entry.link: if '/data/' not in link.href and '/lh/' not in link.href: entry_link = link.href break return entry_link or entry.link[0].href
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_entry_link'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
Returns a unique link for an entry
def _load(self, element, commentchar): for child in element: if "id" in child.attrib: tline = TemplateLine(child, self, commentchar) self.order.append(tline.identifier) self.lines[tline.identifier] = tline else: ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_load'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's...
Loads all the child line elements from the XML group element.
def save_config( self, cmd="copy running-config startup-config", confirm=True, confirm_response="y", ): return super(ExtremeNosSSH, self).save_config( cmd=cmd, confirm=confirm, confirm_response=confirm_response )
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'save_config'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': []...
Save Config for Extreme VDX.
def find_model_by_table_name(name): for model in ModelBase._decl_class_registry.values(): if hasattr(model, '__table__') and model.__table__.fullname == name: return model return None
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_model_by_table_name'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'v...
Find a model reference by its table name
def _render_frame(self): frame = self.frame() output = '\r{0}'.format(frame) self.clear() try: self._stream.write(output) except UnicodeEncodeError: self._stream.write(encode_utf_8_text(output))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_render_frame'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel...
Renders the frame on the line after clearing it.
def main(self): loop = MainLoop(self.view, DEFAULT_PALETTE, handle_mouse=self.handle_mouse) self.view.show_graphs() self.animate_graph(loop) try: loop.run() except (ZeroDivisionError) as err: logging.debug("Some stat caused divide b...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'main'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id...
Starts the main loop and graph animation
def _import_status(data, item, repo_name, repo_tag): status = item['status'] try: if 'Downloading from' in status: return elif all(x in string.hexdigits for x in status): data['Image'] = '{0}:{1}'.format(repo_name, repo_tag) data['Id'] = status except (Att...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_import_status'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [...
Process a status update from docker import, updating the data structure