code
stringlengths
1
18.2k
def can_create_catalog_with_record_types(self, catalog_record_types): """Tests if this user can create a single ``Catalog`` using the desired record types. While ``CatalogingManager.getCatalogRecordTypes()`` can be used to examine which records are supported, this method tests which record(s) are required for creating ...
None: return self._catalog_session.can_create_catalog_with_record_types(catalog_record_types=catalog_record_types) return True
def update_catalog(self, catalog_form): """Updates an existing catalog. arg: catalog_form (osid.cataloging.CatalogForm): the form containing the elements to be updated raise: IllegalState - ``catalog_form`` already used in an update transaction raise: InvalidArgument - the form contains an invalid value raise: NullArgu...
except KeyError: raise errors.Unsupported('catalog_form did not originate from this session') if not catalog_form.is_valid(): raise errors.InvalidArgument('one or more of the form elements is invalid') collection.save(catalog_form._my_map) # save is deprecated - change to replace_one self._forms[catalog_form.get_id().g...
def delete_catalog(self, catalog_id): """Deletes a ``Catalog``. arg: catalog_id (osid.id.Id): the ``Id`` of the ``Catalog`` to remove raise: NotFound - ``catalog_id`` not found raise: NullArgument - ``catalog_id`` is ``null`` raise: OperationFailed - unable to complete request raise: PermissionDenied - authorization fa...
def alias_catalog(self, catalog_id, alias_id): """Adds an ``Id`` to a ``Catalog`` for the purpose of creating compatibility. The primary ``Id`` of the ``Catalog`` is determined by the provider. The new ``Id`` performs as an alias to the primary ``Id``. If the alias is a pointer to another catalog, it is reassigned to t...
def get_root_catalogs(self): """Gets the root catalogs in the catalog hierarchy. A node with no parents is an orphan. While all catalog ``Ids`` are known to the hierarchy, an orphan does not appear in the hierarchy unless explicitly added as a root node or child of another node. return: (osid.cataloging.CatalogList) - ...
def has_parent_catalogs(self, catalog_id): """Tests if the ``Catalog`` has any parents. arg: catalog_id (osid.id.Id): a catalog ``Id`` return: (boolean) - ``true`` if the catalog has parents, ``false`` otherwise raise: NotFound - ``catalog_id`` is not found raise: NullArgument - ``catalog_id`` is ``null`` raise: Operat...
def is_parent_of_catalog(self, id_, catalog_id): """Tests if an ``Id`` is a direct parent of a catalog. arg: id (osid.id.Id): an ``Id`` arg: catalog_id (osid.id.Id): the ``Id`` of a catalog return: (boolean) - ``true`` if this ``id`` is a parent of ``catalog_id,`` ``false`` otherwise raise: NotFound - ``catalog_id`` is...
def get_parent_catalog_ids(self, catalog_id): """Gets the parent ``Ids`` of the given catalog. arg: catalog_id (osid.id.Id): a catalog ``Id`` return: (osid.id.IdList) - the parent ``Ids`` of the catalog raise: NotFound - ``catalog_id`` is not found raise: NullArgument - ``catalog_id`` is ``null`` raise: OperationFailed...
def get_parent_catalogs(self, catalog_id): """Gets the parent catalogs of the given ``id``. arg: catalog_id (osid.id.Id): the ``Id`` of the ``Catalog`` to query return: (osid.cataloging.CatalogList) - the parent catalogs of the ``id`` raise: NotFound - a ``Catalog`` identified by ``Id is`` not found raise: NullArgument...
def is_ancestor_of_catalog(self, id_, catalog_id): """Tests if an ``Id`` is an ancestor of a catalog. arg: id (osid.id.Id): an ``Id`` arg: catalog_id (osid.id.Id): the ``Id`` of a catalog return: (boolean) - ``true`` if this ``id`` is an ancestor of ``catalogId``. ``false`` otherwise raise: NotFound - ``catalog_id`` no...
def has_child_catalogs(self, catalog_id): """Tests if a catalog has any children. arg: catalog_id (osid.id.Id): a ``catalog_id`` return: (boolean) - ``true`` if the ``catalog_id`` has children, ``false`` otherwise raise: NotFound - ``catalog_id`` is not found raise: NullArgument - ``catalog_id`` is ``null`` raise: Oper...
def is_child_of_catalog(self, id_, catalog_id): """Tests if a catalog is a direct child of another. arg: id (osid.id.Id): an ``Id`` arg: catalog_id (osid.id.Id): the ``Id`` of a catalog return: (boolean) - ``true`` if the ``id`` is a child of ``catalog_id,`` ``false`` otherwise raise: NotFound - ``catalog_id`` not foun...
def get_child_catalog_ids(self, catalog_id): """Gets the child ``Ids`` of the given catalog. arg: catalog_id (osid.id.Id): the ``Id`` to query return: (osid.id.IdList) - the children of the catalog raise: NotFound - ``catalog_id`` is not found raise: NullArgument - ``catalog_id`` is ``null`` raise: OperationFailed - un...
def get_child_catalogs(self, catalog_id): """Gets the child catalogs of the given ``id``. arg: catalog_id (osid.id.Id): the ``Id`` of the ``Catalog`` to query return: (osid.cataloging.CatalogList) - the child catalogs of the ``id`` raise: NotFound - a ``Catalog`` identified by ``Id is`` not found raise: NullArgument - ...
def is_descendant_of_catalog(self, id_, catalog_id): """Tests if an ``Id`` is a descendant of a catalog. arg: id (osid.id.Id): an ``Id`` arg: catalog_id (osid.id.Id): the ``Id`` of a catalog return: (boolean) - ``true`` if the ``id`` is a descendant of the ``catalog_id,`` ``false`` otherwise raise: NotFound - ``catalog...
def get_catalog_nodes(self, catalog_id, ancestor_levels, descendant_levels, include_siblings): """Gets a portion of the hierarchy for the given catalog. arg: catalog_id (osid.id.Id): the ``Id`` to query arg: ancestor_levels (cardinal): the maximum number of ancestor levels to include. A value of 0 returns no parents in...
from template for # osid.resource.BinHierarchySession.get_bin_nodes return objects.CatalogNode(self.get_catalog_node_ids( catalog_id=catalog_id, ancestor_levels=ancestor_levels, descendant_levels=descendant_levels, include_siblings=include_siblings)._my_map, runtime=self._runtime, proxy=self._proxy)
def add_root_catalog(self, catalog_id): """Adds a root catalog. arg: catalog_id (osid.id.Id): the ``Id`` of a catalog raise: AlreadyExists - ``catalog_id`` is already in hierarchy raise: NotFound - ``catalog_id`` not found raise: NullArgument - ``catalog_id`` is ``null`` raise: OperationFailed - unable to complete requ...
def remove_root_catalog(self, catalog_id): """Removes a root catalog. arg: catalog_id (osid.id.Id): the ``Id`` of a catalog raise: NotFound - ``catalog_id`` is not a root raise: NullArgument - ``catalog_id`` is ``null`` raise: OperationFailed - unable to complete request raise: PermissionDenied - authorization failure ...
def add_child_catalog(self, catalog_id, child_id): """Adds a child to a catalog. arg: catalog_id (osid.id.Id): the ``Id`` of a catalog arg: child_id (osid.id.Id): the ``Id`` of the new child raise: AlreadyExists - ``catalog_id`` is already a parent of ``child_id`` raise: NotFound - ``catalog_id`` or ``child_id`` not fo...
def remove_child_catalog(self, catalog_id, child_id): """Removes a child from a catalog. arg: catalog_id (osid.id.Id): the ``Id`` of a catalog arg: child_id (osid.id.Id): the ``Id`` of the new child raise: NotFound - ``catalog_id`` is not a parent of ``child_id`` raise: NullArgument - ``catalog_id`` or ``child_id`` is ...
def remove_child_catalogs(self, catalog_id): """Removes all children from a catalog. arg: catalog_id (osid.id.Id): the ``Id`` of a catalog raise: NotFound - ``catalog_id`` is not in hierarchy raise: NullArgument - ``catalog_id`` is ``null`` raise: OperationFailed - unable to complete request raise: PermissionDenied - a...
def generate_scan_parameter_description(scan_parameters): '''Generate scan parameter dictionary. This is the only way to dynamically create table with dictionary, cannot be done with tables.IsDescription Parameters ---------- scan_parameters : list, tuple List of scan parameters names (strings). Returns ------- table_d...
def generate_scan_configuration_description(scan_parameters): '''Generate scan parameter dictionary. This is the only way to dynamically create table with dictionary, cannot be done with tables.IsDescription Parameters ---------- scan_parameters : list, tuple List of scan parameters names (strings). Returns ------- tab...
def split_hostmask(hostmask): """Splits a nick@host string into nick and host.""" nick, _, host = hostmask.partition('@') nick, _, user = nick.partition('!') return nick, user or None, host or None
def compute_histogram(values, edges, use_orig_distr=False): """Computes histogram (density) for a given vector of values.""" if use_orig_distr: return values # ignoring invalid values: Inf and Nan values = check_array(values).compressed() hist, bin_edges = np.histogram(values, bins=edges, density=True) hist = preproces...
def preprocess_histogram(hist, values, edges): """Handles edge-cases and extremely-skewed histograms""" # working with extremely skewed histograms if np.count_nonzero(hist) == 0: # all of them above upper bound if np.all(values >= edges[-1]): hist[-1] = 1 # all of them below lower bound elif np.all(values <= edges[0]):...
def check_array(array): "Converts to flattened numpy arrays and ensures its not empty." if len(array) < 1: raise ValueError('Input array is empty! Must have atleast 1 element.') return np.ma.masked_invalid(array).flatten()
def list(self): """ Return a list of Accounts from Toshl for the current user """ response = self.client._make_request('/accounts') response = response.json() return self.client._list_response(response)
def search(self, account_name): """ Get a list of all the Accounts for the current user and return the ID of the one with the specified name. """ accounts = self.list() for a in accounts: if a['name'] == account_name: return a['id']
def get(self, account_id): """ Return a specific account given its ID """ response = self.client._make_request('/accounts/{0}'.format(account_id)) return response.json()
def get_assessment_part_bank_session(self): """Gets the ``OsidSession`` to lookup assessment part/bank mappings for assessment parts. return: (osid.assessment.authoring.AssessmentPartBankSession) - an ``AssessmentPartBankSession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_ass...
def get_assessment_part_bank_assignment_session(self): """Gets the ``OsidSession`` associated with assigning assessment part to bank. return: (osid.assessment.authoring.AssessmentPartBankAssignmentS ession) - an ``AssessmentPartBankAssignmentSession`` raise: OperationFailed - unable to complete request raise: Unimpleme...
def get_sequence_rule_lookup_session(self): """Gets the ``OsidSession`` associated with the sequence rule lookup service. return: (osid.assessment.authoring.SequenceRuleLookupSession) - a ``SequenceRuleLookupSession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_sequence_rule_lo...
def get_sequence_rule_admin_session(self): """Gets the ``OsidSession`` associated with the sequence rule administration service. return: (osid.assessment.authoring.SequenceRuleAdminSession) - a ``SequenceRuleAdminSession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_sequence_ru...
def get_sequence_rule_admin_session_for_bank(self, bank_id): """Gets the ``OsidSession`` associated with the sequence rule administration service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the ``Bank`` return: (osid.assessment.authoring.SequenceRuleAdminSession) - a ``SequenceRuleAdminSession`` raise:...
def get_assessment_part_item_session(self, *args, **kwargs): """Gets the ``OsidSession`` associated with the assessment part item service. return: (osid.assessment.authoring.AssessmentPartItemSession) - an ``AssessmentPartItemSession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``support...
def get_assessment_part_item_design_session(self, *args, **kwargs): """Gets the ``OsidSession`` associated with the assessment part item design service. return: (osid.assessment.authoring.AssessmentPartItemDesignSession) - an ``AssessmentPartItemDesignSession`` raise: OperationFailed - unable to complete request raise:...
def get_assessment_part_lookup_session(self, proxy): """Gets the ``OsidSession`` associated with the assessment part lookup service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.authoring.AssessmentPartLookupSession) - an ``AssessmentPartLookupSession`` raise: NullArgument - ``proxy`` is ``null`` rai...
def get_assessment_part_lookup_session_for_bank(self, bank_id, proxy): """Gets the ``OsidSession`` associated with the assessment part lookup service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the ``Bank`` arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.authoring.AssessmentPartLookupSe...
def get_assessment_part_query_session(self, proxy): """Gets the ``OsidSession`` associated with the assessment part query service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.authoring.AssessmentPartQuerySession) - an ``AssessmentPartQuerySession`` raise: NullArgument - ``proxy`` is ``null`` raise: ...
def get_assessment_part_query_session_for_bank(self, bank_id, proxy): """Gets the ``OsidSession`` associated with the assessment part query service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the ``Bank`` arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.authoring.AssessmentPartQuerySessi...
def get_assessment_part_admin_session(self, proxy): """Gets the ``OsidSession`` associated with the assessment part administration service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.authoring.AssessmentPartAdminSession) - an ``AssessmentPartAdminSession`` raise: NullArgument - ``proxy`` is ``null`...
def get_assessment_part_admin_session_for_bank(self, bank_id, proxy): """Gets the ``OsidSession`` associated with the assessment part administration service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the ``Bank`` arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.authoring.AssessmentPartA...
def get_sequence_rule_lookup_session_for_bank(self, bank_id, proxy): """Gets the ``OsidSession`` associated with the sequence rule lookup service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the ``Bank`` arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.authoring.SequenceRuleLookupSession)...
def get_assessment_part_item_session(self, proxy): """Gets the ``OsidSession`` associated with the assessment part item service. return: (osid.assessment.authoring.AssessmentPartItemSession) - an ``AssessmentPartItemSession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_assessme...
def get_assessment_part_item_session_for_bank(self, bank_id, proxy): """Gets the ``OsidSession`` associated with the assessment part item service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the ``Bank`` return: (osid.assessment.authoring.AssessmentPartItemSession) - an ``AssessmentPartItemSession`` rai...
def get_assessment_part_item_design_session(self, proxy): """Gets the ``OsidSession`` associated with the assessment part item design service. return: (osid.assessment.authoring.AssessmentPartItemDesignSession) - an ``AssessmentPartItemDesignSession`` raise: OperationFailed - unable to complete request raise: Unimpleme...
def get_assessment_part_item_design_session_for_bank(self, bank_id, proxy): """Gets the ``OsidSession`` associated with the assessment part item design service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the ``Bank`` return: (osid.assessment.authoring.AssessmentPartItemDesignSession) - an ``AssessmentP...
def deprecated(operation=None): """ Mark an operation deprecated. """ def inner(o): o.deprecated = True return o return inner(operation) if operation else inner
def add_param(param): # type: (Param) -> Callable """ Add parameter, you should probably use on of :meth:`path_param`, :meth:`query_param`, :meth:`body_param`, or :meth:`header_param`. """ def inner(o): try: getattr(o, 'parameters').add(param) except AttributeError: setattr(o, 'parameters', {param}) return o return inn...
def response(status, description, resource=DefaultResource): # type: (HTTPStatus, str, Optional[Resource]) -> Callable """ Define an expected response. The values are based off `Swagger <https://swagger.io/specification>`_. """ def inner(o): value = Response(status, description, resource) try: getattr(o, 'responses').a...
def produces(*content_types): """ Define content types produced by an endpoint. """ def inner(o): if not all(isinstance(content_type, _compat.string_types) for content_type in content_types): raise ValueError("In parameter not a valid value.") try: getattr(o, 'produces').update(content_types) except AttributeError: set...
def get_resource_id(self): """Gets the ``resource _id`` for this authorization. return: (osid.id.Id) - the ``Resource Id`` raise: IllegalState - ``has_resource()`` is ``false`` *compliance: mandatory -- This method must be implemented.* """ # Implemented from template for osid.resource.Resource.get_avatar_id_template i...
def get_resource(self): """Gets the ``Resource`` for this authorization. return: (osid.resource.Resource) - the ``Resource`` raise: IllegalState - ``has_resource()`` is ``false`` raise: OperationFailed - unable to complete request *compliance: mandatory -- This method must be implemented.* """ # Implemented from templa...
def get_trust_id(self): """Gets the ``Trust`` ``Id`` for this authorization. return: (osid.id.Id) - the trust ``Id`` raise: IllegalState - ``has_trust()`` is ``false`` *compliance: mandatory -- This method must be implemented.* """ # Implemented from template for osid.resource.Resource.get_avatar_id_template if not boo...
def get_trust(self): """Gets the ``Trust`` for this authorization. return: (osid.authentication.process.Trust) - the ``Trust`` raise: IllegalState - ``has_trust()`` is ``false`` raise: OperationFailed - unable to complete request *compliance: mandatory -- This method must be implemented.* """ # Implemented from templat...
def get_function_id(self): """Gets the ``Function Id`` for this authorization. return: (osid.id.Id) - the function ``Id`` *compliance: mandatory -- This method must be implemented.* """ # Implemented from template for osid.learning.Activity.get_objective_id if not bool(self._my_map['functionId']): raise errors.IllegalS...
def get_function(self): """Gets the ``Function`` for this authorization. return: (osid.authorization.Function) - the function raise: OperationFailed - unable to complete request *compliance: mandatory -- This method must be implemented.* """ # Implemented from template for osid.learning.Activity.get_objective if not bo...
def get_qualifier_id(self): """Gets the ``Qualifier Id`` for this authorization. return: (osid.id.Id) - the qualifier ``Id`` *compliance: mandatory -- This method must be implemented.* """ # Implemented from template for osid.learning.Activity.get_objective_id if not bool(self._my_map['qualifierId']): raise errors.Ille...
def get_qualifier(self): """Gets the qualifier for this authorization. return: (osid.authorization.Qualifier) - the qualifier raise: OperationFailed - unable to complete request *compliance: mandatory -- This method must be implemented.* """ # Implemented from template for osid.learning.Activity.get_objective if not bo...
def _init_map(self, record_types=None, **kwargs): """Initialize form map""" osid_objects.OsidRelationshipForm._init_map(self, record_types=record_types) self._my_map['assignedVaultIds'] = [str(kwargs['vault_id'])] self._my_map['functionId'] = str(kwargs['function_id']) self._my_map['qualifierId'] = str(kwargs['qualifie...
def get_vault(self): """Gets the ``Vault`` at this node. return: (osid.authorization.Vault) - the vault represented by this node *compliance: mandatory -- This method must be implemented.* """ if self._lookup_session is None: mgr = get_provider_manager('AUTHORIZATION', runtime=self._runtime, proxy=self._proxy) self._lo...
def get_parent_vault_nodes(self): """Gets the parents of this vault. return: (osid.authorization.VaultNodeList) - the parents of this vault *compliance: mandatory -- This method must be implemented.* """ parent_vault_nodes = [] for node in self._my_map['parentNodes']: parent_vault_nodes.append(VaultNode( node._my_map, ...
def random_flip(sequence,rnum=None): """Flip a sequence direction with 0.5 probability""" randin = rnum if not randin: randin = RandomSource() if randin.random() < 0.5: return rc(sequence) return sequence
def random_substitution(self,fastq,rate): """Perform the permutation on the sequence :param fastq: FASTQ sequence to permute :type fastq: format.fastq.FASTQ :param rate: how frequently to permute :type rate: float :return: Permutted FASTQ :rtype: format.fastq.FASTQ """ sequence = fastq.sequence seq = '' for i in range(...
def random_deletion(self,fastq,rate): """Perform the permutation on the sequence :param fastq: FASTQ sequence to permute :type fastq: format.fastq.FASTQ :param rate: how frequently to permute :type rate: float :return: Permutted FASTQ :rtype: format.fastq.FASTQ """ sequence = fastq.sequence quality = fastq.qual seq = '...
return FASTQ('@'+fastq.header+"\n"+seq+"\n+\n"+qual+"\n")
def random_insertion(self,fastq,rate,max_inserts=1): """Perform the permutation on the sequence. If authorized to do multiple bases they are done at hte rate defined here. :param fastq: FASTQ sequence to permute :type fastq: format.fastq.FASTQ :param rate: how frequently to permute :type rate: float :param max_inserts:...
z = 0 for i in range(len(sequence)): # check context prev = sequence[i] next = None if i < len(sequence)-1: next = sequence[i+1] if self._before_base and (not prev or prev != self._before_base): seq+=sequence[i] if quality: qual+=quality[i] continue if self._after_base and (not next or next != self._after_base): seq+=s...
def set_custom(self,gmin,gmu,gsigma): """Set a minimum lengtha, and then the gaussian distribution parameters for cutting For any sequence longer than the minimum the guassian parameters will be used""" self._gauss_min = gmin self._gauss_mu = gmu self._gauss_sigma = gsigma
def _is_match(self, response, answer): """Does the response match the answer """ def compare_conditions(droppable_id, spatial_units, response_conditions): """Compare response coordinates with spatial units for droppable_id""" coordinate_match = True for coordinate in response_conditions['coordinate_conditions']['includ...
if not compare_conditions(droppable_id, spatial_units, response_conditions): return False # Compare excluded answer spatial unit areas to response coordinates for droppable_id, spatial_units in answer_conditions['spatial_unit_conditions']['exclude'].items(): if compare_conditions(droppable_id, spatial_units, response_c...
def get_correctness_for_response(self, response): """get measure of correctness available for a particular response""" for answer in self.my_osid_object.get_answers(): if self._is_match(response, answer): try: return answer.get_score() except AttributeError: return 100 for answer in self.my_osid_object.get_wrong_answer...
def get_coordinate_conditions(self): """stub""" condition_list = deepcopy(self.my_osid_object._my_map['coordinateConditions']) for condition in condition_list: condition['coordinate'] = BasicCoordinate(condition['coordinate']) return condition_list
def get_spatial_unit_conditions(self): """stub""" condition_list = deepcopy(self.my_osid_object._my_map['spatialUnitConditions']) for condition in condition_list: condition['spatialUnit'] = SpatialUnitFactory().get_spatial_unit(spatial_unit_map=condition['spatialUnit']) return condition_list
def _init_map(self): """stub""" self.my_osid_object_form._my_map['zoneConditions'] = \ self._zone_conditions_metadata['default_object_values'][0] self.my_osid_object_form._my_map['coordinateConditions'] = \ self._coordinate_conditions_metadata['default_object_values'][0] self.my_osid_object_form._my_map['spatialUnitCon...
def _init_metadata(self): """stub""" self._zone_conditions_metadata = { 'zone_matches': Id(self.my_osid_object_form._authority, self.my_osid_object_form._namespace, 'zone_conditions'), 'element_label': 'zone conditions', 'instructions': 'zone conditions for answer', 'required': False, 'read_only': False, 'linked': Fals...
def add_zone_condition(self, droppable_id, zone_id, match=True): """stub""" self.my_osid_object_form._my_map['zoneConditions'].append( {'droppableId': droppable_id, 'zoneId': zone_id, 'match': match}) self.my_osid_object_form._my_map['zoneConditions'].sort(key=lambda k: k['zoneId'])
def clear_zone_conditions(self): """stub""" if (self.get_zone_conditions_metadata().is_read_only() or self.get_zone_conditions_metadata().is_required()): raise NoAccess() self.my_osid_object_form._my_map['zoneConditions'] = \ self._zone_conditions_metadata['default_object_values'][0]
def add_coordinate_condition(self, droppable_id, container_id, coordinate, match=True): """stub""" if not isinstance(coordinate, BasicCoordinate): raise InvalidArgument('coordinate is not a BasicCoordinate') self.my_osid_object_form._my_map['coordinateConditions'].append( {'droppableId': droppable_id, 'containerId': co...
def clear_coordinate_conditions(self): """stub""" if (self.get_zone_conditions_metadata().is_read_only() or self.get_zone_conditions_metadata().is_required()): raise NoAccess() self.my_osid_object_form._my_map['coordinateConditions'] = \ self._coordinate_conditions_metadata['default_object_values'][0]
def add_spatial_unit_condition(self, droppable_id, container_id, spatial_unit, match=True): """stub""" if not isinstance(spatial_unit, abc_mapping_primitives.SpatialUnit): raise InvalidArgument('spatial_unit is not a SpatialUnit') self.my_osid_object_form._my_map['spatialUnitConditions'].append( {'droppableId': droppab...
def clear_spatial_unit_conditions(self): """stub""" if (self.get_spatial_unit_conditions_metadata().is_read_only() or self.get_zone_conditions_metadata().is_required()): raise NoAccess() self.my_osid_object_form._my_map['spatialUnitConditions'] = \ self._zone_conditions_metadata['default_object_values'][0]
def get_droppables(self): """stub""" droppables = [] for current_droppable in self.my_osid_object._my_map['droppables']: droppables.append({ 'id': current_droppable['id'], 'text': self.get_matching_language_value('texts', dictionary=current_droppable).text, 'name': self.get_matching_language_value('names', dictionary=c...
def get_targets(self): """stub""" targets = [] for current_target in self.my_osid_object._my_map['targets']: targets.append({ 'id': current_target['id'], 'text': self.get_matching_language_value('texts', dictionary=current_target).text, 'name': self.get_matching_language_value('names', dictionary=current_target).text, ...
def get_zones(self): """stub""" zones = [] for current_zone in self.my_osid_object._my_map['zones']: zones.append({ 'id': current_zone['id'], 'name': self.get_matching_language_value('names', dictionary=current_zone).text, 'description': self.get_matching_language_value('descriptions', dictionary=current_zone).text, 's...
def _update_object_map(self, obj_map): """unclear if it's better to use this method or get_object_map My main consideration is that MultiLanguageQuestionRecord already overrides get_object_map """ obj_map['droppables'] = self.get_droppables() obj_map['targets'] = self.get_targets() obj_map['zones'] = self.get_zones()
def _init_map(self): """stub""" super(MultiLanguageDragAndDropQuestionFormRecord, self)._init_map() self.my_osid_object_form._my_map['droppables'] = \ self._droppables_metadata['default_object_values'][0] self.my_osid_object_form._my_map['targets'] = \ self._targets_metadata['default_object_values'][0] self.my_osid_obj...
def _init_metadata(self): """stub""" super(MultiLanguageDragAndDropQuestionFormRecord, self)._init_metadata() self._droppables_metadata = { 'element_id': Id(self.my_osid_object_form._authority, self.my_osid_object_form._namespace, 'droppables'), 'element_label': 'droppables', 'instructions': 'Enter as many droppables a...
= { 'element_id': Id(self.my_osid_object_form._authority, self.my_osid_object_form._namespace, 'shuffleTargets'), 'element_label': 'Shuffle Targets', 'instructions': 'Shuffle targets', 'required': True, 'read_only': False, 'linked': True, 'array': False, 'default_boolean_values': [True], 'syntax': 'BOOLEAN', } self._sh...
def add_droppable(self, droppable_text, name='', reuse=1, drop_behavior_type=None): """stub""" if not isinstance(droppable_text, DisplayText): raise InvalidArgument('droppable_text is not a DisplayText object') if not isinstance(reuse, int): raise InvalidArgument('reuse must be an integer') if reuse < 0: raise InvalidA...
def clear_droppables(self): """stub""" if self.get_droppables_metadata().is_read_only(): raise NoAccess() self.my_osid_object_form._my_map['droppables'] = \ self._droppables_metadata['default_object_values'][0]
def clear_droppable_texts(self, droppable_id): """stub""" if self.get_droppables_metadata().is_read_only(): raise NoAccess() updated_droppables = [] for current_droppable in self.my_osid_object_form._my_map['droppables']: if current_droppable['id'] != droppable_id: updated_droppables.append(current_droppable) else: upd...
def remove_droppable(self, droppable_id): """remove a droppable, given the id""" updated_droppables = [] for droppable in self.my_osid_object_form._my_map['droppables']: if droppable['id'] != droppable_id: updated_droppables.append(droppable) self.my_osid_object_form._my_map['droppables'] = updated_droppables
def set_droppable_order(self, droppable_ids): """ reorder droppables per the passed in list :param droppable_ids: :return: """ reordered_droppables = [] current_droppable_ids = [d['id'] for d in self.my_osid_object_form._my_map['droppables']] if set(droppable_ids) != set(current_droppable_ids): raise IllegalState('drop...
def add_target(self, target_text, name='', drop_behavior_type=None): """stub""" if not isinstance(target_text, DisplayText): raise InvalidArgument('target_text is not a DisplayText object') if not isinstance(name, DisplayText): # if default '' name = self._str_display_text(name) target = { 'id': str(ObjectId()), 'texts...
def clear_targets(self): """stub""" if self.get_targets_metadata().is_read_only(): raise NoAccess() self.my_osid_object_form._my_map['targets'] = \ self._targets_metadata['default_object_values'][0]