Search is not available for this dataset
text stringlengths 75 104k |
|---|
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(':') !... |
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... |
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... |
def constant_compare(a, b):
"""
Compares two byte strings in constant time to see if they are equal
:param a:
The first byte string
:param b:
The second byte string
:return:
A boolean if the two byte strings are equal
"""
if not isinstance(a, byte_cls):
ra... |
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... |
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... |
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... |
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 ... |
def _handshake(self):
"""
Perform an initial TLS handshake
"""
session_context = None
ssl_policy_ref = None
crl_search_ref = None
crl_policy_ref = None
ocsp_search_ref = None
ocsp_policy_ref = None
policy_array_ref = None
try:
... |
def read(self, max_length):
"""
Reads data from the TLS-wrapped socket
:param max_length:
The number of bytes to read - output may be less than this
:raises:
socket.socket - when a non-TLS socket error occurs
oscrypto.errors.TLSError - when a TLS-rel... |
def read_until(self, marker):
"""
Reads data from the socket until a marker is found. Data read includes
the marker.
:param marker:
A byte string or regex object from re.compile(). Used to determine
when to stop reading. Regex objects are more inefficient since
... |
def _os_buffered_size(self):
"""
Returns the number of bytes of decrypted data stored in the Secure
Transport read buffer. This amount of data can be read from SSLRead()
without calling self._socket.recv().
:return:
An integer - the number of available bytes
... |
def write(self, data):
"""
Writes data to the TLS-wrapped socket
:param data:
A byte string to write to the socket
:raises:
socket.socket - when a non-TLS socket error occurs
oscrypto.errors.TLSError - when a TLS-related error occurs
oscr... |
def _shutdown(self, manual):
"""
Shuts down the TLS session and then shuts down the underlying socket
:param manual:
A boolean if the connection was manually shutdown
"""
if self._session_context is None:
return
# Ignore error during close in ca... |
def close(self):
"""
Shuts down the TLS session and socket and forcibly closes it
"""
try:
self.shutdown()
finally:
if self._socket:
try:
self._socket.close()
except (socket_.error):
... |
def _read_certificates(self):
"""
Reads end-entity and intermediate certificate information from the
TLS session
"""
trust_ref = None
cf_data_ref = None
result = None
try:
trust_ref_pointer = new(Security, 'SecTrustRef *')
result ... |
def certificate(self):
"""
An asn1crypto.x509.Certificate object of the end-entity certificate
presented by the server
"""
if self._session_context is None:
self._raise_closed()
if self._certificate is None:
self._read_certificates()
ret... |
def intermediates(self):
"""
A list of asn1crypto.x509.Certificate objects that were presented as
intermediates by the server
"""
if self._session_context is None:
self._raise_closed()
if self._certificate is None:
self._read_certificates()
... |
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... |
def get_list(cache_length=24, map_vendor_oids=True, cert_callback=None):
"""
Retrieves (and caches in memory) the list of CA certs from the OS. Includes
trust information from the OS - purposes the certificate should be trusted
or rejected for.
Trust information is encoded via object identifiers (O... |
def clear_cache(temp_dir=None):
"""
Clears any cached info that was exported from the OS trust store. This will
ensure the latest changes are returned from calls to get_list() and
get_path(), but at the expense of re-exporting and parsing all certificates.
:param temp_dir:
The temporary dir... |
def _ca_path(temp_dir=None):
"""
Returns the file path to the CA certs file
:param temp_dir:
The temporary directory to cache the CA certs in on OS X and Windows.
Needs to have secure permissions so other users can not modify the
contents.
:return:
A 2-element tuple:
... |
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... |
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... |
def rand_bytes(length):
"""
Returns a number of random bytes suitable for cryptographic purposes
:param length:
The desired number of bytes
:raises:
ValueError - when any of the parameters contain an invalid value
TypeError - when any of the parameters are of the wrong type
... |
def pbkdf2(hash_algorithm, password, salt, iterations, key_length):
"""
Implements PBKDF2 from PKCS#5 v2.2 in pure Python
:param hash_algorithm:
The string name of the hash algorithm to use: "md5", "sha1", "sha224",
"sha256", "sha384", "sha512"
:param password:
A byte string of... |
def generate_pair(algorithm, bit_size=None, curve=None):
"""
Generates a public/private key pair
:param algorithm:
The key algorithm - "rsa", "dsa" or "ec"
:param bit_size:
An integer - used for "rsa" and "dsa". For "rsa" the value maye be 1024,
2048, 3072 or 4096. For "dsa" th... |
def generate_dh_parameters(bit_size):
"""
Generates DH parameters for use with Diffie-Hellman key exchange. Returns
a structure in the format of DHParameter defined in PKCS#3, which is also
used by the OpenSSL dhparam tool.
THIS CAN BE VERY TIME CONSUMING!
:param bit_size:
The integer ... |
def _load_x509(certificate):
"""
Loads an ASN.1 object of an x509 certificate into a Certificate object
:param certificate:
An asn1crypto.x509.Certificate object
:return:
A Certificate object
"""
source = certificate.dump()
cf_source = None
try:
cf_source = CF... |
def _load_key(key_object):
"""
Common code to load public and private keys into PublicKey and PrivateKey
objects
:param key_object:
An asn1crypto.keys.PublicKeyInfo or asn1crypto.keys.PrivateKeyInfo
object
:raises:
ValueError - when any of the parameters contain an invalid ... |
def rsa_pkcs1v15_encrypt(certificate_or_public_key, data):
"""
Encrypts a byte string using an RSA public key or certificate. Uses PKCS#1
v1.5 padding.
:param certificate_or_public_key:
A PublicKey or Certificate object
:param data:
A byte string, with a maximum length 11 bytes les... |
def rsa_pkcs1v15_decrypt(private_key, ciphertext):
"""
Decrypts a byte string using an RSA private key. Uses PKCS#1 v1.5 padding.
:param private_key:
A PrivateKey object
:param ciphertext:
A byte string of the encrypted data
:raises:
ValueError - when any of the parameters... |
def _encrypt(certificate_or_public_key, data, padding):
"""
Encrypts plaintext using an RSA public key or certificate
:param certificate_or_public_key:
A Certificate or PublicKey object
:param data:
The plaintext - a byte string
:param padding:
The padding mode to use, spe... |
def _decrypt(private_key, ciphertext, padding):
"""
Decrypts RSA ciphertext using a private key
:param private_key:
A PrivateKey object
:param ciphertext:
The ciphertext - a byte string
:param padding:
The padding mode to use, specified as a kSecPadding*Key value
:rai... |
def rsa_pss_verify(certificate_or_public_key, signature, data, hash_algorithm):
"""
Verifies an RSASSA-PSS signature. For the PSS padding the mask gen algorithm
will be mgf1 using the same hash algorithm as the signature. The salt length
with be the length of the hash algorithm, and the trailer field wi... |
def _verify(certificate_or_public_key, signature, data, hash_algorithm):
"""
Verifies an RSA, DSA or ECDSA signature
:param certificate_or_public_key:
A Certificate or PublicKey instance to verify the signature with
:param signature:
A byte string of the signature to verify
:param... |
def rsa_pss_sign(private_key, data, hash_algorithm):
"""
Generates an RSASSA-PSS signature. For the PSS padding the mask gen
algorithm will be mgf1 using the same hash algorithm as the signature. The
salt length with be the length of the hash algorithm, and the trailer field
with be the standard 0xB... |
def _sign(private_key, data, hash_algorithm):
"""
Generates an RSA, DSA or ECDSA signature
:param private_key:
The PrivateKey to generate the signature with
:param data:
A byte string of the data the signature is for
:param hash_algorithm:
A unicode string of "md5", "sha1"... |
def public_key(self):
"""
:return:
The PublicKey object for the public key this certificate contains
"""
if not self._public_key and self.sec_certificate_ref:
sec_public_key_ref_pointer = new(Security, 'SecKeyRef *')
res = Security.SecCertificateCopyP... |
def backend():
"""
:return:
A unicode string of the backend being used: "openssl", "osx", "win",
"winlegacy"
"""
if _module_values['backend'] is not None:
return _module_values['backend']
with _backend_lock:
if _module_values['backend'] is not None:
retu... |
def use_openssl(libcrypto_path, libssl_path, trust_list_path=None):
"""
Forces using OpenSSL dynamic libraries on OS X (.dylib) or Windows (.dll),
or using a specific dynamic library on Linux/BSD (.so).
This can also be used to configure oscrypto to use LibreSSL dynamic
libraries.
This method ... |
def use_winlegacy():
"""
Forces use of the legacy Windows CryptoAPI. This should only be used on
Windows XP or for testing. It is less full-featured than the Cryptography
Next Generation (CNG) API, and as a result the elliptic curve and PSS
padding features are implemented in pure Python. This isn't... |
def pkcs12_kdf(hash_algorithm, password, salt, iterations, key_length, id_):
"""
KDF from RFC7292 appendix b.2 - https://tools.ietf.org/html/rfc7292#page-19
:param hash_algorithm:
The string name of the hash algorithm to use: "md5", "sha1", "sha224",
"sha256", "sha384", "sha512"
:param... |
def pbkdf2_iteration_calculator(hash_algorithm, key_length, target_ms=100, quiet=False):
"""
Runs pbkdf2() twice to determine the approximate number of iterations to
use to hit a desired time per run. Use this on a production machine to
dynamically adjust the number of iterations as high as you can.
... |
def pbkdf1(hash_algorithm, password, salt, iterations, key_length):
"""
An implementation of PBKDF1 - should only be used for interop with legacy
systems, not new architectures
:param hash_algorithm:
The string name of the hash algorithm to use: "md2", "md5", "sha1"
:param password:
... |
def handle_error(result):
"""
Extracts the last Windows error message into a python unicode string
:param result:
A function result, 0 or None indicates failure
:return:
A unicode string error message
"""
if result:
return
code, error_string = get_error()
if ... |
def aes_cbc_no_padding_encrypt(key, data, iv):
"""
Encrypts plaintext using AES in CBC mode with a 128, 192 or 256 bit key and
no padding. This means the ciphertext must be an exact multiple of 16 bytes
long.
:param key:
The encryption key - a byte string either 16, 24 or 32 bytes long
... |
def aes_cbc_no_padding_decrypt(key, data, iv):
"""
Decrypts AES ciphertext in CBC mode using a 128, 192 or 256 bit key and no
padding.
:param key:
The encryption key - a byte string either 16, 24 or 32 bytes long
:param data:
The ciphertext - a byte string
:param iv:
T... |
def aes_cbc_pkcs7_encrypt(key, data, iv):
"""
Encrypts plaintext using AES in CBC mode with a 128, 192 or 256 bit key and
PKCS#7 padding.
:param key:
The encryption key - a byte string either 16, 24 or 32 bytes long
:param data:
The plaintext - a byte string
:param iv:
... |
def aes_cbc_pkcs7_decrypt(key, data, iv):
"""
Decrypts AES ciphertext in CBC mode using a 128, 192 or 256 bit key
:param key:
The encryption key - a byte string either 16, 24 or 32 bytes long
:param data:
The ciphertext - a byte string
:param iv:
The initialization vector ... |
def rc4_encrypt(key, data):
"""
Encrypts plaintext using RC4 with a 40-128 bit key
:param key:
The encryption key - a byte string 5-16 bytes long
:param data:
The plaintext - a byte string
:raises:
ValueError - when any of the parameters contain an invalid value
Ty... |
def rc4_decrypt(key, data):
"""
Decrypts RC4 ciphertext using a 40-128 bit key
:param key:
The encryption key - a byte string 5-16 bytes long
:param data:
The ciphertext - a byte string
:raises:
ValueError - when any of the parameters contain an invalid value
TypeE... |
def rc2_cbc_pkcs5_encrypt(key, data, iv):
"""
Encrypts plaintext using RC2 with a 64 bit key
:param key:
The encryption key - a byte string 8 bytes long
:param data:
The plaintext - a byte string
:param iv:
The 8-byte initialization vector to use - a byte string - set as N... |
def rc2_cbc_pkcs5_decrypt(key, data, iv):
"""
Decrypts RC2 ciphertext using a 64 bit key
:param key:
The encryption key - a byte string 8 bytes long
:param data:
The ciphertext - a byte string
:param iv:
The initialization vector used for encryption - a byte string
:r... |
def tripledes_cbc_pkcs5_encrypt(key, data, iv):
"""
Encrypts plaintext using 3DES in either 2 or 3 key mode
:param key:
The encryption key - a byte string 16 or 24 bytes long (2 or 3 key mode)
:param data:
The plaintext - a byte string
:param iv:
The 8-byte initialization ... |
def tripledes_cbc_pkcs5_decrypt(key, data, iv):
"""
Decrypts 3DES ciphertext in either 2 or 3 key mode
:param key:
The encryption key - a byte string 16 or 24 bytes long (2 or 3 key mode)
:param data:
The ciphertext - a byte string
:param iv:
The initialization vector used... |
def des_cbc_pkcs5_encrypt(key, data, iv):
"""
Encrypts plaintext using DES with a 56 bit key
:param key:
The encryption key - a byte string 8 bytes long (includes error correction bits)
:param data:
The plaintext - a byte string
:param iv:
The 8-byte initialization vector ... |
def des_cbc_pkcs5_decrypt(key, data, iv):
"""
Decrypts DES ciphertext using a 56 bit key
:param key:
The encryption key - a byte string 8 bytes long (includes error correction bits)
:param data:
The ciphertext - a byte string
:param iv:
The initialization vector used for e... |
def _encrypt(cipher, key, data, iv, padding):
"""
Encrypts plaintext
:param cipher:
A kSecAttrKeyType* value that specifies the cipher to use
:param key:
The encryption key - a byte string 5-16 bytes long
:param data:
The plaintext - a byte string
:param iv:
T... |
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 |
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
... |
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 {
... |
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... |
def _get(self, route, headers=None, failure_message=None):
"""
Execute a post request and return the result
:param headers:
:return:
"""
headers = self._get_headers(headers)
response_lambda = (
lambda: requests.get(self._get_qualified_route(route), hea... |
def _post(self, route, data, headers=None, failure_message=None):
"""
Execute a post request and return the result
:param data:
:param headers:
:return:
"""
headers = self._get_headers(headers)
response_lambda = (
lambda: requests.post(
... |
def _put(self, route, data, headers=None, failure_message=None):
"""
Execute a put request and return the result
:param data:
:param headers:
:return:
"""
headers = self._get_headers(headers)
response_lambda = (
lambda: requests.put(
... |
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,... |
def _delete(self, route, headers=None, failure_message=None):
"""
Execute a delete request and return the result
:param headers:
:return:
"""
headers = self._get_headers(headers)
response_lambda = (lambda: requests.delete(
self._get_qualified_route(rou... |
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`
... |
def pif_search(self, pif_system_returning_query):
"""
Run a PIF query against Citrination.
:param pif_system_returning_query: The PIF system query to execute.
:type pif_system_returning_query: :class:`PifSystemReturningQuery`
:return: :class:`PifSearchResult` object with the res... |
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... |
def _execute_search_query(self, returning_query, result_class):
"""
Run a PIF query against Citrination.
:param returning_query: :class:`BaseReturningQuery` to execute.
:param result_class: The class of the result to return.
:return: ``result_class`` object with the results of t... |
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 ... |
def generate_simple_chemical_query(self, name=None, chemical_formula=None, property_name=None, property_value=None,
property_min=None, property_max=None, property_units=None, reference_doi=None,
include_datasets=[], exclude_datasets=[], from_... |
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... |
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... |
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 ... |
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... |
def get_data_view_service_status(self, data_view_id):
"""
Retrieves the status for all of the services associated with a data view:
- predict
- experimental_design
- data_reports
- model_reports
:param data_view_id: The ID number of the data view ... |
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... |
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... |
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... |
def __snake_case(self, descriptor):
"""
Utility method to convert camelcase to snake
:param descriptor: The dictionary to convert
"""
newdict = {}
for i, (k, v) in enumerate(descriptor.items()):
newkey = ""
for j, c in enumerate(k):
... |
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
"""
... |
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... |
def predict(self, data_view_id, candidates, method="scalar", use_prior=True):
"""
Predict endpoint. This simply wraps the async methods (submit and poll for status/results).
:param data_view_id: The ID of the data view to use for prediction
:type data_view_id: str
:param candida... |
def retrain(self, dataview_id):
"""
Start a model retraining
:param dataview_id: The ID of the views
:return:
"""
url = 'data_views/{}/retrain'.format(dataview_id)
response = self._post_json(url, data={})
if response.status_code != requests.codes.ok:
... |
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 = "... |
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_... |
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... |
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
... |
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 ... |
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 ... |
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
... |
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
... |
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 |
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... |
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... |
def upload(self, dataset_id, source_path, dest_path=None):
"""
Upload a file, specifying source and dest paths a file (acts as the scp command).asdfasdf
:param source_path: The path to the file on the source host asdf
:type source_path: str
:param dest_path: The path to the file... |
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.
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.