code
stringlengths
51
2.34k
sequence
stringlengths
1.16k
13.1k
docstring
stringlengths
11
171
def list_names(cls): ret = dict([(item['id'], item['name']) for item in cls.list({'items_per_page': 500})]) return ret
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'list_names'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'};...
Retrieve paas id and names.
def datetime_to_nanos(dt): if isinstance(dt, pd.Timestamp): return dt.value elif isinstance(dt, str): return pd.Timestamp(dt).value elif isinstance(dt, long): return dt elif isinstance(dt, datetime): return long(dt.strftime("%s%f")) * 1000 raise ValueError
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'datetime_to_nanos'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
Accepts a string, Pandas Timestamp, or long, and returns nanos since the epoch.
def list_cab (archive, compression, cmd, verbosity, interactive): cmdlist = [cmd, '-l'] if verbosity > 0: cmdlist.append('-v') cmdlist.append(archive) return cmdlist
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'list_cab'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': []...
List a CAB archive.
def _create_subset_file(in_file, het_region_bed, work_dir, data): cnv_regions = shared.get_base_cnv_regions(data, work_dir) region_bed = bedutils.intersect_two(het_region_bed, cnv_regions, work_dir, data) out_file = os.path.join(work_dir, "%s-origsubset.bcf" % utils.splitext_plus(os.path.basename(in_file))[...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_create_subset_file'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'childre...
Subset the VCF to a set of pre-calculated smaller regions.
def UNTL_to_encodedUNTL(subject): subject = normalize_UNTL(subject) subject = subject.replace(' ', '_') subject = subject.replace('_-_', '/') return subject
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'UNTL_to_encodedUNTL'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
Normalize a UNTL subject heading to be used in SOLR.
def _infodict(cls, name): info = cls._dataset_info.get(name, None) if info is None: raise ValueError('No such dataset {0} exists, ' 'use list_datasets() to get a list ' 'of available datasets.'.format(name)) return info
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_infodict'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cl...
load the info dictionary for the given name
def _id_map(minion_id, dns_name): bank = 'digicert/minions' cache = salt.cache.Cache(__opts__, syspaths.CACHE_DIR) dns_names = cache.fetch(bank, minion_id) if not isinstance(dns_names, list): dns_names = [] if dns_name not in dns_names: dns_names.append(dns_name) cache.store(bank...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_id_map'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'mini...
Maintain a relationship between a minion and a dns name
def keyPressEvent(self, event): if self._process.state() != self._process.Running: return tc = self.textCursor() sel_start = tc.selectionStart() sel_end = tc.selectionEnd() tc.setPosition(self._formatter._last_cursor_pos) self.setTextCursor(tc) if self...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'keyPressEvent'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
Handle key press event using the defined input handler.
def exclude_from_all(self, exclude_regex): try: re.compile(exclude_regex) except re.error: raise ZAPError('Invalid regex "{0}" provided'.format(exclude_regex)) self.logger.debug('Excluding {0} from proxy, spider and active scanner.'.format(exclude_regex)) self.zap...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'exclude_from_all'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
Exclude a pattern from proxy, spider and active scanner.
def _get_binary_replacement(first, second, cls): expr = ProtoExpr([first, second], {}) if LOG: logger = logging.getLogger('QNET.create') for key, rule in cls._binary_rules.items(): pat, replacement = rule match_dict = match_pattern(pat, expr) if match_dict: try: ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_binary_replacement'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children...
Helper function for match_replace_binary
def create_api_network_ipv6(self): return ApiNetworkIPv6( self.networkapi_url, self.user, self.password, self.user_ldap)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_api_network_ipv6'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'va...
Get an instance of Api Networkv6 services facade.
def _extract_hidden_data(dom): input_tags = dom.find_all('input', attrs={'type': 'hidden'}) data = {} for input_tag in input_tags: data[input_tag['name']] = input_tag['value'] return data
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_extract_hidden_data'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
Extracts hidden input data from DOM and returns the data as dictionary.
def extract_tar (archive, compression, cmd, verbosity, interactive, outdir): try: with tarfile.open(archive) as tfile: tfile.extractall(path=outdir) except Exception as err: msg = "error extracting %s: %s" % (archive, err) raise util.PatoolError(msg) return None
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'extract_tar'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': 'identifier', 'chil...
Extract a TAR archive with the tarfile Python module.
def WriteFile(self, printer): self.Validate() extended_descriptor.WritePythonFile( self.__file_descriptor, self.__package, self.__client_info.version, printer)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'WriteFile'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se...
Write the messages file to out.
def doc_to_html(doc, doc_format="ROBOT"): from robot.libdocpkg.htmlwriter import DocToHtml return DocToHtml(doc_format)(doc)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'doc_to_html'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
Convert documentation to HTML
def finger(self, match, hash_type=None): if hash_type is None: hash_type = __opts__['hash_type'] matches = self.name_match(match, True) ret = {} for status, keys in six.iteritems(matches): ret[status] = {} for key in keys: if status == ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'finger'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
Return the fingerprint for a specified key
def _destroy(self): self.unuse_region() if self._rlist is not None: try: if len(self._rlist) == 0: self._manager._fdict.pop(self._rlist.path_or_fd()) except (TypeError, KeyError): pass
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_destroy'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; ...
Destruction code to decrement counters
def install_from_zip(pkgpath, install_path, register_func, delete_after_install=False): logger.debug("%s is a file, attempting to load zip", pkgpath) pkgtempdir = tempfile.mkdtemp(prefix="honeycomb_") try: with zipfile.ZipFile(pkgpath) as pkgzip: pkgzip.extractall(pkgtempdir) except ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'install_from_zip'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children'...
Install plugin from zipfile.
def ParseMultiple(self, result_dicts): for result_dict in result_dicts: kb_user = rdf_client.User() for wmi_key, kb_key in iteritems(self.account_mapping): try: kb_user.Set(kb_key, result_dict[wmi_key]) except KeyError: pass if kb_user.sid or kb_user.username: ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'ParseMultiple'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
Parse the WMI Win32_UserAccount output.
def posted(self): for who, record in self.logs: if record["field_name"] == "status" and record["added"] == "POST": return True return False
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'posted'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'...
True if bug was moved to POST in given time frame
def _view_removed(self): print("\nPackages with name matching [ {0}{1}{2} ]\n".format( self.meta.color["CYAN"], ", ".join(self.binary), self.meta.color["ENDC"])) removed, packages = self._get_removed() if packages and "--checklist" in self.extra: removed = [] ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_view_removed'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel...
View packages before removed
def upload(name): storage = fs.by_name(name) return jsonify(success=True, **handle_upload(storage))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'upload'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'name'}; {'...
Handle upload on POST if authorized.
def scan_index(content_dir): def scan_directory(root, files): try: for file in files: fullpath = os.path.join(root, file) relpath = os.path.relpath(fullpath, content_dir) fingerprint = utils.file_fingerprint(fullpath) last_fingerpri...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'scan_index'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'conten...
Scan all files in a content directory
def prompt_for_new_password(): while True: passw = getpass.getpass() passw2 = getpass.getpass() if passw == passw2: return passw print 'Passwords do not match'
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'prompt_for_new_password'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5']}; {'id': ...
Prompt the user to enter a new password, with confirmation
def fetchUrls(cls, url, data, urlSearch): searchUrls = [] if cls.css: searchFun = data.cssselect else: searchFun = data.xpath searches = makeSequence(urlSearch) for search in searches: for match in searchFun(search): try: ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fetchUrls'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'v...
Search all entries for given XPath in a HTML page.
def encode_collection(collection, encoding='utf-8'): if isinstance(collection, dict): return dict((encode_collection(key), encode_collection(value)) for key, value in collection.iteritems()) elif isinstance(collection, list): return [encode_collection(element) for element in input] elif isin...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'encode_collection'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
Encodes all the string keys and values in a collection with specified encoding
def _wrap_response(request, data=None, metadata=None, status=200): envelope = metadata or {} if data is not None: envelope['data'] = data return web.Response( status=status, content_type='application/json', text=json.dumps( envelope...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_wrap_response'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children':...
Creates the JSON response envelope to be sent back to the client.
def _assignRootname(self, chip): extname=self._image[self.scienceExt,chip].header["EXTNAME"].lower() extver=self._image[self.scienceExt,chip].header["EXTVER"] expname = self._rootname self._image[self.scienceExt,chip].rootname=expname + "_" + extname + str(extver) self._image[sel...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_assignRootname'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
Assign a unique rootname for the image based in the expname.
def add_detector(self, detector_cls): if not issubclass(detector_cls, detectors.base.Detector): raise TypeError(( '"%(detector_cls)s" is not a subclass of Detector' ) % locals()) name = detector_cls.filth_cls.type if name in self._detectors: ra...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_detector'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
Add a ``Detector`` to scrubadub
def expand_block(self, feat): chrom_end = self._ref_sizes.get(feat.chrom) if chrom_end: if feat.start < self._end_buffer: feat.start = 0 if feat.stop >= chrom_end - self._end_buffer: feat.stop = chrom_end return feat
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'expand_block'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
Expand any blocks which are near the start or end of a contig.
def output(self, attrs=None, header="Set-Cookie:", sep="\015\012"): result = [] items = sorted(self.items()) for key, value in items: result.append(value.output(attrs, header)) return sep.join(result)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'output'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [], 'va...
Return a string suitable for HTTP.
def ftp_walk(ftpconn: FTP, rootpath=''): current_directory = rootpath try: directories, files = directory_listing(ftpconn, current_directory) except ftplib.error_perm: return yield current_directory, directories, files for name in directories: new_path = os.path.join(current_...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'ftp_walk'}; {'id': '3', 'type': 'parameters', 'children': ['4', '8']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']}...
Recursively traverse an ftp directory to discovery directory listing.
def im_history(self, room_id, **kwargs): return self.__call_api_get('im.history', roomId=room_id, kwargs=kwargs)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'im_history'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
Retrieves the history for a private im chat
def _fast_write(self, outfile, value): outfile.truncate(0) outfile.write(str(int(value))) outfile.flush()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_fast_write'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
Function for fast writing to motor files.
def showKeyboard(self, eInputMode, eLineInputMode, pchDescription, unCharMax, pchExistingText, bUseMinimalMode, uUserValue): fn = self.function_table.showKeyboard result = fn(eInputMode, eLineInputMode, pchDescription, unCharMax, pchExistingText, bUseMinimalMode, uUserValue) return result
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'showKeyboard'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '10', '11']}; {'id': '4', 'type': 'ident...
Show the virtual keyboard to accept input
def _region_code_for_number_from_list(numobj, regions): national_number = national_significant_number(numobj) for region_code in regions: metadata = PhoneMetadata.metadata_for_region(region_code.upper(), None) if metadata is None: continue if metadata.leading_digits is not No...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_region_code_for_number_from_list'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'chi...
Find the region in a list that matches a number
def unique_authors(self, limit): seen = set() if limit == 0: limit = None seen_add = seen.add return [x.author for x in self.sorted_commits[:limit] if not (x.author in seen or seen_add(x.author))]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'unique_authors'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
Unique list of authors, but preserving order.
def pop_cell(self, idy=None, idx=None, tags=False): idy = idy if idy is not None else len(self.body) - 1 idx = idx if idx is not None else len(self.body[idy]) - 1 cell = self.body[idy].pop(idx) return cell if tags else cell.childs[0]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'pop_cell'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [], '...
Pops a cell, default the last of the last row
def informed_consent(self): if self.typeable_handle is None: consent_url = [self.config['server']['server_url'], "/get_initial_consent?username="] consent_url.append(urlsafe_b64encode(self.username)) consent_url.append("&password=") cons...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'informed_consent'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
Create a URL for the user to give their consent through
def add_non_hs_service(self, info, address): if self.protocol and self.protocol != PROTOCOL_DMAP: return name = info.properties[b'CtlN'].decode('utf-8') self._handle_service( address, name, conf.DmapService(None, port=info.port))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_non_hs_service'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': []...
Add a new device without Home Sharing to discovered list.
def dump(self, msg, fn_): if six.PY2: fn_.write(self.dumps(msg)) else: fn_.write(self.dumps(msg, use_bin_type=True)) fn_.close()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dump'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se...
Serialize the correct data into the named file object
def _make_ssh_forward_handler_class(self, remote_address_): class Handler(_ForwardHandler): remote_address = remote_address_ ssh_transport = self._transport logger = self.logger return Handler
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_make_ssh_forward_handler_class'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'child...
Make SSH Handler class
def send_request(req=None, method=None, requires_response=True): if req is None: return functools.partial(send_request, method=method, requires_response=requires_response) @functools.wraps(req) def wrapper(self, *args, **kwargs): params = req(self, *args, **k...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'send_request'}; {'id': '3', 'type': 'parameters', 'children': ['4', '7', '10']}; {'id': '4', 'type': 'default_parameter', 'children':...
Call function req and then send its results via ZMQ.
def gettext(self, string, domain=None, **variables): t = self.get_translations(domain) return t.ugettext(string) % variables
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'gettext'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'va...
Translate a string with the current locale.
def _onOffset(self, dt, businesshours): if self.n >= 0: op = self._prev_opening_time(dt) else: op = self._next_opening_time(dt) span = (dt - op).total_seconds() if span <= businesshours: return True else: return False
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_onOffset'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
Slight speedups using calculated values.
def getLong(t): i = c_long() if PL_get_long(t, byref(i)): return i.value else: raise InvalidTypeError("long")
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getLong'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 't'}; {'id...
If t is of type long, return it, otherwise raise InvalidTypeError.
def update_file(finfo, sample_info, config, pass_uptodate=False): storage_dir = utils.safe_makedir(_get_storage_dir(finfo, config)) if finfo.get("type") == "directory": return _copy_finfo_directory(finfo, storage_dir) else: return _copy_finfo(finfo, storage_dir, pass_uptodate=pass_uptodate)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_file'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [],...
Update the file in local filesystem storage.
def build_metadata_class(specfile): with open(specfile) as f: spec = json.load(f) name = os.path.basename(specfile).split('.')[0] spec['name'] = name env = get_jinja_env() metadata_template = env.get_template('metadata.py.jinja2') with open('pycanvas/meta/{}.py...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'build_metadata_class'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
Generate a metadata class for the specified specfile.
def info(self): if self._resources is None: self.__init() url = self._url + "/info" return _info.Info(url=url, securityHandler=self._securityHandler, proxy_url=self._proxy_url, proxy_port=self._proxy_port, ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'info'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id...
A read-only resource that returns meta information about the server
def DeleteOldRuns(self, cutoff_timestamp=None): if cutoff_timestamp is None: raise ValueError("cutoff_timestamp can't be None") return data_store.REL_DB.DeleteOldCronJobRuns( cutoff_timestamp=cutoff_timestamp)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'DeleteOldRuns'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
Deletes runs that were started before the timestamp given.
def collection(cls, cid): url = urljoin(config.API_URL, 'collections/%s' % cid) return Collection(cls.query(url=url))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'collection'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'c...
Get a Collection record
def fix_e302(self, result): add_linenum = 2 - int(result['info'].split()[-1]) cr = '\n' * add_linenum self.source[result['line'] - 1] = cr + self.source[result['line'] - 1]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fix_e302'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel...
Add missing 2 blank lines.
def snapshot(self): snap = connState(connection_end=self.connection_end, read_or_write=self.row, seq_num=self.seq_num, compression_alg=type(self.compression), ciphersuite=type(self.ciphersuite), ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'snapshot'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; ...
This is used mostly as a way to keep the cipher state and the seq_num.
def FindAnomalies(self): for grp_name, group in iteritems(self.entry): shadow = self.shadow.get(grp_name) gshadows = self.gshadow_members.get(grp_name, []) if shadow is not None: diff = self.MemberDiff(group.members, "group", gshadows, "gshadow") if diff: msg = "Group/gsh...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'FindAnomalies'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel...
Identify any anomalous group attributes or memberships.
def subclass(cls, t): t.doc = None t.terms = [] t.__class__ = SectionTerm return t
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'subclass'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls...
Change a term into a Section Term
def _number_parser(str_to_number_func): def _parse_number_value(element_text, state): value = None try: value = str_to_number_func(element_text) except (ValueError, TypeError): state.raise_error(InvalidPrimitiveValue, 'Invalid numeric val...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_number_parser'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'st...
Return a function to parse numbers.
def sets(self): sets = {} for x in self._parents: sets.setdefault(self[x], set()).add(x) return frozenset(frozenset(v) for v in six.viewvalues(sets))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sets'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id...
Returns the equivalence classes as a set of sets.
def keys(self, pattern, *, encoding=_NOTSET): return self.execute(b'KEYS', pattern, encoding=encoding)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'keys'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
Returns all keys matching pattern.
def step_a_new_working_directory(context): command_util.ensure_context_attribute_exists(context, "workdir", None) command_util.ensure_workdir_exists(context) shutil.rmtree(context.workdir, ignore_errors=True)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'step_a_new_working_directory'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': []...
Creates a new, empty working directory
def ensure_valid_environment_config(module_name, config): if not config.get('namespace'): LOGGER.fatal("staticsite: module %s's environment configuration is " "missing a namespace definition!", module_name) sys.exit(1)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'ensure_valid_environment_config'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'child...
Exit if config is invalid.
def _check_lr(name, optimizer, lr): n = len(optimizer.param_groups) if not isinstance(lr, (list, tuple)): return lr * np.ones(n) if len(lr) != n: raise ValueError("{} lr values were passed for {} but there are " "{} param groups.".format(n, name, len(lr))) return...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_check_lr'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
Return one learning rate for each param group.
def __WaitForVolume(volume, desired_state): print 'Waiting for volume %s to be %s...' % (volume.id, desired_state) while True: volume.update() sys.stdout.write('.') sys.stdout.flush() if volume.status == desired_state: break time.sleep(5) return
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '__WaitForVolume'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
Blocks until EBS volume is in desired state.
def remove_timedim(self, var): if self.pps and var.dims[0] == 'time': data = var[0, :, :] data.attrs = var.attrs var = data return var
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'remove_timedim'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
Remove time dimension from dataset
def ip2hex(ip): parts = ip.split(".") if len(parts) != 4: return None ipv = 0 for part in parts: try: p = int(part) if p < 0 or p > 255: return None ipv = (ipv << 8) + p except: return None return ipv
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'ip2hex'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ip'}; {'id...
Converts an ip to a hex value that can be used with a hex bit mask
def build(check, sdist): if check in get_valid_checks(): check_dir = os.path.join(get_root(), check) else: check_dir = resolve_path(check) if not dir_exists(check_dir): abort('`{}` is not an Agent-based Integration or Python package'.format(check)) check = basepath(ch...
{'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': 'check'...
Build a wheel for a check as it is on the repo HEAD
def calendars(self): today = datetime.today() first_day, last_day = monthrange(today.year, today.month) from_dt = datetime(today.year, today.month, first_day) to_dt = datetime(today.year, today.month, last_day) params = dict(self.params) params.update({ 'lang'...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'calendars'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};...
Retrieves calendars for this month
def handle(self): data = cPickle.load(self.rfile) method = data.pop('method') try: retval = getattr(self, 'do_{0}'.format(method))(**data) except Exception as e: retval = e cPickle.dump(retval, self.wfile, cPickle.HIGHEST_PROTOCOL)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'handle'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'...
Parse the RPC, make the call, and pickle up the return value.
def createElement(self, tag: str) -> Node: return create_element(tag, base=self._default_class)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'createElement'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'v...
Create new element whose tag name is ``tag``.
def service_start(name): r = salt.utils.http.query(DETAILS['url']+'service/start/'+name, decode_type='json', decode=True) return r['dict']
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'service_start'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'nam...
Start a "service" on the REST server
def as_command(self): try: params = self.unbound_func.__click_params__ params.reverse() del self.unbound_func.__click_params__ except AttributeError: params = [] help = inspect.getdoc(self.real_func) if isinstance(help, bytes): ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'as_command'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}...
Creates the click command wrapping the function
def _visual_width(line): return len(re.sub(colorama.ansitowin32.AnsiToWin32.ANSI_CSI_RE, "", line))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_visual_width'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'lin...
Get the the number of columns required to display a string
def __getSequenceVariants(self, x1, polyStart, polyStop, listSequence) : if polyStart < len(self.polymorphisms) and polyStart < polyStop: sequence = copy.copy(listSequence) ret = [] pk = self.polymorphisms[polyStart] posInSequence = pk[0]-x1 if posInSequence < len(listSequence) : for allele in pk...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '__getSequenceVariants'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', '...
polyStop, is the polymorphisme at wixh number where the calcul of combinaisons stops
def update_security_group(self, security_group, body=None): return self.put(self.security_group_path % security_group, body=body)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_security_group'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children':...
Updates a security group.
def __DeclareMessageAlias(self, schema, alias_for): message = extended_descriptor.ExtendedMessageDescriptor() message.name = self.__names.ClassName(schema['id']) message.alias_for = alias_for self.__DeclareDescriptor(message.name) self.__AddImport('from %s import extra_types' % ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '__DeclareMessageAlias'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children':...
Declare schema as an alias for alias_for.
def update_version_records(self): from .__init__ import __version__ as version with self.connection(commit=True) as connection: for vrec in self.get_version_records(): if (vrec.rash_version == version and vrec.schema_version == schema_version): ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_version_records'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
Update rash_info table if necessary.
def _insert_new_layers(self, new_layers, start_node_id, end_node_id): new_node_id = self._add_node(deepcopy(self.node_list[end_node_id])) temp_output_id = new_node_id for layer in new_layers[:-1]: temp_output_id = self.add_layer(layer, temp_output_id) self._add_edge(new_layer...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_insert_new_layers'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children...
Insert the new_layers after the node with start_node_id.
def init(self): if hasattr(self, 'data'): return if isinstance(self.dstore, str): self.dstore = hdf5.File(self.dstore, 'r') else: self.dstore.open('r') if self.sids is None: self.sids = self.dstore['sitecol'].sids oq = self.dstore['...
{'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...
Read the poes and set the .data attribute with the hazard curves
def touch_object(self, objects: Set[Object]) -> Set[Object]: objects_per_box = self._separate_objects_by_boxes(objects) return_set = set() for box, box_objects in objects_per_box.items(): candidate_objects = box.objects for object_ in box_objects: for cand...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13', '19']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'touch_object'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'v...
Returns all objects that touch the given set of objects.
def register(cls): registry_entry = RegistryEntry(category = cls.category, namespace = cls.namespace, name = cls.name, cls=cls) if registry_entry not in registry and not exists_in_registry(cls.category, cls.namespace, cls.name): registry.append(registry_entry) else: log.warn("Class {0} alrea...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'register'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {...
Register a given model in the registry
def _checkSize(self): if self._item_height is not None: sz = min(self._max_height_items, self.count()) * self._item_height + 5 sz = max(sz, 20) self.setMinimumSize(0, sz) self.setMaximumSize(1000000, sz) self.resize(self.width(), sz)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_checkSize'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}...
Automatically resizes widget to display at most max_height_items items
def non_increasing(values): return all(x >= y for x, y in zip(values, values[1:]))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'non_increasing'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'va...
True if values are not increasing.
def trainOn(self, dstream): self._validate(dstream) def update(rdd): self._model.update(rdd, self._decayFactor, self._timeUnit) dstream.foreachRDD(update)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'trainOn'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self...
Train the model on the incoming dstream.
def add_def(self, def_item): self.defs.append(def_item) for other in self.others: other.add_def(def_item)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_def'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self...
Adds a def universally.
def clear_threads(self): for aThread in compat.itervalues(self.__threadDict): aThread.clear() self.__threadDict = dict()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'clear_threads'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel...
Clears the threads snapshot.
def copy_any(src, dst, only_missing=False): if not only_missing: remove_if_exist(dst) if os.path.exists(src): if os.path.isdir(src): if not only_missing: shutil.copytree(src, dst, symlinks=False, ignore=None) else: for dirpath, filepath in ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'copy_any'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
Copy a file or a directory tree, deleting the destination before processing
def getInstruments(self): query = {"portal_type": "Instrument", "is_active": True} if self.getRestrictToMethod(): query.update({ "getMethodUIDs": { "query": api.get_uid(self.getRestrictToMethod()), "operator": "or", } ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getInstruments'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se...
Get the allowed instruments
def on_step_end(self, **kwargs:Any)->None: "Update the params from master to model and zero grad." self.learn.model.zero_grad() master2model(self.model_params, self.master_params, self.flat_master)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'on_step_end'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'va...
Update the params from master to model and zero grad.
def _process_table(self, cache=True): table = self.source() assert not isinstance(table, None.__class__), \ "{}.source needs to return something, not None".format(self.__class__.__name__) table = post_process(table, self.post_processors()) if cache: self.to_cache(...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_process_table'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
Applies the post processors
def locale_first_weekday(): first_weekday = 6 try: process = os.popen("locale first_weekday week-1stday") week_offset, week_start = process.read().split('\n')[:2] process.close() week_start = dt.date(*time.strptime(week_start, "%Y%m%d")[:3]) week_offset = dt.timedelta(int...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'locale_first_weekday'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '9', '106']}...
figure if week starts on monday or sunday
def list_domains(self): domains = [] for cookie in iter(self): if cookie.domain not in domains: domains.append(cookie.domain) return domains
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'list_domains'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self...
Utility method to list all the domains in the jar.
def run(): args = parse_args() if args.verbose: log_level = logging.DEBUG else: log_level = logging.INFO logging.basicConfig( level=log_level, format='%(asctime)s %(levelname)s %(name)s: %(message)s') if not args.verbose: req_logger = logging.getLogger('reques...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '11', '30', '42', '66', '75',...
Command line entrypoint for the ``refresh-lsst-bib`` program.
def raise_for_missing_namespace(self, line: str, position: int, namespace: str, name: str) -> None: if not self.has_namespace(namespace): raise UndefinedNamespaceWarning(self.get_line_number(), line, position, namespace, name)
{'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_namespace'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9', '13', '17']}; {'id': '4', 'type': ...
Raise an exception if the namespace is not defined.
def fit(self, X, y): self.glm_model = self.glm_partial(y, X) self.glm_results = self.glm_model.fit() return self
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fit'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel...
Pretend to be a sklearn estimator, fit is called on creation
def parse(binary, **params): encoding = params.get('charset', 'UTF-8') return json.loads(binary, encoding=encoding)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'binary...
Turns a JSON structure into a python object.
def _set_condition(self, condition): assert isinstance(condition, CodeExpression.TYPES) self.condition = condition
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_set_condition'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
Set the condition for this control flow structure.
def retrieve(self, request, _id): _id = deserialize(_id) retrieved = self.collection.find_one({'_id': _id}) if retrieved: return Response(serialize(retrieved)) else: return Response( response=serialize( DocumentNotFoundError(sel...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'retrieve'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
Returns the document containing the given _id or 404
def insertContinuousSet(self, continuousSet): try: models.ContinuousSet.create( id=continuousSet.getId(), datasetid=continuousSet.getParentContainer().getId(), referencesetid=continuousSet.getReferenceSet().getId(), name=continuousSet.g...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'insertContinuousSet'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'v...
Inserts a the specified continuousSet into this repository.
def owner(self): if self._owner: return self._owner elif not self.abstract: return self.read_meta()._owner raise EmptyDocumentException()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'owner'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'i...
Username of document creator
def enforce_versioning(force=False): connect_str, repo_url = get_version_data() LOG.warning("Your database uses an unversioned benchbuild schema.") if not force and not ui.ask( "Should I enforce version control on your schema?"): LOG.error("User declined schema versioning.") retu...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'enforce_versioning'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5',...
Install versioning on the db.
def find_diff_violations(self, patch): violations = collections.defaultdict(list) for line in patch.changed_lines: file_violations = self._all_violations.get(line['file_name']) if not file_violations: continue line_violations = [v for v in file_violati...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_diff_violations'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], '...
Uses the diff for this build to find changed lines that also have violations.