code
stringlengths
1
18.2k
def use_comparative_log_view(self): """Pass through to provider LogEntryLogSession.use_comparative_log_view""" self._log_view = COMPARATIVE # self._get_provider_session('log_entry_log_session') # To make sure the session is tracked for session in self._get_provider_sessions(): try: session.use_comparative_log_view() ex...
def use_plenary_log_view(self): """Pass through to provider LogEntryLogSession.use_plenary_log_view""" self._log_view = PLENARY # self._get_provider_session('log_entry_log_session') # To make sure the session is tracked for session in self._get_provider_sessions(): try: session.use_plenary_log_view() except AttributeEr...
def get_logs_by_provider(self, *args, **kwargs): """Pass through to provider LogLookupSession.get_logs_by_provider""" # Implemented from kitosid template for - # osid.resource.BinLookupSession.get_bins_by_provider catalogs = self._get_provider_session('log_lookup_session').get_logs_by_provider(*args, **kwargs) cat_list...
def get_logs(self): """Pass through to provider LogLookupSession.get_logs""" # Implemented from kitosid template for - # osid.resource.BinLookupSession.get_bins_template catalogs = self._get_provider_session('log_lookup_session').get_logs() cat_list = [] for cat in catalogs: cat_list.append(Log(self._provider_manager, ...
def get_log_form(self, *args, **kwargs): """Pass through to provider LogAdminSession.get_log_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 'log_record_ty...
def update_log(self, *args, **kwargs): """Pass through to provider LogAdminSession.update_log""" # Implemented from kitosid template for - # osid.resource.BinAdminSession.update_bin # OSID spec does not require returning updated catalog return Log( self._provider_manager, self._get_provider_session('log_admin_session')...
def save_log(self, log_form, *args, **kwargs): """Pass through to provider LogAdminSession.update_log""" # Implemented from kitosid template for - # osid.resource.BinAdminSession.update_bin if log_form.is_for_update(): return self.update_log(log_form, *args, **kwargs) else: return self.create_log(log_form, *args, **kwa...
def _set_log_view(self, session): """Sets the underlying log view to match current view""" if self._log_view == FEDERATED: try: session.use_federated_log_view() except AttributeError: pass else: try: session.use_isolated_log_view() except AttributeError: pass
def use_comparative_log_entry_view(self): """Pass through to provider LogEntryLookupSession.use_comparative_log_entry_view""" self._object_views['log_entry'] = COMPARATIVE # self._get_provider_session('log_entry_lookup_session') # To make sure the session is tracked for session in self._get_provider_sessions(): try: se...
def use_plenary_log_entry_view(self): """Pass through to provider LogEntryLookupSession.use_plenary_log_entry_view""" self._object_views['log_entry'] = PLENARY # self._get_provider_session('log_entry_lookup_session') # To make sure the session is tracked for session in self._get_provider_sessions(): try: session.use_pl...
def use_federated_log_view(self): """Pass through to provider LogEntryLookupSession.use_federated_log_view""" self._log_view = FEDERATED # self._get_provider_session('log_entry_lookup_session') # To make sure the session is tracked for session in self._get_provider_sessions(): try: session.use_federated_log_view() exce...
def use_isolated_log_view(self): """Pass through to provider LogEntryLookupSession.use_isolated_log_view""" self._log_view = ISOLATED # self._get_provider_session('log_entry_lookup_session') # To make sure the session is tracked for session in self._get_provider_sessions(): try: session.use_isolated_log_view() except A...
def get_log_entry_form(self, *args, **kwargs): """Pass through to provider LogEntryAdminSession.get_log_entry_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)...
def save_log_entry(self, log_entry_form, *args, **kwargs): """Pass through to provider LogEntryAdminSession.update_log_entry""" # Implemented from kitosid template for - # osid.resource.ResourceAdminSession.update_resource if log_entry_form.is_for_update(): return self.update_log_entry(log_entry_form, *args, **kwargs) ...
def get_next_logs(self, n): """gets next n objects from list""" # Implemented from kitosid template for - # osid.resource.ResourceList.get_next_resources if n > self.available(): # !!! This is not quite as specified (see method docs) !!! raise IllegalState('not enough elements available in this list') else: next_list =...
def init(self, base_user): """ Retrieve a "base user"'s list, and store it in :attr:`._base_scores`. :param str base_user: Base users' username """ self._base_user = base_user # Modify this for multiple services support when the time comes base_list = endpoints.myanimelist(base_user) for anime in base_list: id = anime[...
def comparison(self, username): """ Get a comparison of scores between the "base user" and ``username``. A Key-Value returned will consist of the following: .. code-block:: none { ANIME_ID: [BASE_USER_SCORE, OTHER_USER_SCORE], ... } Example: .. code-block:: none { 30831: [3, 8], 31240: [4, 7], 32901: [1, 5], ... } .. w...
been specified. Call the `init` " "function to retrieve a base users' scores") # Create a local, deep-copy of the scores for modification scores = copy.deepcopy(self._base_scores) user_list = endpoints.myanimelist(username) for anime in user_list: id = anime["id"] score = anime["score"] if id in scores: scores[id].appe...
def calculate_affinity(self, username): """ Get the affinity between the "base user" and ``username``. .. note:: The data returned will be a namedtuple, with the affinity and shared rated anime. This can easily be separated as follows (using the user ``Luna`` as ``username``): .. code-block:: python affinity, shared = ...
be accurately calculated. if len(scores) <= 10: raise NoAffinityError("Shared rated anime count between " "`{}` and `{}` is less than eleven" .format(self._base_user, username)) # Sort multiple rows of scores into two arrays for calculations. # E.G. [1,2], [3,4], [5,6] to [1,3,5], [2,4,6] values = scores.values() score...
def to_bool(value): # type: (Any) -> bool """ Convert a value into a bool but handle "truthy" strings eg, yes, true, ok, y """ if isinstance(value, _compat.string_types): return value.upper() in ('Y', 'YES', 'T', 'TRUE', '1', 'OK') return bool(value)
def dict_filter_update(base, updates): # type: (dict, dict) -> None """ Update dict with None values filtered out. """ base.update((k, v) for k, v in updates.items() if v is not None)
def dict_filter(*args, **kwargs): """ Merge all values into a single dict with all None values removed. """ result = {} for arg in itertools.chain(args, (kwargs,)): dict_filter_update(result, arg) return result
def sort_by_priority(iterable, reverse=False, default_priority=10): """ Return a list or objects sorted by a priority value. """ return sorted(iterable, reverse=reverse, key=lambda o: getattr(o, 'priority', default_priority))
def handle_services(changeset): """Populate the change set with addCharm and deploy changes.""" charms = {} for service_name, service in sorted(changeset.bundle['services'].items()): # Add the addCharm record if one hasn't been added yet. if service['charm'] not in charms: record_id = 'addCharm-{}'.format(changeset.nex...
handle_machines
def handle_machines(changeset): """Populate the change set with addMachines changes.""" machines = sorted(changeset.bundle.get('machines', {}).items()) for machine_name, machine in machines: if machine is None: # We allow the machine value to be unset in the YAML. machine = {} record_id = 'addMachines-{}'.format(change...
def handle_relations(changeset): """Populate the change set with addRelation changes.""" for relation in changeset.bundle.get('relations', []): relations = [models.Relation(*i.split(':')) if ':' in i else models.Relation(i, '') for i in relation] changeset.send({ 'id': 'addRelation-{}'.format(changeset.next_action()), ...
def handle_units(changeset): """Populate the change set with addUnit changes.""" units, records = {}, {} for service_name, service in sorted(changeset.bundle['services'].items()): for i in range(service.get('num_units', 0)): record_id = 'addUnit-{}'.format(changeset.next_action()) unit_name = '{}/{}'.format(service_nam...
def _handle_units_placement(changeset, units, records): """Ensure that requires and placement directives are taken into account.""" for service_name, service in sorted(changeset.bundle['services'].items()): num_units = service.get('num_units') if num_units is None: # This is a subordinate service. continue placement_di...
def _next_unit_in_service(service, placed_in_services): """Return the unit number where to place a unit placed on a service. Receive the service name and a dict mapping service names to the current number of placed units in that service. """ current = placed_in_services.get(service) number = 0 if current is None else c...
def parse(bundle, handler=handle_services): """Return a generator yielding changes required to deploy the given bundle. The bundle argument is a YAML decoded Python dict. """ changeset = ChangeSet(bundle) while True: handler = handler(changeset) for change in changeset.recv(): yield change if handler is None: break
def get_or_create(self, db_name): """ Creates the database named `db_name` if it doesn't already exist and return it """ if not db_name in self: res = self.resource.put(db_name) if not res[0] == 201: raise RuntimeError( 'Failed to create database "{}"'.format(db_name) ) return self[db_name]
def replicate(self, doc_id, source, target, continuous=False): """ Starts a replication from the `source` database to the `target` database by writing a document with the id `doc_id` to the "_relicator" database """ if doc_id in self["_replicator"]: return data = { "_id": doc_id, "source": source, "target": target, "co...
def create_user(self, username, password): """ Creates a user in the CouchDB instance with the username `username` and password `password` """ user_id = "org.couchdb.user:" + username res = self["_users"].resource.put( user_id, body=json.dumps({ "_id": user_id, "name": username, "roles": [], "type": "user", "password":...
def log_in(self, username, password): """ Logs in to the CouchDB instance with the credentials `username` and `password` """ self.resource.credentials = (username, password) return self.resource.get_json("_session")[2]
def get_user_info(self): """ Returns the document representing the currently logged in user on the server """ try: user_id = "org.couchdb.user:"+self.resource.credentials[0] except TypeError: raise RuntimeError( "Please log in before trying to access your user's info" ) status, _, body = self["_users"].resource.get_jso...
def push_design_documents(self, design_path): """ Push the design documents stored in `design_path` to the server """ for db_name in os.listdir(design_path): if db_name.startswith("__") or db_name.startswith("."): continue db_path = os.path.join(design_path, db_name) doc = self._folder_to_dict(db_path) doc_id = "_desig...
def _folder_to_dict(self, path): """ Recursively reads the files from the directory given by `path` and writes their contents to a nested dictionary, which is then returned. """ res = {} for key in os.listdir(path): if key.startswith('.'): continue key_path = os.path.join(path, key) if os.path.isfile(key_path): val = o...
def init_app(self, app): """This callback can be used to initialize an application for use with the OpenERP server. """ app.config.setdefault('OPENERP_SERVER', 'http://localhost:8069') app.config.setdefault('OPENERP_DATABASE', 'openerp') app.config.setdefault('OPENERP_DEFAULT_USER', 'admin') app.config.setdefault('OPEN...
def get_asset_search_session_for_repository(self, repository_id=None): """Gets an asset search session for the given repository. arg: repository_id (osid.id.Id): the Id of the repository return: (osid.repository.AssetSearchSession) - an AssetSearchSession raise: NotFound - repository_id not found raise: NullArgument - ...
def get_asset_admin_session(self, *args, **kwargs): """Gets an asset administration session for creating, updating and deleting assets. return: (osid.repository.AssetAdminSession) - an AssetAdminSession raise: OperationFailed - unable to complete request raise: Unimplemented - supports_asset_admin() is false compliance...
def get_asset_admin_session_for_repository(self, repository_id=None, *args, **kwargs): """Gets an asset administration session for the given repository. arg: repository_id (osid.id.Id): the Id of the repository return: (osid.repository.AssetAdminSession) - an AssetAdminSession raise: NotFound - repository_id not found ...
def get_asset_temporal_session(self): """Gets the session for retrieving temporal coverage of an asset. return: (osid.repository.AssetTemporalSession) - an AssetTemporalSession raise: OperationFailed - unable to complete request raise: Unimplemented - supports_asset_temporal() is false compliance: optional - This metho...
def get_asset_temporal_session_for_repository(self, repository_id=None): """Gets the session for retrieving temporal coverage of an asset for the given repository. arg: repository_id (osid.id.Id): the Id of the repository return: (osid.repository.AssetTemporalSession) - an AssetTemporalSession raise: NotFound - reposit...
def get_asset_temporal_assignment_session(self): """Gets the session for assigning temporal coverage to an asset. return: (osid.repository.AssetTemporalAssignmentSession) - an AssetTemporalAssignmentSession raise: OperationFailed - unable to complete request raise: Unimplemented - supports_asset_temporal_assignment() i...
def get_asset_composition_session(self): """Gets the session for retrieving asset compositions. return: (osid.repository.AssetCompositionSession) - an AssetCompositionSession raise: OperationFailed - unable to complete request raise: Unimplemented - supports_asset_composition() is false compliance: optional - This meth...
def get_asset_composition_design_session(self): """Gets the session for creating asset compositions. return: (osid.repository.AssetCompositionDesignSession) - an AssetCompositionDesignSession raise: OperationFailed - unable to complete request raise: Unimplemented - supports_asset_composition_design() is false complian...
def get_composition_lookup_session(self): """Gets the OsidSession associated with the composition lookup service. return: (osid.repository.CompositionLookupSession) - the new CompositionLookupSession raise: OperationFailed - unable to complete request raise: Unimplemented - supports_composition_lookup() is false compli...
def get_composition_admin_session(self): """Gets a composition administration session for creating, updating and deleting compositions. return: (osid.repository.CompositionAdminSession) - a CompositionAdminSession raise: OperationFailed - unable to complete request raise: Unimplemented - supports_composition_admin() is...
def get_composition_admin_session_for_repository(self, repository_id=None): """Gets a composiiton administrative session for the given repository. arg: repository_id (osid.id.Id): the Id of the repository return: (osid.repository.CompositionAdminSession) - a CompositionAdminSession raise: NotFound - repository_id not f...
def get_repository_query_session(self): """Gets the repository query session. return: (osid.repository.RepositoryQuerySession) - a RepositoryQuerySession raise: OperationFailed - unable to complete request raise: Unimplemented - supports_repository_query() is false compliance: optional - This method must be implemented...
def get_repository_search_session(self): """Gets the repository search session. return: (osid.repository.RepositorySearchSession) - a RepositorySearchSession raise: OperationFailed - unable to complete request raise: Unimplemented - supports_repository_search() is false compliance: optional - This method must be implem...
def get_repository_admin_session(self): """Gets the repository administrative session for creating, updating and deleteing repositories. return: (osid.repository.RepositoryAdminSession) - a RepositoryAdminSession raise: OperationFailed - unable to complete request raise: Unimplemented - supports_repository_admin() is f...
def get_asset_lookup_session(self, proxy, *args, **kwargs): """Gets the OsidSession associated with the asset lookup service. arg proxy (osid.proxy.Proxy): a proxy return: (osid.repository.AssetLookupSession) - the new AssetLookupSession raise: OperationFailed - unable to complete request raise: Unimplemented - support...
def get_asset_lookup_session_for_repository(self, repository_id, proxy, *args, **kwargs): """Gets the OsidSession associated with the asset lookup service for the given repository. arg: repository_id (osid.id.Id): the Id of the repository arg proxy (osid.proxy.Proxy): a proxy return: (osid.repository.AssetLookupSession...
def get_asset_query_session(self, proxy): """Gets an asset query session. arg proxy (osid.proxy.Proxy): a proxy return: (osid.repository.AssetQuerySession) - an AssetQuerySession raise: OperationFailed - unable to complete request raise: Unimplemented - supports_asset_query() is false compliance: optional - This method...
def get_asset_query_session_for_repository(self, repository_id, proxy): """Gets an asset query session for the given repository. arg: repository_id (osid.id.Id): the Id of the repository arg proxy (osid.proxy.Proxy): a proxy return: (osid.repository.AssetQuerySession) - an AssetQuerySession raise: NotFound - repository...
def get_asset_search_session(self, proxy): """Gets an asset search session. arg proxy (osid.proxy.Proxy): a proxy return: (osid.repository.AssetSearchSession) - an AssetSearchSession raise: OperationFailed - unable to complete request raise: Unimplemented - supports_asset_search() is false compliance: optional - This m...
def get_asset_notification_session(self, asset_receiver, proxy): """Gets the notification session for notifications pertaining to asset changes. arg: asset_receiver (osid.repository.AssetReceiver): the notification callback arg proxy (osid.proxy.Proxy): a proxy return: (osid.repository.AssetNotificationSession) - an As...
def get_asset_notification_session_for_repository(self, asset_receiver, repository_id, proxy): """Gets the asset notification session for the given repository. arg: asset_receiver (osid.repository.AssetReceiver): the notification callback arg: repository_id (osid.id.Id): the Id of the repository arg proxy (osid.proxy.P...
def get_asset_repository_session(self, proxy): """Gets the session for retrieving asset to repository mappings. arg proxy (osid.proxy.Proxy): a proxy return: (osid.repository.AssetRepositorySession) - an AssetRepositorySession raise: OperationFailed - unable to complete request raise: Unimplemented - supports_asset_rep...
def get_asset_repository_assignment_session(self, proxy): """Gets the session for assigning asset to repository mappings. arg proxy (osid.proxy.Proxy): a proxy return: (osid.repository.AssetRepositoryAssignmentSession) - an AssetRepositoryAsignmentSession raise: OperationFailed - unable to complete request raise: Unimp...
def get_asset_smart_repository_session(self, repository_id, proxy): """Gets an asset smart repository session for the given repository. arg: repository_id (osid.id.Id): the Id of the repository arg proxy (osid.proxy.Proxy): a proxy return: (osid.repository.AssetSmartRepositorySession) - an AssetSmartRepositorySession r...
def get_asset_temporal_assignment_session_for_repository(self, repository_id, proxy): """Gets the session for assigning temporal coverage of an asset for the given repository. arg: repository_id (osid.id.Id): the Id of the repository arg proxy (osid.proxy.Proxy): a proxy return: (osid.repository.AssetTemporalAssignment...
def get_asset_spatial_session(self, proxy): """Gets the session for retrieving spatial coverage of an asset. arg proxy (osid.proxy.Proxy): a proxy return: (osid.repository.AssetSpatialSession) - an AssetSpatialSession raise: OperationFailed - unable to complete request raise: Unimplemented - supports_spatial_assets() i...
def get_asset_spatial_session_for_repository(self, repository_id, proxy): """Gets the session for retrieving spatial coverage of an asset for the given repository. arg: repository_id (osid.id.Id): the Id of the repository arg proxy (osid.proxy.Proxy): a proxy return: (osid.repository.AssetSpatialSession) - an AssetSpat...
def get_asset_spatial_assignment_session(self, proxy): """Gets the session for assigning spatial coverage to an asset. arg proxy (osid.proxy.Proxy): a proxy return: (osid.repository.AssetSpatialAssignmentSession) - an AssetSpatialAssignmentSession raise: OperationFailed - unable to complete request raise: Unimplemented...
def get_asset_spatial_assignment_session_for_repository(self, repository_id, proxy): """Gets the session for assigning spatial coverage of an asset for the given repository. arg: repository_id (osid.id.Id): the Id of the repository arg proxy (osid.proxy.Proxy): a proxy return: (osid.repository.AssetSpatialAssignmentSes...
def get_composition_lookup_session_for_repository(self, repository_id, proxy): """Gets the OsidSession associated with the composition lookup service for the given repository. arg: repository_id (osid.id.Id): the Id of the repository arg proxy (osid.proxy.Proxy): a proxy return: (osid.repository.CompositionLookupSessio...
def get_composition_query_session(self, proxy): """Gets a composition query session. arg proxy (osid.proxy.Proxy): a proxy return: (osid.repository.CompositionQuerySession) - a CompositionQuerySession raise: OperationFailed - unable to complete request raise: Unimplemented - supports_composition_query() is false compli...
def get_composition_query_session_for_repository(self, repository_id, proxy): """Gets a composition query session for the given repository. arg: repository_id (osid.id.Id): the Id of the repository arg proxy (osid.proxy.Proxy): a proxy return: (osid.repository.CompositionQuerySession) - a CompositionQuerySession raise:...
def get_composition_search_session(self, proxy): """Gets a composition search session. arg proxy (osid.proxy.Proxy): a proxy return: (osid.repository.CompositionSearchSession) - a CompositionSearchSession raise: OperationFailed - unable to complete request raise: Unimplemented - supports_composition_search() is false c...
def get_composition_search_session_for_repository(self, repository_id, proxy): """Gets a composition search session for the given repository. arg: repository_id (osid.id.Id): the Id of the repository arg proxy (osid.proxy.Proxy): a proxy return: (osid.repository.CompositionSearchSession) - a CompositionSearchSession ra...
def get_composition_notification_session_for_repository(self, composition_receiver, repository_id, proxy): """Gets the composition notification session for the given repository. arg: composition_receiver (osid.repository.CompositionReceiver): the notification callback arg: repository_id (osid.id.Id): the Id of the repo...
def get_composition_repository_session(self, proxy): """Gets the session for retrieving composition to repository mappings. arg proxy (osid.proxy.Proxy): a proxy return: (osid.repository.CompositionRepositorySession) - a CompositionRepositorySession raise: OperationFailed - unable to complete request raise: Unimplement...
def get_composition_repository_assignment_session(self, proxy): """Gets the session for assigning composition to repository mappings. arg proxy (osid.proxy.Proxy): a proxy return: (osid.repository.CompositionRepositoryAssignmentSession) - a CompositionRepositoryAssignmentSession raise: OperationFailed - unable to compl...
def get_composition_smart_repository_session(self, repository_id, proxy): """Gets a composition smart repository session for the given repository. arg: repository_id (osid.id.Id): the Id of the repository arg proxy (osid.proxy.Proxy): a proxy return: (osid.repository.CompositionSmartRepositorySession) - a CompositionSm...
def get_repository_lookup_session(self, proxy, *args, **kwargs): """Gets the repository lookup session. arg proxy (osid.proxy.Proxy): a proxy return: (osid.repository.RepositoryLookupSession) - a RepositoryLookupSession raise: OperationFailed - unable to complete request raise: Unimplemented - supports_repository_looku...
def get_repository_notification_session(self, repository_receiver, proxy): """Gets the notification session for subscribing to changes to a repository. arg: repository_receiver (osid.repository.RepositoryReceiver): the notification callback arg proxy (osid.proxy.Proxy): a proxy return: (osid.repository.RepositoryNotifi...
def get_repository_hierarchy_session(self, proxy): """Gets the repository hierarchy traversal session. arg proxy (osid.proxy.Proxy): a proxy return: (osid.repository.RepositoryHierarchySession) - a RepositoryHierarchySession raise: OperationFailed - unable to complete request raise: Unimplemented - supports_repository_...
def get_repository_hierarchy_design_session(self, proxy): """Gets the repository hierarchy design session. arg proxy (osid.proxy.Proxy): a proxy return: (osid.repository.RepositoryHierarchyDesignSession) - a RepostoryHierarchyDesignSession raise: OperationFailed - unable to complete request raise: Unimplemented - suppo...
def get_asset_content_lookup_session_for_repository(self, repository_id=None): """Gets the ``OsidSession`` associated with the asset content lookup service for the given repository. arg: repository_id (osid.id.Id): the ``Id`` of the repository return: (osid.repository.AssetLookupSession) - the new ``AssetLookupSession`...
def get_asset_query_session_for_repository(self, repository_id=None): """Gets an asset query session for the given repository. arg: repository_id (osid.id.Id): the ``Id`` of the repository return: (osid.repository.AssetQuerySession) - an ``AssetQuerySession`` raise: NotFound - ``repository_id`` not found raise: NullArg...
def get_asset_lookup_session(self, proxy=None): """Gets the ``OsidSession`` associated with the asset lookup service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.repository.AssetLookupSession) - an ``AssetLookupSession`` raise: NullArgument - ``proxy`` is ``null`` raise: OperationFailed - unable to complete re...
def get_asset_lookup_session_for_repository(self, repository_id=None, proxy=None): """Gets the ``OsidSession`` associated with the asset lookup service for the given repository. arg: repository_id (osid.id.Id): the ``Id`` of the repository arg: proxy (osid.proxy.Proxy): a proxy return: (osid.repository.AssetLookupSessi...
def get_asset_content_lookup_session(self, proxy=None): """Gets the ``OsidSession`` associated with the asset content lookup service. return: (osid.repository.AssetLookupSession) - the new ``AssetLookupSession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_asset_lookup()`` is ``...
def get_asset_query_session(self, proxy=None): """Gets the ``OsidSession`` associated with the asset query service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.repository.AssetQuerySession) - an ``AssetQuerySession`` raise: NullArgument - ``proxy`` is ``null`` raise: OperationFailed - unable to complete reques...
def get_asset_admin_session(self, proxy=None): """Gets an asset administration session for creating, updating and deleting assets. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.repository.AssetAdminSession) - an ``AssetAdminSession`` raise: NullArgument - ``proxy`` is ``null`` raise: OperationFailed - unable to ...
def get_asset_admin_session_for_repository(self, repository_id=None, proxy=None): """Gets an asset administration session for the given repository. arg: repository_id (osid.id.Id): the ``Id`` of the repository arg: proxy (osid.proxy.Proxy): a proxy return: (osid.repository.AssetAdminSession) - an ``AssetAdminSession`` ...
def get_asset_notification_session_for_repository(self, asset_receiver=None, repository_id=None, proxy=None): """Gets the asset notification session for the given repository. arg: asset_receiver (osid.repository.AssetReceiver): the notification callback arg: repository_id (osid.id.Id): the ``Id`` of the repository arg:...
def get_composition_notification_session_for_repository(self, composition_receiver=None, repository_id=None, proxy=None): """Gets the composition notification session for the given repository. arg: composition_receiver (osid.repository.CompositionReceiver): the notification callback arg: repository_id (osid.id.Id): the...
def calculate(self): """do the TPM calculation""" self._calculated = True for name in self.transcripts: self.transcripts[name]['RPK'] = (float(self.transcripts[name]['count'])/float(self.transcripts[name]['length']))/float(1000) tot = 0.0 for name in self.transcripts: tot += self.transcripts[name]['RPK'] tot = tot/floa...
def _initialize(self, runtime): """Common initializer for OsidManager and OsidProxyManager""" if runtime is None: raise NullArgument() if self._my_runtime is not None: raise IllegalState('this manager has already been initialized.') self._my_runtime = runtime config = runtime.get_configuration() data_store_path_param_i...
def tuple_roll(self, count=0): '''One or more die rolls. :param count: [0] Return list of ``count`` rolls :return: (face, value) of roll or list of same ''' if count: return [self._faces[random.randint(1, self._sides) - 1] for i in range(count)] else: return self._faces[random.randint(1, self._sides) - 1]
def _init_map(self): """stub""" self.my_osid_object_form._my_map['rerandomize'] = \ self._rerandomize_metadata['default_object_values'][0] super(edXMultiChoiceQuestionFormRecord, self)._init_map()
def _init_metadata(self): """stub""" self._rerandomize_metadata = { 'element_id': Id(self.my_osid_object_form._authority, self.my_osid_object_form._namespace, 'rerandomize'), 'element_label': 'Randomize', 'instructions': 'How to rerandomize the parameters', 'required': False, 'read_only': False, 'linked': False, 'array...
def add_rerandomize(self, rerandomize): """stub""" if not self.my_osid_object_form._is_valid_string( rerandomize, self.get_rerandomize_metadata()): raise InvalidArgument('rerandomize') self.my_osid_object_form._my_map['rerandomize'] = rerandomize
def get_objectives(self): """Gets the objective list resulting from the search. return: (osid.learning.ObjectiveList) - the objective list raise: IllegalState - list already retrieved *compliance: mandatory -- This method must be implemented.* """ if self.retrieved: raise errors.IllegalState('List has already been retr...
def get_activities(self): """Gets the activity list resulting from the search. return: (osid.learning.ActivityList) - the activity list raise: IllegalState - list already retrieved *compliance: mandatory -- This method must be implemented.* """ if self.retrieved: raise errors.IllegalState('List has already been retriev...