code
stringlengths
1
18.2k
def get_requisite_objectives(self, objective_id): """Gets a list of ``Objectives`` that are the immediate requisites for the given ``Objective``. In plenary mode, the returned list contains all of the immediate requisites, or an error results if an ``Objective`` is not found or inaccessible. Otherwise, inaccessible ``O...
Type(**Relationship().get_type_data('OBJECTIVE.REQUISITE')) relm = self._get_provider_manager('RELATIONSHIP') rls = relm.get_relationship_lookup_session(proxy=self._proxy) rls.use_federated_family_view() requisite_relationships = rls.get_relationships_by_genus_type_for_source(objective_id, requisite_type) destination_i...
def get_dependent_objectives(self, objective_id): """Gets a list of ``Objectives`` that require the given ``Objective``. In plenary mode, the returned list contains all of the immediate requisites, or an error results if an Objective is not found or inaccessible. Otherwise, inaccessible ``Objectives`` may be omitted fr...
= relm.get_relationship_lookup_session(proxy=self._proxy) rls.use_federated_family_view() requisite_relationships = rls.get_relationships_by_genus_type_for_destination(objective_id, requisite_type) source_ids = [ObjectId(r.get_source_id().identifier) for r in requisite_relationships] collection = JSONClientValidated('l...
def assign_objective_requisite(self, objective_id, requisite_objective_id): """Creates a requirement dependency between two ``Objectives``. arg: objective_id (osid.id.Id): the ``Id`` of the dependent ``Objective`` arg: requisite_objective_id (osid.id.Id): the ``Id`` of the required ``Objective`` raise: AlreadyExists - ...
def unassign_objective_requisite(self, objective_id, requisite_objective_id): """Removes an ``Objective`` requisite from an ``Objective``. arg: objective_id (osid.id.Id): the ``Id`` of the ``Objective`` arg: requisite_objective_id (osid.id.Id): the ``Id`` of the required ``Objective`` raise: NotFound - ``objective_id``...
def get_activity(self, activity_id): """Gets the ``Activity`` specified by its ``Id``. In plenary mode, the exact ``Id`` is found or a ``NotFound`` results. Otherwise, the returned ``Activity`` may have a different ``Id`` than requested, such as the case where a duplicate ``Id`` was assigned to a ``Activity`` and retai...
def get_activities_by_ids(self, activity_ids): """Gets an ``ActivityList`` corresponding to the given ``IdList``. In plenary mode, the returned list contains all of the activities specified in the ``Id`` list, in the order of the list, including duplicates, or an error results if an ``Id`` in the supplied list is not f...
for # osid.resource.ResourceLookupSession.get_resources_by_ids # NOTE: This implementation currently ignores plenary view collection = JSONClientValidated('learning', collection='Activity', runtime=self._runtime) object_id_list = [] for i in activity_ids: object_id_list.append(ObjectId(self._get_id(i, 'learning').get_i...
def get_activities_by_genus_type(self, activity_genus_type): """Gets an ``ActivityList`` corresponding to the given activity genus ``Type`` which does not include activities of genus types derived from the specified ``Type``. In plenary mode, the returned list contains all known activities or an error results. Otherwis...
def get_activities_for_objective(self, objective_id): """Gets the activities for the given objective. In plenary mode, the returned list contains all of the activities mapped to the objective ``Id`` or an error results if an Id in the supplied list is not found or inaccessible. Otherwise, inaccessible ``Activities`` ma...
JSONClientValidated('learning', collection='Activity', runtime=self._runtime) result = collection.find( dict({'objectiveId': str(objective_id)}, **self._view_filter())) return objects.ActivityList(result, runtime=self._runtime)
def get_activities(self): """Gets all ``Activities``. In plenary mode, the returned list contains all known activites or an error results. Otherwise, the returned list may contain only those activities that are accessible through this session. return: (osid.learning.ActivityList) - a ``ActivityList`` raise: OperationFa...
def get_activities_by_query(self, activity_query): """Gets a list of ``Activities`` matching the given activity query. arg: activity_query (osid.learning.ActivityQuery): the activity query return: (osid.learning.ActivityList) - the returned ``ActivityList`` raise: NullArgument - ``activity_query`` is ``null`` raise: Op...
else: result = [] return objects.ActivityList(result, runtime=self._runtime, proxy=self._proxy)
def get_activity_form_for_create(self, objective_id, activity_record_types): """Gets the activity form for creating new activities. A new form should be requested for each create transaction. arg: objective_id (osid.id.Id): the ``Id`` of the ``Objective`` arg: activity_record_types (osid.type.Type[]): array of activity...
valid OSID Type') if activity_record_types == []: # WHY are we passing objective_bank_id = self._catalog_id below, seems redundant: obj_form = objects.ActivityForm( objective_bank_id=self._catalog_id, objective_id=objective_id, catalog_id=self._catalog_id, runtime=self._runtime, proxy=self._proxy) else: obj_form = obje...
def create_activity(self, activity_form): """Creates a new ``Activity``. arg: activity_form (osid.learning.ActivityForm): the form for this ``Activity`` return: (osid.learning.Activity) - the new ``Activity`` raise: IllegalState - ``activity_form`` already used in a create transaction raise: InvalidArgument - one or mo...
raise errors.Unsupported('activity_form did not originate from this session') if not activity_form.is_valid(): raise errors.InvalidArgument('one or more of the form elements is invalid') insert_result = collection.insert_one(activity_form._my_map) self._forms[activity_form.get_id().get_identifier()] = CREATED result = ...
def update_activity(self, activity_form): """Updates an existing activity,. arg: activity_form (osid.learning.ActivityForm): the form containing the elements to be updated raise: IllegalState - ``activity_form`` already used in an update transaction raise: InvalidArgument - the form contains an invalid value raise: Nul...
from this session') if not activity_form.is_valid(): raise errors.InvalidArgument('one or more of the form elements is invalid') collection.save(activity_form._my_map) self._forms[activity_form.get_id().get_identifier()] = UPDATED # Note: this is out of spec. The OSIDs don't require an object to be returned: return obj...
def delete_activity(self, activity_id): """Deletes the ``Activity`` identified by the given ``Id``. arg: activity_id (osid.id.Id): the ``Id`` of the ``Activity`` to delete raise: NotFound - an ``Activity`` was not found identified by the given ``Id`` raise: NullArgument - ``activity_id`` is ``null`` raise: OperationFai...
def alias_activity(self, activity_id, alias_id): """Adds an ``Id`` to an ``Activity`` for the purpose of creating compatibility. The primary ``Id`` of the ``Activity`` is determined by the provider. The new ``Id`` performs as an alias to the primary ``Id``. If the alias is a pointer to another activity, it is reassigne...
def get_activity_ids_by_objective_bank(self, objective_bank_id): """Gets the list of ``Activity`` ``Ids`` associated with an ``ObjectiveBank``. arg: objective_bank_id (osid.id.Id): ``Id`` of the ``ObjectiveBank`` return: (osid.id.IdList) - list of related activity ``Ids`` raise: NotFound - ``objective_bank_id`` is not ...
def get_activities_by_objective_bank(self, objective_bank_id): """Gets the list of ``Activities`` associated with an ``ObjectiveBank``. arg: objective_bank_id (osid.id.Id): ``Id`` of the ``ObjectiveBank`` return: (osid.learning.ActivityList) - list of related activities raise: NotFound - ``objective_bank_id`` is not fo...
def get_activity_ids_by_objective_banks(self, objective_bank_ids): """Gets the list of ``Activity Ids`` corresponding to a list of ``ObjectiveBanks``. arg: objective_bank_ids (osid.id.IdList): list of objective bank ``Ids`` return: (osid.id.IdList) - list of activity ``Ids`` raise: NullArgument - ``objective_bank_ids``...
def get_activities_by_objective_banks(self, objective_bank_ids): """Gets the list of ``Activities`` corresponding to a list of ``ObjectiveBanks``. arg: objective_bank_ids (osid.id.IdList): list of objective bank ``Ids`` return: (osid.learning.ActivityList) - list of activities raise: NullArgument - ``objective_bank_ids...
def get_objective_bank_ids_by_activity(self, activity_id): """Gets the list of ``ObjectiveBank Ids`` mapped to a ``Activity``. arg: activity_id (osid.id.Id): ``Id`` of a ``Activity`` return: (osid.id.IdList) - list of objective bank ``Ids`` raise: NotFound - ``activity_id`` is not found raise: NullArgument - ``activity...
def get_objective_banks_by_activity(self, activity_id): """Gets the list of ``ObjectiveBanks`` mapped to a ``Activity``. arg: activity_id (osid.id.Id): ``Id`` of a ``Activity`` return: (osid.learning.ObjectiveBankList) - list of objective bank ``Ids`` raise: NotFound - ``activity_id`` is not found raise: NullArgument -...
def assign_activity_to_objective_bank(self, activity_id, objective_bank_id): """Adds an existing ``Activity`` to a ``ObjectiveBank``. arg: activity_id (osid.id.Id): the ``Id`` of the ``Activity`` arg: objective_bank_id (osid.id.Id): the ``Id`` of the ``ObjectiveBank`` raise: AlreadyExists - ``activity_id`` already mapp...
def unassign_activity_from_objective_bank(self, activity_id, objective_bank_id): """Removes a ``Activity`` from a ``ObjectiveBank``. arg: activity_id (osid.id.Id): the ``Id`` of the ``Activity`` arg: objective_bank_id (osid.id.Id): the ``Id`` of the ``ObjectiveBank`` raise: NotFound - ``activity_id`` or ``objective_ban...
def reassign_activity_to_objective_bank(self, activity_id, from_objective_bank_id, to_objective_bank_id): """Moves an ``Activity`` from one ``ObjectiveBank`` to another. Mappings to other ``ObjectiveBanks`` are unaffected. arg: activity_id (osid.id.Id): the ``Id`` of the ``Activity`` arg: from_objective_bank_id (osid.i...
def get_proficiency(self, proficiency_id): """Gets the ``Proficiency`` specified by its ``Id``. arg: proficiency_id (osid.id.Id): the ``Id`` of the ``Proficiency`` to retrieve return: (osid.learning.Proficiency) - the returned ``Proficiency`` raise: NotFound - no ``Proficiency`` found with the given ``Id`` raise: NullA...
def get_proficiencies_by_ids(self, proficiency_ids): """Gets a ``ProficiencyList`` corresponding to the given ``IdList``. arg: proficiency_ids (osid.id.IdList): the list of ``Ids`` to retrieve return: (osid.learning.ProficiencyList) - the returned ``Proficiency`` list raise: NotFound - an ``Id`` was not found raise: Nu...
def get_proficiencies_by_genus_type(self, proficiency_genus_type): """Gets a ``ProficiencyList`` corresponding to the given proficiency genus ``Type`` which does not include proficiencies of types derived from the specified ``Type``. arg: proficiency_genus_type (osid.type.Type): a proficiency genus type return: (osid.l...
def get_proficiencies_on_date(self, from_, to): """Gets a ``ProficiencyList`` effecyive 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.learning.ProficiencyList) - the ret...
def get_proficiencies_for_objective_on_date(self, objective_id, from_, to): """Gets a ``ProficiencyList`` relating to the given objective effective during the entire given date range inclusive but not confined to the date range. arg: objective_id (osid.id.Id): an objective ``Id`` arg: from (osid.calendaring.DateTime): ...
def get_proficiencies_for_objectives(self, objective_ids): """Gets a ``ProficiencyList`` relating to the given objectives. arg: objective_ids (osid.id.IdList): the objective ``Ids`` return: (osid.learning.ProficiencyList) - the returned ``Proficiency`` list raise: NullArgument - ``objective_ids`` is ``null`` raise: Ope...
def get_proficiencies_for_resource_on_date(self, resource_id, from_, to): """Gets a ``ProficiencyList`` relating to the given resource effective during the entire given date range inclusive but not confined to the date range. arg: resource_id (osid.id.Id): a resource ``Id`` arg: from (osid.calendaring.DateTime): starti...
def get_proficiencies_by_genus_type_for_resource_on_date(self, resource_id, proficiency_genus_type, from_, to): """Gets a ``ProficiencyList`` of the given proficiency genus type relating to the given resource effective during the entire given date range inclusive but not confined to the date range. arg: resource_id (os...
def get_proficiencies_for_resources(self, resource_ids): """Gets a ``ProficiencyList`` relating to the given resources. arg: resource_ids (osid.id.IdList): the resource ``Ids`` return: (osid.learning.ProficiencyList) - the returned ``Proficiency`` list raise: NullArgument - ``resource_ids`` is ``null`` raise: Operation...
def get_proficiencies_for_objective_and_resource(self, objective_id, resource_id): """Gets a ``ProficiencyList`` relating to the given objective and resource ````. arg: objective_id (osid.id.Id): an objective ``Id`` arg: resource_id (osid.id.Id): a resource ``Id`` return: (osid.learning.ProficiencyList) - the returned ...
def get_proficiencies(self): """Gets all ``Proficiencies``. return: (osid.learning.ProficiencyList) - a list of ``Proficiencies`` raise: OperationFailed - unable to complete request raise: PermissionDenied - authorization failure *compliance: mandatory -- This method must be implemented.* """ # Implemented from templat...
def get_proficiencies_by_query(self, proficiency_query): """Gets a list of ``Proficiencies`` matching the given proficiency query. arg: proficiency_query (osid.learning.ProficiencyQuery): the proficiency query return: (osid.learning.ProficiencyList) - the returned ``ProficiencyList`` raise: NullArgument - ``proficiency...
else: result = [] return objects.ProficiencyList(result, runtime=self._runtime, proxy=self._proxy)
def get_proficiency_form_for_create(self, objective_id, resource_id, proficiency_record_types): """Gets the proficiency form for creating new proficiencies. A new form should be requested for each create transaction. arg: objective_id (osid.id.Id): the ``Id`` of the ``Objective`` arg: resource_id (osid.id.Id): the ``Id...
Type as ABCType if not isinstance(objective_id, ABCId): raise errors.InvalidArgument('argument is not a valid OSID Id') if not isinstance(resource_id, ABCId): raise errors.InvalidArgument('argument is not a valid OSID Id') for arg in proficiency_record_types: if not isinstance(arg, ABCType): raise errors.InvalidArgumen...
def create_proficiency(self, proficiency_form): """Creates a new ``Proficiency``. A new form should be requested for each create transaction. arg: proficiency_form (osid.learning.ProficiencyForm): the form for this ``Proficiency`` return: (osid.learning.Proficiency) - the new ``Proficiency`` raise: IllegalState - ``pro...
raise errors.IllegalState('proficiency_form already used in a create transaction') except KeyError: raise errors.Unsupported('proficiency_form did not originate from this session') if not proficiency_form.is_valid(): raise errors.InvalidArgument('one or more of the form elements is invalid') insert_result = collection....
def update_proficiency(self, proficiency_form): """Updates an existing proficiency. arg: proficiency_form (osid.learning.ProficiencyForm): the form containing the elements to be updated raise: IllegalState - ``proficiency_form`` already used in an update transaction raise: InvalidArgument - the form contains an invalid...
from this session') if not proficiency_form.is_valid(): raise errors.InvalidArgument('one or more of the form elements is invalid') collection.save(proficiency_form._my_map) self._forms[proficiency_form.get_id().get_identifier()] = UPDATED # Note: this is out of spec. The OSIDs don't require an object to be returned: r...
def delete_proficiency(self, proficiency_id): """Deletes a ``Proficiency``. arg: proficiency_id (osid.id.Id): the ``Id`` of the ``Proficiency`` to remove raise: NotFound - ``proficiency_id`` not found raise: NullArgument - ``proficiency_id`` is ``null`` raise: OperationFailed - unable to complete request raise: Permiss...
def alias_proficiency(self, proficiency_id, alias_id): """Adds an ``Id`` to a ``Proficiency`` for the purpose of creating compatibility. The primary ``Id`` of the ``Proficiency`` is determined by the provider. The new ``Id`` performs as an alias to the primary ``Id``. If the alias is a pointer to another proficiency, i...
def assign_proficiency_to_objective_bank(self, proficiency_id, objective_bank_id): """Adds an existing ``Proficiency`` to a ``ObjectiveBank``. arg: proficiency_id (osid.id.Id): the ``Id`` of the ``Proficiency`` arg: objective_bank_id (osid.id.Id): the ``Id`` of the ``ObjectiveBank`` raise: AlreadyExists - ``proficiency...
def unassign_proficiency_from_objective_bank(self, proficiency_id, objective_bank_id): """Removes a ``Proficiency`` from a ``ObjectiveBank``. arg: proficiency_id (osid.id.Id): the ``Id`` of the ``Proficiency`` arg: objective_bank_id (osid.id.Id): the ``Id`` of the ``ObjectiveBank`` raise: NotFound - ``proficiency_id`` ...
def reassign_proficiency_to_objective_bank(self, proficiency_id, from_objective_bank_id, to_objective_bank_id): """Moves a ``Proficiency`` from one ``ObjectiveBank`` to another. Mappings to other ``ObjectiveBanks`` are unaffected. arg: proficiency_id (osid.id.Id): the ``Id`` of the ``Proficiency`` arg: from_objective_b...
def get_objective_banks(self): """Gets all ``ObjectiveBanks``. In plenary mode, the returned list contains all known objective banks or an error results. Otherwise, the returned list may contain only those objective banks that are accessible through this session. return: (osid.learning.ObjectiveBankList) - a ``Objectiv...
def can_create_objective_bank_with_record_types(self, objective_bank_record_types): """Tests if this user can create a single ``ObjectiveBank`` using the desired record types. While ``LearningManager.getObjectiveBankRecordTypes()`` can be used to examine which records are supported, this method tests which record(s) ar...
None: return self._catalog_session.can_create_catalog_with_record_types(catalog_record_types=objective_bank_record_types) return True
def update_objective_bank(self, objective_bank_form): """Updates an existing objective bank. arg: objective_bank_form (osid.learning.ObjectiveBankForm): the form containing the elements to be updated raise: IllegalState - ``objective_bank_form`` already used in an update transaction raise: InvalidArgument - the form co...
transaction') except KeyError: raise errors.Unsupported('objective_bank_form did not originate from this session') if not objective_bank_form.is_valid(): raise errors.InvalidArgument('one or more of the form elements is invalid') collection.save(objective_bank_form._my_map) # save is deprecated - change to replace_one ...
def alias_objective_bank(self, objective_bank_id, alias_id): """Adds an ``Id`` to an ``ObjectiveBank`` for the purpose of creating compatibility. The primary ``Id`` of the ``ObjectiveBank`` is determined by the provider. The new ``Id`` performs as an alias to the primary ``Id``. If the alias is a pointer to another obj...
self._alias_id(primary_id=objective_bank_id, equivalent_id=alias_id)
def get_root_objective_banks(self): """Gets the root objective banks in this objective bank hierarchy. return: (osid.learning.ObjectiveBankList) - the root objective banks raise: OperationFailed - unable to complete request raise: PermissionDenied - authorization failure *compliance: mandatory -- This method is must be...
def has_parent_objective_banks(self, objective_bank_id): """Tests if the ``ObjectiveBank`` has any parents. arg: objective_bank_id (osid.id.Id): the ``Id`` of an objective bank return: (boolean) - ``true`` if the objective bank has parents, ``false`` otherwise raise: NotFound - ``objective_bank_id`` is not found raise:...
def is_parent_of_objective_bank(self, id_, objective_bank_id): """Tests if an ``Id`` is a direct parent of an objective bank. arg: id (osid.id.Id): an ``Id`` arg: objective_bank_id (osid.id.Id): the ``Id`` of an objective bank return: (boolean) - ``true`` if this ``id`` is a parent of ``objective_bank_id,`` ``false`` o...
def get_parent_objective_bank_ids(self, objective_bank_id): """Gets the parent ``Ids`` of the given objective bank. arg: objective_bank_id (osid.id.Id): the ``Id`` of an objective bank return: (osid.id.IdList) - the parent ``Ids`` of the objective bank raise: NotFound - ``objective_bank_id`` is not found raise: NullArg...
def get_parent_objective_banks(self, objective_bank_id): """Gets the parents of the given objective bank. arg: objective_bank_id (osid.id.Id): the ``Id`` of an objective bank return: (osid.learning.ObjectiveBankList) - the parents of the objective bank raise: NotFound - ``objective_bank_id`` is not found raise: NullArg...
def is_ancestor_of_objective_bank(self, id_, objective_bank_id): """Tests if an ``Id`` is an ancestor of an objective bank. arg: id (osid.id.Id): an ``Id`` arg: objective_bank_id (osid.id.Id): the ``Id`` of an objective bank return: (boolean) - ``true`` if this ``id`` is an ancestor of ``objective_bank_id,`` ``false`` ...
def has_child_objective_banks(self, objective_bank_id): """Tests if an objective bank has any children. arg: objective_bank_id (osid.id.Id): the ``Id`` of an objective bank return: (boolean) - ``true`` if the ``objective_bank_id`` has children, ``false`` otherwise raise: NotFound - ``objective_bank_id`` is not found ra...
def is_child_of_objective_bank(self, id_, objective_bank_id): """Tests if an objective bank is a direct child of another. arg: id (osid.id.Id): an ``Id`` arg: objective_bank_id (osid.id.Id): the ``Id`` of an objective bank return: (boolean) - ``true`` if the ``id`` is a child of ``objective_bank_id,`` ``false`` otherwi...
def get_child_objective_bank_ids(self, objective_bank_id): """Gets the child ``Ids`` of the given objective bank. arg: objective_bank_id (osid.id.Id): the ``Id`` to query return: (osid.id.IdList) - the children of the objective bank raise: NotFound - ``objective_bank_id`` is not found raise: NullArgument - ``objective_...
def get_child_objective_banks(self, objective_bank_id): """Gets the children of the given objective bank. arg: objective_bank_id (osid.id.Id): the ``Id`` to query return: (osid.learning.ObjectiveBankList) - the children of the objective bank raise: NotFound - ``objective_bank_id`` is not found raise: NullArgument - ``o...
def is_descendant_of_objective_bank(self, id_, objective_bank_id): """Tests if an ``Id`` is a descendant of an objective bank. arg: id (osid.id.Id): an ``Id`` arg: objective_bank_id (osid.id.Id): the ``Id`` of an objective bank return: (boolean) - ``true`` if the ``id`` is a descendant of the ``objective_bank_id,`` ``f...
def get_objective_bank_nodes(self, objective_bank_id, ancestor_levels, descendant_levels, include_siblings): """Gets a portion of the hierarchy for the given objective bank. arg: objective_bank_id (osid.id.Id): the ``Id`` to query arg: ancestor_levels (cardinal): the maximum number of ancestor levels to include. A valu...
# osid.resource.BinHierarchySession.get_bin_nodes return objects.ObjectiveBankNode(self.get_objective_bank_node_ids( objective_bank_id=objective_bank_id, ancestor_levels=ancestor_levels, descendant_levels=descendant_levels, include_siblings=include_siblings)._my_map, runtime=self._runtime, proxy=self._proxy)
def add_root_objective_bank(self, objective_bank_id): """Adds a root objective bank. arg: objective_bank_id (osid.id.Id): the ``Id`` of an objective bank raise: AlreadyExists - ``objective_bank_id`` is already in hierarchy raise: NotFound - ``objective_bank_id`` not found raise: NullArgument - ``objective_bank_id`` is ...
def remove_root_objective_bank(self, objective_bank_id): """Removes a root objective bank. arg: objective_bank_id (osid.id.Id): the ``Id`` of an objective bank raise: NotFound - ``objective_bank_id`` is not a root raise: NullArgument - ``objective_bank_id`` is ``null`` raise: OperationFailed - unable to complete reques...
def add_child_objective_bank(self, objective_bank_id, child_id): """Adds a child to an objective bank. arg: objective_bank_id (osid.id.Id): the ``Id`` of an objective bank arg: child_id (osid.id.Id): the ``Id`` of the new child raise: AlreadyExists - ``objective_bank_id`` is already a parent of ``child_id`` raise: NotF...
def remove_child_objective_bank(self, objective_bank_id, child_id): """Removes a child from an objective bank. arg: objective_bank_id (osid.id.Id): the ``Id`` of an objective bank arg: child_id (osid.id.Id): the ``Id`` of the child raise: NotFound - ``objective_bank_id`` not a parent of ``child_id`` raise: NullArgument...
def remove_child_objective_banks(self, objective_bank_id): """Removes all children from an objective bank. arg: objective_bank_id (osid.id.Id): the ``Id`` of an objective bank raise: NotFound - ``objective_bank_id`` not in hierarchy raise: NullArgument - ``objective_bank_id`` is ``null`` raise: OperationFailed - unable...
def is_ignored(mod_or_pkg, ignored_package): """Test, if this :class:`docfly.pkg.picage.Module` or :class:`docfly.pkg.picage.Package` should be included to generate API reference document. :param mod_or_pkg: module or package :param ignored_package: ignored package **中文文档** 根据全名判断一个包或者模块是否要被包含到自动生成的API文档中。 """ ignored_...
def fly(self): """ Generate doc tree. """ dst_dir = Path(self.conf_file).parent.abspath package_dir = Path(dst_dir, self.package.shortname) # delete existing api document try: if package_dir.exists(): shutil.rmtree(package_dir.abspath) except Exception as e: print("'%s' can't be removed! Error: %s" % (package_dir, e)) ...
def generate_package_content(self, package): """Generate package.rst text content. :: {{ package_name }} ================== .. automodule:: {{ package_name }} :members: sub packages and modules ------------------------ .. toctree:: :maxdepth: 1 {{ sub_package_name1 }} <{{ sub_package_name1 }}/__init__> {{ sub_package_n...
def generate_module_content(self, module): """Generate module.rst text content. :: {{ module_name }} ================= .. automodule:: {{ module_fullname }} :members: """ if isinstance(module, Module): return module.render() else: # pragma: no cover raise Exception("%r is not a Module object" % module)
def open(self, fname, mode='rb'): """ (Re-)opens a backup file """ self.close() self.fp = open(fname, mode) self.fname = fname
def parse(self): """ Parses a backup file header. Will be done automatically if used together with the 'with' statement """ self.fp.seek(0) magic = self.fp.readline() assert magic == b'ANDROID BACKUP\n' self.version = int(self.fp.readline().strip()) self.compression = CompressionType(int(self.fp.readline().strip())) se...
def _decrypt(self, fp, password=None): """ Internal decryption function Uses either the password argument for the decryption, or, if not supplied, the password field of the object :param fp: a file object or similar which supports the readline and read methods :rtype: Proxy """ if AES is None: raise ImportError("PyCryp...
master key user_key = PBKDF2(password, user_salt, dkLen=256 // 8, count=rounds) # decrypt the master key and iv cipher = AES.new(user_key, mode=AES.MODE_CBC, IV=iv) master_key = bytearray(cipher.decrypt(master_key)) # format: <len IV: 1 byte><IV: n bytes><len key: 1 byte><key: m bytes><len checksum: 1 byte><checksum: k...
decrypt(data): data = bytearray(cipher.decrypt(data)) if fp.tell() - off >= length: # check padding (PKCS#7) pad = data[-1] assert data.endswith(bytearray([pad] * pad)), "Expected {!r} got {!r}".format(bytearray([pad] * pad), data[-pad:]) data = data[:-pad] return data return Proxy(decrypt, fp, cipher.block_size) else:...
def encode_utf8(mk): """ (Double-)encodes the given string (masterkey) with utf-8 Tries to behave like the Java implementation """ utf8mk = mk.decode('raw_unicode_escape') utf8mk = list(utf8mk) to_char = chr if sys.version_info[0] < 3: to_char = unichr for i in range(len(utf8mk)): c = ord(utf8mk[i]) # fix java encoding...
def _encrypt(self, dec, password=None): """ Internal encryption function Uses either the password argument for the encryption, or, if not supplied, the password field of the object :param dec: a byte string representing the to be encrypted data :rtype: bytes """ if AES is None: raise ImportError("PyCrypto required") if...
the master key checksum master_ck = PBKDF2(self.encode_utf8(master_key), master_salt, dkLen=256//8, count=rounds) # generate the user key from the given password user_key = PBKDF2(password, user_salt, dkLen=256//8, count=rounds) # encrypt the master key and iv master_dec = b"\x10" + master_iv + b"\x20" + master_key + b...
def _decompress(self, fp): """ Internal function for decompressing a backup file with the DEFLATE algorithm :rtype: Proxy """ decompressor = zlib.decompressobj() if self.stream: return Proxy(decompressor.decompress, fp) else: out = io.BytesIO(decompressor.decompress(fp.read())) out.write(decompressor.flush()) out.seek(...
def read_data(self, password=None): """ Helper function which decrypts and decompresses the data if necessary and returns a tarfile.TarFile to interact with """ fp = self.fp fp.seek(self.__data_start) if self.is_encrypted(): fp = self._decrypt(fp, password=password) if self.compression == CompressionType.ZLIB: fp = sel...
def unpack(self, target_dir=None, password=None, pickle_fname=None): """ High level function for unpacking a backup file into the given target directory (will be generated based on the filename if not given). Creates also a filename.pickle file containing the exact order of the included files (required for repacking). ...
def pack(self, fname, source_dir=None, password=None, pickle_fname=None): """ High level function for repacking a backup file from the given target directory (will be generated based on the filename if not given). Requires also a filename.pickle file which was generated during the unpacking step. The fields `version`, ...
None, "Encryption level is not set" data = io.BytesIO() tar = tarfile.TarFile(name=fname, fileobj=data, mode='w', format=tarfile.PAX_FORMAT) with open(pickle_fname, 'rb') as fp: members = pickle.load(fp) with open(fname, 'wb') as fp: os.chdir(source_dir) for member in members: if member.isreg(): tar.addfile(member, ope...
def set_display_name(self, display_name): """Sets a display name. arg: display_name (string): the new display name raise: InvalidArgument - ``display_name`` is invalid raise: NoAccess - ``display_name`` cannot be modified raise: NullArgument - ``display_name`` is ``null`` *compliance: mandatory -- This method must be i...
def clear_display_name(self): """Clears the display name. raise: NoAccess - ``display_name`` cannot be modified *compliance: mandatory -- This method must be implemented.* """ if (self.get_display_name_metadata().is_read_only() or self.get_display_name_metadata().is_required()): raise errors.NoAccess() self._my_map['di...