code
stringlengths
51
2.34k
sequence
stringlengths
1.16k
13.1k
docstring
stringlengths
11
171
def load_help_files(data): for command_name, help_yaml in helps.items(): help_entry = yaml.safe_load(help_yaml) try: help_type = help_entry['type'] except KeyError: continue if command_name not in data and help_type == 'command': logger.debug('Comm...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_help_files'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'd...
loads all the extra information from help files
def load_skills_data() -> dict: skills_data_file = expanduser('~/.mycroft/skills.json') if isfile(skills_data_file): try: with open(skills_data_file) as f: return json.load(f) except json.JSONDecodeError: return {} else: return {}
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_skills_data'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'type', 'children': ['5']}; {'id': '5'...
Contains info on how skills should be updated
def _parse(self, stream, context, path): start = stream.tell() read_bytes = "" if self.max_length: read_bytes = stream.read(self.max_length) else: read_bytes = stream.read() skip = read_bytes.find(self.find) + len(self.find) stream.seek(start + ski...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_parse'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
Parse stream to find a given byte string.
def load(self, line): words = line.split() try: float(words[0]) self.__name = "" self.__value = " ".join(words) except ValueError: self.__name = words[0].upper() if len(words) > 2 and words[1][0]=="[" and words[1][-1]=="]": ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};...
Load this keyword from a file-like object
def unwatch_source(self, source_id): source_id = int(source_id) self._watched_sources.remove(source_id) return (yield from self._send_cmd("WATCH S[%d] OFF" % ( source_id, )))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'unwatch_source'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
Remove a souce from the watchlist.
def _parse_caps_devices_features(node): result = {} for child in node: if child.get('supported') == 'yes': enums = [_parse_caps_enum(node) for node in child.findall('enum')] result[child.tag] = {item[0]: item[1] for item in enums if item[0]} return result
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_parse_caps_devices_features'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': []...
Parse the devices or features list of the domain capatilities
def neg_int(i): try: if isinstance(i, string_types): i = int(i) if not isinstance(i, int) or i > 0: raise Exception() except: raise ValueError("Not a negative integer") return i
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'neg_int'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id...
Simple negative integer validation.
async def check_chat(self, event=None): if self.me is None: return chat = self.chat.get().strip() try: chat = int(chat) except ValueError: pass try: old = self.chat_id self.chat_id = await self.cl.get_peer_id(chat) ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_chat'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's...
Checks the input chat where to send and listen messages from.
def _init_shape(self): shape = self._par['geometry']['shape'].lower() aspect = self._header['aspect'] if self.rcmb is not None and self.rcmb >= 0: self._shape['cyl'] = self.twod_xz and (shape == 'cylindrical' or aspect[0] >= np.pi) ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_init_shape'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'...
Determine shape of geometry
def reload_source(self, name): src = self.roi.get_source_by_name(name) if hasattr(self.like.logLike, 'loadSourceMap'): self.like.logLike.loadSourceMap(str(name), True, False) srcmap_utils.delete_source_map(self.files['srcmap'], name) self.like.logLike.saveSourceMaps(s...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'reload_source'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
Recompute the source map for a single source in the model.
def deduplicate(list_object): new = [] for item in list_object: if item not in new: new.append(item) return new
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'deduplicate'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'list_...
Rebuild `list_object` removing duplicated and keeping order
def load_config(files=None, root_path=None, local_path=None): config = cfg.ConfigOpts() config.register_opts([ cfg.Opt('root_path', default=root_path), cfg.Opt('local_path', default=local_path), ]) if files is not None: config(args=[], default_config_files=files) return confi...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_config'}; {'id': '3', 'type': 'parameters', 'children': ['4', '7', '10']}; {'id': '4', 'type': 'default_parameter', 'children': ...
Load the configuration from specified files.
def visit_exec(self, node): if node.locals: return "exec %s in %s, %s" % ( node.expr.accept(self), node.locals.accept(self), node.globals.accept(self), ) if node.globals: return "exec %s in %s" % (node.expr.accept(self),...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'visit_exec'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's...
return an astroid.Exec node as string
def __json_date_parse(json_object): known_date_fields = ["created_at", "week", "day", "expires_at", "scheduled_at"] for k, v in json_object.items(): if k in known_date_fields: if v != None: try: if isinstance(v, int): ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '__json_date_parse'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
Parse dates in certain known json fields, if possible.
def connect_entry_signals(): post_save.connect( ping_directories_handler, sender=Entry, dispatch_uid=ENTRY_PS_PING_DIRECTORIES) post_save.connect( ping_external_urls_handler, sender=Entry, dispatch_uid=ENTRY_PS_PING_EXTERNAL_URLS) post_save.connect( flush_similar_cach...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'connect_entry_signals'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '18', '31',...
Connect all the signals on Entry model.
def to_minutes(days=0, hours=0, minutes=0, seconds=0, milliseconds=0, round_to_int=True): total = float(days)*24*60 + float(hours)*60 + float(minutes) + \ float(seconds)/60 + float(milliseconds)/1000/60 return int(round(total)) if round_to_int else total
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '22']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_minutes'}; {'id': '3', 'type': 'parameters', 'children': ['4', '7', '10', '13', '16', '19']}; {'id': '4', 'type': 'default_paramet...
Returns the computed total number of minutes
def search(ctx, tags, prefix=None): _generate_api(ctx) for i, match in enumerate(ctx.obj.api.search(*tags, prefix=prefix)): click.echo(match, nl=False) print('')
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'search'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
List all archives matching tag search criteria
def process_event(self, event_id): with db.session.begin_nested(): event = Event.query.get(event_id) event._celery_task = self event.receiver.run(event) flag_modified(event, 'response') flag_modified(event, 'response_headers') db.session.add(event) db.session.comm...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'process_event'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
Process event in Celery.
def predict(self,function,args): param = self.model.param_array fs = [] for p in self.chain: self.model.param_array = p fs.append(function(*args)) self.model.param_array = param return fs
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'predict'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
Make a prediction for the function, to which we will pass the additional arguments
def close(self): if self.streamSock: self.watch(enable=False) self.streamSock.close() self.streamSock = None
{'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...
turn off stream and close socket
def polygon(surf, points, color): gfxdraw.aapolygon(surf, points, color) gfxdraw.filled_polygon(surf, points, color) x = min([x for (x, y) in points]) y = min([y for (x, y) in points]) xm = max([x for (x, y) in points]) ym = max([y for (x, y) in points]) return pygame.Rect(x, y, xm - x, ym -...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'polygon'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
Draw an antialiased filled polygon on a surface
def usable_id(cls, id): try: qry_id = cls.from_name(id) if not qry_id: qry_id = int(id) except DuplicateResults as exc: cls.error(exc.errors) except Exception: qry_id = None if not qry_id: msg = 'unknown identifi...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'usable_id'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cl...
Retrieve id from input which can be name or id.
def getdocumenttext(document): paratextlist = [] paralist = [] for element in document.iter(): if element.tag == '{'+nsprefixes['w']+'}p': paralist.append(element) for para in paralist: paratext = u'' for element in para.iter(): if element.tag == '{'+nspre...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getdocumenttext'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'd...
Return the raw text of a document, as a list of paragraphs.
def clamp(value, lower=0, upper=sys.maxsize): return max(lower, min(upper, value))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'clamp'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
Clamp float between given range
def nonlocal_packages_path(self): paths = self.packages_path[:] if self.local_packages_path in paths: paths.remove(self.local_packages_path) return paths
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'nonlocal_packages_path'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
Returns package search paths with local path removed.
def _from_dict(cls, _dict): args = {} if 'feedback_type' in _dict: args['feedback_type'] = _dict.get('feedback_type') if 'document' in _dict: args['document'] = ShortDoc._from_dict(_dict.get('document')) if 'model_id' in _dict: args['model_id'] = _dict...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_from_dict'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'c...
Initialize a FeedbackDataOutput object from a json dictionary.
def from_pauli(pauli, coeff=1.0): if pauli.is_identity or coeff == 0: return Term((), coeff) return Term((pauli,), coeff)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'from_pauli'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'p...
Make new Term from an Pauli operator
def _construct_url(self, url, base, quote): if not base and not quote: return url else: url = url + base.lower() + quote.lower() + "/" return url
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_construct_url'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [...
Adds the orderbook to the url if base and quote are specified.
def install(cls): [os.makedirs('{}/{}'.format(cls.home, cls.dirs[d])) for d in cls.dirs]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'install'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'...
Create the required directories in the home directory
def encode(self, pdu): if _debug: BVLCI._debug("encode %s", str(pdu)) PCI.update(pdu, self) pdu.put( self.bvlciType ) pdu.put( self.bvlciFunction ) if (self.bvlciLength != len(self.pduData) + 4): raise EncodingError("invalid BVLCI length") pdu.put_short( self....
{'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'...
encode the contents of the BVLCI into the PDU.
def aa_frequencies(seq, gap_chars='-.'): aa_counts = Counter(seq) for gap_char in gap_chars: if gap_char in aa_counts: del aa_counts[gap_char] scale = 1.0 / sum(aa_counts.values()) return dict((aa, cnt * scale) for aa, cnt in aa_counts.iteritems())
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'aa_frequencies'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
Calculate the amino acid frequencies in a sequence set.
def OnCellFontSize(self, event): with undo.group(_("Font size")): self.grid.actions.set_attr("pointsize", event.size) self.grid.ForceRefresh() self.grid.update_attribute_toolbar() event.Skip()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'OnCellFontSize'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
Cell font size event handler
def getRoot(): root = settings.MEDIA_ROOT.replace('\\', '/') if not root.endswith('/'): root += '/' return path.Path(root)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getRoot'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '17', '30']}; {'id': '5',...
Convenience to return the media root with forward slashes
def add_step(self, value_map): if len(self.trace) == 0: raise PyrtlError('error, simulation trace needs at least 1 signal to track ' '(by default, unnamed signals are not traced -- try either passing ' 'a name to a WireVector or setting a "wi...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_step'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel...
Add the values in value_map to the end of the trace.
def _svd_sym_koopman(K, C00_train, Ctt_train): from pyemma._ext.variational.solvers.direct import spd_inv_sqrt C0t_re = mdot(C00_train, K) K_sym = mdot(spd_inv_sqrt(C00_train), C0t_re, spd_inv_sqrt(Ctt_train)) U, S, Vt = np.linalg.svd(K_sym, compute_uv=True, full_matrices=False) U = mdot(spd_inv_sqr...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_svd_sym_koopman'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], ...
Computes the SVD of the symmetrized Koopman operator in the empirical distribution.
def init(directory=None, multidb=False): if directory is None: directory = current_app.extensions['migrate'].directory config = Config() config.set_main_option('script_location', directory) config.config_file_name = os.path.join(directory, 'alembic.ini') config = current_app.extensions['migr...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'init'}; {'id': '3', 'type': 'parameters', 'children': ['4', '7']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}; ...
Creates a new migration repository
def gradient(self): func = self.left op = self.right class FunctionalCompositionGradient(Operator): def __init__(self): super(FunctionalCompositionGradient, self).__init__( op.domain, op.domain, linear=False) def _call(self, x): ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'gradient'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; ...
Gradient of the compositon according to the chain rule.
def _authenticate_ssh(org): username = os.environ.get(f"{org.upper()}_USERNAME") child = pexpect.spawn("ssh -T git@github.com", encoding="utf8") i = child.expect(["Hi (.+)! You've successfully authenticated", "Enter passphrase for key", "Permission denied", ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_authenticate_ssh'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
Try authenticating via ssh, if succesful yields a User, otherwise raises Error.
def tqdm(self): async_tqdm = utils.async_tqdm with async_tqdm(total=0, desc='Dl Completed...', unit=' url') as pbar_url: with async_tqdm(total=0, desc='Dl Size...', unit=' MiB') as pbar_dl_size: self._pbar_url = pbar_url self._pbar_dl_size = pbar_dl_size yield
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'tqdm'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id...
Add a progression bar for the current download.
def find_cycle(self): for node in self.nodes: cyc = self._follow_children(node) if len(cyc) > 0: return [self._nodes[x] for x in cyc] 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_cycle'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}...
greedy search for a cycle
def build(self, shutit): if shutit.build['delivery'] in ('docker','dockerfile'): if shutit.get_current_shutit_pexpect_session_environment().install_type == 'apt': shutit.add_to_bashrc('export DEBIAN_FRONTEND=noninteractive') if not shutit.command_available('lsb_release'): shutit.install('lsb-release')...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'build'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}...
Initializes target ready for build and updating package management if in container.
def takes_parameters(count): def decorator(f): @wraps(f) def wrapper(filter_operation_info, location, context, parameters, *args, **kwargs): if len(parameters) != count: raise GraphQLCompilationError(u'Incorrect number of parameters, expected {} got ' ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'takes_parameters'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
Ensure the filter function has "count" parameters specified.
def create_service(self, service_type, plan_name, service_name, params, async=False, **kwargs): if self.space.has_service_with_name(service_name): logging.warning("Service already exists with that name.") return self.get_instance(service_name) if self.space.has_servic...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_service'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '12']}; {'id': '4', 'type': 'identifie...
Create a service instance.
def _pin_mongos(self, server): self._transaction.sharded = True self._transaction.pinned_address = server.description.address
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_pin_mongos'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
Pin this session to the given mongos Server.
def render(self, data, accepted_media_type=None, renderer_context=None): if data is None: return '' stream = StringIO() xml = SimplerXMLGenerator(stream, self.charset) xml.startDocument() xml.startElement(self.root_tag_name, {}) self._to_xml(xml, data) ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'render'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
Renders `data` into serialized XML.
def validate(self): if self.required and len(self.selected()) == 0: raise ReliureError("No component selected for block '%s'" % self.name)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'validate'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; ...
check that the block can be run
def autocrop(im, bgcolor): "Crop away a border of the given background color." if im.mode != "RGB": im = im.convert("RGB") bg = Image.new("RGB", im.size, bgcolor) diff = ImageChops.difference(im, bg) bbox = diff.getbbox() if bbox: return im.crop(bbox) return im
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'autocrop'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'im'...
Crop away a border of the given background color.
def read_corpus(file_name): with io.open(file_name, encoding='utf-8') as data_file: return yaml.load(data_file)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'read_corpus'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'file_...
Read and return the data from a corpus json file.
def main(): project_root = utils.get_project_root() infofile = os.path.join(project_root, "raw-datasets/info.yml") logging.info("Read '%s'...", infofile) with open(infofile, 'r') as ymlfile: datasets = yaml.load(ymlfile) for dataset in datasets: local_path_file = os.path.join(project...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'main'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '13', '25', '33', '54']}; {'...
Main part of the download script.
def unsubscribe_multi(self, topics): if self.sock == NC.INVALID_SOCKET: return NC.ERR_NO_CONN self.logger.info("UNSUBSCRIBE: %s", ', '.join(topics)) return self.send_unsubscribe(False, [utf8encode(topic) for topic in topics])
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'unsubscribe_multi'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
Unsubscribe to some topics.
def compute_dependency_specs(cls, kwargs=None, payload=None): for spec in super(ImportRemoteSourcesMixin, cls).compute_dependency_specs(kwargs, payload): yield spec imported_target_specs = cls.imported_target_specs(kwargs=kwargs, payload=payload) for spec in imported_target_specs: yield spec
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'compute_dependency_specs'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'childr...
Tack imported_target_specs onto the traversable_specs generator for this target.
def switch_add_record(self, userid, interface, port=None, switch=None, comments=None): with get_network_conn() as conn: conn.execute("INSERT INTO switch VALUES (?, ?, ?, ?, ?)", (userid, interface, switch, port, comments)) LOG.debug("New...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'switch_add_record'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10', '13']}; {'id': '4', 'type': 'identifier...
Add userid and nic name address into switch table.
def write(self): index_file = self.path new_index_file = index_file + '.new' bak_index_file = index_file + '.bak' if not self._db: return with open(new_index_file, 'w') as f: json.dump(self._db, f, indent=4) if exists(index_file): copy(...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'write'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'i...
Safely write the index data to the index file
def install_handler(self, app): basedir = dirname(app.config['LOGGING_FS_LOGFILE']) if not exists(basedir): raise ValueError( 'Log directory {0} does not exists.'.format(basedir)) handler = RotatingFileHandler( app.config['LOGGING_FS_LOGFILE'], ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'install_handler'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
Install log handler on Flask application.
def _add_from_str(self, s): if sys.version_info[0] < 3 and isinstance(s, str): s = s.decode('utf-8') for line in s.split("\n"): self._parse_line(line)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_add_from_str'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
Add locations from a string
def textwidth(self, text, config): surface = cairo.SVGSurface(None, 1280, 200) ctx = cairo.Context(surface) ctx.select_font_face(config['font_face'], cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_BOLD) ctx.set_font_size(int(config['f...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'textwidth'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
Calculates the width of the specified text.
def _selection_by_callable(self, view, num_slices, non_empty_slices): selected = [sl for sl in non_empty_slices if self._sampler(self._get_axis(self._image, view, sl))] return selected[:num_slices]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_selection_by_callable'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'chil...
Returns all the slices selected by the given callable.
def pageId(self, pageId): if pageId is None: return if self.mets is None: raise Exception("OcrdFile %s has no member 'mets' pointing to parent OcrdMets" % self) self.mets.set_physical_page_for_file(pageId, self)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'pageId'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'...
Set the ID of the physical page this file manifests.
def _expired(self): LOG.info('Negotiated hold time %s expired.', self._holdtime) code = BGP_ERROR_HOLD_TIMER_EXPIRED subcode = BGP_ERROR_SUB_HOLD_TIMER_EXPIRED self.send_notification(code, subcode) self.connection_lost('Negotiated hold time %s expired.' % ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_expired'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; ...
Hold timer expired event handler.
def init(self): for type_, data in self.chunks: if type_ == "IHDR": self.hdr = data elif type_ == "IEND": self.end = data if self.hdr: self.width, self.height = struct.unpack("!II", self.hdr[8:16])
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'init'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id...
Extract some info from chunks
def raise_for_missing_name(self, line: str, position: int, namespace: str, name: str) -> None: self.raise_for_missing_namespace(line, position, namespace, name) if self.has_enumerated_namespace(namespace) and not self.has_enumerated_namespace_name(namespace, name): raise MissingNamespaceName...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '21', '23']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'raise_for_missing_name'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9', '13', '17']}; {'id': '4', 'type': 'iden...
Raise an exception if the namespace is not defined or if it does not validate the given name.
def reply_count(self, url, mode=5, after=0): sql = ['SELECT comments.parent,count(*)', 'FROM comments INNER JOIN threads ON', ' threads.uri=? AND comments.tid=threads.id AND', ' (? | comments.mode = ?) AND', ' comments.created > ?', ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'reply_count'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [],...
Return comment count for main thread and all reply threads for one url.
def showBeamlines(self): cnt = 0 blidlist = [] for k in self.all_elements: try: if 'beamline' in self.all_elements.get(k): cnt += 1 blidlist.append(k) except: pass retstr = '{total:<3d}beamlin...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'showBeamlines'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel...
show all defined beamlines
def _validate(self): self._errors = [] self._validate_type() if self.is_valid(): self._validate_value()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_validate'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};...
Run validation, save errors to object in self._errors
def pick_monomials_of_degree(monomials, degree): selected_monomials = [] for monomial in monomials: if ncdegree(monomial) == degree: selected_monomials.append(monomial) return selected_monomials
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'pick_monomials_of_degree'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [...
Collect all monomials up of a given degree.
def _restore_clipboard_selection(self, backup: str): time.sleep(1) self.clipboard.selection = backup if backup is not None else ""
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_restore_clipboard_selection'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children...
Restore the selection clipboard content.
def schedule_from_proto_dicts( device: 'xmon_device.XmonDevice', ops: Iterable[Dict], ) -> Schedule: scheduled_ops = [] last_time_picos = 0 for op in ops: delay_picos = 0 if 'incremental_delay_picoseconds' in op: delay_picos = op['incremental_delay_picoseconds'] ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16', '18']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'schedule_from_proto_dicts'}; {'id': '3', 'type': 'parameters', 'children': ['4', '8']}; {'id': '4', 'type': 'typed_parameter', ...
Convert proto dictionaries into a Schedule for the given device.
def stop(self): if self.run is True and all([self.job, self.job.is_alive()]): print('Done.') self.job.terminate()
{'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 indicator process.
def make_text_page(self, valumap): logger.info('Making a text report page using template %r.', self.text_template) fh = open(self.text_template) template = fh.read() fh.close() parts = [] for sr in self.subreports: report_data = [item.text for item in sr.repor...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'make_text_page'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
Builds the report as text page, using the template page from file.
def sha1(s): h = hashlib.new('sha1') h.update(s) return h.hexdigest()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sha1'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': ...
Returns a sha1 of the given string
def validate_profile_exists(self): if self.args.profile_name not in self.profiles: self.handle_error('Could not find profile "{}"'.format(self.args.profile_name))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'validate_profile_exists'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'va...
Validate the provided profiles name exists.
def _import_parsers(): global ARCGIS_NODES global ARCGIS_ROOTS global ArcGISParser global FGDC_ROOT global FgdcParser global ISO_ROOTS global IsoParser global VALID_ROOTS if ARCGIS_NODES is None or ARCGIS_ROOTS is None or ArcGISParser is None: from gis_metadata.arcgis_metadat...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_import_parsers'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '7', '9', '11', '...
Lazy imports to prevent circular dependencies between this module and utils
def hash_data(data, blocksize=65536): data = pickle.dumps(data) hasher = hashlib.sha1() hasher.update(data) 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': 'hash_data'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'da...
Hashes list of data, strings or data
def _set_format(profile): x = set() for sample in profile: x = x.union(set(profile[sample].keys())) if not x: return '' end, start = max(x), min(x) x = range(start, end, 4) scaled_profile = defaultdict(list) for pos in x: for sample in profile: y = _get_cl...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_set_format'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'profi...
Prepare dict to list of y values with same x
def detect_keep_boundary(start, end, namespaces): result_start, result_end = False, False parent_start = start.getparent() parent_end = end.getparent() if parent_start.tag == "{%s}p" % namespaces['text']: result_start = len(parent_start.getchildren()) > 1 if parent_end.tag == "{%s}p" % names...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'detect_keep_boundary'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': ...
a helper to inspect a link and see if we should keep the link boundary
def update_port_precommit(self, context): vlan_segment, vxlan_segment = self._get_segments( context.top_bound_segment, context.bottom_bound_segment) orig_vlan_segment, orig_vxlan_segment = self._get_segments( context.original_top_bound_segment, context.original_bottom...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_port_precommit'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], ...
Update port pre-database transaction commit event.
def NotifyQueue(self, notification, **kwargs): self._MultiNotifyQueue(notification.session_id.Queue(), [notification], **kwargs)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'NotifyQueue'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
This signals that there are new messages available in a queue.
def subvolumes(self): self.SYNC() self._getDevices() self._getRoots() self._getMounts() self._getUsage() volumes = self.volumes.values() volumes.sort(key=(lambda v: v.fullPath)) return volumes
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'subvolumes'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}...
Subvolumes contained in this mount.
def create(cls, fpath): "Creates a `Config` from `fpath`." fpath = _expand_path(fpath) assert(fpath.suffix == '.yml') if fpath.exists(): return fpath.parent.mkdir(parents=True, exist_ok=True) with open(fpath, 'w') as yaml_file: yaml.dump(cls.DEFAULT_CONFIG, ya...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}...
Creates a `Config` from `fpath`.
def _authenticate(self): if not self._get_provider_option( 'auth_username') or not self._get_provider_option('auth_password'): raise Exception( 'No valid authentication data passed, expected: auth-username and auth-password') response = self._request_login(sel...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_authenticate'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel...
Logs-in the user and checks the domain name
def save_vocabulary(self, vocab_path): index = 0 if os.path.isdir(vocab_path): vocab_file = os.path.join(vocab_path, VOCAB_NAME) with open(vocab_file, "w", encoding="utf-8") as writer: for token, token_index in sorted(self.vocab.items(), key=lambda kv: kv[1]): ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'save_vocabulary'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
Save the tokenizer vocabulary to a directory or file.
def __FinalizeRequest(self, http_request, url_builder): if (http_request.http_method == 'GET' and len(http_request.url) > _MAX_URL_LENGTH): http_request.http_method = 'POST' http_request.headers['x-http-method-override'] = 'GET' http_request.headers[ ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '__FinalizeRequest'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [],...
Make any final general adjustments to the request.
def circuit_to_pyquil(circuit: Circuit) -> pyquil.Program: prog = pyquil.Program() for elem in circuit.elements: if isinstance(elem, Gate) and elem.name in QUIL_GATES: params = list(elem.params.values()) if elem.params else [] prog.gate(elem.name, params, elem.qubits) eli...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'circuit_to_pyquil'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'typed_parameter', 'children': ['...
Convert a QuantumFlow circuit to a pyQuil program
def reach_process_pmc(): if request.method == 'OPTIONS': return {} response = request.body.read().decode('utf-8') body = json.loads(response) pmcid = body.get('pmcid') rp = reach.process_pmc(pmcid) return _stmts_from_proc(rp)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'reach_process_pmc'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '14', '29', '38...
Process PubMedCentral article and return INDRA Statements.
def _task_to_dict(task): payload = task.payload if payload and task.content_type == 'application/json': payload = json.loads(payload) return dict( task_id=task.task_id, queue_name=task.queue_name, eta=_datetime_to_epoch_seconds(task.eta), source=task.source, c...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_task_to_dict'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'tas...
Converts a WorkQueue to a JSON-able dictionary.
def ensure_connectable(self, nailgun): attempt_count = 1 while 1: try: with closing(nailgun.try_connect()) as sock: logger.debug('Verified new ng server is connectable at {}'.format(sock.getpeername())) return except nailgun.NailgunConnectionError: if attempt_coun...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'ensure_connectable'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'va...
Ensures that a nailgun client is connectable or raises NailgunError.
def connect_telnet(name, ip_address=None, user='micro', password='python'): if ip_address is None: try: ip_address = socket.gethostbyname(name) except socket.gaierror: ip_address = name if not QUIET: if name == ip_address: print('Connecting to (%s) ......
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'connect_telnet'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children':...
Connect to a MicroPython board via telnet.
def _simpleparsefun(date): if hasattr(date, 'year'): return date try: date = datetime.datetime.strptime(date, '%Y-%m-%d') except ValueError: date = datetime.datetime.strptime(date, '%Y-%m-%d %H:%M:%S') return date
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_simpleparsefun'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'd...
Simple date parsing function
def _prompt_wrapper(message, default=None, validator=None): class MockDocument: def __init__(self, text): self.text = text if HAS_INPUT: ret = prompt(message, default=default, validator=validator) else: ret = sys.stdin.readline().strip() print(message, ret) ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_prompt_wrapper'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], ...
Handle references piped from file
def all(self, *args, **kwargs): return self.client._get( self._url(), {}, headers={ 'x-contentful-enable-alpha-feature': 'usage-insights' } )
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'all'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel...
Gets all usage periods.
def dir_exists(location, use_sudo=False): with settings(hide('running', 'stdout', 'stderr'), warn_only=True): if use_sudo: return not bool(sudo('test -d %s' % (location)).return_code) else: return not bool(run('test -d %s' % (location)).return_code)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dir_exists'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'l...
Tells if there is a remote directory at the given location.
def heading2table(soup, table, row): tr = Tag(soup, name="tr") table.append(tr) for attr in row: th = Tag(soup, name="th") tr.append(th) th.append(attr)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'heading2table'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'va...
add heading row to table
def _parse_rdf(self, file): store = Graph() store.parse(file) print len(store)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_parse_rdf'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's...
Returns a case from the given file.
def _onLexerError(self, message): self.isOK = False if message.strip() != "": self.lexerErrors.append(message)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_onLexerError'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
Memorizes a lexer error message
def on_message(self, new_data): LOGGER.debug("new frame [%r]", new_data) try: what = int(new_data[0]) data = new_data[1:] data = data and from_json(data) if what == 0: self.ping_interval = float(data["pingInterval"]) / 1000 ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'on_message'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's...
Processes incoming messages according to engine-io rules
def tidy_eggs_list(eggs_list): tmp = [] for line in eggs_list: line = line.lstrip().rstrip() line = line.replace('\'', '') line = line.replace(',', '') if line.endswith('site-packages'): continue tmp.append(line) return tmp
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'tidy_eggs_list'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'eg...
Tidy the given eggs list
def import_lib(self): try: import ambry.build module = sys.modules['ambry.build'] except ImportError: module = imp.new_module('ambry.build') sys.modules['ambry.build'] = module bf = self.record if not bf.has_contents: return ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'import_lib'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}...
Import the lib.py file into the bundle module
def on_focusout(self, event, a): if event.widget.get() == '': event.widget.insert(0, default_text[a]) event.widget.config(fg = 'grey')
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'on_focusout'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
function that gets called whenever anywhere except entry is clicked
def zero_state(self, batch_size): return torch.zeros(batch_size, self.state_dim, dtype=torch.float32)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'zero_state'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's...
Initial state of the network
def login(self, email=None, password=None, remember=False): from flask_login import login_user user = self.first(email=email) if user is None: events.login_failed_nonexistent_event.send() return False if user.is_locked(): raise x.AccountLocked(locked_u...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'login'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
Authenticate user and emit event.