def set_or_clear_gnx_test_meta_on_coll(collnpath, operation, N, callback, partial_pages=True): import irods_types if partial_pages: lower_bound = 0 else: lower_bound = 1000 - 768 thousands = 0 meta_string = "kvp_page={}%" .format(thousands) + \ "%".join("{:04d}={}".format(i,-(i%10+1)) for i in range(lower_bound,1000)) for thousands in range(int(N)): kvp = callback.msiString2KeyValPair( meta_string, irods_types.KeyValPair())['arguments'][1] if operation.upper() in ('ASSOC', 'SET', '+'): retval = callback.msiAssociateKeyValuePairsToObj( kvp, collnpath, "-C") elif operation.upper() in ('CLEAR', 'CLR', '-'): retval = callback.msiRemoveKeyValuePairsFromObj( kvp, collnpath, "-C") meta_string = meta_string.replace("%{}".format(thousands), "%{}".format(thousands + 1)).replace( "={}".format(thousands), "={}".format(thousands + 1))
def meta_stamp (callback, object_path, object_type = "-d", task_id = "" ): METADATA_TAG = Metadata_Tag rv = callback.msiString2KeyValPair("{METADATA_TAG}={task_id}".format(**locals()), irods_types.KeyValPair()) if rv ['status']: rv = callback.msiSetKeyValuePairsToObj(rv['arguments'][1], object_path, object_type ) return rv['status']
def str_to_key_value(self, pair): """ Wrapper for msiString2KeyValuePair. :param str pair: stringified key value pair :rtype: irods_types.KeyValPair """ debug.trace_begin(self, locals()) return self.validate_result( self._irods.msiString2KeyValPair(pair, irods_types.KeyValPair()), 1)
def make_key_vals(self, kvals): """ Creates an iRODS KeyValuePair struct out of the given kvals dict. :param dict kvals: key value pairs to be inserted into the new KeyValPair struct. :rtype: irods_types.KeyValPair :returns: an iRODS KeyValuePair type containing the given input key value pairs """ debug.trace_begin(self, locals()) obj = irods_types.KeyValPair() for key, val in kvals.iteritems(): obj = self.add_key_val(key, val, obj) return obj
def add_key_val(self, key, val, key_vals=None): """ Wrapper for msiAddKeyVal. Appends the given key value pair to the optional input key_vals param. If the key_vals param is None, a new KeyValPair will be created. :param str key: meta attribute key :param str val: meta attribute value :param irods_types.KeyValPair key_vals: :return: the updated KeyValPair :rtype: irods_types.KeyValPair """ debug.trace_begin(self, locals()) check_kvp_key(key) if key_vals is None: key_vals = irods_types.KeyValPair() return self.validate_result( self._irods.msiAddKeyVal(key_vals, key, val if val is not None else ""), 0)