_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q269800
X509Name.der
test
def der(self): """ Return the DER encoding of this name. :return: The DER encoded form of this name. :rtype: :py:class:`bytes` """ result_buffer = _ffi.new('unsigned char**') encode_result = _lib.i2d_X509_NAME(self._name, result_buffer) _openssl_assert(en...
python
{ "resource": "" }
q269801
X509Name.get_components
test
def get_components(self): """ Returns the components of this name, as a sequence of 2-tuples. :return: The components of this name. :rtype: :py:class:`list` of ``name, value`` tuples. """ result = [] for i in range(_lib.X509_NAME_entry_count(self._name)): ...
python
{ "resource": "" }
q269802
X509Extension.get_short_name
test
def get_short_name(self): """ Returns the short type name of this X.509 extension. The result is a byte string such as :py:const:`b"basicConstraints"`. :return: The short type name. :rtype: :py:data:`bytes` .. versionadded:: 0.12 """ obj = _lib.X509_EXT...
python
{ "resource": "" }
q269803
X509Extension.get_data
test
def get_data(self): """ Returns the data of the X509 extension, encoded as ASN.1. :return: The ASN.1 encoded data of this X509 extension. :rtype: :py:data:`bytes` .. versionadded:: 0.12 """ octet_result = _lib.X509_EXTENSION_get_data(self._extension) str...
python
{ "resource": "" }
q269804
X509Req.to_cryptography
test
def to_cryptography(self): """ Export as a ``cryptography`` certificate signing request. :rtype: ``cryptography.x509.CertificateSigningRequest`` .. versionadded:: 17.1.0 """ from cryptography.hazmat.backends.openssl.x509 import ( _CertificateSigningRequest ...
python
{ "resource": "" }
q269805
X509Req.set_pubkey
test
def set_pubkey(self, pkey): """ Set the public key of the certificate signing request. :param pkey: The public key to use. :type pkey: :py:class:`PKey` :return: ``None`` """ set_result = _lib.X509_REQ_set_pubkey(self._req, pkey._pkey) _openssl_assert(set...
python
{ "resource": "" }
q269806
X509Req.get_pubkey
test
def get_pubkey(self): """ Get the public key of the certificate signing request. :return: The public key. :rtype: :py:class:`PKey` """ pkey = PKey.__new__(PKey) pkey._pkey = _lib.X509_REQ_get_pubkey(self._req) _openssl_assert(pkey._pkey != _ffi.NULL) ...
python
{ "resource": "" }
q269807
X509Req.get_subject
test
def get_subject(self): """ Return the subject of this certificate signing request. This creates a new :class:`X509Name` that wraps the underlying subject name field on the certificate signing request. Modifying it will modify the underlying signing request, and will have the eff...
python
{ "resource": "" }
q269808
X509Req.add_extensions
test
def add_extensions(self, extensions): """ Add extensions to the certificate signing request. :param extensions: The X.509 extensions to add. :type extensions: iterable of :py:class:`X509Extension` :return: ``None`` """ stack = _lib.sk_X509_EXTENSION_new_null() ...
python
{ "resource": "" }
q269809
X509Req.get_extensions
test
def get_extensions(self): """ Get X.509 extensions in the certificate signing request. :return: The X.509 extensions in this request. :rtype: :py:class:`list` of :py:class:`X509Extension` objects. .. versionadded:: 0.15 """ exts = [] native_exts_obj = _l...
python
{ "resource": "" }
q269810
X509Req.verify
test
def verify(self, pkey): """ Verifies the signature on this certificate signing request. :param PKey key: A public key. :return: ``True`` if the signature is correct. :rtype: bool :raises OpenSSL.crypto.Error: If the signature is invalid or there is a proble...
python
{ "resource": "" }
q269811
X509.to_cryptography
test
def to_cryptography(self): """ Export as a ``cryptography`` certificate. :rtype: ``cryptography.x509.Certificate`` .. versionadded:: 17.1.0 """ from cryptography.hazmat.backends.openssl.x509 import _Certificate backend = _get_backend() return _Certificat...
python
{ "resource": "" }
q269812
X509.set_version
test
def set_version(self, version): """ Set the version number of the certificate. Note that the version value is zero-based, eg. a value of 0 is V1. :param version: The version number of the certificate. :type version: :py:class:`int` :return: ``None`` """ ...
python
{ "resource": "" }
q269813
X509.get_pubkey
test
def get_pubkey(self): """ Get the public key of the certificate. :return: The public key. :rtype: :py:class:`PKey` """ pkey = PKey.__new__(PKey) pkey._pkey = _lib.X509_get_pubkey(self._x509) if pkey._pkey == _ffi.NULL: _raise_current_error() ...
python
{ "resource": "" }
q269814
X509.set_pubkey
test
def set_pubkey(self, pkey): """ Set the public key of the certificate. :param pkey: The public key. :type pkey: :py:class:`PKey` :return: :py:data:`None` """ if not isinstance(pkey, PKey): raise TypeError("pkey must be a PKey instance") set_...
python
{ "resource": "" }
q269815
X509.sign
test
def sign(self, pkey, digest): """ Sign the certificate with this key and digest type. :param pkey: The key to sign with. :type pkey: :py:class:`PKey` :param digest: The name of the message digest to use. :type digest: :py:class:`bytes` :return: :py:data:`None` ...
python
{ "resource": "" }
q269816
X509.get_signature_algorithm
test
def get_signature_algorithm(self): """ Return the signature algorithm used in the certificate. :return: The name of the algorithm. :rtype: :py:class:`bytes` :raises ValueError: If the signature algorithm is undefined. .. versionadded:: 0.13 """ algor = ...
python
{ "resource": "" }
q269817
X509.digest
test
def digest(self, digest_name): """ Return the digest of the X509 object. :param digest_name: The name of the digest algorithm to use. :type digest_name: :py:class:`bytes` :return: The digest of the object, formatted as :py:const:`b":"`-delimited hex pairs. :...
python
{ "resource": "" }
q269818
X509.set_serial_number
test
def set_serial_number(self, serial): """ Set the serial number of the certificate. :param serial: The new serial number. :type serial: :py:class:`int` :return: :py:data`None` """ if not isinstance(serial, _integer_types): raise TypeError("serial must...
python
{ "resource": "" }
q269819
X509.get_serial_number
test
def get_serial_number(self): """ Return the serial number of this certificate. :return: The serial number. :rtype: int """ asn1_serial = _lib.X509_get_serialNumber(self._x509) bignum_serial = _lib.ASN1_INTEGER_to_BN(asn1_serial, _ffi.NULL) try: ...
python
{ "resource": "" }
q269820
X509.gmtime_adj_notAfter
test
def gmtime_adj_notAfter(self, amount): """ Adjust the time stamp on which the certificate stops being valid. :param int amount: The number of seconds by which to adjust the timestamp. :return: ``None`` """ if not isinstance(amount, int): raise Typ...
python
{ "resource": "" }
q269821
X509.gmtime_adj_notBefore
test
def gmtime_adj_notBefore(self, amount): """ Adjust the timestamp on which the certificate starts being valid. :param amount: The number of seconds by which to adjust the timestamp. :return: ``None`` """ if not isinstance(amount, int): raise TypeError("amount ...
python
{ "resource": "" }
q269822
X509.has_expired
test
def has_expired(self): """ Check whether the certificate has expired. :return: ``True`` if the certificate has expired, ``False`` otherwise. :rtype: bool """ time_string = _native(self.get_notAfter()) not_after = datetime.datetime.strptime(time_string, "%Y%m%d%H%...
python
{ "resource": "" }
q269823
X509.get_issuer
test
def get_issuer(self): """ Return the issuer of this certificate. This creates a new :class:`X509Name` that wraps the underlying issuer name field on the certificate. Modifying it will modify the underlying certificate, and will have the effect of modifying any other :cla...
python
{ "resource": "" }
q269824
X509.set_issuer
test
def set_issuer(self, issuer): """ Set the issuer of this certificate. :param issuer: The issuer. :type issuer: :py:class:`X509Name` :return: ``None`` """ self._set_name(_lib.X509_set_issuer_name, issuer) self._issuer_invalidator.clear()
python
{ "resource": "" }
q269825
X509.get_subject
test
def get_subject(self): """ Return the subject of this certificate. This creates a new :class:`X509Name` that wraps the underlying subject name field on the certificate. Modifying it will modify the underlying certificate, and will have the effect of modifying any other :...
python
{ "resource": "" }
q269826
X509.set_subject
test
def set_subject(self, subject): """ Set the subject of this certificate. :param subject: The subject. :type subject: :py:class:`X509Name` :return: ``None`` """ self._set_name(_lib.X509_set_subject_name, subject) self._subject_invalidator.clear()
python
{ "resource": "" }
q269827
X509.add_extensions
test
def add_extensions(self, extensions): """ Add extensions to the certificate. :param extensions: The extensions to add. :type extensions: An iterable of :py:class:`X509Extension` objects. :return: ``None`` """ for ext in extensions: if not isinstance(e...
python
{ "resource": "" }
q269828
X509.get_extension
test
def get_extension(self, index): """ Get a specific extension of the certificate by index. Extensions on a certificate are kept in order. The index parameter selects which extension will be returned. :param int index: The index of the extension to retrieve. :return: The ...
python
{ "resource": "" }
q269829
X509Store.add_cert
test
def add_cert(self, cert): """ Adds a trusted certificate to this store. Adding a certificate with this method adds this certificate as a *trusted* certificate. :param X509 cert: The certificate to add to this store. :raises TypeError: If the certificate is not an :clas...
python
{ "resource": "" }
q269830
X509Store.add_crl
test
def add_crl(self, crl): """ Add a certificate revocation list to this store. The certificate revocation lists added to a store will only be used if the associated flags are configured to check certificate revocation lists. .. versionadded:: 16.1.0 :param CRL cr...
python
{ "resource": "" }
q269831
X509Store.set_time
test
def set_time(self, vfy_time): """ Set the time against which the certificates are verified. Normally the current time is used. .. note:: For example, you can determine if a certificate was valid at a given time. .. versionadded:: 17.0.0 :param dat...
python
{ "resource": "" }
q269832
X509StoreContext._init
test
def _init(self): """ Set up the store context for a subsequent verification operation. Calling this method more than once without first calling :meth:`_cleanup` will leak memory. """ ret = _lib.X509_STORE_CTX_init( self._store_ctx, self._store._store, self._c...
python
{ "resource": "" }
q269833
X509StoreContext._exception_from_context
test
def _exception_from_context(self): """ Convert an OpenSSL native context error failure into a Python exception. When a call to native OpenSSL X509_verify_cert fails, additional information about the failure can be obtained from the store context. """ errors = [ ...
python
{ "resource": "" }
q269834
X509StoreContext.verify_certificate
test
def verify_certificate(self): """ Verify a certificate in a context. .. versionadded:: 0.15 :raises X509StoreContextError: If an error occurred when validating a certificate in the context. Sets ``certificate`` attribute to indicate which certificate caused the erro...
python
{ "resource": "" }
q269835
Revoked.set_serial
test
def set_serial(self, hex_str): """ Set the serial number. The serial number is formatted as a hexadecimal number encoded in ASCII. :param bytes hex_str: The new serial number. :return: ``None`` """ bignum_serial = _ffi.gc(_lib.BN_new(), _lib.BN_free) ...
python
{ "resource": "" }
q269836
Revoked.get_serial
test
def get_serial(self): """ Get the serial number. The serial number is formatted as a hexadecimal number encoded in ASCII. :return: The serial number. :rtype: bytes """ bio = _new_mem_buf() asn1_int = _lib.X509_REVOKED_get0_serialNumber(self._rev...
python
{ "resource": "" }
q269837
Revoked.set_reason
test
def set_reason(self, reason): """ Set the reason of this revocation. If :data:`reason` is ``None``, delete the reason instead. :param reason: The reason string. :type reason: :class:`bytes` or :class:`NoneType` :return: ``None`` .. seealso:: :meth...
python
{ "resource": "" }
q269838
Revoked.get_reason
test
def get_reason(self): """ Get the reason of this revocation. :return: The reason, or ``None`` if there is none. :rtype: bytes or NoneType .. seealso:: :meth:`all_reasons`, which gives you a list of all supported reasons this method might return. ...
python
{ "resource": "" }
q269839
Revoked.set_rev_date
test
def set_rev_date(self, when): """ Set the revocation timestamp. :param bytes when: The timestamp of the revocation, as ASN.1 TIME. :return: ``None`` """ dt = _lib.X509_REVOKED_get0_revocationDate(self._revoked) return _set_asn1_time(dt, when)
python
{ "resource": "" }
q269840
CRL.to_cryptography
test
def to_cryptography(self): """ Export as a ``cryptography`` CRL. :rtype: ``cryptography.x509.CertificateRevocationList`` .. versionadded:: 17.1.0 """ from cryptography.hazmat.backends.openssl.x509 import ( _CertificateRevocationList ) backend...
python
{ "resource": "" }
q269841
CRL.get_revoked
test
def get_revoked(self): """ Return the revocations in this certificate revocation list. These revocations will be provided by value, not by reference. That means it's okay to mutate them: it won't affect this CRL. :return: The revocations in this CRL. :rtype: :class:`tup...
python
{ "resource": "" }
q269842
CRL.get_issuer
test
def get_issuer(self): """ Get the CRL's issuer. .. versionadded:: 16.1.0 :rtype: X509Name """ _issuer = _lib.X509_NAME_dup(_lib.X509_CRL_get_issuer(self._crl)) _openssl_assert(_issuer != _ffi.NULL) _issuer = _ffi.gc(_issuer, _lib.X509_NAME_free) ...
python
{ "resource": "" }
q269843
CRL.sign
test
def sign(self, issuer_cert, issuer_key, digest): """ Sign the CRL. Signing a CRL enables clients to associate the CRL itself with an issuer. Before a CRL is meaningful to other OpenSSL functions, it must be signed by an issuer. This method implicitly sets the issuer's n...
python
{ "resource": "" }
q269844
CRL.export
test
def export(self, cert, key, type=FILETYPE_PEM, days=100, digest=_UNSPECIFIED): """ Export the CRL as a string. :param X509 cert: The certificate used to sign the CRL. :param PKey key: The key used to sign the CRL. :param int type: The export format, either :data:`...
python
{ "resource": "" }
q269845
PKCS7.get_type_name
test
def get_type_name(self): """ Returns the type name of the PKCS7 structure :return: A string with the typename """ nid = _lib.OBJ_obj2nid(self._pkcs7.type) string_type = _lib.OBJ_nid2sn(nid) return _ffi.string(string_type)
python
{ "resource": "" }
q269846
PKCS12.set_ca_certificates
test
def set_ca_certificates(self, cacerts): """ Replace or set the CA certificates within the PKCS12 object. :param cacerts: The new CA certificates, or :py:const:`None` to unset them. :type cacerts: An iterable of :py:class:`X509` or :py:const:`None` :return: ``None`` ...
python
{ "resource": "" }
q269847
PKCS12.export
test
def export(self, passphrase=None, iter=2048, maciter=1): """ Dump a PKCS12 object as a string. For more information, see the :c:func:`PKCS12_create` man page. :param passphrase: The passphrase used to encrypt the structure. Unlike some other passphrase arguments, this *must...
python
{ "resource": "" }
q269848
NetscapeSPKI.sign
test
def sign(self, pkey, digest): """ Sign the certificate request with this key and digest type. :param pkey: The private key to sign with. :type pkey: :py:class:`PKey` :param digest: The message digest to use. :type digest: :py:class:`bytes` :return: ``None`` ...
python
{ "resource": "" }
q269849
NetscapeSPKI.verify
test
def verify(self, key): """ Verifies a signature on a certificate request. :param PKey key: The public key that signature is supposedly from. :return: ``True`` if the signature is correct. :rtype: bool :raises OpenSSL.crypto.Error: If the signature is invalid, or there ...
python
{ "resource": "" }
q269850
NetscapeSPKI.b64_encode
test
def b64_encode(self): """ Generate a base64 encoded representation of this SPKI object. :return: The base64 encoded string. :rtype: :py:class:`bytes` """ encoded = _lib.NETSCAPE_SPKI_b64_encode(self._spki) result = _ffi.string(encoded) _lib.OPENSSL_free(e...
python
{ "resource": "" }
q269851
NetscapeSPKI.get_pubkey
test
def get_pubkey(self): """ Get the public key of this certificate. :return: The public key. :rtype: :py:class:`PKey` """ pkey = PKey.__new__(PKey) pkey._pkey = _lib.NETSCAPE_SPKI_get_pubkey(self._spki) _openssl_assert(pkey._pkey != _ffi.NULL) pkey....
python
{ "resource": "" }
q269852
NetscapeSPKI.set_pubkey
test
def set_pubkey(self, pkey): """ Set the public key of the certificate :param pkey: The public key :return: ``None`` """ set_result = _lib.NETSCAPE_SPKI_set_pubkey(self._spki, pkey._pkey) _openssl_assert(set_result == 1)
python
{ "resource": "" }
q269853
exception_from_error_queue
test
def exception_from_error_queue(exception_type): """ Convert an OpenSSL library failure into a Python exception. When a call to the native OpenSSL library fails, this is usually signalled by the return value, and an error code is stored in an error queue associated with the current thread. The err l...
python
{ "resource": "" }
q269854
text_to_bytes_and_warn
test
def text_to_bytes_and_warn(label, obj): """ If ``obj`` is text, emit a warning that it should be bytes instead and try to convert it to bytes automatically. :param str label: The name of the parameter from which ``obj`` was taken (so a developer can easily find the source of the problem and cor...
python
{ "resource": "" }
q269855
_print_token_factory
test
def _print_token_factory(col): """Internal helper to provide color names.""" def _helper(msg): style = style_from_dict({ Token.Color: col, }) tokens = [ (Token.Color, msg) ] print_tokens(tokens, style=style) def _helper_no_terminal(msg): ...
python
{ "resource": "" }
q269856
TrelloService.get_service_metadata
test
def get_service_metadata(self): """ Return extra config options to be passed to the TrelloIssue class """ return { 'import_labels_as_tags': self.config.get('import_labels_as_tags', False, asbool), 'label_template': self.config.get('label_te...
python
{ "resource": "" }
q269857
TrelloService.issues
test
def issues(self): """ Returns a list of dicts representing issues from a remote service. """ for board in self.get_boards(): for lst in self.get_lists(board['id']): listextra = dict(boardname=board['name'], listname=lst['name']) for card in sel...
python
{ "resource": "" }
q269858
TrelloService.annotations
test
def annotations(self, card_json): """ A wrapper around get_comments that build the taskwarrior annotations. """ comments = self.get_comments(card_json['id']) annotations = self.build_annotations( ((c['memberCreator']['username'], c['data']['text']) for c in comments), ...
python
{ "resource": "" }
q269859
TrelloService.get_boards
test
def get_boards(self): """ Get the list of boards to pull cards from. If the user gave a value to trello.include_boards use that, otherwise ask the Trello API for the user's boards. """ if 'include_boards' in self.config: for boardid in self.config.get('includ...
python
{ "resource": "" }
q269860
TrelloService.get_lists
test
def get_lists(self, board): """ Returns a list of the filtered lists for the given board This filters the trello lists according to the configuration values of trello.include_lists and trello.exclude_lists. """ lists = self.api_request( "/1/boards/{board_id}/l...
python
{ "resource": "" }
q269861
TrelloService.get_cards
test
def get_cards(self, list_id): """ Returns an iterator for the cards in a given list, filtered according to configuration values of trello.only_if_assigned and trello.also_unassigned """ params = {'fields': 'name,idShort,shortLink,shortUrl,url,labels,due'} member = self.config.get...
python
{ "resource": "" }
q269862
TrelloService.get_comments
test
def get_comments(self, card_id): """ Returns an iterator for the comments on a certain card. """ params = {'filter': 'commentCard', 'memberCreator_fields': 'username'} comments = self.api_request( "/1/cards/{card_id}/actions".format(card_id=card_id), **params) for...
python
{ "resource": "" }
q269863
GithubClient._api_url
test
def _api_url(self, path, **context): """ Build the full url to the API endpoint """ if self.host == 'github.com': baseurl = "https://api.github.com" else: baseurl = "https://{}/api/v3".format(self.host) return baseurl + path.format(**context)
python
{ "resource": "" }
q269864
GithubClient._getter
test
def _getter(self, url, subkey=None): """ Pagination utility. Obnoxious. """ kwargs = {} if 'basic' in self.auth: kwargs['auth'] = self.auth['basic'] results = [] link = dict(next=url) while 'next' in link: response = self.session.get(link['next...
python
{ "resource": "" }
q269865
GithubClient._link_field_to_dict
test
def _link_field_to_dict(field): """ Utility for ripping apart github's Link header field. It's kind of ugly. """ if not field: return dict() return dict([ ( part.split('; ')[1][5:-1], part.split('; ')[0][1:-1], ...
python
{ "resource": "" }
q269866
GithubService.get_query
test
def get_query(self, query): """ Grab all issues matching a github query """ issues = {} for issue in self.client.get_query(query): url = issue['html_url'] try: repo = self.get_repository_from_issue(issue) except ValueError as e: ...
python
{ "resource": "" }
q269867
GithubService._reqs
test
def _reqs(self, tag): """ Grab all the pull requests """ return [ (tag, i) for i in self.client.get_pulls(*tag.split('/')) ]
python
{ "resource": "" }
q269868
aggregate_issues
test
def aggregate_issues(conf, main_section, debug): """ Return all issues from every target. """ log.info("Starting to aggregate remote issues.") # Create and call service objects for every target in the config targets = aslist(conf.get(main_section, 'targets')) queue = multiprocessing.Queue() l...
python
{ "resource": "" }
q269869
IssueService._get_config_or_default
test
def _get_config_or_default(self, key, default, as_type=lambda x: x): """Return a main config value, or default if it does not exist.""" if self.main_config.has_option(self.main_section, key): return as_type(self.main_config.get(self.main_section, key)) return default
python
{ "resource": "" }
q269870
IssueService.get_templates
test
def get_templates(self): """ Get any defined templates for configuration values. Users can override the value of any Taskwarrior field using this feature on a per-key basis. The key should be the name of the field to you would like to configure the value of, followed by '_templ...
python
{ "resource": "" }
q269871
IssueService.validate_config
test
def validate_config(cls, service_config, target): """ Validate generic options for a particular target """ if service_config.has_option(target, 'only_if_assigned'): die("[%s] has an 'only_if_assigned' option. Should be " "'%s.only_if_assigned'." % (target, cls.CONFIG_PREFIX)...
python
{ "resource": "" }
q269872
IssueService.include
test
def include(self, issue): """ Return true if the issue in question should be included """ only_if_assigned = self.config.get('only_if_assigned', None) if only_if_assigned: owner = self.get_owner(issue) include_owners = [only_if_assigned] if self.config.get('...
python
{ "resource": "" }
q269873
make_table
test
def make_table(grid): """ Make a RST-compatible table From http://stackoverflow.com/a/12539081 """ cell_width = 2 + max( reduce( lambda x, y: x+y, [[len(item) for item in row] for row in grid], [] ) ) num_cols = len(grid[0]) rst = table_div(num_cols, cell_width,...
python
{ "resource": "" }
q269874
oracle_eval
test
def oracle_eval(command): """ Retrieve password from the given command """ p = subprocess.Popen( command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) p.wait() if p.returncode == 0: return p.stdout.readline().strip().decode('utf-8') else: die( "Erro...
python
{ "resource": "" }
q269875
BugwarriorConfigParser.getint
test
def getint(self, section, option): """ Accepts both integers and empty values. """ try: return super(BugwarriorConfigParser, self).getint(section, option) except ValueError: if self.get(section, option) == u'': return None else: ...
python
{ "resource": "" }
q269876
pull
test
def pull(dry_run, flavor, interactive, debug): """ Pull down tasks from forges and add them to your taskwarrior tasks. Relies on configuration in bugwarriorrc """ try: main_section = _get_section_name(flavor) config = _try_load_config(main_section, interactive) lockfile_path =...
python
{ "resource": "" }
q269877
BitbucketService.get_data
test
def get_data(self, url): """ Perform a request to the fully qualified url and return json. """ return self.json_response(requests.get(url, **self.requests_kwargs))
python
{ "resource": "" }
q269878
BitbucketService.get_collection
test
def get_collection(self, url): """ Pages through an object collection from the bitbucket API. Returns an iterator that lazily goes through all the 'values' of all the pages in the collection. """ url = self.BASE_API2 + url while url is not None: response = self.get_da...
python
{ "resource": "" }
q269879
find_local_uuid
test
def find_local_uuid(tw, keys, issue, legacy_matching=False): """ For a given issue issue, find its local UUID. Assembles a list of task IDs existing in taskwarrior matching the supplied issue (`issue`) on the combination of any set of supplied unique identifiers (`keys`) or, optionally, the task's ...
python
{ "resource": "" }
q269880
merge_left
test
def merge_left(field, local_task, remote_issue, hamming=False): """ Merge array field from the remote_issue into local_task * Local 'left' entries are preserved without modification * Remote 'left' are appended to task if not present in local. :param `field`: Task field to merge. :param `local_tas...
python
{ "resource": "" }
q269881
build_uda_config_overrides
test
def build_uda_config_overrides(targets): """ Returns a list of UDAs defined by given targets For all targets in `targets`, build a dictionary of configuration overrides representing the UDAs defined by the passed-in services (`targets`). Given a hypothetical situation in which you have two services, t...
python
{ "resource": "" }
q269882
_parse_sprint_string
test
def _parse_sprint_string(sprint): """ Parse the big ugly sprint string stored by JIRA. They look like: com.atlassian.greenhopper.service.sprint.Sprint@4c9c41a5[id=2322,rapid ViewId=1173,state=ACTIVE,name=Sprint 1,startDate=2016-09-06T16:08:07.4 55Z,endDate=2016-09-23T16:08:00.000Z,compl...
python
{ "resource": "" }
q269883
GmailService.get_credentials
test
def get_credentials(self): """Gets valid user credentials from storage. If nothing has been stored, or if the stored credentials are invalid, the OAuth2 flow is completed to obtain the new credentials. Returns: Credentials, the obtained credential. """ with ...
python
{ "resource": "" }
q269884
multi_rouge_n
test
def multi_rouge_n(sequences, scores_ids, n=2): """ Efficient way to compute highly repetitive scoring i.e. sequences are involved multiple time Args: sequences(list[str]): list of sequences (either hyp or ref) scores_ids(list[tuple(int)]): list of pairs (hyp_id, ref_id) ie. ...
python
{ "resource": "" }
q269885
calc_pvalues
test
def calc_pvalues(query, gene_sets, background=20000, **kwargs): """ calculate pvalues for all categories in the graph :param set query: set of identifiers for which the p value is calculated :param dict gene_sets: gmt file dict after background was set :param set background: total number of genes in yo...
python
{ "resource": "" }
q269886
fdrcorrection
test
def fdrcorrection(pvals, alpha=0.05): """ benjamini hocheberg fdr correction. inspired by statsmodels """ # Implement copy from GOATools. pvals = np.asarray(pvals) pvals_sortind = np.argsort(pvals) pvals_sorted = np.take(pvals, pvals_sortind) ecdffactor = _ecdf(pvals_sorted) reject = p...
python
{ "resource": "" }
q269887
zscore
test
def zscore(data2d, axis=0): """Standardize the mean and variance of the data axis Parameters. :param data2d: DataFrame to normalize. :param axis: int, Which axis to normalize across. If 0, normalize across rows, if 1, normalize across columns. If None, don't change data ...
python
{ "resource": "" }
q269888
heatmap
test
def heatmap(df, z_score=None, title='', figsize=(5,5), cmap='RdBu_r', xticklabels=True, yticklabels=True, ofname=None, **kwargs): """Visualize the dataframe. :param df: DataFrame from expression table. :param z_score: z_score axis{0, 1}. If None, don't normalize data. :param title: gene se...
python
{ "resource": "" }
q269889
adjust_spines
test
def adjust_spines(ax, spines): """function for removing spines and ticks. :param ax: axes object :param spines: a list of spines names to keep. e.g [left, right, top, bottom] if spines = []. remove all spines and ticks. """ for loc, spine in ax.spines.items(): if loc in...
python
{ "resource": "" }
q269890
prepare_argparser
test
def prepare_argparser(): """Prepare argparser object. New options will be added in this function first.""" description = "%(prog)s -- Gene Set Enrichment Analysis in Python" epilog = "For command line options of each command, type: %(prog)s COMMAND -h" # top-level parser argparser = ap.ArgumentPars...
python
{ "resource": "" }
q269891
add_prerank_parser
test
def add_prerank_parser(subparsers): """Add function 'prerank' argument parsers.""" argparser_prerank = subparsers.add_parser("prerank", help="Run GSEApy Prerank tool on preranked gene list.") # group for input files prerank_input = argparser_prerank.add_argument_group("Input files arguments") prer...
python
{ "resource": "" }
q269892
add_plot_parser
test
def add_plot_parser(subparsers): """Add function 'plot' argument parsers.""" argparser_replot = subparsers.add_parser("replot", help="Reproduce GSEA desktop output figures.") group_replot = argparser_replot.add_argument_group("Input arguments") group_replot.add_argument("-i", "--indir", action="store...
python
{ "resource": "" }
q269893
add_enrichr_parser
test
def add_enrichr_parser(subparsers): """Add function 'enrichr' argument parsers.""" argparser_enrichr = subparsers.add_parser("enrichr", help="Using Enrichr API to perform GO analysis.") # group for required options. enrichr_opt = argparser_enrichr.add_argument_group("Input arguments") enrichr_opt....
python
{ "resource": "" }
q269894
enrichment_score
test
def enrichment_score(gene_list, correl_vector, gene_set, weighted_score_type=1, nperm=1000, rs=np.random.RandomState(), single=False, scale=False): """This is the most important function of GSEApy. It has the same algorithm with GSEA and ssGSEA. :param gene_list: The ordered gene li...
python
{ "resource": "" }
q269895
ranking_metric_tensor
test
def ranking_metric_tensor(exprs, method, permutation_num, pos, neg, classes, ascending, rs=np.random.RandomState()): """Build shuffled ranking matrix when permutation_type eq to phenotype. :param exprs: gene_expression DataFrame, gene_name indexed. :param str method: calc...
python
{ "resource": "" }
q269896
ranking_metric
test
def ranking_metric(df, method, pos, neg, classes, ascending): """The main function to rank an expression table. :param df: gene_expression DataFrame. :param method: The method used to calculate a correlation or ranking. Default: 'log2_ratio_of_classes'. Others methods are...
python
{ "resource": "" }
q269897
gsea_pval
test
def gsea_pval(es, esnull): """Compute nominal p-value. From article (PNAS): estimate nominal p-value for S from esnull by using the positive or negative portion of the distribution corresponding to the sign of the observed ES(S). """ # to speed up, using numpy function to compute pval in p...
python
{ "resource": "" }
q269898
gsea_significance
test
def gsea_significance(enrichment_scores, enrichment_nulls): """Compute nominal pvals, normalized ES, and FDR q value. For a given NES(S) = NES* >= 0. The FDR is the ratio of the percentage of all (S,pi) with NES(S,pi) >= 0, whose NES(S,pi) >= NES*, divided by the percentage of observed S wi...
python
{ "resource": "" }
q269899
Biomart.get_marts
test
def get_marts(self): """Get available marts and their names.""" mart_names = pd.Series(self.names, name="Name") mart_descriptions = pd.Series(self.displayNames, name="Description") return pd.concat([mart_names, mart_descriptions], axis=1)
python
{ "resource": "" }