code
stringlengths
1
18.2k
def get_proficiencies(self): """Gets the proficiency list resulting from a search. return: (osid.learning.ProficiencyList) - the proficiency list raise: IllegalState - list already retrieved *compliance: mandatory -- This method must be implemented.* """ if self.retrieved: raise errors.IllegalState('List has already be...
def get_objective_banks(self): """Gets the objective bank list resulting from the search. return: (osid.learning.ObjectiveBankList) - the objective bank list raise: IllegalState - list already retrieved *compliance: mandatory -- This method must be implemented.* """ if self.retrieved: raise errors.IllegalState('List ha...
def _set_bin_view(self, session): """Sets the underlying bin view to match current view""" if self._bin_view == COMPARATIVE: try: session.use_comparative_bin_view() except AttributeError: pass else: try: session.use_plenary_bin_view() except AttributeError: pass
def initialize(self, runtime): """OSID Manager initialize""" from .primitives import Id if self._runtime is not None: raise IllegalState('Manager has already been initialized') self._runtime = runtime config = runtime.get_configuration() parameter_id = Id('parameter:resourceProviderImpl@dlkit_service') provider_impl = ...
def use_comparative_bin_view(self): """Pass through to provider ResourceBinSession.use_comparative_bin_view""" self._bin_view = COMPARATIVE # self._get_provider_session('resource_bin_session') # To make sure the session is tracked for session in self._get_provider_sessions(): try: session.use_comparative_bin_view() exc...
def use_plenary_bin_view(self): """Pass through to provider ResourceBinSession.use_plenary_bin_view""" self._bin_view = PLENARY # self._get_provider_session('resource_bin_session') # To make sure the session is tracked for session in self._get_provider_sessions(): try: session.use_plenary_bin_view() except AttributeErr...
def get_bins_by_resource(self, *args, **kwargs): """Pass through to provider ResourceBinSession.get_bins_by_resource""" # Implemented from kitosid template for - # osid.resource.ResourceBinSession.get_bins_by_resource catalogs = self._get_provider_session('resource_bin_session').get_bins_by_resource(*args, **kwargs) ca...
def get_bin(self, *args, **kwargs): """Pass through to provider BinLookupSession.get_bin""" # Implemented from kitosid template for - # osid.resource.BinLookupSession.get_bin return Bin( self._provider_manager, self._get_provider_session('bin_lookup_session').get_bin(*args, **kwargs), self._runtime, self._proxy)
def get_bins(self): """Pass through to provider BinLookupSession.get_bins""" # Implemented from kitosid template for - # osid.resource.BinLookupSession.get_bins_template catalogs = self._get_provider_session('bin_lookup_session').get_bins() cat_list = [] for cat in catalogs: cat_list.append(Bin(self._provider_manager, ...
def get_bin_form(self, *args, **kwargs): """Pass through to provider BinAdminSession.get_bin_form_for_update""" # Implemented from kitosid template for - # osid.resource.BinAdminSession.get_bin_form_for_update_template # This method might be a bit sketchy. Time will tell. if isinstance(args[-1], list) or 'bin_record_ty...
def save_bin(self, bin_form, *args, **kwargs): """Pass through to provider BinAdminSession.update_bin""" # Implemented from kitosid template for - # osid.resource.BinAdminSession.update_bin if bin_form.is_for_update(): return self.update_bin(bin_form, *args, **kwargs) else: return self.create_bin(bin_form, *args, **kwa...
def _set_bin_view(self, session): """Sets the underlying bin view to match current view""" if self._bin_view == FEDERATED: try: session.use_federated_bin_view() except AttributeError: pass else: try: session.use_isolated_bin_view() except AttributeError: pass
def use_comparative_resource_view(self): """Pass through to provider ResourceLookupSession.use_comparative_resource_view""" self._object_views['resource'] = COMPARATIVE # self._get_provider_session('resource_lookup_session') # To make sure the session is tracked for session in self._get_provider_sessions(): try: sessio...
def use_plenary_resource_view(self): """Pass through to provider ResourceLookupSession.use_plenary_resource_view""" self._object_views['resource'] = PLENARY # self._get_provider_session('resource_lookup_session') # To make sure the session is tracked for session in self._get_provider_sessions(): try: session.use_plenar...
def use_federated_bin_view(self): """Pass through to provider ResourceLookupSession.use_federated_bin_view""" self._bin_view = FEDERATED # self._get_provider_session('resource_lookup_session') # To make sure the session is tracked for session in self._get_provider_sessions(): try: session.use_federated_bin_view() excep...
def use_isolated_bin_view(self): """Pass through to provider ResourceLookupSession.use_isolated_bin_view""" self._bin_view = ISOLATED # self._get_provider_session('resource_lookup_session') # To make sure the session is tracked for session in self._get_provider_sessions(): try: session.use_isolated_bin_view() except At...
def get_resource_form(self, *args, **kwargs): """Pass through to provider ResourceAdminSession.get_resource_form_for_update""" # Implemented from kitosid template for - # osid.resource.ResourceAdminSession.get_resource_form_for_update # This method might be a bit sketchy. Time will tell. if isinstance(args[-1], list) o...
def save_resource(self, resource_form, *args, **kwargs): """Pass through to provider ResourceAdminSession.update_resource""" # Implemented from kitosid template for - # osid.resource.ResourceAdminSession.update_resource if resource_form.is_for_update(): return self.update_resource(resource_form, *args, **kwargs) else: ...
def use_comparative_agent_view(self): """Pass through to provider ResourceAgentSession.use_comparative_agent_view""" self._object_views['agent'] = COMPARATIVE # self._get_provider_session('resource_agent_session') # To make sure the session is tracked for session in self._get_provider_sessions(): try: session.use_compa...
def use_plenary_agent_view(self): """Pass through to provider ResourceAgentSession.use_plenary_agent_view""" self._object_views['agent'] = PLENARY # self._get_provider_session('resource_agent_session') # To make sure the session is tracked for session in self._get_provider_sessions(): try: session.use_plenary_agent_vie...
def disk_usage(path, human=False): """disk usage in bytes or human readable format (e.g. '2,1GB')""" command = ['du', '-s', path] if human: command.append('-h') return subprocess.check_output(command).split()[0].decode('utf-8')
def _join(segments): """simply list by joining adjacent segments.""" new = [] start = segments[0][0] end = segments[0][1] for i in range(len(segments)-1): if segments[i+1][0] != segments[i][1]: new.append((start, end)) start = segments[i+1][0] end = segments[i+1][1] new.append((start, end)) return new
def _filter_messages(messages, products=None, levels=None): """filter messages for desired products and levels.""" if products is None: products = [] if levels is None: levels = [] segments = [] bounds = len(messages) for i, message in enumerate(messages): if (message[3] in products or len(products) == 0) and \ (messag...
def _download_segments(filename, url, segments): """download segments into a single file.""" gribfile = open(filename, 'w') for start, end in segments: req = urllib2.Request(url) req.add_header('User-Agent', 'caelum/0.1 +https://github.com/nrcharles/caelum') if end: req.headers['Range'] = 'bytes=%s-%s' % (start, end) e...
def download(timestamp, dataset, path=None, products=None, levels=None, offset=0): """save GFS grib file to DATA_PATH. Args: dataset(function): naming convention function. eg. pgrb2 timestamp(datetime): ??? path(str): if None defaults to DATA_PATH products(list): TMP, etc. if None downloads all. layers(list): surface, ...
def message_index(index_url): """get message index of components for urllib2. Args: url(string): Returns: list: messages """ idx = csv.reader(urllib2.urlopen(index_url), delimiter=':') messages = [] for line in idx: messages.append(line) return messages
def is_dir(value): """ This function checks whether given path as argument exists. :param str value: Assumed directory path :rtype: str :return: If given value is valid, retuning given value. """ value = os.path.expanduser(value) value = os.path.expandvars(value) value = os.path.abspath(value) if os.path.exists(value):...
def extend_is_dir(value, minimum=None, maximum=None): u""" This function is extended is_dir(). This function was able to take ListType or StringType as argument. """ if isinstance(value, list): return [is_dir(member) for member in validate.is_list(value, minimum, maximum)] else: return is_dir(value)
def is_log(value): """ This function checks whether file path that is specified at "log_file" option exists, whether write permission to the file path. Return the following value: case1: exists path and write permission is_log('/tmp') '/tmp/hogehoge.log' case2: non-exists path and write permission is_log('/tmp/hogehoge...
Recommended giving he full path including the file name. :param str value: log file path You can specify not only absolute path but also relational path. :rtype: str :return: Converted absolute log file path. """ if value.lower() == 'syslog': return 'syslog' value = os.path.expanduser(value) value = os.path.expandvars(...
file or directory.' ''.format(directory=directory) ) raise validate.VdtValueError(err_message)
def is_log_level(value): u""" Check whether the value as argument be included the following list. ['debug', 'info', 'warn', 'error', 'crit'] """ log_levels = ['debug', 'info', 'warn', 'error', 'crit'] if value in log_levels: return value else: err_message = ('"log_level" supported following value: ' '{0}'.format(log_le...
def is_log_format(value): u""" Check whether the value as argument be included the following list. ['ltsv', 'combined'] """ log_levels = ['ltsv', 'combined'] if value in log_levels: return value else: err_message = ('"log_format" supported following value: ' '{0}'.format(log_levels) ) raise validate.VdtValueError(err_m...
def is_user(value, min=None, max=None): """ Check whether username or uid as argument exists. if this function recieved username, convert uid and exec validation. """ if type(value) == str: try: entry = pwd.getpwnam(value) value = entry.pw_uid except KeyError: err_message = ('{0}: No such user.'.format(value)) raise va...
def is_group(value): """ Check whether groupname or gid as argument exists. if this function recieved groupname, convert gid and exec validation. """ if type(value) == str: try: entry = grp.getgrnam(value) value = entry.gr_gid except KeyError: err_message = ('{0}: No such group.'.format(value)) raise validate.VdtValueE...
def _configobj_factory(self, infile, raise_errors=True, list_values=True, file_error=True, interpolation=False, configspec=None, stringify=True, _inspec=False ): """ Factory Method. Create Configobj instance and register it to self.config. This method also is used to create configspec instance. Because configspec insta...
def _get_global_include_abs_path(self, path): """ Get a value after converting to absolute path. Becoming different from other parameter, validation of `include` parameter is complex. Before other validation(at first) this method is called to merge to one configuration. :param str path: You can specify relative path an...
def _validate_global_include(self, path): """ Normally validation method is writen in each validation of parameters. But `include` of global section needs to be read before validation. :param str path: absolute path :rtype: bool :return: If given path passes validation, returns True. """ if not path.endswith('/'): path...
def _merge_includes(self): """ If "include" option exists in "default.cfg", read the file(glob-match) in the directory. """ raw_include_path = self.get_global_include() if raw_include_path: abs_include_path = self._get_global_include_abs_path( raw_include_path ) self._validate_global_include(abs_include_path) self.set_...
def register(self, observers): """ Concrete method of Subject.register(). Register observers as an argument to self.observers. """ if isinstance(observers, list) or isinstance(observers, tuple): for observer in observers: # check whether inhelitance "base.Observer" if isinstance(observer, base.Observer): self._observer...
def unregister(self, observers): u""" Concrete method of Subject.unregister(). Unregister observers as an argument to self.observers. """ if isinstance(observers, list) or isinstance(observers, tuple): for observer in observers: try: index = self._observers.index(observer) self._observers.remove(self._observers[index])...
def notify(self, name, job): """ Concrete method of Subject.notify(). Notify to change the status of Subject for observer. This method call Observer.update(). In this program, ConfigReader.notify() call JobObserver.update(). For exmaple, register threads.redis.ConcreateJob to JobObserver.jobs. """ for observer in self....
def add_default_module_dir(self): """ Add directory to store built-in plugins to `module_dir` parameter. Default directory to store plugins is `BLACKBIRD_INSTALL_DIR/plugins`. :rtype: None :return: None """ default_module_dir = os.path.join( os.path.abspath(os.path.curdir), 'plugins' ) module_dir_params = { 'module_dir...
def global_validate(self): """ Validate only global section. The options in global section is used by other private methods of ConfigReader. So, validate only global section at first. "raw_spec" is configspec for global section. "functions" is passed as an argument in "validate.Validator". about "functions" 'name': <fu...
'group': is_group, 'dir': extend_is_dir, 'log': is_log, 'log_level': is_log_level, 'log_format': is_log_format } validator = validate.Validator(functions=functions) spec = self._configobj_factory(infile=raw_spec, _inspec=True ) self.config.configspec = spec result = self.config.validate(validator, preserve_errors=True)...
def _get_modules(self): """ Get modules under the self.config['global']['module_dirs'] directories. Plugin modules has the two classes of "ConcreteJob" and "Validator". Further, "Validator.module" property is used to deciding which one to use plugin module. This method returns a dictionary as following: modules = { 're...
def _register_jobs(self): """ This method extracts only the "ConcreteJob" class from modules that were collected by ConfigReader._get_modules(). And, this method called Subject.notify(), append "ConcreteJob" classes to JobObserver.jobs. """ # job_name is hard-corded job_name = 'ConcreteJob' modules = self._get_modules(...
def _get_raw_specs(self, config): """ This method extract only the "Validate.spec" from modules that were collected by ConfigReader._get_modules(). And, this method append "Validate.spec" to raw_specs. This method creates a dictionary like the following: raw_specs = { 'redis': ( "[redis]", "host = string(default='127.0...
def _create_specs(self): """ Create configspec instances based "conf/defaults.cfg". This function takes as arguments to the required section and module. Take them out from self.config, _create_specs pass the _config_factory. """ raw_specs = self._get_raw_specs(self.config) spec = self._configobj_factory(infile=None, _i...
def _configspec_factory(self, section, module, infile): """ ConfigObj(_inspec=True) factory method. ConfibObj instance that the "_inspec" argument is True is called "configspec". This method is called by ConfigReader._create_specs(). Beforehand, you need to define type definitions and default values in "spec file" as f...
section name in spec file from [memcached] to specified [local_memcached] in conf/defaults.cfg. """ configspec = self._configobj_factory( infile=infile, _inspec=True ) # Override the name of section in spec file # by given module as argument. configspec.rename(module, section) return configspec
def validate(self): """ validate whether value in config file is correct. """ spec = self._create_specs() # support in future functions = {} validator = validate.Validator(functions=functions) self.config.configspec = spec result = self.config.validate(validator, preserve_errors=True) if self._parse_result(result): ret...
def _parse_result(self, result): u""" This method parses validation results. If result is True, then do nothing. if include even one false to result, this method parse result and raise Exception. """ if result is not True: for section, errors in result.iteritems(): for key, value in errors.iteritems(): if value is not ...
def main(args): of = sys.stdout if args.output and args.output[-4:] == '.bam': cmd = 'samtools view -Sb - -o '+args.output pof = Popen(cmd.split(),stdin=PIPE) of = pof.stdin elif args.output: of = open(args.output,'w') """Use the valid input file to get the header information.""" header = None if args.HQ: cmd = 'samtoo...
view -H '+args.subreadsCorrected sys.stderr.write(cmd+"\n") header = Popen(cmd.split(),stdout=PIPE).communicate()[0] of.write(header) _nameprog = re.compile('^(\S+)') negative_filter = set() # remove these """ Next read throught he alignments THAT ALIGNED in order of priority""" negative_filter = get_best_set(negative_...
def _do_subread_set(flag,input_file,of,negative_filter,aligned): best = {} cmd = 'samtools view '+flag+' '+input_file sys.stderr.write(cmd+"\n") p = Popen(cmd.split(),stdout=PIPE) z = 0 for line in p.stdout: z += 1 if z%10000==0: sys.stderr.write(str(z) + " subread alignment paths scanned for alignment length\r") pbnam...
0 p = Popen(cmd.split(),stdout=PIPE) for line in p.stdout: z += 1 if z%10000==0: sys.stderr.write(str(z) + " subreads alignment paths scanned during selected for best\r") pbname = PacBioReadName(_nameprog.match(line).group(1)) mol = pbname.get_molecule() name = pbname.name() if mol in negative_filter: continue if not b...
def _traverse_unobserved(stream,negative_filter,of): """Go through a stream and print out anything not in observed set""" observed = set() for line in stream: name = PacBioReadName(_nameprog.match(line).group(1)) if name.get_molecule() not in negative_filter: of.write(line) observed.add(name.get_molecule()) return nega...
def default_tasks(self): """Return default tasks""" return dict((name, Task(action=name, label="Harpoon")) for name in default_actions)
def find_tasks(self, overrides): """Find the custom tasks and record the associated image with each task""" tasks = self.default_tasks() configuration = self.collector.configuration for image in list(configuration["images"].keys()): path = configuration.path(["images", image, "tasks"], joined="images.{0}.tasks".format(...
def strptime(string, timezone=0): """necessary because of 24:00 end of day labeling""" year = int(string[0:4]) month = int(string[5:7]) day = int(string[8:10]) hour = int(string[-5:-3]) minute = int(string[-2:]) ts = datetime.datetime(year, month, day) + \ datetime.timedelta(hours=hour, minutes=minute) - \ datetime.tim...
def monthly(usaf, year, field='GHI (W/m^2)'): """monthly insolation""" m = [] lastm = 1 usafdata = Data(usaf, year) t = 0 for r in usafdata: r['GHI (W/m^2)'] = r['Glo Mod (Wh/m^2)'] r['DHI (W/m^2)'] = r['Dif Mod (Wh/m^2)'] r['DNI (W/m^2)'] = r['Dir Mod (Wh/m^2)'] if r['datetime'].month != lastm: m.append(t/1000.) t = 0...
def report(usaf): """generate report for usaf base""" fig = plt.figure() ax = fig.add_subplot(111) station_info = geo.station_info(usaf) y = {} for i in range(1991, 2011): monthData = monthly(usaf, i) t = sum(monthData) y[i] = t print t tmy3tot = tmy3.total(usaf) average = sum([v for k, v in y.items()])/20. s = sorted(...
np.array([k for k, v in o]) y = np.array([v for k, v in o]) rx = x[1:] ry = [(v + y[i+1])/2 for i, v in enumerate(y[:-1])] fit = pylab.polyfit(x, y, 3) fit_fn = pylab.poly1d(fit) f = interp1d(x, y, kind='cubic') f2 = interp1d(rx, ry, kind='cubic') xnew = np.linspace(min(x), max(x), 200) x2 = np.linspace(min(rx), max(rx...
def get_proxy(self, input): """Gets a proxy. :param input: a proxy condition :type input: ``osid.proxy.ProxyCondition`` :return: a proxy :rtype: ``osid.proxy.Proxy`` :raise: ``NullArgument`` -- ``input`` is ``null`` :raise: ``OperationFailed`` -- unable to complete request :raise: ``PermissionDenied`` -- authorization ...
def make_file(abspath, text): """ Make a file with utf-8 text. """ try: with open(abspath, "wb") as f: f.write(text.encode("utf-8")) print("Made: %s" % abspath) except: # pragma: no cover pass
def _calculate_hash(self, filename, **kwargs): """ Calculates the hash of the file and the hash of the file + metadata (passed in ``kwargs``). Args: filename (str): Name of the file testnet (bool): testnet flag. Defaults to False **kwargs: Additional metadata to be encoded with the file. Only the values are used to com...
magicbyte=self._magicbyte)) return address_piece, address_piece_with_metadata
def match_created_date(self, start, end, match): """Match assets that are created between the specified time period. arg: start (osid.calendaring.DateTime): start time of the query arg: end (osid.calendaring.DateTime): end time of the query arg: match (boolean): ``true`` for a positive match, ``false`` for a negative m...
def match_published_date(self, start, end, match): """Match assets that are published between the specified time period. arg: start (osid.calendaring.DateTime): start time of the query arg: end (osid.calendaring.DateTime): end time of the query arg: match (boolean): ``true`` for a positive match, ``false`` for a negati...
def throttled_login(request): "Displays the login form and handles the login action." # if the user is already logged-in, simply redirect them to the entry page if request.user.is_authenticated(): return HttpResponseRedirect(settings.LOGIN_REDIRECT_URL) login_allowed = request.session.get('login_allowed', True) if requ...
def get_comment(self, comment_id): """Gets the ``Comment`` specified by its ``Id``. arg: comment_id (osid.id.Id): the ``Id`` of the ``Comment`` to retrieve return: (osid.commenting.Comment) - the returned ``Comment`` raise: NotFound - no ``Comment`` found with the given ``Id`` raise: NullArgument - ``comment_id`` is ``...
def get_comments_by_ids(self, comment_ids): """Gets a ``CommentList`` corresponding to the given ``IdList``. arg: comment_ids (osid.id.IdList): the list of ``Ids`` to retrieve return: (osid.commenting.CommentList) - the returned ``Comment list`` raise: NotFound - an ``Id was`` not found raise: NullArgument - ``comment_...
def get_comments_by_genus_type(self, comment_genus_type): """Gets a ``CommentList`` corresponding to the given comment genus ``Type`` which does not include comments of genus types derived from the specified ``Type``. arg: comment_genus_type (osid.type.Type): a comment genus type return: (osid.commenting.CommentList) -...
def get_comments_on_date(self, from_, to): """Gets a ``CommentList`` effective during the entire given date range inclusive but not confined to the date range. arg: from (osid.calendaring.DateTime): starting date arg: to (osid.calendaring.DateTime): ending date return: (osid.commenting.CommentList) - the returned ``Com...
def get_comments_for_commentor_on_date(self, resource_id, from_, to): """Gets a list of all comments corresponding to a resource ``Id`` and effective during the entire given date range inclusive but not confined to the date range. arg: resource_id (osid.id.Id): the ``Id`` of the resource arg: from (osid.calendaring.Dat...
def get_comments_for_reference_on_date(self, reference_id, from_, to): """Gets a list of all comments corresponding to a reference ``Id`` and effective during the entire given date range inclusive but not confined to the date range. arg: reference_id (osid.id.Id): a reference ``Id`` arg: from (osid.calendaring.DateTime...
def get_comments_by_genus_type_for_reference_on_date(self, reference_id, comment_genus_type, from_, to): """Gets a list of all comments of the given genus type corresponding to a reference ``Id`` and effective during the entire given date range inclusive but not confined to the date range. arg: reference_id (osid.id.Id...
runtime=self._runtime)
def get_comments_for_commentor_and_reference(self, resource_id, reference_id): """Gets a list of comments corresponding to a resource and reference ``Id``. arg: resource_id (osid.id.Id): the ``Id`` of the resource arg: reference_id (osid.id.Id): the ``Id`` of the reference return: (osid.commenting.CommentList) - the re...
def get_comments(self): """Gets all comments. return: (osid.commenting.CommentList) - a list of comments raise: OperationFailed - unable to complete request raise: PermissionDenied - authorization failure *compliance: mandatory -- This method must be implemented.* """ # Implemented from template for # osid.resource.Res...
def get_comments_by_query(self, comment_query): """Gets a list of comments matching the given search. arg: comment_query (osid.commenting.CommentQuery): the search query array return: (osid.commenting.CommentList) - the returned ``CommentList`` raise: NullArgument - ``comment_query`` is ``null`` raise: OperationFailed ...
else: result = [] return objects.CommentList(result, runtime=self._runtime, proxy=self._proxy)
def get_comment_form_for_create(self, reference_id, comment_record_types): """Gets the comment form for creating new comments. A new form should be requested for each create transaction. arg: reference_id (osid.id.Id): the ``Id`` for the reference object arg: comment_record_types (osid.type.Type[]): array of comment re...
is not a valid OSID Type') if comment_record_types == []: # WHY are we passing book_id = self._catalog_id below, seems redundant: # Probably don't need to send effective_agent_id, since the form can get that from proxy. obj_form = objects.CommentForm( book_id=self._catalog_id, reference_id=reference_id, effective_agent...
def create_comment(self, comment_form): """Creates a new ``Comment``. arg: comment_form (osid.commenting.CommentForm): the form for this ``Comment`` return: (osid.commenting.Comment) - the new ``Comment`` raise: IllegalState - ``comment_form`` already used in a create transaction raise: InvalidArgument - one or more of...
raise errors.Unsupported('comment_form did not originate from this session') if not comment_form.is_valid(): raise errors.InvalidArgument('one or more of the form elements is invalid') insert_result = collection.insert_one(comment_form._my_map) self._forms[comment_form.get_id().get_identifier()] = CREATED result = obje...
def update_comment(self, comment_form): """Updates an existing comment. arg: comment_form (osid.commenting.CommentForm): the form containing the elements to be updated raise: IllegalState - ``comment_form`` already used in an update transaction raise: InvalidArgument - the form contains an invalid value raise: NullArgu...
from this session') if not comment_form.is_valid(): raise errors.InvalidArgument('one or more of the form elements is invalid') collection.save(comment_form._my_map) self._forms[comment_form.get_id().get_identifier()] = UPDATED # Note: this is out of spec. The OSIDs don't require an object to be returned: return object...
def delete_comment(self, comment_id): """Deletes a ``Comment``. arg: comment_id (osid.id.Id): the ``Id`` of the ``Comment`` to remove raise: NotFound - ``comment_id`` not found raise: NullArgument - ``comment_id`` is ``null`` raise: OperationFailed - unable to complete request raise: PermissionDenied - authorization fa...
def alias_comment(self, comment_id, alias_id): """Adds an ``Id`` to a ``Comment`` for the purpose of creating compatibility. The primary ``Id`` of the ``Comment`` is determined by the provider. The new ``Id`` performs as an alias to the primary ``Id``. If the alias is a pointer to another comment, it is reassigned to t...
def get_comment_ids_by_book(self, book_id): """Gets the list of Comment Ids associated with a ``Book``. arg: book_id (osid.id.Id): ``Id`` of a ``Book``. return: (osid.id.IdList) - list of related comment ``Ids`` raise: NotFound - ``book_id`` is not found raise: NullArgument - ``book_id`` is ``null`` raise: OperationFai...
def get_comments_by_book(self, book_id): """Gets the list of ``Comments`` associated with a ``Book``. arg: book_id (osid.id.Id): ``Id`` of a ``Book`` return: (osid.commenting.CommentList) - list of related comments raise: NotFound - ``book_id`` is not found raise: NullArgument - ``book_id`` is ``null`` raise: Operation...
def get_comment_ids_by_books(self, book_ids): """Gets the list of ``Comment Ids`` corresponding to a list of ``Book`` objects. arg: book_ids (osid.id.IdList): list of book ``Ids`` return: (osid.id.IdList) - list of comment ``Ids`` raise: NullArgument - ``book_ids`` is ``null`` raise: OperationFailed - unable to complet...
def get_comments_by_books(self, book_ids): """Gets the list of ``Comments`` corresponding to a list of ``Books``. arg: book_ids (osid.id.IdList): list of book ``Ids`` return: (osid.commenting.CommentList) - list of comments raise: NullArgument - ``book_ids`` is ``null`` raise: OperationFailed - unable to complete reque...
def get_book_ids_by_comment(self, comment_id): """Gets the list of ``Book`` ``Ids`` mapped to a ``Comment``. arg: comment_id (osid.id.Id): ``Id`` of a ``Comment`` return: (osid.id.IdList) - list of book ``Ids`` raise: NotFound - ``comment_id`` is not found raise: NullArgument - ``comment_id`` is ``null`` raise: Operati...
def get_books_by_comment(self, comment_id): """Gets the list of ``Book`` objects mapped to a ``Comment``. arg: comment_id (osid.id.Id): ``Id`` of a ``Comment`` return: (osid.commenting.BookList) - list of books raise: NotFound - ``comment_id`` is not found raise: NullArgument - ``comment_id`` is ``null`` raise: Operati...
def get_assignable_book_ids(self, book_id): """Gets a list of books including and under the given book node in which any comment can be assigned. arg: book_id (osid.id.Id): the ``Id`` of the ``Book`` return: (osid.id.IdList) - list of assignable book ``Ids`` raise: NullArgument - ``book_id`` is ``null`` raise: Operatio...
def assign_comment_to_book(self, comment_id, book_id): """Adds an existing ``Comment`` to a ``Book``. arg: comment_id (osid.id.Id): the ``Id`` of the ``Comment`` arg: book_id (osid.id.Id): the ``Id`` of the ``Book`` raise: AlreadyExists - ``comment_id`` is already assigned to ``book_id`` raise: NotFound - ``comment_id`...
def unassign_comment_from_book(self, comment_id, book_id): """Removes a ``Comment`` from a ``Book``. arg: comment_id (osid.id.Id): the ``Id`` of the ``Comment`` arg: book_id (osid.id.Id): the ``Id`` of the ``Book`` raise: NotFound - ``comment_id`` or ``book_id`` not found or ``comment_id`` not assigned to ``book_id`` r...