_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q270600 | ProtocolVersion.read | test | def read(self, input_stream, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Read the data encoding the ProtocolVersion struct and decode it into
its constituent parts.
Args:
input_stream (stream): A data stream containing encoded object
data, supporting a read... | python | {
"resource": ""
} |
q270601 | ProtocolVersion.write | test | def write(self, output_stream, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Write the data encoding the ProtocolVersion struct to a stream.
Args:
output_stream (stream): A data stream in which to encode object
data, supporting a write method; usually a BytearrayStre... | python | {
"resource": ""
} |
q270602 | Authentication.read | test | def read(self, input_stream, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Read the data encoding the Authentication struct and decode it into
its constituent parts.
Args:
input_stream (stream): A data stream containing encoded object
data, supporting a read ... | python | {
"resource": ""
} |
q270603 | Authentication.write | test | def write(self, output_stream, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Write the data encoding the Authentication struct to a stream.
Args:
output_stream (stream): A data stream in which to encode object
data, supporting a write method; usually a BytearrayStrea... | python | {
"resource": ""
} |
q270604 | PollRequestPayload.read | test | def read(self, input_stream, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Read the data encoding the Poll request payload and decode it into
its constituent parts.
Args:
input_stream (stream): A data stream containing encoded object
data, supporting a read m... | python | {
"resource": ""
} |
q270605 | Certificate.read | test | def read(self, istream, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Read the data encoding the Certificate object and decode it into its
constituent parts.
Args:
istream (Stream): A data stream containing encoded object data,
supporting a read method; usual... | python | {
"resource": ""
} |
q270606 | Certificate.write | test | def write(self, ostream, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Write the data encoding the Certificate object to a stream.
Args:
ostream (Stream): A data stream in which to encode object data,
supporting a write method; usually a BytearrayStream object.
... | python | {
"resource": ""
} |
q270607 | SLUGSConnector.authenticate | test | def authenticate(self,
connection_certificate=None,
connection_info=None,
request_credentials=None):
"""
Query the configured SLUGS service with the provided credentials.
Args:
connection_certificate (cryptography.x509.C... | python | {
"resource": ""
} |
q270608 | ArchiveResponsePayload.read | test | def read(self, input_stream, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Read the data encoding the Archive response payload and decode it
into its constituent parts.
Args:
input_stream (stream): A data stream containing encoded object
data, supporting a re... | python | {
"resource": ""
} |
q270609 | ArchiveResponsePayload.write | test | def write(self, output_stream, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Write the data encoding the Archive response payload to a stream.
Args:
output_stream (stream): A data stream in which to encode object
data, supporting a write method; usually a BytearraySt... | python | {
"resource": ""
} |
q270610 | KmipSession.run | test | def run(self):
"""
The main thread routine executed by invoking thread.start.
This method manages the new client connection, running a message
handling loop. Once this method completes, the thread is finished.
"""
self._logger.info("Starting session: {0}".format(self.nam... | python | {
"resource": ""
} |
q270611 | RekeyResponsePayload.read | test | def read(self, input_stream, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Read the data encoding the Rekey response payload and decode it into
its constituent parts.
Args:
input_stream (stream): A data stream containing encoded object
data, supporting a read... | python | {
"resource": ""
} |
q270612 | KMIPProxy.is_profile_supported | test | def is_profile_supported(self, conformance_clause, authentication_suite):
"""
Check if a profile is supported by the client.
Args:
conformance_clause (ConformanceClause):
authentication_suite (AuthenticationSuite):
Returns:
bool: True if the profile ... | python | {
"resource": ""
} |
q270613 | KMIPProxy.derive_key | test | def derive_key(self,
object_type,
unique_identifiers,
derivation_method,
derivation_parameters,
template_attribute,
credential=None):
"""
Derive a new key or secret data from an existing man... | python | {
"resource": ""
} |
q270614 | KMIPProxy.get_attributes | test | def get_attributes(self, uuid=None, attribute_names=None):
"""
Send a GetAttributes request to the server.
Args:
uuid (string): The ID of the managed object with which the
retrieved attributes should be associated. Optional, defaults
to None.
... | python | {
"resource": ""
} |
q270615 | KMIPProxy.get_attribute_list | test | def get_attribute_list(self, uid=None):
"""
Send a GetAttributeList request to the server.
Args:
uid (string): The ID of the managed object with which the retrieved
attribute names should be associated.
Returns:
result (GetAttributeListResult): A... | python | {
"resource": ""
} |
q270616 | KMIPProxy.query | test | def query(self, batch=False, query_functions=None, credential=None):
"""
Send a Query request to the server.
Args:
batch (boolean): A flag indicating if the operation should be sent
with a batch of additional operations. Defaults to False.
query_functions... | python | {
"resource": ""
} |
q270617 | KMIPProxy.sign | test | def sign(self, data, unique_identifier=None,
cryptographic_parameters=None, credential=None):
"""
Sign specified data using a specified signing key.
Args:
data (bytes): Data to be signed. Required.
unique_identifier (string): The unique ID of the signing
... | python | {
"resource": ""
} |
q270618 | ProxyKmipClient.open | test | def open(self):
"""
Open the client connection.
Raises:
ClientConnectionFailure: if the client connection is already open
Exception: if an error occurs while trying to open the connection
"""
if self._is_open:
raise exceptions.ClientConnection... | python | {
"resource": ""
} |
q270619 | ProxyKmipClient.close | test | def close(self):
"""
Close the client connection.
Raises:
Exception: if an error occurs while trying to close the connection
"""
if not self._is_open:
return
else:
try:
self.proxy.close()
self._is_open =... | python | {
"resource": ""
} |
q270620 | ProxyKmipClient.create | test | def create(self, algorithm, length, operation_policy_name=None, name=None,
cryptographic_usage_mask=None):
"""
Create a symmetric key on a KMIP appliance.
Args:
algorithm (CryptographicAlgorithm): An enumeration defining the
algorithm to use to generat... | python | {
"resource": ""
} |
q270621 | ProxyKmipClient.create_key_pair | test | def create_key_pair(self,
algorithm,
length,
operation_policy_name=None,
public_name=None,
public_usage_mask=None,
private_name=None,
private_usage_mask... | python | {
"resource": ""
} |
q270622 | ProxyKmipClient.register | test | def register(self, managed_object):
"""
Register a managed object with a KMIP appliance.
Args:
managed_object (ManagedObject): A managed object to register. An
instantiatable subclass of ManagedObject from the Pie API.
Returns:
string: The uid of... | python | {
"resource": ""
} |
q270623 | ProxyKmipClient.rekey | test | def rekey(self,
uid=None,
offset=None,
**kwargs):
"""
Rekey an existing key.
Args:
uid (string): The unique ID of the symmetric key to rekey.
Optional, defaults to None.
offset (int): The time delta, in seconds, b... | python | {
"resource": ""
} |
q270624 | ProxyKmipClient.derive_key | test | def derive_key(self,
object_type,
unique_identifiers,
derivation_method,
derivation_parameters,
**kwargs):
"""
Derive a new key or secret data from existing managed objects.
Args:
object_t... | python | {
"resource": ""
} |
q270625 | ProxyKmipClient.locate | test | def locate(self, maximum_items=None, storage_status_mask=None,
object_group_member=None, attributes=None):
"""
Search for managed objects, depending on the attributes specified in
the request.
Args:
maximum_items (integer): Maximum number of object identifiers... | python | {
"resource": ""
} |
q270626 | ProxyKmipClient.check | test | def check(self,
uid=None,
usage_limits_count=None,
cryptographic_usage_mask=None,
lease_time=None):
"""
Check the constraints for a managed object.
Args:
uid (string): The unique ID of the managed object to check.
... | python | {
"resource": ""
} |
q270627 | ProxyKmipClient.get | test | def get(self, uid=None, key_wrapping_specification=None):
"""
Get a managed object from a KMIP appliance.
Args:
uid (string): The unique ID of the managed object to retrieve.
key_wrapping_specification (dict): A dictionary containing various
settings to b... | python | {
"resource": ""
} |
q270628 | ProxyKmipClient.get_attributes | test | def get_attributes(self, uid=None, attribute_names=None):
"""
Get the attributes associated with a managed object.
If the uid is not specified, the appliance will use the ID placeholder
by default.
If the attribute_names list is not specified, the appliance will
return ... | python | {
"resource": ""
} |
q270629 | ProxyKmipClient.activate | test | def activate(self, uid=None):
"""
Activate a managed object stored by a KMIP appliance.
Args:
uid (string): The unique ID of the managed object to activate.
Optional, defaults to None.
Returns:
None
Raises:
ClientConnectionNo... | python | {
"resource": ""
} |
q270630 | ProxyKmipClient.revoke | test | def revoke(self, revocation_reason, uid=None, revocation_message=None,
compromise_occurrence_date=None):
"""
Revoke a managed object stored by a KMIP appliance.
Args:
revocation_reason (RevocationReasonCode): An enumeration indicating
the revocation re... | python | {
"resource": ""
} |
q270631 | ProxyKmipClient.mac | test | def mac(self, data, uid=None, algorithm=None):
"""
Get the message authentication code for data.
Args:
data (string): The data to be MACed.
uid (string): The unique ID of the managed object that is the key
to use for the MAC operation.
algorit... | python | {
"resource": ""
} |
q270632 | ProxyKmipClient._build_cryptographic_parameters | test | def _build_cryptographic_parameters(self, value):
"""
Build a CryptographicParameters struct from a dictionary.
Args:
value (dict): A dictionary containing the key/value pairs for a
CryptographicParameters struct.
Returns:
None: if value is None
... | python | {
"resource": ""
} |
q270633 | ProxyKmipClient._build_encryption_key_information | test | def _build_encryption_key_information(self, value):
"""
Build an EncryptionKeyInformation struct from a dictionary.
Args:
value (dict): A dictionary containing the key/value pairs for a
EncryptionKeyInformation struct.
Returns:
EncryptionKeyInfor... | python | {
"resource": ""
} |
q270634 | ProxyKmipClient._build_mac_signature_key_information | test | def _build_mac_signature_key_information(self, value):
"""
Build an MACSignatureKeyInformation struct from a dictionary.
Args:
value (dict): A dictionary containing the key/value pairs for a
MACSignatureKeyInformation struct.
Returns:
MACSignatur... | python | {
"resource": ""
} |
q270635 | ProxyKmipClient._build_key_wrapping_specification | test | def _build_key_wrapping_specification(self, value):
"""
Build a KeyWrappingSpecification struct from a dictionary.
Args:
value (dict): A dictionary containing the key/value pairs for a
KeyWrappingSpecification struct.
Returns:
KeyWrappingSpecific... | python | {
"resource": ""
} |
q270636 | ProxyKmipClient._build_common_attributes | test | def _build_common_attributes(self, operation_policy_name=None):
'''
Build a list of common attributes that are shared across
symmetric as well as asymmetric objects
'''
common_attributes = []
if operation_policy_name:
common_attributes.append(
... | python | {
"resource": ""
} |
q270637 | ProxyKmipClient._build_name_attribute | test | def _build_name_attribute(self, name=None):
'''
Build a name attribute, returned in a list for ease
of use in the caller
'''
name_list = []
if name:
name_list.append(self.attribute_factory.create_attribute(
enums.AttributeType.NAME,
... | python | {
"resource": ""
} |
q270638 | QueryRequestPayload.read | test | def read(self, input_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Read the data encoding the QueryRequestPayload object and decode it
into its constituent parts.
Args:
input_buffer (Stream): A data stream containing encoded object
data, supporting a ... | python | {
"resource": ""
} |
q270639 | QueryRequestPayload.write | test | def write(self, output_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Write the data encoding the QueryRequestPayload object to a stream.
Args:
output_buffer (Stream): A data stream in which to encode object
data, supporting a write method; usually a Bytearray... | python | {
"resource": ""
} |
q270640 | QueryResponsePayload.write | test | def write(self, output_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Write the data encoding the QueryResponsePayload object to a stream.
Args:
output_buffer (Stream): A data stream in which to encode object
data, supporting a write method; usually a Bytearra... | python | {
"resource": ""
} |
q270641 | GetAttributesResponsePayload.read | test | def read(self, input_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Read the data encoding the GetAttributes response payload and decode
it into its constituent parts.
Args:
input_buffer (stream): A data stream containing encoded object
data, supportin... | python | {
"resource": ""
} |
q270642 | GetAttributesResponsePayload.write | test | def write(self, output_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Write the data encoding the GetAttributes response payload to a
stream.
Args:
output_buffer (stream): A data stream in which to encode object
data, supporting a write method; usually... | python | {
"resource": ""
} |
q270643 | get_single | test | def get_single(group, name, path=None):
"""Find a single entry point.
Returns an :class:`EntryPoint` object, or raises :exc:`NoSuchEntryPoint`
if no match is found.
"""
for config, distro in iter_files_distros(path=path):
if (group in config) and (name in config[group]):
epstr =... | python | {
"resource": ""
} |
q270644 | get_group_named | test | def get_group_named(group, path=None):
"""Find a group of entry points with unique names.
Returns a dictionary of names to :class:`EntryPoint` objects.
"""
result = {}
for ep in get_group_all(group, path=path):
if ep.name not in result:
result[ep.name] = ep
return result | python | {
"resource": ""
} |
q270645 | get_group_all | test | def get_group_all(group, path=None):
"""Find all entry points in a group.
Returns a list of :class:`EntryPoint` objects.
"""
result = []
for config, distro in iter_files_distros(path=path):
if group in config:
for name, epstr in config[group].items():
with BadEnt... | python | {
"resource": ""
} |
q270646 | EntryPoint.load | test | def load(self):
"""Load the object to which this entry point refers.
"""
mod = import_module(self.module_name)
obj = mod
if self.object_name:
for attr in self.object_name.split('.'):
obj = getattr(obj, attr)
return obj | python | {
"resource": ""
} |
q270647 | EntryPoint.from_string | test | def from_string(cls, epstr, name, distro=None):
"""Parse an entry point from the syntax in entry_points.txt
:param str epstr: The entry point string (not including 'name =')
:param str name: The name of this entry point
:param Distribution distro: The distribution in which the entry poi... | python | {
"resource": ""
} |
q270648 | live | test | def live():
"""Run livereload server"""
from livereload import Server
server = Server(app)
map(server.watch, glob2.glob("application/pages/**/*.*")) # pages
map(server.watch, glob2.glob("application/macros/**/*.html")) # macros
map(server.watch, glob2.glob("application/static/**/*.*")) # pu... | python | {
"resource": ""
} |
q270649 | generate_project | test | def generate_project(args):
"""New project."""
# Project templates path
src = os.path.join(dirname(abspath(__file__)), 'project')
project_name = args.get('<project>')
if not project_name:
logger.warning('Project name cannot be empty.')
return
# Destination project path
dst... | python | {
"resource": ""
} |
q270650 | generate_controller | test | def generate_controller(args):
"""Generate controller, include the controller file, template & css & js directories."""
controller_template = os.path.join(dirname(abspath(__file__)), 'templates/controller.py')
test_template = os.path.join(dirname(abspath(__file__)), 'templates/unittest.py')
controller_n... | python | {
"resource": ""
} |
q270651 | generate_action | test | def generate_action(args):
"""Generate action."""
controller = args.get('<controller>')
action = args.get('<action>')
with_template = args.get('-t')
current_path = os.getcwd()
logger.info('Start generating action.')
controller_file_path = os.path.join(current_path, 'application/controllers... | python | {
"resource": ""
} |
q270652 | generate_form | test | def generate_form(args):
"""Generate form."""
form_name = args.get('<form>')
logger.info('Start generating form.')
_generate_form(form_name)
logger.info('Finish generating form.') | python | {
"resource": ""
} |
q270653 | generate_model | test | def generate_model(args):
"""Generate model."""
model_name = args.get('<model>')
if not model_name:
logger.warning('Model name cannot be empty.')
return
logger.info('Start generating model.')
model_template = os.path.join(dirname(abspath(__file__)), 'templates/model.py')
curren... | python | {
"resource": ""
} |
q270654 | generate_macro | test | def generate_macro(args):
"""Genarate macro."""
macro = args.get('<macro>').replace('-', '_')
category = args.get('<category>')
if not macro:
logger.warning('Macro name cannot be empty.')
return
logger.info('Start generating macro.')
current_path = os.getcwd()
if category... | python | {
"resource": ""
} |
q270655 | _mkdir_p | test | def _mkdir_p(path):
"""mkdir -p path"""
try:
os.makedirs(path)
except OSError as exc:
if exc.errno == errno.EEXIST and os.path.isdir(path):
pass
else:
raise
else:
logger.info("New: %s%s", path, os.path.sep) | python | {
"resource": ""
} |
q270656 | _rewrite_and_copy | test | def _rewrite_and_copy(src_file, dst_file, project_name):
"""Replace vars and copy."""
# Create temp file
fh, abs_path = mkstemp()
with io.open(abs_path, 'w', encoding='utf-8') as new_file:
with io.open(src_file, 'r', encoding='utf-8') as old_file:
for line in old_file:
... | python | {
"resource": ""
} |
q270657 | timesince | test | def timesince(value):
"""Friendly time gap"""
if not value:
return ""
if not isinstance(value, datetime.date):
return value
now = datetime.datetime.now()
delta = now - value
if value > now:
return "right now"
elif delta.days > 365:
return '%d years ago' % (... | python | {
"resource": ""
} |
q270658 | check_url | test | def check_url(form, field):
"""Check url schema."""
url = field.data.strip()
if not url:
return
result = urlparse(url)
if result.scheme == "":
field.data = "http://%s" % re.sub(r'^:?/*', '', url) | python | {
"resource": ""
} |
q270659 | encode | test | def encode(something):
"""Encode something with SECRET_KEY."""
secret_key = current_app.config.get('SECRET_KEY')
s = URLSafeSerializer(secret_key)
return s.dumps(something) | python | {
"resource": ""
} |
q270660 | decode | test | def decode(something):
"""Decode something with SECRET_KEY."""
secret_key = current_app.config.get('SECRET_KEY')
s = URLSafeSerializer(secret_key)
try:
return s.loads(something)
except BadSignature:
return None | python | {
"resource": ""
} |
q270661 | jsonify | test | def jsonify(func):
"""JSON decorator."""
@functools.wraps(func)
def wrapper(*args, **kwargs):
r = func(*args, **kwargs)
if isinstance(r, tuple):
code, data = r
else:
code, data = 200, r
return Response(json.dumps(data), status=code, mimetype='applicat... | python | {
"resource": ""
} |
q270662 | absolute_url_for | test | def absolute_url_for(endpoint, **values):
"""Absolute url for endpoint."""
config = current_app.config
site_domain = config.get('SITE_DOMAIN')
relative_url = url_for(endpoint, **values)
return join_url(site_domain, relative_url) | python | {
"resource": ""
} |
q270663 | load_config | test | def load_config():
"""Load config."""
mode = os.environ.get('MODE')
try:
if mode == 'PRODUCTION':
from .production import ProductionConfig
return ProductionConfig
elif mode == 'TESTING':
from .testing import TestingConfig
return TestingConfig
... | python | {
"resource": ""
} |
q270664 | signin_user | test | def signin_user(user, permenent=True):
"""Sign in user."""
session.permanent = permenent
session['user_id'] = user.id | python | {
"resource": ""
} |
q270665 | get_current_user | test | def get_current_user():
"""Get current user."""
if not 'user_id' in session:
return None
user = User.query.filter(User.id == session['user_id']).first()
if not user:
signout_user()
return None
return user | python | {
"resource": ""
} |
q270666 | create_app | test | def create_app():
"""Create Flask app."""
config = load_config()
app = Flask(__name__)
app.config.from_object(config)
# Proxy fix
app.wsgi_app = ProxyFix(app.wsgi_app)
# CSRF protect
CsrfProtect(app)
if app.debug or app.testing:
DebugToolbarExtension(app)
# Serve... | python | {
"resource": ""
} |
q270667 | register_jinja | test | def register_jinja(app):
"""Register jinja filters, vars, functions."""
import jinja2
from .utils import filters, permissions, helpers
if app.debug or app.testing:
my_loader = jinja2.ChoiceLoader([
app.jinja_loader,
jinja2.FileSystemLoader([
os.path.join(... | python | {
"resource": ""
} |
q270668 | register_routes | test | def register_routes(app):
"""Register routes."""
from . import controllers
from flask.blueprints import Blueprint
for module in _import_submodules_from_package(controllers):
bp = getattr(module, 'bp')
if bp and isinstance(bp, Blueprint):
app.register_blueprint(bp) | python | {
"resource": ""
} |
q270669 | register_error_handle | test | def register_error_handle(app):
"""Register HTTP error pages."""
@app.errorhandler(403)
def page_403(error):
return render_template('site/403/403.html'), 403
@app.errorhandler(404)
def page_404(error):
return render_template('site/404/404.html'), 404
@app.errorhandler(500)
... | python | {
"resource": ""
} |
q270670 | register_hooks | test | def register_hooks(app):
"""Register hooks."""
@app.before_request
def before_request():
g.user = get_current_user()
if g.user and g.user.is_admin:
g._before_request_time = time.time()
@app.after_request
def after_request(response):
if hasattr(g, '_before_reques... | python | {
"resource": ""
} |
q270671 | _dataframe_to_csv | test | def _dataframe_to_csv(writer, dataframe, delimiter, with_header):
"""serialize the dataframe with different delimiters"""
encoding_writer = codecs.getwriter('utf-8')(writer)
dataframe.to_csv(
path_or_buf=encoding_writer,
sep=delimiter,
header=with_header,
index=False
) | python | {
"resource": ""
} |
q270672 | _dataframe_from_csv | test | def _dataframe_from_csv(reader, delimiter, with_header, skipspace):
"""Returns csv data as a pandas Dataframe object"""
sep = delimiter
header = 0
if not with_header:
header = None
return pd.read_csv(
reader,
header=header,
sep=sep,
skipinitialspace=skipspace... | python | {
"resource": ""
} |
q270673 | serialize_dataframe | test | def serialize_dataframe(writer, data_type_id, dataframe):
"""
Serialize a dataframe.
Parameters
----------
writer : file
File-like object to write to. Must be opened in binary mode.
data_type_id : dict
Serialization format to use.
See the azureml.DataTypeIds class for co... | python | {
"resource": ""
} |
q270674 | deserialize_dataframe | test | def deserialize_dataframe(reader, data_type_id):
"""
Deserialize a dataframe.
Parameters
----------
reader : file
File-like object to read from. Must be opened in binary mode.
data_type_id : dict
Serialization format of the raw data.
See the azureml.DataTypeIds class for... | python | {
"resource": ""
} |
q270675 | SourceDataset._update_from_dataframe | test | def _update_from_dataframe(self, dataframe, data_type_id=None, name=None,
description=None):
"""
Serialize the specified DataFrame and replace the existing dataset.
Parameters
----------
dataframe : pandas.DataFrame
Data to serialize.
... | python | {
"resource": ""
} |
q270676 | SourceDataset._update_from_raw_data | test | def _update_from_raw_data(self, raw_data, data_type_id=None, name=None,
description=None):
"""
Upload already serialized raw data and replace the existing dataset.
Parameters
----------
raw_data: bytes
Dataset contents to upload.
... | python | {
"resource": ""
} |
q270677 | SourceDataset.contents_url | test | def contents_url(self):
"""Full URL to the dataset contents."""
loc = self.download_location
return loc.base_uri + loc.location + loc.access_credential | python | {
"resource": ""
} |
q270678 | Datasets.add_from_dataframe | test | def add_from_dataframe(self, dataframe, data_type_id, name, description):
"""
Serialize the specified DataFrame and upload it as a new dataset.
Parameters
----------
dataframe : pandas.DataFrame
Data to serialize.
data_type_id : str
Format to seri... | python | {
"resource": ""
} |
q270679 | Datasets.add_from_raw_data | test | def add_from_raw_data(self, raw_data, data_type_id, name, description):
"""
Upload already serialized raw data as a new dataset.
Parameters
----------
raw_data: bytes
Dataset contents to upload.
data_type_id : str
Serialization format of the raw d... | python | {
"resource": ""
} |
q270680 | IntermediateDataset.open | test | def open(self):
'''Open and return a stream for the dataset contents.'''
return self.workspace._rest.open_intermediate_dataset_contents(
self.workspace.workspace_id,
self.experiment.experiment_id,
self.node_id,
self.port_name
) | python | {
"resource": ""
} |
q270681 | IntermediateDataset.read_as_binary | test | def read_as_binary(self):
'''Read and return the dataset contents as binary.'''
return self.workspace._rest.read_intermediate_dataset_contents_binary(
self.workspace.workspace_id,
self.experiment.experiment_id,
self.node_id,
self.port_name
) | python | {
"resource": ""
} |
q270682 | IntermediateDataset.read_as_text | test | def read_as_text(self):
'''Read and return the dataset contents as text.'''
return self.workspace._rest.read_intermediate_dataset_contents_text(
self.workspace.workspace_id,
self.experiment.experiment_id,
self.node_id,
self.port_name
) | python | {
"resource": ""
} |
q270683 | IntermediateDataset._to_dataframe | test | def _to_dataframe(self):
"""Read and return the dataset contents as a pandas DataFrame."""
#TODO: figure out why passing in the opened stream directly gives invalid data
data = self.read_as_binary()
reader = BytesIO(data)
return deserialize_dataframe(reader, self.data_type_id) | python | {
"resource": ""
} |
q270684 | Experiment.get_intermediate_dataset | test | def get_intermediate_dataset(self, node_id, port_name, data_type_id):
"""
Get an intermediate dataset.
Parameters
----------
node_id : str
Module node id from the experiment graph.
port_name : str
Output port of the module.
data_type_id : ... | python | {
"resource": ""
} |
q270685 | _RestClient.get_experiments | test | def get_experiments(self, workspace_id):
"""Runs HTTP GET request to retrieve the list of experiments."""
api_path = self.EXPERIMENTS_URI_FMT.format(workspace_id)
return self._send_get_req(api_path) | python | {
"resource": ""
} |
q270686 | _RestClient.get_datasets | test | def get_datasets(self, workspace_id):
"""Runs HTTP GET request to retrieve the list of datasets."""
api_path = self.DATASOURCES_URI_FMT.format(workspace_id)
return self._send_get_req(api_path) | python | {
"resource": ""
} |
q270687 | _RestClient.get_dataset | test | def get_dataset(self, workspace_id, dataset_id):
"""Runs HTTP GET request to retrieve a single dataset."""
api_path = self.DATASOURCE_URI_FMT.format(workspace_id, dataset_id)
return self._send_get_req(api_path) | python | {
"resource": ""
} |
q270688 | publish | test | def publish(func_or_workspace_id, workspace_id_or_token = None, workspace_token_or_none = None, files=(), endpoint=None):
'''publishes a callable function or decorates a function to be published.
Returns a callable, iterable object. Calling the object will invoke the published service.
Iterating the object will... | python | {
"resource": ""
} |
q270689 | service | test | def service(url, api_key, help_url = None):
'''Marks a function as having been published and causes all invocations to go to the remote
operationalized service.
>>> @service(url, api_key)
>>> def f(a, b):
>>> pass
'''
def do_publish(func):
return published(url, api_key, help_url, func, None)
re... | python | {
"resource": ""
} |
q270690 | types | test | def types(**args):
"""Specifies the types used for the arguments of a published service.
@types(a=int, b = str)
def f(a, b):
pass
"""
def l(func):
if hasattr(func, '__annotations__'):
func.__annotations__.update(args)
else:
func.__annotations__ = args
return ... | python | {
"resource": ""
} |
q270691 | returns | test | def returns(type):
"""Specifies the return type for a published service.
@returns(int)
def f(...):
pass
"""
def l(func):
if hasattr(func, '__annotations__'):
func.__annotations__['return'] = type
else:
func.__annotations__ = {'return': type}
return func
r... | python | {
"resource": ""
} |
q270692 | attach | test | def attach(name, contents = None):
"""attaches a file to the payload to be uploaded.
If contents is omitted the file is read from disk.
If name is a tuple it specifies the on-disk filename and the destination filename.
"""
def do_attach(func):
if hasattr(func, '__attachments__'):
func.__att... | python | {
"resource": ""
} |
q270693 | _Serializer.find_globals | test | def find_globals(code):
"""walks the byte code to find the variables which are actually globals"""
cur_byte = 0
byte_code = code.co_code
names = set()
while cur_byte < len(byte_code):
op = ord(byte_code[cur_byte])
if op >= dis.HAVE_ARGUMENT:
... | python | {
"resource": ""
} |
q270694 | Pen.copy | test | def copy(self):
"""Create a copy of this pen."""
pen = Pen()
pen.__dict__ = self.__dict__.copy()
return pen | python | {
"resource": ""
} |
q270695 | lookup_color | test | def lookup_color(c):
"""Return RGBA values of color c
c should be either an X11 color or a brewer color set and index
e.g. "navajowhite", "greens3/2"
"""
import sys
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('PangoCairo', '1.0')
from gi.repository import Gdk
... | python | {
"resource": ""
} |
q270696 | Shape.draw | test | def draw(self, cr, highlight=False, bounding=None):
"""Draw this shape with the given cairo context"""
if bounding is None or self._intersects(bounding):
self._draw(cr, highlight, bounding) | python | {
"resource": ""
} |
q270697 | BezierShape._cubic_bernstein_extrema | test | def _cubic_bernstein_extrema(p0, p1, p2, p3):
"""
Find extremas of a function of real domain defined by evaluating
a cubic bernstein polynomial of given bernstein coefficients.
"""
# compute coefficients of derivative
a = 3.*(p3-p0+3.*(p1-p2))
b = 6.*(p0+p2-2.*p1)... | python | {
"resource": ""
} |
q270698 | BezierShape._cubic_bernstein | test | def _cubic_bernstein(p0, p1, p2, p3, t):
"""
Evaluate polynomial of given bernstein coefficients
using de Casteljau's algorithm.
"""
u = 1 - t
return p0*(u**3) + 3*t*u*(p1*u + p2*t) + p3*(t**3) | python | {
"resource": ""
} |
q270699 | TreeItemChoiceField._build_choices | test | def _build_choices(self):
"""Build choices list runtime using 'sitetree_tree' tag"""
tree_token = u'sitetree_tree from "%s" template "%s"' % (self.tree, self.template)
context_kwargs = {'current_app': 'admin'}
context = template.Context(context_kwargs) if VERSION >= (1, 8) else template... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.