_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q49000
is_pid
train
def is_pid(value): """ This function checks whether file path that is specified at "pid_file" option eixsts, whether write permission to the file path. Return the following value: case1: exists path and write permission is_pid('/tmp') '/tmp/hogehoge.pid' case2: non-exis...
python
{ "resource": "" }
q49001
Scheduler.run
train
def run(self): """ Run the schedule """ self.main_task.thread.start() self.main_task.thread.join()
python
{ "resource": "" }
q49002
HierarchySearchResults.get_hierarchies
train
def get_hierarchies(self): """Gets the hierarchy list resulting from the search. return: (osid.hierarchy.HierarchyList) - the hierarchy list raise: IllegalState - the hierarchy list was already retrieved *compliance: mandatory -- This method must be implemented.* """ i...
python
{ "resource": "" }
q49003
Sequence2Bit._set_seq
train
def _set_seq(self,sequence,start=0): """Set the sequence from a start position for the length of the sequence""" if start+len(sequence) > self._slen: sys.stderr.write("Error not long enough to add\n") sys.exit() z = 0 for i in xrange(start, start+len(sequence)): self._set_nt(sequence[...
python
{ "resource": "" }
q49004
AgentLookupSession.get_agent
train
def get_agent(self, agent_id): """Gets the ``Agent`` specified by its ``Id``. In plenary mode, the exact ``Id`` is found or a ``NotFound`` results. Otherwise, the returned ``Agent`` may have a different ``Id`` than requested, such as the case where a duplicate ``Id`` was assigne...
python
{ "resource": "" }
q49005
AgentLookupSession.get_agents_by_ids
train
def get_agents_by_ids(self, agent_ids): """Gets an ``AgentList`` corresponding to the given ``IdList``. In plenary mode, the returned list contains all of the agents specified in the ``Id`` list, in the order of the list, including duplicates, or an error results if an ``Id`` in the ...
python
{ "resource": "" }
q49006
AgentLookupSession.get_agents_by_genus_type
train
def get_agents_by_genus_type(self, agent_genus_type): """Gets an ``AgentList`` corresponding to the given agent genus ``Type`` which does not include agents of genus types derived from the specified ``Type``. In plenary mode, the returned list contains all known agents or an error results. Othe...
python
{ "resource": "" }
q49007
AgentLookupSession.get_agents
train
def get_agents(self): """Gets all ``Agents``. In plenary mode, the returned list contains all known agents or an error results. Otherwise, the returned list may contain only those agents that are accessible through this session. return: (osid.authentication.AgentList) - a list ...
python
{ "resource": "" }
q49008
Logger.lastLogged
train
def lastLogged(self): """Get a dictionary of last logged messages. Keys are log types and values are the the last messages.""" d = copy.deepcopy(self.__lastLogged) d.pop(-1, None) return d
python
{ "resource": "" }
q49009
Logger.set_stdout
train
def set_stdout(self, stream=None): """ Set the logger standard output stream. :Parameters: #. stdout (None, stream): The standard output stream. If None, system standard output will be set automatically. Otherwise any stream with read and write methods can...
python
{ "resource": "" }
q49010
Logger.set_log_type_flags
train
def set_log_type_flags(self, logType, stdoutFlag, fileFlag): """ Set a defined log type flags. :Parameters: #. logType (string): A defined logging type. #. stdoutFlag (boolean): Whether to log to the standard output stream. #. fileFlag (boolean): Whether to log ...
python
{ "resource": "" }
q49011
Logger.set_log_file
train
def set_log_file(self, logfile): """ Set the log file full path including directory path basename and extension. :Parameters: #. logFile (string): the full log file path including basename and extension. If this is given, all of logFileBasename and logFileExtension ...
python
{ "resource": "" }
q49012
Logger.set_log_file_extension
train
def set_log_file_extension(self, logFileExtension): """ Set the log file extension. :Parameters: #. logFileExtension (string): Logging file extension. A logging file full name is set as logFileBasename.logFileExtension """ assert isinstance(logFileExtens...
python
{ "resource": "" }
q49013
Logger.__set_log_file_name
train
def __set_log_file_name(self): """Automatically set logFileName attribute""" # ensure directory exists dir, _ = os.path.split(self.__logFileBasename) if len(dir) and not os.path.exists(dir): os.makedirs(dir) # create logFileName self.__logFileName = self.__log...
python
{ "resource": "" }
q49014
Logger.set_log_file_maximum_size
train
def set_log_file_maximum_size(self, logFileMaxSize): """ Set the log file maximum size in megabytes :Parameters: #. logFileMaxSize (number): The maximum size in Megabytes of a logging file. Once exceeded, another logging file as logFileBasename_N.logFileExtension ...
python
{ "resource": "" }
q49015
Logger.set_minimum_level
train
def set_minimum_level(self, level=0, stdoutFlag=True, fileFlag=True): """ Set the minimum logging level. All levels below the minimum will be ignored at logging. :Parameters: #. level (None, number, str): The minimum level of logging. If None, minimum level checking is ...
python
{ "resource": "" }
q49016
Logger.force_log_type_stdout_flag
train
def force_log_type_stdout_flag(self, logType, flag): """ Force a logtype standard output logging flag despite minimum and maximum logging level boundaries. :Parameters: #. logType (string): A defined logging type. #. flag (None boolean): The standard output logging flag. ...
python
{ "resource": "" }
q49017
Logger.force_log_type_file_flag
train
def force_log_type_file_flag(self, logType, flag): """ Force a logtype file logging flag despite minimum and maximum logging level boundaries. :Parameters: #. logType (string): A defined logging type. #. flag (None, boolean): The file logging flag. If None, l...
python
{ "resource": "" }
q49018
Logger.force_log_type_flags
train
def force_log_type_flags(self, logType, stdoutFlag, fileFlag): """ Force a logtype logging flags. :Parameters: #. logType (string): A defined logging type. #. stdoutFlag (None, boolean): The standard output logging flag. If None, logtype stdoutFlag forcing is...
python
{ "resource": "" }
q49019
Logger.set_log_type_name
train
def set_log_type_name(self, logType, name): """ Set a logtype name. :Parameters: #. logType (string): A defined logging type. #. name (string): The logtype new name. """ assert logType in self.__logTypeStdoutFlags.keys(), "logType '%s' not defined" %logType...
python
{ "resource": "" }
q49020
Logger.set_log_type_level
train
def set_log_type_level(self, logType, level): """ Set a logtype logging level. :Parameters: #. logType (string): A defined logging type. #. level (number): The level of logging. """ assert _is_number(level), "level must be a number" level = float(le...
python
{ "resource": "" }
q49021
Logger.remove_log_type
train
def remove_log_type(self, logType, _assert=False): """ Remove a logtype. :Parameters: #. logType (string): The logtype. #. _assert (boolean): Raise an assertion error if logType is not defined. """ # check logType if _assert: assert logT...
python
{ "resource": "" }
q49022
Logger.add_log_type
train
def add_log_type(self, logType, name=None, level=0, stdoutFlag=None, fileFlag=None, color=None, highlight=None, attributes=None): """ Add a new logtype. :Parameters: #. logType (string): The logtype. #. name (None, string): The logtype name. If None, name will be set to lo...
python
{ "resource": "" }
q49023
Logger.update_log_type
train
def update_log_type(self, logType, name=None, level=None, stdoutFlag=None, fileFlag=None, color=None, highlight=None, attributes=None): """ update a logtype. :Parameters: #. logType (string): The logtype. #. name (None, string): The logtype name. If None, name will be set ...
python
{ "resource": "" }
q49024
Logger.log
train
def log(self, logType, message, data=None, tback=None): """ log a message of a certain logtype. :Parameters: #. logType (string): A defined logging type. #. message (string): Any message to log. #. data (None, object): Any type of data to print and/or write to ...
python
{ "resource": "" }
q49025
Logger.force_log
train
def force_log(self, logType, message, data=None, tback=None, stdout=True, file=True): """ Force logging a message of a certain logtype whether logtype level is allowed or not. :Parameters: #. logType (string): A defined logging type. #. message (string): Any message to log...
python
{ "resource": "" }
q49026
Logger.flush
train
def flush(self): """Flush all streams.""" if self.__logFileStream is not None: try: self.__logFileStream.flush() except: pass try: os.fsync(self.__logFileStream.fileno()) except: pass ...
python
{ "resource": "" }
q49027
Transcriptome.sort_transcripts
train
def sort_transcripts(self): """Sort the transcripts stored here""" txs = sorted(self.transcripts,key=lambda x: (x.range.chr, x.range.start, x.range.end)) self._transcripts = txs
python
{ "resource": "" }
q49028
LocaleManager._set_no_catalog_view
train
def _set_no_catalog_view(self, session): """Sets the underlying no_catalog view to match current view""" if self._no_catalog_view == COMPARATIVE: try: session.use_comparative_no_catalog_view() except AttributeError: pass else: t...
python
{ "resource": "" }
q49029
Mailer.send
train
def send(self, send_to, from_who, subject, message, reply_to=None): """Send Email. To use this module pass in a message, send_to, from_who, and subject. :param send_to: ``str`` :param from_who: ``str`` :param subject: ``str`` :param message: ``str`` :param reply...
python
{ "resource": "" }
q49030
ZimbraClient.authenticate
train
def authenticate(self, account_name, password): """ Authenticates zimbra account. @param account_name: account email address @param password: account password @raise AuthException: if authentication fails @raise SoapException: if soap communication fails """ ...
python
{ "resource": "" }
q49031
ZimbraClient.change_password
train
def change_password(self, current_password, new_password): """ Changes account password. @param current_password: current password @param new_password: new password """ attrs = {sconstant.A_BY: sconstant.V_NAME} account = SOAPpy.Types.stringType(data=self.auth_tok...
python
{ "resource": "" }
q49032
ZimbraClient.get_info
train
def get_info(self, params={}): """ Gets mailbox info. @param params: params to retrieve @return: AccountInfo """ res = self.invoke(zconstant.NS_ZIMBRA_ACC_URL, sconstant.GetInfoRequest, params) return res
python
{ "resource": "" }
q49033
get_relationship_mdata
train
def get_relationship_mdata(): """Return default mdata map for Relationship""" return { 'source': { 'element_label': { 'text': 'source', 'languageTypeId': str(DEFAULT_LANGUAGE_TYPE), 'scriptTypeId': str(DEFAULT_SCRIPT_TYPE), 'for...
python
{ "resource": "" }
q49034
OsidQuery._match_minimum_date_time
train
def _match_minimum_date_time(self, match_key, date_time_value, match=True): """Matches a minimum date time value""" if match: gtelt = '$gte' else: gtelt = '$lt' if match_key in self._query_terms: self._query_terms[match_key][gtelt] = date_time_value ...
python
{ "resource": "" }
q49035
OsidQuery._clear_minimum_terms
train
def _clear_minimum_terms(self, match_key): """clears minimum match_key term values""" try: # clear match = True case del self._query_terms[match_key]['$gte'] except KeyError: pass try: # clear match = False case del self._query_terms[match_key]['$lt'...
python
{ "resource": "" }
q49036
OsidQuery._clear_maximum_terms
train
def _clear_maximum_terms(self, match_key): """clears maximum match_key term values""" try: # clear match = True case del self._query_terms[match_key]['$lte'] except KeyError: pass try: # clear match = False case del self._query_terms[match_key]['$gt'...
python
{ "resource": "" }
q49037
OsidQuery.match_keyword
train
def match_keyword(self, keyword, string_match_type=DEFAULT_STRING_MATCH_TYPE, match=True): """Adds a keyword to match. Multiple keywords can be added to perform a boolean ``OR`` among them. A keyword may be applied to any of the elements defined in this object such as the display name, ...
python
{ "resource": "" }
q49038
OsidQuery.match_any
train
def match_any(self, match): """Matches any object. arg: match (boolean): ``true`` to match any object ``,`` ``false`` to match no objects *compliance: mandatory -- This method must be implemented.* """ match_key = '_id' param = '$exists' if ma...
python
{ "resource": "" }
q49039
OsidTemporalQuery.match_start_date
train
def match_start_date(self, start, end, match): """Matches temporals whose start date falls in between the given dates inclusive. arg: start (osid.calendaring.DateTime): start of date range arg: end (osid.calendaring.DateTime): end of date range arg: match (boolean): ``true`` if...
python
{ "resource": "" }
q49040
OsidTemporalQuery.match_end_date
train
def match_end_date(self, start, end, match): """Matches temporals whose effective end date falls in between the given dates inclusive. arg: start (osid.calendaring.DateTime): start of date range arg: end (osid.calendaring.DateTime): end of date range arg: match (boolean): ``tru...
python
{ "resource": "" }
q49041
OsidTemporalQuery.match_date
train
def match_date(self, from_, to, match): """Matches temporals where the given date range falls entirely between the start and end dates inclusive. arg: from (osid.calendaring.DateTime): start date arg: to (osid.calendaring.DateTime): end date arg: match (boolean): ``true`` if a ...
python
{ "resource": "" }
q49042
NamedAtomicLock.acquire
train
def acquire(self, timeout=None): ''' acquire - Acquire given lock. Can be blocking or nonblocking by providing a timeout. Returns "True" if you got the lock, otherwise "False" @param timeout <None/float> - Max number of seconds to wait, or None to block until we can acquir...
python
{ "resource": "" }
q49043
NamedAtomicLock.release
train
def release(self, forceRelease=False): ''' release - Release the lock. @param forceRelease <bool> default False - If True, will release the lock even if we don't hold it. @return - True if lock is released, otherwise False ''' if not self.held: i...
python
{ "resource": "" }
q49044
NamedAtomicLock.isHeld
train
def isHeld(self): ''' isHeld - True if anyone holds the lock, otherwise False. @return bool - If lock is held by anyone ''' if not os.path.exists(self.lockPath): return False try: mtime = os.stat(self.lockPath).st_mtime ex...
python
{ "resource": "" }
q49045
NamedAtomicLock.hasLock
train
def hasLock(self): ''' hasLock - Property, returns True if we have the lock, or False if we do not. @return <bool> - True/False if we have the lock or not. ''' # If we don't hold it currently, return False if self.held is False: return False ...
python
{ "resource": "" }
q49046
validate
train
def validate(bundle): """Validate a bundle object and all of its components. The bundle must be passed as a YAML decoded object. Return a list of bundle errors, or an empty list if the bundle is valid. """ errors = [] add_error = errors.append # Check that the bundle sections are well for...
python
{ "resource": "" }
q49047
_validate_sections
train
def _validate_sections(bundle, add_error): """Check that the base bundle sections are valid. The bundle argument is a YAML decoded bundle content. A bundle is composed of series, services, machines and relations. Only the services section is mandatory. Use the given add_error callable to register...
python
{ "resource": "" }
q49048
_validate_series
train
def _validate_series(series, label, add_error): """Check that the given series is valid. Use the given label (e.g. "machine X" or just "bundle") to describe possible errors. Use the given add_error callable to register validation error. """ if series is None: return if not isstring(...
python
{ "resource": "" }
q49049
_validate_services
train
def _validate_services(services, machines, add_error): """Validate each service within the bundle. Receive the services and machines sections of the bundle. Use the given add_error callable to register validation error. """ machine_ids = set() for service_name, service in services.items(): ...
python
{ "resource": "" }
q49050
_validate_charm
train
def _validate_charm(url, service_name, add_error): """Validate the given charm URL. Use the given service name to describe possible errors. Use the given add_error callable to register validation error. If the URL is valid, return the corresponding charm reference object. Return None otherwise. ...
python
{ "resource": "" }
q49051
_validate_num_units
train
def _validate_num_units(num_units, service_name, add_error): """Check that the given num_units is valid. Use the given service name to describe possible errors. Use the given add_error callable to register validation error. If no errors are encountered, return the number of units as an integer. Re...
python
{ "resource": "" }
q49052
_validate_constraints
train
def _validate_constraints(constraints, label, add_error): """Validate the given service or machine constraints. Use the given label (e.g. "machine X" or "service Y") to describe possible errors. Use the given add_error callable to register validation error. """ if constraints is None: r...
python
{ "resource": "" }
q49053
_validate_storage
train
def _validate_storage(storage, service_name, add_error): """Lazily validate the storage constraints, ensuring that they are a dict. Use the given add_error callable to register validation error. """ if storage is None: return if not isdict(storage): msg = 'service {} has invalid sto...
python
{ "resource": "" }
q49054
_validate_options
train
def _validate_options(options, service_name, add_error): """Lazily validate the options, ensuring that they are a dict. Use the given add_error callable to register validation error. """ if options is None: return if not isdict(options): add_error('service {} has malformed options'....
python
{ "resource": "" }
q49055
_validate_annotations
train
def _validate_annotations(annotations, label, add_error): """Check that the given service or machine annotations are valid. Use the given label (e.g. "machine X" or "service Y") to describe possible errors. Use the given add_error callable to register validation error. """ if annotations is Non...
python
{ "resource": "" }
q49056
_validate_placement
train
def _validate_placement(placement, services, machines, charm, add_error): """Validate a placement directive against other services. Receive the placement (possibly as a string), the services and machines bundle sections, the corresponding charm (or None if invalid) and the add_error callable used to re...
python
{ "resource": "" }
q49057
_validate_machines
train
def _validate_machines(machines, add_error): """Validate the given machines section. Validation includes machines constraints, series and annotations. Use the given add_error callable to register validation error. """ if not machines: return for machine_id, machine in machines.items(): ...
python
{ "resource": "" }
q49058
_validate_relations
train
def _validate_relations(relations, services, add_error): """Validate relations, ensuring that the endpoints exist. Receive the relations and services bundle sections. Use the given add_error callable to register validation error. """ if not relations: return for relation in relations: ...
python
{ "resource": "" }
q49059
get_block_bounds
train
def get_block_bounds(filename): """Pre block starts start 0-indexted, end 1-indexted :param filename: filename :type filename: string :return: 0-index start and 1-index end :rtype: array of arrays with the [start end] of each block """ bs = [] with open(filename,'rb') as inf: while True: bytes1 = inf....
python
{ "resource": "" }
q49060
reader.read
train
def read(self,size): """read size bytes and return them""" done = 0 #number of bytes that have been read so far v = '' while True: if size-done < len(self._buffer['data']) - self._buffer_pos: v += self._buffer['data'][self._buffer_pos:self._buffer_pos+(size-done)] self._buffer_pos...
python
{ "resource": "" }
q49061
OsidSearch.limit_result_set
train
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 ...
python
{ "resource": "" }
q49062
CommentingManager.get_comment_lookup_session
train
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 - ``suppor...
python
{ "resource": "" }
q49063
CommentingManager.get_comment_book_session
train
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()...
python
{ "resource": "" }
q49064
CommentingManager.get_comment_book_assignment_session
train
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: Unimplement...
python
{ "resource": "" }
q49065
CommentingManager.get_book_lookup_session
train
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_look...
python
{ "resource": "" }
q49066
CommentingProxyManager.get_comment_lookup_session_for_book
train
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.CommentLo...
python
{ "resource": "" }
q49067
CommentingProxyManager.get_comment_query_session
train
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 ``nu...
python
{ "resource": "" }
q49068
CommentingProxyManager.get_comment_query_session_for_book
train
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.CommentQuer...
python
{ "resource": "" }
q49069
CommentingProxyManager.get_comment_admin_session
train
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`...
python
{ "resource": "" }
q49070
CommentingProxyManager.get_comment_admin_session_for_book
train
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.Co...
python
{ "resource": "" }
q49071
CommentingProxyManager.get_book_admin_session
train
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`...
python
{ "resource": "" }
q49072
CommentingProxyManager.get_book_hierarchy_session
train
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 ...
python
{ "resource": "" }
q49073
CommentingProxyManager.get_book_hierarchy_design_session
train
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: Nu...
python
{ "resource": "" }
q49074
ScriptFields.add_field
train
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) ...
python
{ "resource": "" }
q49075
getfield
train
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
python
{ "resource": "" }
q49076
Input.data
train
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.env...
python
{ "resource": "" }
q49077
distro_check
train
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'...
python
{ "resource": "" }
q49078
PackageInstaller._installer
train
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 =...
python
{ "resource": "" }
q49079
PackageInstaller.install
train
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'))
python
{ "resource": "" }
q49080
Comment.get_commenting_agent
train
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...
python
{ "resource": "" }
q49081
Comment.get_rating_id
train
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....
python
{ "resource": "" }
q49082
CommentForm.get_text_metadata
train
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 metadat...
python
{ "resource": "" }
q49083
CommentForm.set_text
train
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 b...
python
{ "resource": "" }
q49084
CommentForm.clear_text
train
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_...
python
{ "resource": "" }
q49085
CommentForm.get_rating_metadata
train
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 met...
python
{ "resource": "" }
q49086
CommentForm.set_rating
train
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: manda...
python
{ "resource": "" }
q49087
CommentForm.clear_rating
train
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_a...
python
{ "resource": "" }
q49088
BookNode.get_book
train
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('COM...
python
{ "resource": "" }
q49089
BookNode.get_parent_book_nodes
train
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['parentNo...
python
{ "resource": "" }
q49090
CommentLookupSession.get_comments_for_reference_on_date
train
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 ...
python
{ "resource": "" }
q49091
CommentSearchSession.get_comments_by_search
train
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'): ...
python
{ "resource": "" }
q49092
OsidForm._init_metadata
train
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...
python
{ "resource": "" }
q49093
OsidForm._is_valid_id
train
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
python
{ "resource": "" }
q49094
OsidForm._is_valid_type
train
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
python
{ "resource": "" }
q49095
OsidForm._is_valid_string
train
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_len...
python
{ "resource": "" }
q49096
OsidForm._is_valid_cardinal
train
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() ...
python
{ "resource": "" }
q49097
OsidForm._is_valid_integer
train
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 i...
python
{ "resource": "" }
q49098
OsidForm._is_valid_decimal
train
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() an...
python
{ "resource": "" }
q49099
OsidForm._is_valid_date_time
train
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): ...
python
{ "resource": "" }