_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q257600 | TLSSession._obtain_credentials | validation | def _obtain_credentials(self):
"""
Obtains a credentials handle from secur32.dll for use with SChannel
"""
protocol_values = {
'SSLv3': Secur32Const.SP_PROT_SSL3_CLIENT,
'TLSv1': Secur32Const.SP_PROT_TLS1_CLIENT,
'TLSv1.1': Secur32Const.SP_PROT_TLS1_1... | python | {
"resource": ""
} |
q257601 | TLSSocket._create_buffers | validation | def _create_buffers(self, number):
"""
Creates a SecBufferDesc struct and contained SecBuffer structs
:param number:
The number of contains SecBuffer objects to create
:return:
A tuple of (SecBufferDesc pointer, SecBuffer array)
"""
buffers = ne... | python | {
"resource": ""
} |
q257602 | TLSSocket.select_read | validation | def select_read(self, timeout=None):
"""
Blocks until the socket is ready to be read from, or the timeout is hit
:param timeout:
A float - the period of time to wait for data to be read. None for
no time limit.
:return:
A boolean - if data is ready t... | python | {
"resource": ""
} |
q257603 | TLSSocket.read_exactly | validation | def read_exactly(self, num_bytes):
"""
Reads exactly the specified number of bytes from the socket
:param num_bytes:
An integer - the exact number of bytes to read
:return:
A byte string of the data that was read
"""
output = b''
remaini... | python | {
"resource": ""
} |
q257604 | TLSSocket.select_write | validation | def select_write(self, timeout=None):
"""
Blocks until the socket is ready to be written to, or the timeout is hit
:param timeout:
A float - the period of time to wait for the socket to be ready to
written to. None for no time limit.
:return:
A boole... | python | {
"resource": ""
} |
q257605 | TLSSocket._raw_read | validation | def _raw_read(self):
"""
Reads data from the socket and writes it to the memory bio
used by libssl to decrypt the data. Returns the unencrypted
data for the purpose of debugging handshakes.
:return:
A byte string of ciphertext from the socket. Used for
de... | python | {
"resource": ""
} |
q257606 | TLSSocket._raw_write | validation | def _raw_write(self):
"""
Takes ciphertext from the memory bio and writes it to the
socket.
:return:
A byte string of ciphertext going to the socket. Used
for debugging the handshake only.
"""
data_available = libssl.BIO_ctrl_pending(self._wbio)
... | python | {
"resource": ""
} |
q257607 | _advapi32_encrypt | validation | def _advapi32_encrypt(cipher, key, data, iv, padding):
"""
Encrypts plaintext via CryptoAPI
:param cipher:
A unicode string of "aes", "des", "tripledes_2key", "tripledes_3key",
"rc2", "rc4"
:param key:
The encryption key - a byte string 5-16 bytes long
:param data:
... | python | {
"resource": ""
} |
q257608 | _bcrypt_encrypt | validation | def _bcrypt_encrypt(cipher, key, data, iv, padding):
"""
Encrypts plaintext via CNG
:param cipher:
A unicode string of "aes", "des", "tripledes_2key", "tripledes_3key",
"rc2", "rc4"
:param key:
The encryption key - a byte string 5-16 bytes long
:param data:
The pla... | python | {
"resource": ""
} |
q257609 | handle_openssl_error | validation | def handle_openssl_error(result, exception_class=None):
"""
Checks if an error occured, and if so throws an OSError containing the
last OpenSSL error message
:param result:
An integer result code - 1 or greater indicates success
:param exception_class:
The exception class to use fo... | python | {
"resource": ""
} |
q257610 | peek_openssl_error | validation | def peek_openssl_error():
"""
Peeks into the error stack and pulls out the lib, func and reason
:return:
A three-element tuple of integers (lib, func, reason)
"""
error = libcrypto.ERR_peek_error()
lib = int((error >> 24) & 0xff)
func = int((error >> 12) & 0xfff)
reason = int(e... | python | {
"resource": ""
} |
q257611 | extract_from_system | validation | def extract_from_system(cert_callback=None, callback_only_on_failure=False):
"""
Extracts trusted CA certificates from the OS X trusted root keychain.
:param cert_callback:
A callback that is called once for each certificate in the trust store.
It should accept two parameters: an asn1crypto... | python | {
"resource": ""
} |
q257612 | _cert_callback | validation | def _cert_callback(callback, der_cert, reason):
"""
Constructs an asn1crypto.x509.Certificate object and calls the export
callback
:param callback:
The callback to call
:param der_cert:
A byte string of the DER-encoded certificate
:param reason:
None if cert is being e... | python | {
"resource": ""
} |
q257613 | _cert_details | validation | def _cert_details(cert_pointer):
"""
Return the certificate and a hash of it
:param cert_pointer:
A SecCertificateRef
:return:
A 2-element tuple:
- [0]: A byte string of the SHA1 hash of the cert
- [1]: A byte string of the DER-encoded contents of the cert
"""
... | python | {
"resource": ""
} |
q257614 | _extract_error | validation | def _extract_error():
"""
Extracts the last OS error message into a python unicode string
:return:
A unicode string error message
"""
error_num = errno()
try:
error_string = os.strerror(error_num)
except (ValueError):
return str_cls(error_num)
if isinstance(er... | python | {
"resource": ""
} |
q257615 | CFHelpers.cf_dictionary_to_dict | validation | def cf_dictionary_to_dict(dictionary):
"""
Converts a CFDictionary object into a python dictionary
:param dictionary:
The CFDictionary to convert
:return:
A python dict
"""
dict_length = CoreFoundation.CFDictionaryGetCount(dictionary)
k... | python | {
"resource": ""
} |
q257616 | handle_sec_error | validation | def handle_sec_error(error, exception_class=None):
"""
Checks a Security OSStatus error code and throws an exception if there is an
error to report
:param error:
An OSStatus
:param exception_class:
The exception class to use for the exception if an error occurred
:raises:
... | python | {
"resource": ""
} |
q257617 | _get_func_info | validation | def _get_func_info(docstring, def_lineno, code_lines, prefix):
"""
Extracts the function signature and description of a Python function
:param docstring:
A unicode string of the docstring for the function
:param def_lineno:
An integer line number that function was defined on
:para... | python | {
"resource": ""
} |
q257618 | _find_sections | validation | def _find_sections(md_ast, sections, last, last_class, total_lines=None):
"""
Walks through a CommonMark AST to find section headers that delineate
content that should be updated by this script
:param md_ast:
The AST of the markdown document
:param sections:
A dict to store the sta... | python | {
"resource": ""
} |
q257619 | walk_ast | validation | def walk_ast(node, code_lines, sections, md_chunks):
"""
A callback used to walk the Python AST looking for classes, functions,
methods and attributes. Generates chunks of markdown markup to replace
the existing content.
:param node:
An _ast module node object
:param code_lines:
... | python | {
"resource": ""
} |
q257620 | system_path | validation | def system_path():
"""
Tries to find a CA certs bundle in common locations
:raises:
OSError - when no valid CA certs bundle was found on the filesystem
:return:
The full filesystem path to a CA certs bundle file
"""
ca_path = None
# Common CA cert paths
paths = [
... | python | {
"resource": ""
} |
q257621 | extract_from_system | validation | def extract_from_system(cert_callback=None, callback_only_on_failure=False):
"""
Extracts trusted CA certs from the system CA cert bundle
:param cert_callback:
A callback that is called once for each certificate in the trust store.
It should accept two parameters: an asn1crypto.x509.Certifi... | python | {
"resource": ""
} |
q257622 | _convert_filetime_to_timestamp | validation | def _convert_filetime_to_timestamp(filetime):
"""
Windows returns times as 64-bit unsigned longs that are the number
of hundreds of nanoseconds since Jan 1 1601. This converts it to
a datetime object.
:param filetime:
A FILETIME struct object
:return:
An integer unix timestamp
... | python | {
"resource": ""
} |
q257623 | extract_chain | validation | def extract_chain(server_handshake_bytes):
"""
Extracts the X.509 certificates from the server handshake bytes for use
when debugging
:param server_handshake_bytes:
A byte string of the handshake data received from the server
:return:
A list of asn1crypto.x509.Certificate objects
... | python | {
"resource": ""
} |
q257624 | detect_client_auth_request | validation | def detect_client_auth_request(server_handshake_bytes):
"""
Determines if a CertificateRequest message is sent from the server asking
the client for a certificate
:param server_handshake_bytes:
A byte string of the handshake data received from the server
:return:
A boolean - if a c... | python | {
"resource": ""
} |
q257625 | get_dh_params_length | validation | def get_dh_params_length(server_handshake_bytes):
"""
Determines the length of the DH params from the ServerKeyExchange
:param server_handshake_bytes:
A byte string of the handshake data received from the server
:return:
None or an integer of the bit size of the DH parameters
"""
... | python | {
"resource": ""
} |
q257626 | parse_alert | validation | def parse_alert(server_handshake_bytes):
"""
Parses the handshake for protocol alerts
:param server_handshake_bytes:
A byte string of the handshake data received from the server
:return:
None or an 2-element tuple of integers:
0: 1 (warning) or 2 (fatal)
1: The alert ... | python | {
"resource": ""
} |
q257627 | parse_session_info | validation | def parse_session_info(server_handshake_bytes, client_handshake_bytes):
"""
Parse the TLS handshake from the client to the server to extract information
including the cipher suite selected, if compression is enabled, the
session id and if a new or reused session ticket exists.
:param server_handsha... | python | {
"resource": ""
} |
q257628 | parse_tls_records | validation | def parse_tls_records(data):
"""
Creates a generator returning tuples of information about each record
in a byte string of data from a TLS client or server. Stops as soon as it
find a ChangeCipherSpec message since all data from then on is encrypted.
:param data:
A byte string of TLS record... | python | {
"resource": ""
} |
q257629 | parse_handshake_messages | validation | def parse_handshake_messages(data):
"""
Creates a generator returning tuples of information about each message in
a byte string of data from a TLS handshake record
:param data:
A byte string of a TLS handshake record data
:return:
A generator that yields 2-element tuples:
[... | python | {
"resource": ""
} |
q257630 | _parse_hello_extensions | validation | def _parse_hello_extensions(data):
"""
Creates a generator returning tuples of information about each extension
from a byte string of extension data contained in a ServerHello ores
ClientHello message
:param data:
A byte string of a extension data from a TLS ServerHello or ClientHello
... | python | {
"resource": ""
} |
q257631 | raise_hostname | validation | def raise_hostname(certificate, hostname):
"""
Raises a TLSVerificationError due to a hostname mismatch
:param certificate:
An asn1crypto.x509.Certificate object
:raises:
TLSVerificationError
"""
is_ip = re.match('^\\d+\\.\\d+\\.\\d+\\.\\d+$', hostname) or hostname.find(':') !... | python | {
"resource": ""
} |
q257632 | raise_expired_not_yet_valid | validation | def raise_expired_not_yet_valid(certificate):
"""
Raises a TLSVerificationError due to certificate being expired, or not yet
being valid
:param certificate:
An asn1crypto.x509.Certificate object
:raises:
TLSVerificationError
"""
validity = certificate['tbs_certificate']['v... | python | {
"resource": ""
} |
q257633 | detect_other_protocol | validation | def detect_other_protocol(server_handshake_bytes):
"""
Looks at the server handshake bytes to try and detect a different protocol
:param server_handshake_bytes:
A byte string of the handshake data received from the server
:return:
None, or a unicode string of "ftp", "http", "imap", "po... | python | {
"resource": ""
} |
q257634 | _try_decode | validation | def _try_decode(byte_string):
"""
Tries decoding a byte string from the OS into a unicode string
:param byte_string:
A byte string
:return:
A unicode string
"""
try:
return str_cls(byte_string, _encoding)
# If the "correct" encoding did not work, try some defaults... | python | {
"resource": ""
} |
q257635 | _read_callback | validation | def _read_callback(connection_id, data_buffer, data_length_pointer):
"""
Callback called by Secure Transport to actually read the socket
:param connection_id:
An integer identifing the connection
:param data_buffer:
A char pointer FFI type to write the data to
:param data_length_p... | python | {
"resource": ""
} |
q257636 | _read_remaining | validation | def _read_remaining(socket):
"""
Reads everything available from the socket - used for debugging when there
is a protocol error
:param socket:
The socket to read from
:return:
A byte string of the remaining data
"""
output = b''
old_timeout = socket.gettimeout()
tr... | python | {
"resource": ""
} |
q257637 | _write_callback | validation | def _write_callback(connection_id, data_buffer, data_length_pointer):
"""
Callback called by Secure Transport to actually write to the socket
:param connection_id:
An integer identifing the connection
:param data_buffer:
A char pointer FFI type containing the data to write
:param ... | python | {
"resource": ""
} |
q257638 | get_path | validation | def get_path(temp_dir=None, cache_length=24, cert_callback=None):
"""
Get the filesystem path to a file that contains OpenSSL-compatible CA certs.
On OS X and Windows, there are extracted from the system certificate store
and cached in a file on the filesystem. This path should not be writable
by o... | python | {
"resource": ""
} |
q257639 | _map_oids | validation | def _map_oids(oids):
"""
Takes a set of unicode string OIDs and converts vendor-specific OIDs into
generics OIDs from RFCs.
- 1.2.840.113635.100.1.3 (apple_ssl) -> 1.3.6.1.5.5.7.3.1 (server_auth)
- 1.2.840.113635.100.1.3 (apple_ssl) -> 1.3.6.1.5.5.7.3.2 (client_auth)
- 1.2.840.113635.100.1.8... | python | {
"resource": ""
} |
q257640 | _cached_path_needs_update | validation | def _cached_path_needs_update(ca_path, cache_length):
"""
Checks to see if a cache file needs to be refreshed
:param ca_path:
A unicode string of the path to the cache file
:param cache_length:
An integer representing the number of hours the cache is valid for
:return:
A b... | python | {
"resource": ""
} |
q257641 | Service.version | validation | def version(self):
""" Create a new version under this service. """
ver = Version()
ver.conn = self.conn
ver.attrs = {
# Parent params
'service_id': self.attrs['id'],
}
ver.save()
return ver | python | {
"resource": ""
} |
q257642 | Version.vcl | validation | def vcl(self, name, content):
""" Create a new VCL under this version. """
vcl = VCL()
vcl.conn = self.conn
vcl.attrs = {
# Parent params
'service_id': self.attrs['service_id'],
'version': self.attrs['number'],
# New instance params
... | python | {
"resource": ""
} |
q257643 | BaseColumn.to_dict | validation | def to_dict(self):
"""
Converts the column to a dictionary representation accepted
by the Citrination server.
:return: Dictionary with basic options, plus any column type specific
options held under the "options" key
:rtype: dict
"""
return {
... | python | {
"resource": ""
} |
q257644 | DataViewBuilder.add_descriptor | validation | def add_descriptor(self, descriptor, role='ignore', group_by_key=False):
"""
Add a descriptor column.
:param descriptor: A Descriptor instance (e.g., RealDescriptor, InorganicDescriptor, etc.)
:param role: Specify a role (input, output, latentVariable, or ignore)
:param group_by... | python | {
"resource": ""
} |
q257645 | BaseClient._patch | validation | def _patch(self, route, data, headers=None, failure_message=None):
"""
Execute a patch request and return the result
"""
headers = self._get_headers(headers)
response_lambda = (
lambda: requests.patch(
self._get_qualified_route(route), headers=headers,... | python | {
"resource": ""
} |
q257646 | SearchClient._validate_search_query | validation | def _validate_search_query(self, returning_query):
"""
Checks to see that the query will not exceed the max query depth
:param returning_query: The PIF system or Dataset query to execute.
:type returning_query: :class:`PifSystemReturningQuery` or :class: `DatasetReturningQuery`
... | python | {
"resource": ""
} |
q257647 | SearchClient.dataset_search | validation | def dataset_search(self, dataset_returning_query):
"""
Run a dataset query against Citrination.
:param dataset_returning_query: :class:`DatasetReturningQuery` to execute.
:type dataset_returning_query: :class:`DatasetReturningQuery`
:return: Dataset search result object with the... | python | {
"resource": ""
} |
q257648 | SearchClient.pif_multi_search | validation | def pif_multi_search(self, multi_query):
"""
Run each in a list of PIF queries against Citrination.
:param multi_query: :class:`MultiQuery` object to execute.
:return: :class:`PifMultiSearchResult` object with the results of the query.
"""
failure_message = "Error while ... | python | {
"resource": ""
} |
q257649 | check_for_rate_limiting | validation | def check_for_rate_limiting(response, response_lambda, timeout=1, attempts=0):
"""
Takes an initial response, and a way to repeat the request that produced it and retries the request with an increasing sleep period between requests if rate limiting resposne codes are encountered.
If more than 3 attempts ar... | python | {
"resource": ""
} |
q257650 | DataViewsClient.create | validation | def create(self, configuration, name, description):
"""
Creates a data view from the search template and ml template given
:param configuration: Information to construct the data view from (eg descriptors, datasets etc)
:param name: Name of the data view
:param description: Desc... | python | {
"resource": ""
} |
q257651 | DataViewsClient.update | validation | def update(self, id, configuration, name, description):
"""
Updates an existing data view from the search template and ml template given
:param id: Identifier for the data view. This returned from the create method.
:param configuration: Information to construct the data view from (eg ... | python | {
"resource": ""
} |
q257652 | DataViewsClient.get | validation | def get(self, data_view_id):
"""
Gets basic information about a view
:param data_view_id: Identifier of the data view
:return: Metadata about the view as JSON
"""
failure_message = "Dataview get failed"
return self._get_success_json(self._get(
'v1/da... | python | {
"resource": ""
} |
q257653 | DataViewsClient.create_ml_configuration_from_datasets | validation | def create_ml_configuration_from_datasets(self, dataset_ids):
"""
Creates an ml configuration from dataset_ids and extract_as_keys
:param dataset_ids: Array of dataset identifiers to make search template from
:return: An identifier used to request the status of the builder job (get_ml_c... | python | {
"resource": ""
} |
q257654 | DataViewsClient.create_ml_configuration | validation | def create_ml_configuration(self, search_template, extract_as_keys, dataset_ids):
"""
This method will spawn a server job to create a default ML configuration based on a search template and
the extract as keys.
This function will submit the request to build, and wait for the configuratio... | python | {
"resource": ""
} |
q257655 | DataViewsClient.__convert_response_to_configuration | validation | def __convert_response_to_configuration(self, result_blob, dataset_ids):
"""
Utility function to turn the result object from the configuration builder endpoint into something that
can be used directly as a configuration.
:param result_blob: Nested dicts representing the possible descrip... | python | {
"resource": ""
} |
q257656 | DataViewsClient.__get_ml_configuration_status | validation | def __get_ml_configuration_status(self, job_id):
"""
After invoking the create_ml_configuration async method, you can use this method to
check on the status of the builder job.
:param job_id: The identifier returned from create_ml_configuration
:return: Job status
"""
... | python | {
"resource": ""
} |
q257657 | ModelsClient.tsne | validation | def tsne(self, data_view_id):
"""
Get the t-SNE projection, including responses and tags.
:param data_view_id: The ID of the data view to retrieve TSNE from
:type data_view_id: int
:return: The TSNE analysis
:rtype: :class:`Tsne`
"""
analysis = self._data... | python | {
"resource": ""
} |
q257658 | ModelsClient._data_analysis | validation | def _data_analysis(self, data_view_id):
"""
Data analysis endpoint.
:param data_view_id: The model identifier (id number for data views)
:type data_view_id: str
:return: dictionary containing information about the data, e.g. dCorr and tsne
"""
failure_message = "... | python | {
"resource": ""
} |
q257659 | ModelsClient.submit_predict_request | validation | def submit_predict_request(self, data_view_id, candidates, prediction_source='scalar', use_prior=True):
"""
Submits an async prediction request.
:param data_view_id: The id returned from create
:param candidates: Array of candidates
:param prediction_source: 'scalar' or 'scalar_... | python | {
"resource": ""
} |
q257660 | ModelsClient.check_predict_status | validation | def check_predict_status(self, view_id, predict_request_id):
"""
Returns a string indicating the status of the prediction job
:param view_id: The data view id returned from data view create
:param predict_request_id: The id returned from predict
:return: Status data, also includ... | python | {
"resource": ""
} |
q257661 | ModelsClient.submit_design_run | validation | def submit_design_run(self, data_view_id, num_candidates, effort, target=None, constraints=[], sampler="Default"):
"""
Submits a new experimental design run.
:param data_view_id: The ID number of the data view to which the
run belongs, as a string
:type data_view_id: str
... | python | {
"resource": ""
} |
q257662 | ModelsClient.get_design_run_status | validation | def get_design_run_status(self, data_view_id, run_uuid):
"""
Retrieves the status of an in progress or completed design run
:param data_view_id: The ID number of the data view to which the
run belongs, as a string
:type data_view_id: str
:param run_uuid: The UUID of ... | python | {
"resource": ""
} |
q257663 | ModelsClient.get_design_run_results | validation | def get_design_run_results(self, data_view_id, run_uuid):
"""
Retrieves the results of an existing designrun
:param data_view_id: The ID number of the data view to which the
run belongs, as a string
:type data_view_id: str
:param run_uuid: The UUID of the design run ... | python | {
"resource": ""
} |
q257664 | ModelsClient.get_data_view | validation | def get_data_view(self, data_view_id):
"""
Retrieves a summary of information for a given data view
- view id
- name
- description
- columns
:param data_view_id: The ID number of the data view to which the
run belongs, as a string
... | python | {
"resource": ""
} |
q257665 | ModelsClient.kill_design_run | validation | def kill_design_run(self, data_view_id, run_uuid):
"""
Kills an in progress experimental design run
:param data_view_id: The ID number of the data view to which the
run belongs, as a string
:type data_view_id: str
:param run_uuid: The UUID of the design run to kill
... | python | {
"resource": ""
} |
q257666 | load_file_as_yaml | validation | def load_file_as_yaml(path):
"""
Given a filepath, loads the file as a dictionary from YAML
:param path: The path to a YAML file
"""
with open(path, "r") as f:
raw_yaml = f.read()
parsed_dict = yaml.load(raw_yaml)
return parsed_dict | python | {
"resource": ""
} |
q257667 | get_credentials_from_file | validation | def get_credentials_from_file(filepath):
"""
Extracts credentials from the yaml formatted credential filepath
passed in. Uses the default profile if the CITRINATION_PROFILE env var
is not set, otherwise looks for a profile with that name in the credentials file.
:param filepath: The path of the cre... | python | {
"resource": ""
} |
q257668 | get_preferred_credentials | validation | def get_preferred_credentials(api_key, site, cred_file=DEFAULT_CITRINATION_CREDENTIALS_FILE):
"""
Given an API key, a site url and a credentials file path, runs through a prioritized list of credential sources to find credentials.
Specifically, this method ranks credential priority as follows:
1. T... | python | {
"resource": ""
} |
q257669 | DataClient.list_files | validation | def list_files(self, dataset_id, glob=".", is_dir=False):
"""
List matched filenames in a dataset on Citrination.
:param dataset_id: The ID of the dataset to search for files.
:type dataset_id: int
:param glob: A pattern which will be matched against files in the dataset.
... | python | {
"resource": ""
} |
q257670 | DataClient.matched_file_count | validation | def matched_file_count(self, dataset_id, glob=".", is_dir=False):
"""
Returns the number of files matching a pattern in a dataset.
:param dataset_id: The ID of the dataset to search for files.
:type dataset_id: int
:param glob: A pattern which will be matched against files in th... | python | {
"resource": ""
} |
q257671 | DataClient.get_dataset_files | validation | def get_dataset_files(self, dataset_id, glob=".", is_dir=False, version_number=None):
"""
Retrieves URLs for the files matched by a glob or a path to a directory
in a given dataset.
:param dataset_id: The id of the dataset to retrieve files from
:type dataset_id: int
:pa... | python | {
"resource": ""
} |
q257672 | DataClient.get_dataset_file | validation | def get_dataset_file(self, dataset_id, file_path, version = None):
"""
Retrieves a dataset file matching a provided file path
:param dataset_id: The id of the dataset to retrieve file from
:type dataset_id: int
:param file_path: The file path within the dataset
:type fil... | python | {
"resource": ""
} |
q257673 | DataClient.get_pif | validation | def get_pif(self, dataset_id, uid, dataset_version = None):
"""
Retrieves a PIF from a given dataset.
:param dataset_id: The id of the dataset to retrieve PIF from
:type dataset_id: int
:param uid: The uid of the PIF to retrieve
:type uid: str
:param dataset_vers... | python | {
"resource": ""
} |
q257674 | DataClient.create_dataset | validation | def create_dataset(self, name=None, description=None, public=False):
"""
Create a new data set.
:param name: name of the dataset
:type name: str
:param description: description for the dataset
:type description: str
:param public: A boolean indicating whether or ... | python | {
"resource": ""
} |
q257675 | DataClient.update_dataset | validation | def update_dataset(self, dataset_id, name=None, description=None, public=None):
"""
Update a data set.
:param dataset_id: The ID of the dataset to update
:type dataset_id: int
:param name: name of the dataset
:type name: str
:param description: description for th... | python | {
"resource": ""
} |
q257676 | DataClient.create_dataset_version | validation | def create_dataset_version(self, dataset_id):
"""
Create a new data set version.
:param dataset_id: The ID of the dataset for which the version must be bumped.
:type dataset_id: int
:return: The new dataset version.
:rtype: :class:`DatasetVersion`
"""
fai... | python | {
"resource": ""
} |
q257677 | SearchTemplateClient.get_available_columns | validation | def get_available_columns(self, dataset_ids):
"""
Retrieves the set of columns from the combination of dataset ids given
:param dataset_ids: The id of the dataset to retrieve columns from
:type dataset_ids: list of int
:return: A list of column names from the dataset ids given.
... | python | {
"resource": ""
} |
q257678 | SearchTemplateClient.__generate_search_template | validation | def __generate_search_template(self, dataset_ids):
"""
Generates a default search templates from the available columns in the dataset ids given.
:param dataset_ids: The id of the dataset to retrieve files from
:type dataset_ids: list of int
:return: A search template based on th... | python | {
"resource": ""
} |
q257679 | SearchTemplateClient.__prune_search_template | validation | def __prune_search_template(self, extract_as_keys, search_template):
"""
Returns a new search template, but the new template has only the extract_as_keys given.
:param extract_as_keys: List of extract as keys to keep
:param search_template: The search template to prune
:return: ... | python | {
"resource": ""
} |
q257680 | QueryEncoder.default | validation | def default(self, obj):
"""
Convert an object to a form ready to dump to json.
:param obj: Object being serialized. The type of this object must be one of the following: None; a single object derived from the Pio class; or a list of objects, each derived from the Pio class.
:return: Lis... | python | {
"resource": ""
} |
q257681 | QueryEncoder._keys_to_camel_case | validation | def _keys_to_camel_case(self, obj):
"""
Make a copy of a dictionary with all keys converted to camel case. This is just calls to_camel_case on each of the keys in the dictionary and returns a new dictionary.
:param obj: Dictionary to convert keys to camel case.
:return: Dictionary with ... | python | {
"resource": ""
} |
q257682 | ModelTemplateClient.validate | validation | def validate(self, ml_template):
"""
Runs the template against the validation endpoint, returns a message indicating status of the templte
:param ml_template: Template to validate
:return: OK or error message if validation failed
"""
data = {
"ml_template":
... | python | {
"resource": ""
} |
q257683 | add_organization_course | validation | def add_organization_course(organization_data, course_key):
"""
Adds a organization-course link to the system
"""
_validate_course_key(course_key)
_validate_organization_data(organization_data)
data.create_organization_course(
organization=organization_data,
course_key=course_key... | python | {
"resource": ""
} |
q257684 | remove_organization_course | validation | def remove_organization_course(organization, course_key):
"""
Removes the specfied course from the specified organization
"""
_validate_organization_data(organization)
_validate_course_key(course_key)
return data.delete_organization_course(course_key=course_key, organization=organization) | python | {
"resource": ""
} |
q257685 | course_key_is_valid | validation | def course_key_is_valid(course_key):
"""
Course key object validation
"""
if course_key is None:
return False
try:
CourseKey.from_string(text_type(course_key))
except (InvalidKeyError, UnicodeDecodeError):
return False
return True | python | {
"resource": ""
} |
q257686 | organization_data_is_valid | validation | def organization_data_is_valid(organization_data):
"""
Organization data validation
"""
if organization_data is None:
return False
if 'id' in organization_data and not organization_data.get('id'):
return False
if 'name' in organization_data and not organization_data.get('name'):
... | python | {
"resource": ""
} |
q257687 | _inactivate_organization | validation | def _inactivate_organization(organization):
"""
Inactivates an activated organization as well as any active relationships
"""
[_inactivate_organization_course_relationship(record) for record
in internal.OrganizationCourse.objects.filter(organization_id=organization.id, active=True)]
[_inactiva... | python | {
"resource": ""
} |
q257688 | _activate_organization_course_relationship | validation | def _activate_organization_course_relationship(relationship): # pylint: disable=invalid-name
"""
Activates an inactive organization-course relationship
"""
# If the relationship doesn't exist or the organization isn't active we'll want to raise an error
relationship = internal.OrganizationCourse.ob... | python | {
"resource": ""
} |
q257689 | _inactivate_organization_course_relationship | validation | def _inactivate_organization_course_relationship(relationship): # pylint: disable=invalid-name
"""
Inactivates an active organization-course relationship
"""
relationship = internal.OrganizationCourse.objects.get(
id=relationship.id,
active=True
)
_inactivate_record(relationship... | python | {
"resource": ""
} |
q257690 | fetch_organization_courses | validation | def fetch_organization_courses(organization):
"""
Retrieves the set of courses currently linked to the specified organization
"""
organization_obj = serializers.deserialize_organization(organization)
queryset = internal.OrganizationCourse.objects.filter(
organization=organization_obj,
... | python | {
"resource": ""
} |
q257691 | fetch_course_organizations | validation | def fetch_course_organizations(course_key):
"""
Retrieves the organizations linked to the specified course
"""
queryset = internal.OrganizationCourse.objects.filter(
course_id=text_type(course_key),
active=True
).select_related('organization')
return [serializers.serialize_organi... | python | {
"resource": ""
} |
q257692 | serialize_organization | validation | def serialize_organization(organization):
"""
Organization object-to-dict serialization
"""
return {
'id': organization.id,
'name': organization.name,
'short_name': organization.short_name,
'description': organization.description,
'logo': organization.logo
} | python | {
"resource": ""
} |
q257693 | deserialize_organization | validation | def deserialize_organization(organization_dict):
"""
Organization dict-to-object serialization
"""
return models.Organization(
id=organization_dict.get('id'),
name=organization_dict.get('name', ''),
short_name=organization_dict.get('short_name', ''),
description=organizat... | python | {
"resource": ""
} |
q257694 | ImageExtractor.is_valid_filename | validation | def is_valid_filename(self, image_node):
"""\
will check the image src against a list
of bad image files we know of like buttons, etc...
"""
src = self.parser.getAttribute(image_node, attr='src')
if not src:
return False
if self.badimages_names_re.se... | python | {
"resource": ""
} |
q257695 | ImageExtractor.get_images_bytesize_match | validation | def get_images_bytesize_match(self, images):
"""\
loop through all the images and find the ones
that have the best bytez to even make them a candidate
"""
cnt = 0
max_bytes_size = 15728640
good_images = []
for image in images:
if cnt > 30:
... | python | {
"resource": ""
} |
q257696 | ImageExtractor.check_link_tag | validation | def check_link_tag(self):
"""\
checks to see if we were able to
find open link_src on this page
"""
node = self.article.raw_doc
meta = self.parser.getElementsByTag(node, tag='link', attr='rel', value='image_src')
for item in meta:
src = self.parser.get... | python | {
"resource": ""
} |
q257697 | ImageExtractor.get_local_image | validation | def get_local_image(self, src):
"""\
returns the bytes of the image file on disk
"""
return ImageUtils.store_image(self.fetcher, self.article.link_hash, src, self.config) | python | {
"resource": ""
} |
q257698 | VideoExtractor.get_video | validation | def get_video(self, node):
"""
Create a video object from a video embed
"""
video = Video()
video._embed_code = self.get_embed_code(node)
video._embed_type = self.get_embed_type(node)
video._width = self.get_width(node)
video._height = self.get_height(node... | python | {
"resource": ""
} |
q257699 | ImageUtils.store_image | validation | def store_image(cls, http_client, link_hash, src, config):
"""\
Writes an image src http string to disk as a temporary file
and returns the LocallyStoredImage object
that has the info you should need on the image
"""
# check for a cache hit already on disk
image =... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.