code
stringlengths
1
18.2k
def get_objective_query_session(self, proxy): """Gets the ``OsidSession`` associated with the objective query service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.learning.ObjectiveQuerySession) - an ``ObjectiveQuerySession`` raise: NullArgument - ``proxy`` is ``null`` raise: OperationFailed - unable to comple...
def get_objective_query_session_for_objective_bank(self, objective_bank_id, proxy): """Gets the ``OsidSession`` associated with the objective query service for the given objective bank. arg: objective_bank_id (osid.id.Id): the ``Id`` of the objective bank arg: proxy (osid.proxy.Proxy): a proxy return: (osid.learning.Ob...
def get_objective_hierarchy_session(self, proxy): """Gets the session for traversing objective hierarchies. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.learning.ObjectiveHierarchySession) - an ``ObjectiveHierarchySession`` raise: NullArgument - ``proxy`` is ``null`` raise: OperationFailed - unable to complete ...
def get_objective_hierarchy_session_for_objective_bank(self, objective_bank_id, proxy): """Gets the ``OsidSession`` associated with the objective hierarchy traversal service for the given objective bank. arg: objective_bank_id (osid.id.Id): the ``Id`` of the objective bank arg: proxy (osid.proxy.Proxy): a proxy return:...
def get_objective_hierarchy_design_session(self, proxy): """Gets the session for designing objective hierarchies. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.learning.ObjectiveHierarchyDesignSession) - an ``ObjectiveHierarchyDesignSession`` raise: NullArgument - ``proxy`` is ``null`` raise: OperationFailed - u...
def get_objective_hierarchy_design_session_for_objective_bank(self, objective_bank_id, proxy): """Gets the ``OsidSession`` associated with the objective hierarchy design service for the given objective bank. arg: objective_bank_id (osid.id.Id): the ``Id`` of the objective bank arg: proxy (osid.proxy.Proxy): a proxy ret...
def get_objective_sequencing_session(self, proxy): """Gets the session for sequencing objectives. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.learning.ObjectiveSequencingSession) - an ``ObjectiveSequencingSession`` raise: NullArgument - ``proxy`` is ``null`` raise: OperationFailed - unable to complete request ...
def get_objective_sequencing_session_for_objective_bank(self, objective_bank_id, proxy): """Gets the ``OsidSession`` associated with the objective sequencing service for the given objective bank. arg: objective_bank_id (osid.id.Id): the ``Id`` of the objective bank arg: proxy (osid.proxy.Proxy): a proxy return: (osid.l...
def get_objective_requisite_session(self, proxy): """Gets the session for examining objective requisites. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.learning.ObjectiveRequisiteSession) - an ``ObjectiveRequisiteSession`` raise: NullArgument - ``proxy`` is ``null`` raise: OperationFailed - unable to complete re...
def get_objective_requisite_session_for_objective_bank(self, objective_bank_id, proxy): """Gets the ``OsidSession`` associated with the objective sequencing service for the given objective bank. arg: objective_bank_id (osid.id.Id): the ``Id`` of the objective bank arg: proxy (osid.proxy.Proxy): a proxy return: (osid.le...
def get_objective_requisite_assignment_session(self, proxy): """Gets the session for managing objective requisites. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.learning.ObjectiveRequisiteAssignmentSession) - an ``ObjectiveRequisiteAssignmentSession`` raise: NullArgument - ``proxy`` is ``null`` raise: Operation...
def get_objective_requisite_assignment_session_for_objective_bank(self, objective_bank_id, proxy): """Gets the ``OsidSession`` associated with the objective sequencing service for the given objective bank. arg: objective_bank_id (osid.id.Id): the ``Id`` of the objective bank arg: proxy (osid.proxy.Proxy): a proxy retur...
def get_activity_lookup_session(self, proxy): """Gets the ``OsidSession`` associated with the activity lookup service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.learning.ActivityLookupSession) - an ``ActivityLookupSession`` raise: NullArgument - ``proxy`` is ``null`` raise: OperationFailed - unable to comple...
def get_activity_lookup_session_for_objective_bank(self, objective_bank_id, proxy): """Gets the ``OsidSession`` associated with the activity lookup service for the given objective bank. arg: objective_bank_id (osid.id.Id): the ``Id`` of the objective bank arg: proxy (osid.proxy.Proxy): a proxy return: (osid.learning.Ac...
def get_activity_admin_session(self, proxy): """Gets the ``OsidSession`` associated with the activity administration service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.learning.ActivityAdminSession) - an ``ActivityAdminSession`` raise: NullArgument - ``proxy`` is ``null`` raise: OperationFailed - unable to c...
def get_activity_admin_session_for_objective_bank(self, objective_bank_id, proxy): """Gets the ``OsidSession`` associated with the activity admin service for the given objective bank. arg: objective_bank_id (osid.id.Id): the ``Id`` of the objective bank arg: proxy (osid.proxy.Proxy): a proxy return: (osid.learning.Acti...
def get_activity_objective_bank_session(self, proxy): """Gets the session for retrieving activity to objective bank mappings. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.learning.ActivityObjectiveBankSession) - an ``ActivityObjectiveBankSession`` raise: NullArgument - ``proxy`` is ``null`` raise: OperationFail...
def get_activity_objective_bank_assignment_session(self, proxy): """Gets the session for assigning activity to objective bank mappings. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.learning.ActivityObjectiveBankAssignmentSession) - an ``ActivityObjectiveBankAssignmentSession`` raise: NullArgument - ``proxy`` is...
def get_proficiency_lookup_session(self, proxy): """Gets the ``OsidSession`` associated with the proficiency lookup service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.learning.ProficiencyLookupSession) - a ``ProficiencyLookupSession`` raise: NullArgument - ``proxy`` is ``null`` raise: OperationFailed - unabl...
def get_proficiency_lookup_session_for_objective_bank(self, objective_bank_id, proxy): """Gets the ``OsidSession`` associated with the proficiency lookup service for the given objective bank. arg: objective_bank_id (osid.id.Id): the ``Id`` of the obective bank arg: proxy (osid.proxy.Proxy): a proxy return: (osid.learni...
def get_proficiency_admin_session(self, proxy): """Gets the ``OsidSession`` associated with the proficiency administration service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.learning.ProficiencyAdminSession) - a ``ProficiencyAdminSession`` raise: NullArgument - ``proxy`` is ``null`` raise: OperationFailed - ...
def get_proficiency_admin_session_for_objective_bank(self, objective_bank_id, proxy): """Gets the ``OsidSession`` associated with the proficiency administration service for the given objective bank. arg: objective_bank_id (osid.id.Id): the ``Id`` of the ``ObjectiveBank`` arg: proxy (osid.proxy.Proxy): a proxy return: (...
def get_proficiency_objective_bank_assignment_session(self, proxy): """Gets the ``OsidSession`` associated with assigning proficiencies to objective banks. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.learning.ProficiencyObjectiveBankAssignmentSession ) - a ``ProficiencyObjectiveBankAssignmentSession`` raise: N...
def get_objective_bank_lookup_session(self, proxy): """Gets the OsidSession associated with the objective bank lookup service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.learning.ObjectiveBankLookupSession) - an ``ObjectiveBankLookupSession`` raise: NullArgument - ``proxy`` is ``null`` raise: OperationFailed ...
def get_objective_bank_admin_session(self, proxy): """Gets the OsidSession associated with the objective bank administration service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.learning.ObjectiveBankAdminSession) - an ``ObjectiveBankAdminSession`` raise: NullArgument - ``proxy`` is ``null`` raise: OperationFa...
def get_objective_bank_hierarchy_session(self, proxy): """Gets the session traversing objective bank hierarchies. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.learning.ObjectiveBankHierarchySession) - an ``ObjectiveBankHierarchySession`` raise: NullArgument - ``proxy`` is ``null`` raise: OperationFailed - unabl...
def limit_result_set(self, start, end): """By default, searches return all matching results. This method restricts the number of results by setting the start and end of the result set, starting from 1. The starting and ending results can be used for paging results when a certain ordering is requested. The ending positi...
indexed # Spec says that passing in (1, 25) should include 25 entries (1 - 25) # Python indices 0 - 24 # Python [#:##] stops before the last index, but does not include it self._limit_result_set_start = start - 1 self._limit_result_set_end = end
def _init_map(self): """stub""" self.my_osid_object_form._my_map['startTimestamp'] = \ self._start_timestamp_metadata['default_integer_values'][0] self.my_osid_object_form._my_map['endTimestamp'] = \ self._end_timestamp_metadata['default_integer_values'][0]
def _init_metadata(self): """stub""" self._start_timestamp_metadata = { 'element_id': Id(self.my_osid_object_form._authority, self.my_osid_object_form._namespace, 'start_timestamp'), 'element_label': 'start timestamp', 'instructions': 'enter an integer number of seconds for the start time', 'required': False, 'read_onl...
def set_start_timestamp(self, start_timestamp=None): """stub""" if start_timestamp is None: raise NullArgument() if self.get_start_timestamp_metadata().is_read_only(): raise NoAccess() if not self.my_osid_object_form._is_valid_integer( start_timestamp, self.get_start_timestamp_metadata()): raise InvalidArgument() self....
def clear_start_timestamp(self): """stub""" if (self.get_start_timestamp_metadata().is_read_only() or self.get_start_timestamp_metadata().is_required()): raise NoAccess() self.my_osid_object_form._my_map['startTimestamp'] = \ self.get_start_timestamp_metadata().get_default_integer_values()
def set_end_timestamp(self, end_timestamp=None): """stub""" if end_timestamp is None: raise NullArgument() if self.get_end_timestamp_metadata().is_read_only(): raise NoAccess() if not self.my_osid_object_form._is_valid_integer( end_timestamp, self.get_end_timestamp_metadata()): raise InvalidArgument() self.my_osid_obje...
def clear_end_timestamp(self): """stub""" if (self.get_end_timestamp_metadata().is_read_only() or self.get_end_timestamp_metadata().is_required()): raise NoAccess() self.my_osid_object_form._my_map['endTimestamp'] = \ self.get_end_timestamp_metadata().get_default_integer_values()
def get_comment_lookup_session(self): """Gets the ``OsidSession`` associated with the comment lookup service. return: (osid.commenting.CommentLookupSession) - a ``CommentLookupSession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_comment_lookup()`` is ``false`` *compliance: opt...
def get_comment_book_session(self): """Gets the session for retrieving comment to book mappings. return: (osid.commenting.CommentBookSession) - a ``CommentBookSession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_comment_book()`` is ``false`` *compliance: optional -- This metho...
def get_comment_book_assignment_session(self): """Gets the session for assigning comment to book mappings. return: (osid.commenting.CommentBookAssignmentSession) - a ``CommentBookAssignmentSession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_comment_book_assignment()`` is ``fa...
def get_book_lookup_session(self): """Gets the ``OsidSession`` associated with the book lookup service. return: (osid.commenting.BookLookupSession) - a ``BookLookupSession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_book_lookup()`` is ``false`` *compliance: optional -- This m...
def get_comment_lookup_session_for_book(self, book_id, proxy): """Gets the ``OsidSession`` associated with the comment lookup service for the given book. arg: book_id (osid.id.Id): the ``Id`` of the ``Book`` arg: proxy (osid.proxy.Proxy): a proxy return: (osid.commenting.CommentLookupSession) - a ``CommentLookupSession...
def get_comment_query_session(self, proxy): """Gets the ``OsidSession`` associated with the comment query service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.commenting.CommentQuerySession) - a ``CommentQuerySession`` raise: NullArgument - ``proxy`` is ``null`` raise: OperationFailed - unable to complete requ...
def get_comment_query_session_for_book(self, book_id, proxy): """Gets the ``OsidSession`` associated with the comment query service for the given book. arg: book_id (osid.id.Id): the ``Id`` of the ``Book`` arg: proxy (osid.proxy.Proxy): a proxy return: (osid.commenting.CommentQuerySession) - a ``CommentQuerySession`` r...
def get_comment_admin_session(self, proxy): """Gets the ``OsidSession`` associated with the comment administration service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.commenting.CommentAdminSession) - a ``CommentAdminSession`` raise: NullArgument - ``proxy`` is ``null`` raise: OperationFailed - unable to comp...
def get_comment_admin_session_for_book(self, book_id, proxy): """Gets the ``OsidSession`` associated with the comment administration service for the given book. arg: book_id (osid.id.Id): the ``Id`` of the ``Book`` arg: proxy (osid.proxy.Proxy): a proxy return: (osid.commenting.CommentAdminSession) - a ``CommentAdminSe...
def get_book_admin_session(self, proxy): """Gets the ``OsidSession`` associated with the book administrative service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.commenting.BookAdminSession) - a ``BookAdminSession`` raise: NullArgument - ``proxy`` is ``null`` raise: OperationFailed - unable to complete request...
def get_book_hierarchy_session(self, proxy): """Gets the ``OsidSession`` associated with the book hierarchy service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.commenting.BookHierarchySession) - a ``BookHierarchySession`` raise: NullArgument - ``proxy`` is ``null`` raise: OperationFailed - unable to complete ...
def get_book_hierarchy_design_session(self, proxy): """Gets the ``OsidSession`` associated with the book hierarchy design service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.commenting.BookHierarchyDesignSession) - a ``BookHierarchyDesignSession`` raise: NullArgument - ``proxy`` is ``null`` raise: OperationFa...
def build_items(self): """ main loop """ conn = self.connect(address=self.server_address, port=self.server_port) if conn: while not self.queue.empty(): item = self.queue.get() self.pool.append(item) if type(item.data) is (tuple or list): self.body['data'].extend(item.data) else: self.body['data'].append(item.data) self...
def _reverse_queue(self): u"""When socket.timeout has occurred for Zabbix server, this method is called. Enqueue items in self.pool[]. """ while self.pool: item = self.pool.pop() self.queue.put(item, block=False)
def build_statistics_item(self): """ Statistics items are as following: * zabbix_sender result + processed, failed, total and more... """ if self.result is not None: stats = dict() result = self.get_result() info = result['info'] info = info.split(';') info = [entry.split(':') for entry in info] prefix = 'blackbird.zab...
key = '.'.join([prefix, 'response']) stats[key] = result['response'] for key, value in stats.iteritems(): stats_key_list = [ 'blackbird.zabbix_sender.processed', 'blackbird.zabbix_sender.failed', 'blackbird.zabbix_sender.total', ] item = BlackbirdStatisticsItem( key=key, value=value, host=self.options['hostname'] ) if ...
def add_field(self, field_instance): """ Appends a field. """ if isinstance(field_instance, BaseScriptField): field_instance = field_instance else: raise ValueError('Expected a basetring or Field instance') self.fields.append(field_instance) return self
def to_query(self): """ Returns a json-serializable representation. """ query = {} for field_instance in self.fields: query.update(field_instance.to_query()) return query
def to_query(self): """ Returns a json-serializable representation. """ return { self.name: { 'lang': self.lang, 'script': self.script, 'params': self.script_params } }
def getfield(f): """convert values from cgi.Field objects to plain values.""" if isinstance(f, list): return [getfield(x) for x in f] else: return f.value
def data(self): """Returns the data sent with the request.""" # the environment variable CONTENT_LENGTH may be empty or missing try: request_body_size = int(self.environ.get('CONTENT_LENGTH', 0)) except (ValueError): request_body_size = 0 data = self.environ['wsgi.input'].read(request_body_size) return data
def distro_check(): """Return a string containing the distro package manager.""" distro_data = platform.linux_distribution() distro = [d.lower() for d in distro_data if d.isalpha()] if any(['ubuntu' in distro, 'debian' in distro]) is True: return 'apt' elif any(['centos' in distro, 'redhat' in distro]) is True: return ...
def _installer(self, package_list, install_string=None): """Install operating system packages for the system. :param: package_list: ``list`` :param install_string: ``str`` """ packages = ' '.join(package_list) if install_string is None: self.install_string = self.install_process[self.distro] % packages else: self.insta...
def install(self): """Install packages from the packages_dict.""" self.distro = distro_check() package_list = self.packages_dict.get(self.distro) self._installer(package_list=package_list.get('packages'))
def get_commenting_agent(self): """Gets the agent who created this comment. return: (osid.authentication.Agent) - the ``Agent`` raise: OperationFailed - unable to complete request *compliance: mandatory -- This method must be implemented.* """ if not self.has_commentor(): raise errors.IllegalState('this Comment has no ...
def get_rating_id(self): """Gets the ``Id`` of the ``Grade``. return: (osid.id.Id) - the ``Agent`` ``Id`` raise: IllegalState - ``has_rating()`` is ``false`` *compliance: mandatory -- This method must be implemented.* """ # Implemented from template for osid.resource.Resource.get_avatar_id_template if not bool(self._my...
def _init_metadata(self, **kwargs): """Initialize form metadata""" osid_objects.OsidRelationshipForm._init_metadata(self, **kwargs) update_display_text_defaults(self._mdata['text'], self._locale_map) self._text_default = dict(self._mdata['text']['default_string_values'][0]) self._rating_default = self._mdata['rating'][...
def get_text_metadata(self): """Gets the metadata for the text. return: (osid.Metadata) - metadata for the text *compliance: mandatory -- This method must be implemented.* """ # Implemented from template for osid.resource.ResourceForm.get_group_metadata_template metadata = dict(self._mdata['text']) metadata.update({'ex...
def set_text(self, text): """Sets the text. arg: text (string): the new text raise: InvalidArgument - ``text`` is invalid raise: NoAccess - ``Metadata.isReadOnly()`` is ``true`` raise: NullArgument - ``text`` is ``null`` *compliance: mandatory -- This method must be implemented.* """ # Implemented from template for osi...
def clear_text(self): """Clears the text. raise: NoAccess - ``Metadata.isRequired()`` or ``Metadata.isReadOnly()`` is ``true`` *compliance: mandatory -- This method must be implemented.* """ # Implemented from template for osid.repository.AssetForm.clear_title_template if (self.get_text_metadata().is_read_only() or sel...
def get_rating_metadata(self): """Gets the metadata for a rating. return: (osid.Metadata) - metadata for the rating *compliance: mandatory -- This method must be implemented.* """ # Implemented from template for osid.resource.ResourceForm.get_group_metadata_template metadata = dict(self._mdata['rating']) metadata.updat...
def set_rating(self, grade_id): """Sets the rating. arg: grade_id (osid.id.Id): the new rating raise: InvalidArgument - ``grade_id`` is invalid raise: NoAccess - ``Metadata.isReadOnly()`` is ``true`` raise: NullArgument - ``grade_id`` is ``null`` *compliance: mandatory -- This method must be implemented.* """ # Impleme...
def clear_rating(self): """Clears the rating. raise: NoAccess - ``Metadata.isRequired()`` or ``Metadata.isReadOnly()`` is ``true`` *compliance: mandatory -- This method must be implemented.* """ # Implemented from template for osid.resource.ResourceForm.clear_avatar_template if (self.get_rating_metadata().is_read_only(...
def get_book(self): """Gets the ``Book`` at this node. return: (osid.commenting.Book) - the book represented by this node *compliance: mandatory -- This method must be implemented.* """ if self._lookup_session is None: mgr = get_provider_manager('COMMENTING', runtime=self._runtime, proxy=self._proxy) self._lookup_sessi...
def get_parent_book_nodes(self): """Gets the parents of this book. return: (osid.commenting.BookNodeList) - the parents of this book *compliance: mandatory -- This method must be implemented.* """ parent_book_nodes = [] for node in self._my_map['parentNodes']: parent_book_nodes.append(BookNode( node._my_map, runtime=se...
def get_comments_for_reference_on_date(self, reference_id, from_, to): """Pass through to provider CommentLookupSession.get_comments_for_reference_on_date""" # Implemented from azosid template for - # osid.relationship.RelationshipLookupSession.get_relationships_for_source_on_date_template if self._can('lookup'): retur...
def get_comments_by_search(self, comment_query, comment_search): """Pass through to provider CommentSearchSession.get_comments_by_search""" # Implemented from azosid template for - # osid.resource.ResourceSearchSession.get_resources_by_search_template if not self._can('search'): raise PermissionDenied() return self._pr...
def get_genus_type(self): """Gets the genus type of this object. return: (osid.type.Type) - the genus type of this object *compliance: mandatory -- This method must be implemented.* """ try: # Try to stand up full Type objects if they can be found # (Also need to LOOK FOR THE TYPE IN types or through type lookup) genus...
def _init_metadata(self): """Initialize OsidObjectForm metadata.""" # pylint: disable=attribute-defined-outside-init # this method is called from descendent __init__ self._mdata.update(default_mdata.get_osid_form_mdata()) update_display_text_defaults(self._mdata['journal_comment'], self._locale_map) for element_name in...
def _is_valid_input(self, inpt, metadata, array): """The _is_valid_input method takes three arguments: the user input to be checked, the associated osid.Metadata object containing validation requirements and a boolean value indicating whether this is an array value. """ # pylint: disable=too-many-branches,no-self-use #...
elif syntax == 'TYPE': valid = self._is_valid_type(inpt) elif syntax == 'BOOLEAN': valid = self._is_valid_boolean(inpt) elif syntax == 'STRING': valid = self._is_valid_string(inpt, metadata) elif syntax == 'INTEGER': valid = self._is_valid_integer(inpt, metadata) elif syntax == 'DECIMAL': valid = self._is_valid_decimal...
def _is_valid_id(self, inpt): """Checks if input is a valid Id""" from dlkit.abstract_osid.id.primitives import Id as abc_id if isinstance(inpt, abc_id): return True else: return False
def _is_valid_type(self, inpt): """Checks if input is a valid Type""" from dlkit.abstract_osid.type.primitives import Type as abc_type if isinstance(inpt, abc_type): return True else: return False
def _is_valid_string(self, inpt, metadata): """Checks if input is a valid string""" if not is_string(inpt): return False if metadata.get_minimum_string_length() and len(inpt) < metadata.get_minimum_string_length(): return False elif metadata.get_maximum_string_length() and len(inpt) > metadata.get_maximum_string_length...
def _is_valid_cardinal(self, inpt, metadata): """Checks if input is a valid cardinal value""" if not isinstance(inpt, int): return False if metadata.get_minimum_cardinal() and inpt < metadata.get_maximum_cardinal(): return False if metadata.get_maximum_cardinal() and inpt > metadata.get_minimum_cardinal(): return False...
def _is_valid_integer(self, inpt, metadata): """Checks if input is a valid integer value""" if not isinstance(inpt, int): return False if metadata.get_minimum_integer() and inpt < metadata.get_maximum_integer(): return False if metadata.get_maximum_integer() and inpt > metadata.get_minimum_integer(): return False if me...
def _is_valid_decimal(self, inpt, metadata): """Checks if input is a valid decimal value""" if not (isinstance(inpt, float) or isinstance(inpt, Decimal)): return False if not isinstance(inpt, Decimal): inpt = Decimal(str(inpt)) if metadata.get_minimum_decimal() and inpt < metadata.get_minimum_decimal(): return False if...
def _is_valid_date_time(self, inpt, metadata): """Checks if input is a valid DateTime object""" # NEED TO ADD CHECKS FOR OTHER METADATA, LIKE MINIMUM, MAXIMUM, ETC. from dlkit.abstract_osid.calendaring.primitives import DateTime as abc_datetime if isinstance(inpt, abc_datetime): return True else: return False
def _is_valid_duration(self, inpt, metadata): """Checks if input is a valid Duration""" # NEED TO ADD CHECKS FOR OTHER METADATA, LIKE MINIMUM, MAXIMUM, ETC. from dlkit.abstract_osid.calendaring.primitives import Duration as abc_duration if isinstance(inpt, abc_duration): return True else: return False
def _is_in_set(self, inpt, metadata): """checks if the input is in the metadata's *_set list""" # makes an assumption there is only one _set in the metadata dict get_set_methods = [m for m in dir(metadata) if 'get_' in m and '_set' in m] set_results = None for m in get_set_methods: try: set_results = getattr(metadata, ...
def set_locale(self, language_type, script_type): """Specifies a language and script type for ``DisplayText`` fields in this form. Setting a locale to something other than the default locale may affect the ``Metadata`` in this form. If multiple locales are available for managing translations, the ``Metadata`` indicates...
def set_journal_comment(self, comment): """Sets a comment. arg: comment (string): the new comment raise: InvalidArgument - ``comment`` is invalid raise: NoAccess - ``Metadata.isReadonly()`` is ``true`` raise: NullArgument - ``comment`` is ``null`` *compliance: mandatory -- This method must be implemented.* """ self._my...
def _get_record(self, record_type): """This overrides _get_record in osid.Extensible. Perhaps we should leverage it somehow? """ if (not self.has_record_type(record_type) and record_type.get_identifier() not in self._record_type_data_sets): raise errors.Unsupported() if str(record_type) not in self._records: record_ini...
def _init_record(self, record_type_idstr): """Override this from osid.Extensible because Forms use a different attribute in record_type_data.""" record_type_data = self._record_type_data_sets[Id(record_type_idstr).get_identifier()] module = importlib.import_module(record_type_data['module_path']) record = getattr(modul...
def get_start_date_metadata(self): """Gets the metadata for a start date. return: (osid.Metadata) - metadata for the date *compliance: mandatory -- This method must be implemented.* """ metadata = dict(self._mdata['start_date']) metadata.update({'existing_date_time_values': self._my_map['startDate']}) return Metadata(*...
def set_start_date(self, date): """Sets the start date. arg: date (osid.calendaring.DateTime): the new date raise: InvalidArgument - ``date`` is invalid raise: NoAccess - ``Metadata.isReadOnly()`` is ``true`` raise: NullArgument - ``date`` is ``null`` *compliance: mandatory -- This method must be implemented.* """ if s...
def clear_start_date(self): """Clears the start date. raise: NoAccess - ``Metadata.isRequired()`` or ``Metadata.isReadOnly()`` is ``true`` *compliance: mandatory -- This method must be implemented.* """ if (self.get_start_date_metadata().is_read_only() or self.get_start_date_metadata().is_required()): raise errors.NoAc...
def get_end_date_metadata(self): """Gets the metadata for an end date. return: (osid.Metadata) - metadata for the date *compliance: mandatory -- This method must be implemented.* """ metadata = dict(self._mdata['end_date']) metadata.update({'existing_date_time_values': self._my_map['endDate']}) return Metadata(**metada...
def set_end_date(self, date): """Sets the end date. arg: date (osid.calendaring.DateTime): the new date raise: InvalidArgument - ``date`` is invalid raise: NoAccess - ``Metadata.isReadOnly()`` is ``true`` raise: NullArgument - ``date`` is ``null`` *compliance: mandatory -- This method must be implemented.* """ if self....
def clear_end_date(self): """Clears the end date. raise: NoAccess - ``Metadata.isRequired()`` or ``Metadata.isReadOnly()`` is ``true`` *compliance: mandatory -- This method must be implemented.* """ if (self.get_end_date_metadata().is_read_only() or self.get_end_date_metadata().is_required()): raise errors.NoAccess() s...
def set_sequestered(self, sequestered): """Sets the sequestered flag. arg: sequestered (boolean): the new sequestered flag raise: InvalidArgument - ``sequestered`` is invalid raise: NoAccess - ``Metadata.isReadOnly()`` is ``true`` *compliance: mandatory -- This method must be implemented.* """ if sequestered is None: r...
def clear_sequestered(self): """Clears the sequestered flag. raise: NoAccess - ``Metadata.isRequired()`` or ``Metadata.isReadOnly()`` is ``true`` *compliance: mandatory -- This method must be implemented.* """ if (self.get_sequestered_metadata().is_read_only() or self.get_sequestered_metadata().is_required()): raise er...
def get_provider_metadata(self): """Gets the metadata for a provider. return: (osid.Metadata) - metadata for the provider *compliance: mandatory -- This method must be implemented.* """ metadata = dict(self._mdata['provider']) metadata.update({'existing_id_values': self._my_map['providerId']}) return Metadata(**metadat...
def set_provider(self, provider_id): """Sets a provider. arg: provider_id (osid.id.Id): the new provider raise: InvalidArgument - ``provider_id`` is invalid raise: NoAccess - ``Metadata.isReadOnly()`` is ``true`` raise: NullArgument - ``provider_id`` is ``null`` *compliance: mandatory -- This method must be implemented...
def clear_provider(self): """Removes the provider. raise: NoAccess - ``Metadata.isRequired()`` is ``true`` or ``Metadata.isReadOnly()`` is ``true`` *compliance: mandatory -- This method must be implemented.* """ if (self.get_provider_metadata().is_read_only() or self.get_provider_metadata().is_required()): raise errors...
def get_branding_metadata(self): """Gets the metadata for the asset branding. return: (osid.Metadata) - metadata for the asset branding. *compliance: mandatory -- This method must be implemented.* """ metadata = dict(self._mdata['branding']) metadata.update({'existing_id_values': self._my_map['brandingIds']}) return Me...