Code stringlengths 103 85.9k | Summary listlengths 0 94 |
|---|---|
Please provide a description of the function:def read_data(self, offsets):
# type: (Descriptor, Offsets) -> Tuple[bytes, Offsets]
newoffset = None
if not self.local_path.use_stdin:
if offsets.num_bytes == 0:
return None, None
# compute start from ... | [
"Read data from file\n :param Descriptor self: this\n :param Offsets offsets: offsets\n :rtype: tuple\n :return: (file data bytes, new Offsets if stdin)\n "
] |
Please provide a description of the function:def generate_metadata(self):
# type: (Descriptor) -> dict
genmeta = {}
encmeta = {}
# page align md5
if (self.must_compute_md5 and
self._ase.mode == blobxfer.models.azure.StorageModes.Page):
aligned... | [
"Generate metadata for descriptor\n :param Descriptor self: this\n :rtype: dict or None\n :return: kv metadata dict\n "
] |
Please provide a description of the function:def add_cli_options(cli_options, action):
# type: (dict, str) -> None
cli_options['_action'] = action.name.lower()
# if url is present, convert to constituent options
if blobxfer.util.is_not_empty(cli_options.get('storage_url')):
if (blobxfer.uti... | [
"Adds CLI options to the configuration object\n :param dict cli_options: CLI options dict\n :param TransferAction action: action\n "
] |
Please provide a description of the function:def _merge_setting(cli_options, conf, name, name_cli=None, default=None):
# type: (dict, dict, str, str, Any) -> Any
val = cli_options.get(name_cli or name)
if val is None:
val = conf.get(name, default)
return val | [
"Merge a setting, preferring the CLI option if set\n :param dict cli_options: cli options\n :param dict conf: configuration sub-block\n :param str name: key name\n :param str name_cli: override key name for cli_options\n :param Any default: default value to set if missing\n :rtype: Any\n :retur... |
Please provide a description of the function:def merge_global_settings(config, cli_options):
# type: (dict, dict) -> None
# check for valid version from YAML
if (not blobxfer.util.is_none_or_empty(config) and
('version' not in config or
config['version'] not in _SUPPORTED_YAML_... | [
"Merge \"global\" CLI options into main config\n :param dict config: config dict\n :param dict cli_options: cli options\n "
] |
Please provide a description of the function:def create_azure_storage_credentials(config, general_options):
# type: (dict, blobxfer.models.options.General) ->
# blobxfer.operations.azure.StorageCredentials
creds = blobxfer.operations.azure.StorageCredentials(general_options)
endpoint = confi... | [
"Create an Azure StorageCredentials object from configuration\n :param dict config: config dict\n :param blobxfer.models.options.General: general options\n :rtype: blobxfer.operations.azure.StorageCredentials\n :return: credentials object\n "
] |
Please provide a description of the function:def create_general_options(config, action):
# type: (dict, TransferAction) -> blobxfer.models.options.General
conc = config['options']['concurrency']
# split http proxy host into host:port
proxy = None
if blobxfer.util.is_not_empty(config['options'][... | [
"Create a General Options object from configuration\n :param dict config: config dict\n :param TransferAction action: transfer action\n :rtype: blobxfer.models.options.General\n :return: general options object\n "
] |
Please provide a description of the function:def create_download_specifications(ctx_cli_options, config):
# type: (dict, dict) -> List[blobxfer.models.download.Specification]
cli_conf = ctx_cli_options[ctx_cli_options['_action']]
cli_options = cli_conf['options']
specs = []
for conf in config['... | [
"Create a list of Download Specification objects from configuration\n :param dict ctx_cli_options: cli options\n :param dict config: config dict\n :rtype: list\n :return: list of Download Specification objects\n "
] |
Please provide a description of the function:def create_synccopy_specifications(ctx_cli_options, config):
# type: (dict, dict) -> List[blobxfer.models.synccopy.Specification]
cli_conf = ctx_cli_options[ctx_cli_options['_action']]
cli_options = cli_conf['options']
specs = []
for conf in config['... | [
"Create a list of SyncCopy Specification objects from configuration\n :param dict ctx_cli_options: cli options\n :param dict config: config dict\n :rtype: list\n :return: list of SyncCopy Specification objects\n "
] |
Please provide a description of the function:def create_upload_specifications(ctx_cli_options, config):
# type: (dict, dict) -> List[blobxfer.models.upload.Specification]
cli_conf = ctx_cli_options[ctx_cli_options['_action']]
cli_options = cli_conf['options']
specs = []
for conf in config['uplo... | [
"Create a list of Upload Specification objects from configuration\n :param dict ctx_cli_options: cli options\n :param dict config: config dict\n :rtype: list\n :return: list of Upload Specification objects\n "
] |
Please provide a description of the function:def _initialize_processes(self, target, num_workers, description):
# type: (_MultiprocessOffload, function, int, str) -> None
if num_workers is None or num_workers < 1:
raise ValueError('invalid num_workers: {}'.format(num_workers))
... | [
"Initialize processes\n :param _MultiprocessOffload self: this\n :param function target: target function for process\n :param int num_workers: number of worker processes\n :param str description: description\n "
] |
Please provide a description of the function:def finalize_processes(self):
# type: (_MultiprocessOffload) -> None
self._term_signal.value = 1
if self._check_thread is not None:
self._check_thread.join()
for proc in self._procs:
proc.join() | [
"Finalize processes\n :param _MultiprocessOffload self: this\n "
] |
Please provide a description of the function:def initialize_check_thread(self, check_func):
# type: (_MultiprocessOffload, function) -> None
self._check_thread = threading.Thread(target=check_func)
self._check_thread.start() | [
"Initialize the multiprocess done queue check thread\n :param Downloader self: this\n :param function check_func: check function\n "
] |
Please provide a description of the function:def download(ctx):
settings.add_cli_options(ctx.cli_options, settings.TransferAction.Download)
ctx.initialize(settings.TransferAction.Download)
specs = settings.create_download_specifications(
ctx.cli_options, ctx.config)
del ctx.cli_options
... | [
"Download blobs or files from Azure Storage"
] |
Please provide a description of the function:def synccopy(ctx):
settings.add_cli_options(ctx.cli_options, settings.TransferAction.Synccopy)
ctx.initialize(settings.TransferAction.Synccopy)
specs = settings.create_synccopy_specifications(
ctx.cli_options, ctx.config)
del ctx.cli_options
... | [
"Synchronously copy blobs or files between Azure Storage accounts"
] |
Please provide a description of the function:def upload(ctx):
settings.add_cli_options(ctx.cli_options, settings.TransferAction.Upload)
ctx.initialize(settings.TransferAction.Upload)
specs = settings.create_upload_specifications(
ctx.cli_options, ctx.config)
del ctx.cli_options
for spec... | [
"Upload files to Azure Storage"
] |
Please provide a description of the function:def initialize(self, action):
# type: (CliContext, settings.TransferAction) -> None
self._init_config()
self.general_options = settings.create_general_options(
self.config, action)
self.credentials = settings.create_azure_... | [
"Initialize context\n :param CliContext self: this\n :param settings.TransferAction action: transfer action\n "
] |
Please provide a description of the function:def _read_yaml_file(self, yaml_file):
# type: (CliContext, pathlib.Path) -> None
with yaml_file.open('r') as f:
if self.config is None:
self.config = ruamel.yaml.load(
f, Loader=ruamel.yaml.RoundTripLoa... | [
"Read a yaml file into self.config\n :param CliContext self: this\n :param pathlib.Path yaml_file: yaml file to load\n "
] |
Please provide a description of the function:def _init_config(self):
# type: (CliContext) -> None
# load yaml config file into memory
if blobxfer.util.is_not_empty(self.cli_options['yaml_config']):
yaml_config = pathlib.Path(self.cli_options['yaml_config'])
self.... | [
"Initializes configuration of the context\n :param CliContext self: this\n "
] |
Please provide a description of the function:def send_messages(self, emails):
'''
Comments
'''
if not emails:
return
count = 0
for email in emails:
mail = self._build_sg_mail(email)
try:
self.sg.client.mail.send.post(re... | [] |
Please provide a description of the function:def get_idp_sso_supported_bindings(idp_entity_id=None, config=None):
if config is None:
# avoid circular import
from djangosaml2.conf import get_config
config = get_config()
# load metadata store from config
meta = getattr(config, 'me... | [
"Returns the list of bindings supported by an IDP\n This is not clear in the pysaml2 code, so wrapping it in a util"
] |
Please provide a description of the function:def fail_acs_response(request, *args, **kwargs):
failure_function = import_string(get_custom_setting('SAML_ACS_FAILURE_RESPONSE_FUNCTION',
'djangosaml2.acs_failures.template_failure'))
return failure_functi... | [
" Serves as a common mechanism for ending ACS in case of any SAML related failure.\n Handling can be configured by setting the SAML_ACS_FAILURE_RESPONSE_FUNCTION as\n suitable for the project.\n\n The default behavior uses SAML specific template that is rendered on any ACS error,\n but this can be simpl... |
Please provide a description of the function:def login(request,
config_loader_path=None,
wayf_template='djangosaml2/wayf.html',
authorization_error_template='djangosaml2/auth_error.html',
post_binding_form_template='djangosaml2/post_binding_form.html'):
logger.debug('Log... | [
"SAML Authorization Request initiator\n\n This view initiates the SAML2 Authorization handshake\n using the pysaml2 library to create the AuthnRequest.\n It uses the SAML 2.0 Http Redirect protocol binding.\n\n * post_binding_form_template - path to a template containing HTML form with\n hidden input... |
Please provide a description of the function:def assertion_consumer_service(request,
config_loader_path=None,
attribute_mapping=None,
create_unknown_user=None):
attribute_mapping = attribute_mapping or get_custom_setti... | [
"SAML Authorization Response endpoint\n\n The IdP will send its response to this view, which\n will process it with pysaml2 help and log the user\n in using the custom Authorization backend\n djangosaml2.backends.Saml2Backend that should be\n enabled in the settings.py\n "
] |
Please provide a description of the function:def echo_attributes(request,
config_loader_path=None,
template='djangosaml2/echo_attributes.html'):
state = StateCache(request.session)
conf = get_config(config_loader_path, request)
client = Saml2Client(conf, state_c... | [
"Example view that echo the SAML attributes of an user"
] |
Please provide a description of the function:def logout(request, config_loader_path=None):
state = StateCache(request.session)
conf = get_config(config_loader_path, request)
client = Saml2Client(conf, state_cache=state,
identity_cache=IdentityCache(request.session))
subjec... | [
"SAML Logout Request initiator\n\n This view initiates the SAML2 Logout request\n using the pysaml2 library to create the LogoutRequest.\n "
] |
Please provide a description of the function:def do_logout_service(request, data, binding, config_loader_path=None, next_page=None,
logout_error_template='djangosaml2/logout_error.html'):
logger.debug('Logout service started')
conf = get_config(config_loader_path, request)
state = S... | [
"SAML Logout Response endpoint\n\n The IdP will send the logout response to this view,\n which will process it with pysaml2 help and log the user\n out.\n Note that the IdP can request a logout even when\n we didn't initiate the process as a single logout\n request started by another SP.\n "
] |
Please provide a description of the function:def metadata(request, config_loader_path=None, valid_for=None):
conf = get_config(config_loader_path, request)
metadata = entity_descriptor(conf)
return HttpResponse(content=text_type(metadata).encode('utf-8'),
content_type="text/xml;... | [
"Returns an XML with the SAML 2.0 metadata for this\n SP as configured in the settings.py file.\n "
] |
Please provide a description of the function:def configure_user(self, user, attributes, attribute_mapping):
user.set_unusable_password()
return self.update_user(user, attributes, attribute_mapping,
force_save=True) | [
"Configures a user after creation and returns the updated user.\n\n By default, returns the user with his attributes updated.\n "
] |
Please provide a description of the function:def update_user(self, user, attributes, attribute_mapping,
force_save=False):
if not attribute_mapping:
return user
user_modified = False
for saml_attr, django_attrs in attribute_mapping.items():
a... | [
"Update a user with a set of attributes and returns the updated user.\n\n By default it uses a mapping defined in the settings constant\n SAML_ATTRIBUTE_MAPPING. For each attribute, if the user object has\n that field defined it will be set.\n "
] |
Please provide a description of the function:def _set_attribute(self, obj, attr, value):
field = obj._meta.get_field(attr)
if field.max_length is not None and len(value) > field.max_length:
cleaned_value = value[:field.max_length]
logger.warn('The attribute "%s" was trim... | [
"Set an attribute of an object to a specific value.\n\n Return True if the attribute was changed and False otherwise.\n "
] |
Please provide a description of the function:def config_settings_loader(request=None):
conf = SPConfig()
conf.load(copy.deepcopy(settings.SAML_CONFIG))
return conf | [
"Utility function to load the pysaml2 configuration.\n\n This is also the default config loader.\n "
] |
Please provide a description of the function:def mkpath(*segments, **query):
# Remove empty segments (e.g. no key specified)
segments = [bytes_to_str(s) for s in segments if s is not None]
# Join the segments into a path
pathstring = '/'.join(segments)
# Remove extra slashes
pathstring = re... | [
"\n Constructs the path & query portion of a URI from path segments\n and a dict.\n "
] |
Please provide a description of the function:def search_index_path(self, index=None, **options):
if not self.yz_wm_index:
raise RiakError("Yokozuna search is unsupported by this Riak node")
if index:
quote_plus(index)
return mkpath(self.yz_wm_index, "index", inde... | [
"\n Builds a Yokozuna search index URL.\n\n :param index: optional name of a yz index\n :type index: string\n :param options: optional list of additional arguments\n :type index: dict\n :rtype URL string\n "
] |
Please provide a description of the function:def search_schema_path(self, index, **options):
if not self.yz_wm_schema:
raise RiakError("Yokozuna search is unsupported by this Riak node")
return mkpath(self.yz_wm_schema, "schema", quote_plus(index),
**options) | [
"\n Builds a Yokozuna search Solr schema URL.\n\n :param index: a name of a yz solr schema\n :type index: string\n :param options: optional list of additional arguments\n :type index: dict\n :rtype URL string\n "
] |
Please provide a description of the function:def preflist_path(self, bucket, key, bucket_type=None, **options):
if not self.riak_kv_wm_preflist:
raise RiakError("Preflists are unsupported by this Riak node")
if self.riak_kv_wm_bucket_type and bucket_type:
return mkpath("... | [
"\n Generate the URL for bucket/key preflist information\n\n :param bucket: Name of a Riak bucket\n :type bucket: string\n :param key: Name of a Key\n :type key: string\n :param bucket_type: Optional Riak Bucket Type\n :type bucket_type: None or string\n :rtyp... |
Please provide a description of the function:def deep_merge(a, b):
assert quacks_like_dict(a), quacks_like_dict(b)
dst = a.copy()
stack = [(dst, b)]
while stack:
current_dst, current_src = stack.pop()
for key in current_src:
if key not in current_dst:
cu... | [
"Merge two deep dicts non-destructively\n\n Uses a stack to avoid maximum recursion depth exceptions\n\n >>> a = {'a': 1, 'b': {1: 1, 2: 2}, 'd': 6}\n >>> b = {'c': 3, 'b': {2: 7}, 'd': {'z': [1, 2, 3]}}\n >>> c = deep_merge(a, b)\n >>> from pprint import pprint; pprint(c)\n {'a': 1, 'b': {1: 1, 2... |
Please provide a description of the function:def to_op(self):
if not self._adds:
return None
changes = {}
if self._adds:
changes['adds'] = list(self._adds)
return changes | [
"\n Extracts the modification operation from the Hll.\n\n :rtype: dict, None\n "
] |
Please provide a description of the function:def add(self, element):
if not isinstance(element, six.string_types):
raise TypeError("Hll elements can only be strings")
self._adds.add(element) | [
"\n Adds an element to the HyperLogLog. Datatype cardinality will\n be updated when the object is saved.\n\n :param element: the element to add\n :type element: str\n "
] |
Please provide a description of the function:def ping(self):
status, _, body = self._request('GET', self.ping_path())
return(status is not None) and (bytes_to_str(body) == 'OK') | [
"\n Check server is alive over HTTP\n "
] |
Please provide a description of the function:def stats(self):
status, _, body = self._request('GET', self.stats_path(),
{'Accept': 'application/json'})
if status == 200:
return json.loads(bytes_to_str(body))
else:
return No... | [
"\n Gets performance statistics and server information\n "
] |
Please provide a description of the function:def get_resources(self):
status, _, body = self._request('GET', '/',
{'Accept': 'application/json'})
if status == 200:
tmp, resources = json.loads(bytes_to_str(body)), {}
for k in tmp:
... | [
"\n Gets a JSON mapping of server-side resource names to paths\n :rtype dict\n "
] |
Please provide a description of the function:def get(self, robj, r=None, pr=None, timeout=None, basic_quorum=None,
notfound_ok=None, head_only=False):
# We could detect quorum_controls here but HTTP ignores
# unknown flags/params.
params = {'r': r, 'pr': pr, 'timeout': timeo... | [
"\n Get a bucket/key from the server\n "
] |
Please provide a description of the function:def put(self, robj, w=None, dw=None, pw=None, return_body=True,
if_none_match=False, timeout=None):
# We could detect quorum_controls here but HTTP ignores
# unknown flags/params.
params = {'returnbody': return_body, 'w': w, 'dw':... | [
"\n Puts a (possibly new) object.\n "
] |
Please provide a description of the function:def delete(self, robj, rw=None, r=None, w=None, dw=None, pr=None, pw=None,
timeout=None):
# We could detect quorum_controls here but HTTP ignores
# unknown flags/params.
params = {'rw': rw, 'r': r, 'w': w, 'dw': dw, 'pr': pr, '... | [
"\n Delete an object.\n "
] |
Please provide a description of the function:def get_keys(self, bucket, timeout=None):
bucket_type = self._get_bucket_type(bucket.bucket_type)
url = self.key_list_path(bucket.name, bucket_type=bucket_type,
timeout=timeout)
status, _, body = self._request... | [
"\n Fetch a list of keys for the bucket\n "
] |
Please provide a description of the function:def get_buckets(self, bucket_type=None, timeout=None):
bucket_type = self._get_bucket_type(bucket_type)
url = self.bucket_list_path(bucket_type=bucket_type,
timeout=timeout)
status, headers, body = self._re... | [
"\n Fetch a list of all buckets\n "
] |
Please provide a description of the function:def stream_buckets(self, bucket_type=None, timeout=None):
if not self.bucket_stream():
raise NotImplementedError('Streaming list-buckets is not '
"supported on %s" %
self... | [
"\n Stream list of buckets through an iterator\n "
] |
Please provide a description of the function:def get_bucket_props(self, bucket):
bucket_type = self._get_bucket_type(bucket.bucket_type)
url = self.bucket_properties_path(bucket.name,
bucket_type=bucket_type)
status, headers, body = self._reques... | [
"\n Get properties for a bucket\n "
] |
Please provide a description of the function:def set_bucket_props(self, bucket, props):
bucket_type = self._get_bucket_type(bucket.bucket_type)
url = self.bucket_properties_path(bucket.name,
bucket_type=bucket_type)
headers = {'Content-Type': 'a... | [
"\n Set the properties on the bucket object given\n "
] |
Please provide a description of the function:def clear_bucket_props(self, bucket):
bucket_type = self._get_bucket_type(bucket.bucket_type)
url = self.bucket_properties_path(bucket.name,
bucket_type=bucket_type)
url = self.bucket_properties_path(... | [
"\n reset the properties on the bucket object given\n "
] |
Please provide a description of the function:def get_bucket_type_props(self, bucket_type):
self._check_bucket_types(bucket_type)
url = self.bucket_type_properties_path(bucket_type.name)
status, headers, body = self._request('GET', url)
if status == 200:
props = json... | [
"\n Get properties for a bucket-type\n "
] |
Please provide a description of the function:def set_bucket_type_props(self, bucket_type, props):
self._check_bucket_types(bucket_type)
url = self.bucket_type_properties_path(bucket_type.name)
headers = {'Content-Type': 'application/json'}
content = json.dumps({'props': props})
... | [
"\n Set the properties on the bucket-type\n "
] |
Please provide a description of the function:def mapred(self, inputs, query, timeout=None):
# Construct the job, optionally set the timeout...
content = self._construct_mapred_json(inputs, query, timeout)
# Do the request...
url = self.mapred_path()
headers = {'Content-... | [
"\n Run a MapReduce query.\n "
] |
Please provide a description of the function:def get_index(self, bucket, index, startkey, endkey=None,
return_terms=None, max_results=None, continuation=None,
timeout=None, term_regex=None):
if term_regex and not self.index_term_regex():
raise NotImplemen... | [
"\n Performs a secondary index query.\n "
] |
Please provide a description of the function:def stream_index(self, bucket, index, startkey, endkey=None,
return_terms=None, max_results=None, continuation=None,
timeout=None, term_regex=None):
if not self.stream_indexes():
raise NotImplementedError... | [
"\n Streams a secondary index query.\n "
] |
Please provide a description of the function:def create_search_index(self, index, schema=None, n_val=None,
timeout=None):
if not self.yz_wm_index:
raise NotImplementedError("Search 2.0 administration is not "
"supported for t... | [
"\n Create a Solr search index for Yokozuna.\n\n :param index: a name of a yz index\n :type index: string\n :param schema: XML of Solr schema\n :type schema: string\n :param n_val: N value of the write\n :type n_val: int\n :param timeout: optional timeout (in ... |
Please provide a description of the function:def get_search_index(self, index):
if not self.yz_wm_index:
raise NotImplementedError("Search 2.0 administration is not "
"supported for this version")
url = self.search_index_path(index)
# ... | [
"\n Fetch the specified Solr search index for Yokozuna.\n\n :param index: a name of a yz index\n :type index: string\n\n :rtype string\n "
] |
Please provide a description of the function:def list_search_indexes(self):
if not self.yz_wm_index:
raise NotImplementedError("Search 2.0 administration is not "
"supported for this version")
url = self.search_index_path()
# Run the r... | [
"\n Return a list of Solr search indexes from Yokozuna.\n\n :rtype list of dicts\n "
] |
Please provide a description of the function:def delete_search_index(self, index):
if not self.yz_wm_index:
raise NotImplementedError("Search 2.0 administration is not "
"supported for this version")
url = self.search_index_path(index)
... | [
"\n Fetch the specified Solr search index for Yokozuna.\n\n :param index: a name of a yz index\n :type index: string\n\n :rtype boolean\n "
] |
Please provide a description of the function:def create_search_schema(self, schema, content):
if not self.yz_wm_schema:
raise NotImplementedError("Search 2.0 administration is not "
"supported for this version")
url = self.search_schema_path(sc... | [
"\n Create a new Solr schema for Yokozuna.\n\n :param schema: name of Solr schema\n :type schema: string\n :param content: actual defintion of schema (XML)\n :type content: string\n\n :rtype boolean\n "
] |
Please provide a description of the function:def get_search_schema(self, schema):
if not self.yz_wm_schema:
raise NotImplementedError("Search 2.0 administration is not "
"supported for this version")
url = self.search_schema_path(schema)
... | [
"\n Fetch a Solr schema from Yokozuna.\n\n :param schema: name of Solr schema\n :type schema: string\n\n :rtype dict\n "
] |
Please provide a description of the function:def search(self, index, query, **params):
if index is None:
index = 'search'
options = {}
if 'op' in params:
op = params.pop('op')
options['q.op'] = op
options.update(params)
url = self.so... | [
"\n Performs a search query.\n "
] |
Please provide a description of the function:def fulltext_add(self, index, docs):
xml = Document()
root = xml.createElement('add')
for doc in docs:
doc_element = xml.createElement('doc')
for key in doc:
value = doc[key]
field = xml... | [
"\n Adds documents to the search index.\n "
] |
Please provide a description of the function:def fulltext_delete(self, index, docs=None, queries=None):
xml = Document()
root = xml.createElement('delete')
if docs:
for doc in docs:
doc_element = xml.createElement('id')
text = xml.createTextNo... | [
"\n Removes documents from the full-text index.\n "
] |
Please provide a description of the function:def get_preflist(self, bucket, key):
if not self.preflists():
raise NotImplementedError("fetching preflists is not supported.")
bucket_type = self._get_bucket_type(bucket.bucket_type)
url = self.preflist_path(bucket.name, key, buc... | [
"\n Get the preflist for a bucket/key\n\n :param bucket: Riak Bucket\n :type bucket: :class:`~riak.bucket.RiakBucket`\n :param key: Riak Key\n :type key: string\n :rtype: list of dicts\n "
] |
Please provide a description of the function:def release(self):
if self.errored:
self.pool.delete_resource(self)
else:
self.pool.release(self) | [
"\n Releases this resource back to the pool it came from.\n "
] |
Please provide a description of the function:def acquire(self, _filter=None, default=None):
if not _filter:
def _filter(obj):
return True
elif not callable(_filter):
raise TypeError("_filter is not a callable")
resource = None
with self.l... | [
"\n acquire(_filter=None, default=None)\n\n Claims a resource from the pool for manual use. Resources are\n created as needed when all members of the pool are claimed or\n the pool is empty. Most of the time you will want to use\n :meth:`transaction`.\n\n :param _filter: a ... |
Please provide a description of the function:def release(self, resource):
with self.releaser:
resource.claimed = False
self.releaser.notify_all() | [
"release(resource)\n\n Returns a resource to the pool. Most of the time you will want\n to use :meth:`transaction`, but if you use :meth:`acquire`,\n you must release the acquired resource back to the pool when\n finished. Failure to do so could result in deadlock.\n\n :param reso... |
Please provide a description of the function:def transaction(self, _filter=None, default=None, yield_resource=False):
resource = self.acquire(_filter=_filter, default=default)
try:
if yield_resource:
yield resource
else:
yield resource.obj... | [
"\n transaction(_filter=None, default=None)\n\n Claims a resource from the pool for use in a thread-safe,\n reentrant manner (as part of a with statement). Resources are\n created as needed when all members of the pool are claimed or\n the pool is empty.\n\n :param _filter:... |
Please provide a description of the function:def delete_resource(self, resource):
with self.lock:
self.resources.remove(resource)
self.destroy_resource(resource.object)
del resource | [
"\n Deletes the resource from the pool and destroys the associated\n resource. Not usually needed by users of the pool, but called\n internally when BadResource is raised.\n\n :param resource: the resource to remove\n :type resource: Resource\n "
] |
Please provide a description of the function:def encode_timeseries_put(self, tsobj):
'''
Returns an Erlang-TTB encoded tuple with the appropriate data and
metadata from a TsObject.
:param tsobj: a TsObject
:type tsobj: TsObject
:rtype: term-to-binary encoded object
... | [] |
Please provide a description of the function:def decode_timeseries(self, resp_ttb, tsobj,
convert_timestamp=False):
if resp_ttb is None:
return tsobj
self.maybe_err_ttb(resp_ttb)
# NB: some queries return a BARE 'tsqueryresp' atom
# catch ... | [
"\n Fills an TsObject with the appropriate data and\n metadata from a TTB-encoded TsGetResp / TsQueryResp.\n\n :param resp_ttb: the decoded TTB data\n :type resp_ttb: TTB-encoded tsqueryrsp or tsgetresp\n :param tsobj: a TsObject\n :type tsobj: TsObject\n :param conv... |
Please provide a description of the function:def decode_timeseries_row(self, tsrow, tsct, convert_timestamp=False):
row = []
for i, cell in enumerate(tsrow):
if cell is None:
row.append(None)
elif isinstance(cell, list) and len(cell) == 0:
... | [
"\n Decodes a TTB-encoded TsRow into a list\n\n :param tsrow: the TTB decoded TsRow to decode.\n :type tsrow: TTB dncoded row\n :param tsct: the TTB decoded column types (atoms).\n :type tsct: list\n :param convert_timestamp: Convert timestamps to datetime objects\n ... |
Please provide a description of the function:def to_op(self):
if not self._adds and not self._removes:
return None
changes = {}
if self._adds:
changes['adds'] = list(self._adds)
if self._removes:
changes['removes'] = list(self._removes)
... | [
"\n Extracts the modification operation from the set.\n\n :rtype: dict, None\n "
] |
Please provide a description of the function:def discard(self, element):
_check_element(element)
self._require_context()
self._removes.add(element) | [
"\n Removes an element from the set.\n\n .. note: You may remove elements from the set that are not\n present, but a context from the server is required.\n\n :param element: the element to remove\n :type element: str\n "
] |
Please provide a description of the function:def getall(self, key):
result = []
for k, v in self._items:
if key == k:
result.append(v)
return result | [
"\n Return a list of all values matching the key (may be an empty list)\n "
] |
Please provide a description of the function:def getone(self, key):
v = self.getall(key)
if not v:
raise KeyError('Key not found: %r' % key)
if len(v) > 1:
raise KeyError('Multiple values match %r: %r' % (key, v))
return v[0] | [
"\n Get one value matching the key, raising a KeyError if multiple\n values were found.\n "
] |
Please provide a description of the function:def mixed(self):
result = {}
multi = {}
for key, value in self._items:
if key in result:
# We do this to not clobber any lists that are
# *actual* values in this dictionary:
if key i... | [
"\n Returns a dictionary where the values are either single\n values, or a list of values when a key/value appears more than\n once in this dictionary. This is similar to the kind of\n dictionary often used to represent the variables in a web\n request.\n "
] |
Please provide a description of the function:def dict_of_lists(self):
result = {}
for key, value in self._items:
if key in result:
result[key].append(value)
else:
result[key] = [value]
return result | [
"\n Returns a dictionary where each key is associated with a\n list of values.\n "
] |
Please provide a description of the function:def multiget(client, keys, **options):
transient_pool = False
outq = Queue()
if 'pool' in options:
pool = options['pool']
del options['pool']
else:
pool = MultiGetPool()
transient_pool = True
try:
pool.start(... | [
"Executes a parallel-fetch across multiple threads. Returns a list\n containing :class:`~riak.riak_object.RiakObject` or\n :class:`~riak.datatypes.Datatype` instances, or 4-tuples of\n bucket-type, bucket, key, and the exception raised.\n\n If a ``pool`` option is included, the request will use the give... |
Please provide a description of the function:def multiput(client, objs, **options):
transient_pool = False
outq = Queue()
if 'pool' in options:
pool = options['pool']
del options['pool']
else:
pool = MultiPutPool()
transient_pool = True
try:
pool.start(... | [
"Executes a parallel-store across multiple threads. Returns a list\n containing booleans or :class:`~riak.riak_object.RiakObject`\n\n If a ``pool`` option is included, the request will use the given worker\n pool and not a transient :class:`~riak.client.multi.MultiPutPool`. This\n option will be passed ... |
Please provide a description of the function:def enq(self, task):
if not self._stop.is_set():
self._inq.put(task)
else:
raise RuntimeError("Attempted to enqueue an operation while "
"multi pool was shutdown!") | [
"\n Enqueues a fetch task to the pool of workers. This will raise\n a RuntimeError if the pool is stopped or in the process of\n stopping.\n\n :param task: the Task object\n :type task: Task or PutTask\n "
] |
Please provide a description of the function:def start(self):
# Check whether we are already started, skip if we are.
if not self._started.is_set():
# If we are not started, try to capture the lock.
if self._lock.acquire(False):
# If we got the lock, go a... | [
"\n Starts the worker threads if they are not already started.\n This method is thread-safe and will be called automatically\n when executing an operation.\n "
] |
Please provide a description of the function:def stop(self):
if not self.stopped():
self._stop.set()
for worker in self._workers:
worker.join() | [
"\n Signals the worker threads to exit and waits on them.\n "
] |
Please provide a description of the function:def _worker_method(self):
while not self._should_quit():
try:
task = self._inq.get(block=True, timeout=0.25)
except TypeError:
if self._should_quit():
break
else:
... | [
"\n The body of the multi-get worker. Loops until\n :meth:`_should_quit` returns ``True``, taking tasks off the\n input queue, fetching the object, and putting them on the\n output queue.\n "
] |
Please provide a description of the function:def _worker_method(self):
while not self._should_quit():
try:
task = self._inq.get(block=True, timeout=0.25)
except TypeError:
if self._should_quit():
break
else:
... | [
"\n The body of the multi-put worker. Loops until\n :meth:`_should_quit` returns ``True``, taking tasks off the\n input queue, storing the object, and putting the result on\n the output queue.\n "
] |
Please provide a description of the function:def _check_key(self, key):
if not len(key) == 2:
raise TypeError('invalid key: %r' % key)
elif key[1] not in TYPES:
raise TypeError('invalid datatype: %s' % key[1]) | [
"\n Ensures well-formedness of a key.\n "
] |
Please provide a description of the function:def value(self):
pvalue = {}
for key in self._value:
pvalue[key] = self._value[key].value
return pvalue | [
"\n Returns a copy of the original map's value. Nested values are\n pure Python values as returned by :attr:`Datatype.value` from\n the nested types.\n\n :rtype: dict\n "
] |
Please provide a description of the function:def modified(self):
if self._removes:
return True
for v in self._value:
if self._value[v].modified:
return True
for v in self._updates:
if self._updates[v].modified:
return T... | [
"\n Whether the map has staged local modifications.\n "
] |
Please provide a description of the function:def to_op(self):
removes = [('remove', r) for r in self._removes]
value_updates = list(self._extract_updates(self._value))
new_updates = list(self._extract_updates(self._updates))
all_updates = removes + value_updates + new_updates
... | [
"\n Extracts the modification operation(s) from the map.\n\n :rtype: list, None\n "
] |
Please provide a description of the function:def _format_python2_or_3(self):
pb_files = set()
with open(self.source, 'r', buffering=1) as csvfile:
reader = csv.reader(csvfile)
for row in reader:
_, _, proto = row
pb_files.add('riak/pb/{0}_... | [
"\n Change the PB files to use full pathnames for Python 3.x\n and modify the metaclasses to be version agnostic\n "
] |
Please provide a description of the function:def reload(self, **params):
if not self.bucket:
raise ValueError('bucket property not assigned')
if not self.key:
raise ValueError('key property not assigned')
dtype, value, context = self.bucket._client._fetch_datat... | [
"\n Reloads the datatype from Riak.\n\n .. warning: This clears any local modifications you might have\n made.\n\n :param r: the read quorum\n :type r: integer, string, None\n :param pr: the primary read quorum\n :type pr: integer, string, None\n :param bas... |
Please provide a description of the function:def delete(self, **params):
self.clear()
self._context = None
self._set_value(self._default_value())
self.bucket._client.delete(self, **params)
return self | [
"\n Deletes the datatype from Riak. See :meth:`RiakClient.delete()\n <riak.client.RiakClient.delete>` for options.\n "
] |
Please provide a description of the function:def update(self, **params):
if not self.modified:
raise ValueError("No operation to perform")
params.setdefault('return_body', True)
self.bucket._client.update_datatype(self, **params)
self.clear()
return self | [
"\n Sends locally staged mutations to Riak.\n\n :param w: W-value, wait for this many partitions to respond\n before returning to client.\n :type w: integer\n :param dw: DW-value, wait for this many partitions to\n confirm the write before returning to client.\n :t... |
Please provide a description of the function:def encode_quorum(self, rw):
if rw in QUORUM_TO_PB:
return QUORUM_TO_PB[rw]
elif type(rw) is int and rw >= 0:
return rw
else:
return None | [
"\n Converts a symbolic quorum value into its on-the-wire\n equivalent.\n\n :param rw: the quorum\n :type rw: string, integer\n :rtype: integer\n "
] |
Please provide a description of the function:def decode_contents(self, contents, obj):
obj.siblings = [self.decode_content(c, RiakContent(obj))
for c in contents]
# Invoke sibling-resolution logic
if len(obj.siblings) > 1 and obj.resolver is not None:
... | [
"\n Decodes the list of siblings from the protobuf representation\n into the object.\n\n :param contents: a list of RpbContent messages\n :type contents: list\n :param obj: a RiakObject\n :type obj: RiakObject\n :rtype RiakObject\n "
] |
Please provide a description of the function:def decode_content(self, rpb_content, sibling):
if rpb_content.HasField("deleted") and rpb_content.deleted:
sibling.exists = False
else:
sibling.exists = True
if rpb_content.HasField("content_type"):
sibli... | [
"\n Decodes a single sibling from the protobuf representation into\n a RiakObject.\n\n :param rpb_content: a single RpbContent message\n :type rpb_content: riak.pb.riak_pb2.RpbContent\n :param sibling: a RiakContent sibling container\n :type sibling: RiakContent\n :r... |
Please provide a description of the function:def encode_content(self, robj, rpb_content):
if robj.content_type:
rpb_content.content_type = str_to_bytes(robj.content_type)
if robj.charset:
rpb_content.charset = str_to_bytes(robj.charset)
if robj.content_encoding:
... | [
"\n Fills an RpbContent message with the appropriate data and\n metadata from a RiakObject.\n\n :param robj: a RiakObject\n :type robj: RiakObject\n :param rpb_content: the protobuf message to fill\n :type rpb_content: riak.pb.riak_pb2.RpbContent\n "
] |
Please provide a description of the function:def decode_link(self, link):
if link.HasField("bucket"):
bucket = bytes_to_str(link.bucket)
else:
bucket = None
if link.HasField("key"):
key = bytes_to_str(link.key)
else:
key = None
... | [
"\n Decodes an RpbLink message into a tuple\n\n :param link: an RpbLink message\n :type link: riak.pb.riak_pb2.RpbLink\n :rtype tuple\n "
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.