code
stringlengths
1
18.2k
def _arithmetic_operation(self, other, operation): """ Applies an operation between the values of a trajectories and a scalar or between the respective values of two trajectories. In the latter case, trajectories should have equal descriptions and time points """ if isinstance(other, Trajectory): if self.description !=...
def _arithmetic_operation(self, other, operation): """ Applies an operation between the values of a trajectories and a scalar or between the respective values of two trajectories. In the latter case, trajectories should have equal descriptions and time points """ if isinstance(other, TrajectoryWithSensitivityData): if ...
def to_csv(self, file): """ Write all the trajectories of a collection to a csv file with the headers 'description', 'time' and 'value'. :param file: a file object to write to :type file: :class:`file` :return: """ file.write("description,time,value\n") for traj in self: for t,v in traj: file.write("%s,%f,%f\n"% (traj....
def xform(self, number, base): """ Get a number as a string. :param number: a number :type number: list of int :param int base: the base in which this number is being represented :raises BasesValueError: if config is unsuitable for number """ if self.CONFIG.use_letters: digits = \ self._UPPER_DIGITS if self.CONFIG.use_...
def _strip_trailing_zeros(value): """ Strip trailing zeros from a list of ints. :param value: the value to be stripped :type value: list of str :returns: list with trailing zeros stripped :rtype: list of int """ return list( reversed( list(itertools.dropwhile(lambda x: x == 0, reversed(value))) ) )
def xform(self, number, relation): """ Strip trailing zeros from a number according to config and relation. :param number: a number :type number: list of int :param int relation: the relation of the display value to the actual """ # pylint: disable=too-many-boolean-expressions if (self.CONFIG.strip) or \ (self.CONFIG.s...
def xform(self, left, right, repeating, base, sign): """ Return prefixes for tuple. :param str left: left of the radix :param str right: right of the radix :param str repeating: repeating part :param int base: the base in which value is displayed :param int sign: -1, 0, 1 as appropriate :returns: the number string :rty...
if repeating != "" else "", 'base_separator' : '' if base_subscript == '' else '_', 'base_subscript' : base_subscript } return self._FMT_STR % result
def decorators(self, relation): """ Return prefixes for tuple. :param int relation: relation of string value to actual value """ if self.CONFIG.show_approx_str: approx_str = Decorators.relation_to_symbol(relation) else: approx_str = '' return _Decorators(approx_str=approx_str)
def xform(self, radix, relation): """ Transform a radix and some information to a str according to configurations. :param Radix radix: the radix :param int relation: relation of display value to actual value :param units: element of UNITS() :returns: a string representing the value :rtype: str :raises BasesValueError: ...
def get_provider_link_ids(self): """Gets the resource Ids representing the source of this asset in order from the most recent provider to the originating source. return: (osid.id.IdList) - the provider Ids compliance: mandatory - This method must be implemented. """ id_list = [] for id_ in self._my_map['providerLinkIds...
def set_title(self, title=None): """Sets the title. :param title: the new title :type title: ``string`` :raise: ``InvalidArgument`` -- ``title`` is invalid :raise: ``NoAccess`` -- ``Metadata.isReadOnly()`` is ``true`` :raise: ``NullArgument`` -- ``title`` is ``null`` *compliance: mandatory -- This method must be implem...
def clear_title(self): """Removes the title. :raise: ``NoAccess`` -- ``Metadata.isRequired()`` is ``true`` or ``Metadata.isReadOnly()`` is ``true`` *compliance: mandatory -- This method must be implemented.* """ metadata = Metadata(**settings.METADATA['title']) if metadata.is_read_only() or metadata.is_required(): rais...
def set_public_domain(self, public_domain=None): """Sets the public domain flag. :param public_domain: the public domain status :type public_domain: ``boolean`` :raise: ``NoAccess`` -- ``Metadata.isReadOnly()`` is ``true`` *compliance: mandatory -- This method must be implemented.* """ if public_domain is None: raise N...
def set_copyright(self, copyright=None): """Sets the copyright. :param copyright: the new copyright :type copyright: ``string`` :raise: ``InvalidArgument`` -- ``copyright`` is invalid :raise: ``NoAccess`` -- ``Metadata.isReadOnly()`` is ``true`` :raise: ``NullArgument`` -- ``copyright`` is ``null`` *compliance: mandato...
def set_copyright_registration(self, registration): """Sets the copyright registration. arg: registration (string): the new copyright registration raise: InvalidArgument - ``copyright`` is invalid raise: NoAccess - ``Metadata.isReadOnly()`` is ``true`` raise: NullArgument - ``copyright`` is ``null`` *compliance: mandat...
def set_distribute_verbatim(self, distribute_verbatim=None): """Sets the distribution rights. :param distribute_verbatim: right to distribute verbatim copies :type distribute_verbatim: ``boolean`` :raise: ``InvalidArgument`` -- ``distribute_verbatim`` is invalid :raise: ``NoAccess`` -- authorization failure *compliance...
def set_distribute_alterations(self, distribute_mods=None): """Sets the distribute alterations flag. This also sets distribute verbatim to ``true``. :param distribute_mods: right to distribute modifications :type distribute_mods: ``boolean`` :raise: ``InvalidArgument`` -- ``distribute_mods`` is invalid :raise: ``NoAcce...
def set_distribute_compositions(self, distribute_comps=None): """Sets the distribution rights. This sets distribute verbatim to ``true``. :param distribute_comps: right to distribute modifications :type distribute_comps: ``boolean`` :raise: ``InvalidArgument`` -- ``distribute_comps`` is invalid :raise: ``NoAccess`` -- ...
def set_source(self, source_id=None): """Sets the source. :param source_id: the new publisher :type source_id: ``osid.id.Id`` :raise: ``InvalidArgument`` -- ``source_id`` is invalid :raise: ``NoAccess`` -- ``Metadata.isReadOnly()`` is ``true`` :raise: ``NullArgument`` -- ``source_id`` is ``null`` *compliance: mandatory...
def set_provider_links(self, resource_ids=None): """Sets a provider chain in order from the most recent source to the originating source. :param resource_ids: the new source :type resource_ids: ``osid.id.Id[]`` :raise: ``InvalidArgument`` -- ``resource_ids`` is invalid :raise: ``NoAccess`` -- ``Metadata.isReadOnly()`` ...
def set_created_date(self, created_date=None): """Sets the created date. :param created_date: the new created date :type created_date: ``osid.calendaring.DateTime`` :raise: ``InvalidArgument`` -- ``created_date`` is invalid :raise: ``NoAccess`` -- ``Metadata.isReadOnly()`` is ``true`` :raise: ``NullArgument`` -- ``crea...
def set_published(self, published=None): """Sets the published status. :param published: the published status :type published: ``boolean`` :raise: ``NoAccess`` -- ``Metadata.isReadOnly()`` is ``true`` *compliance: mandatory -- This method must be implemented.* """ if published is None: raise NullArgument() metadata = M...
def clear_published(self): """Removes the published status. :raise: ``NoAccess`` -- ``Metadata.isRequired()`` is ``true`` or ``Metadata.isReadOnly()`` is ``true`` *compliance: mandatory -- This method must be implemented.* """ metadata = Metadata(**settings.METADATA['published']) if metadata.is_read_only() or metadata....
def set_published_date(self, published_date=None): """Sets the published date. :param published_date: the new published date :type published_date: ``osid.calendaring.DateTime`` :raise: ``InvalidArgument`` -- ``published_date`` is invalid :raise: ``NoAccess`` -- ``Metadata.isReadOnly()`` is ``true`` :raise: ``NullArgume...
def set_principal_credit_string(self, credit_string=None): """Sets the principal credit string. :param credit_string: the new credit string :type credit_string: ``string`` :raise: ``InvalidArgument`` -- ``credit_string`` is invalid :raise: ``NoAccess`` -- ``Metadata.isReadOnly()`` is ``true`` :raise: ``NullArgument`` -...
def set_composition(self, composition_id=None): """Sets the composition. :param composition_id: a composition :type composition_id: ``osid.id.Id`` :raise: ``InvalidArgument`` -- ``composition_id`` is invalid :raise: ``NoAccess`` -- ``Metadata.isReadOnly()`` is ``true`` :raise: ``NullArgument`` -- ``composition_id`` is ...
def get_next_asset(self): """Gets the next Asset in this list. return: (osid.repository.Asset) - the next Asset in this list. The has_next() method should be used to test that a next Asset is available before calling this method. raise: IllegalState - no more elements available in this list raise: OperationFailed - una...
def add_accessibility_type(self, accessibility_type=None): """Adds an accessibility type. Multiple types can be added. :param accessibility_type: a new accessibility type :type accessibility_type: ``osid.type.Type`` :raise: ``InvalidArgument`` -- ``accessibility_type`` is invalid :raise: ``NoAccess`` -- ``Metadata.isRe...
def remove_accessibility_type(self, accessibility_type=None): """Removes an accessibility type. :param accessibility_type: accessibility type to remove :type accessibility_type: ``osid.type.Type`` :raise: ``NoAccess`` -- ``Metadata.isReadOnly()`` is ``true`` :raise: ``NotFound`` -- acessibility type not found :raise: `...
def set_url(self, url=None): """Sets the url. :param url: the new copyright :type url: ``string`` :raise: ``InvalidArgument`` -- ``url`` is invalid :raise: ``NoAccess`` -- ``Metadata.isReadOnly()`` is ``true`` :raise: ``NullArgument`` -- ``url`` is ``null`` *compliance: mandatory -- This method must be implemented.* ""...
def get_next_asset_content(self): """Gets the next AssetContent in this list. return: (osid.repository.AssetContent) - the next AssetContent in this list. The has_next() method should be used to test that a next AssetContent is available before calling this method. raise: IllegalState - no more elements available in th...
def get_next_repository(self): """Gets the next ``Repository`` in this list. :return: the next ``Repository`` in this list. The ``has_next()`` method should be used to test that a next ``Repository`` is available before calling this method. :rtype: ``osid.repository.Repository`` :raise: ``IllegalState`` -- no more elem...
def profile(message=None, verbose=False): """Decorator for profiling a function. TODO: Support `@profile` syntax (without parens). This would involve inspecting the args. In this case `profile` would receive a single argument, which is the function to be decorated. """ import functools from harrison.registered_timer im...
def get_item_lookup_session(self): """Gets the ``OsidSession`` associated with the item lookup service. return: (osid.assessment.ItemLookupSession) - an ``ItemLookupSession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_item_lookup()`` is ``false`` *compliance: optional -- This ...
def get_item_lookup_session_for_bank(self, bank_id): """Gets the ``OsidSession`` associated with the item lookup service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the bank return: (osid.assessment.ItemLookupSession) - ``an _item_lookup_session`` raise: NotFound - ``bank_id`` not found raise: NullArgu...
def get_item_query_session(self): """Gets the ``OsidSession`` associated with the item query service. return: (osid.assessment.ItemQuerySession) - an ``ItemQuerySession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_item_query()`` is ``false`` *compliance: optional -- This metho...
def get_item_query_session_for_bank(self, bank_id): """Gets the ``OsidSession`` associated with the item query service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the bank return: (osid.assessment.ItemQuerySession) - ``an _item_query_session`` raise: NotFound - ``bank_id`` not found raise: NullArgument...
def get_item_notification_session(self, item_receiver): """Gets the notification session for notifications pertaining to item changes. arg: item_receiver (osid.assessment.ItemReceiver): the item receiver interface return: (osid.assessment.ItemNotificationSession) - an ``ItemNotificationSession`` raise: NullArgument - `...
def get_item_notification_session_for_bank(self, item_receiver, bank_id): """Gets the ``OsidSession`` associated with the item notification service for the given bank. arg: item_receiver (osid.assessment.ItemReceiver): the item receiver interface arg: bank_id (osid.id.Id): the ``Id`` of the bank return: (osid.assessmen...
def get_item_bank_session(self): """Gets the ``OsidSession`` associated with the item banking service. return: (osid.assessment.ItemBankSession) - an ``ItemBankSession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_item_bank()`` is ``false`` *compliance: optional -- This method ...
def get_item_bank_assignment_session(self): """Gets the ``OsidSession`` associated with the item bank assignment service. return: (osid.assessment.ItemBankAssignmentSession) - an ``ItemBankAssignmentSession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_item_bank_assignment()`` ...
def get_assessment_admin_session(self): """Gets the ``OsidSession`` associated with the assessment administration service. return: (osid.assessment.AssessmentAdminSession) - an ``AssessmentAdminSession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_assessment_admin()`` is ``fals...
def get_assessment_admin_session_for_bank(self, bank_id): """Gets the ``OsidSession`` associated with the assessment admin service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the bank return: (osid.assessment.AssessmentAdminSession) - ``an _assessment_admin_session`` raise: NotFound - ``bank_id`` not f...
def get_assessment_notification_session(self, assessment_receiver): """Gets the notification session for notifications pertaining to assessment changes. arg: assessment_receiver (osid.assessment.AssessmentReceiver): the assessment receiver interface return: (osid.assessment.AssessmentNotificationSession) - an ``Assessm...
def get_assessment_notification_session_for_bank(self, assessment_receiver, bank_id): """Gets the ``OsidSession`` associated with the assessment notification service for the given bank. arg: assessment_receiver (osid.assessment.AssessmentReceiver): the assessment receiver interface arg: bank_id (osid.id.Id): the ``Id``...
def get_assessment_offered_lookup_session(self): """Gets the ``OsidSession`` associated with the assessment offered lookup service. return: (osid.assessment.AssessmentOfferedLookupSession) - an ``AssessmentOfferedLookupSession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_asses...
def get_assessment_offered_lookup_session_for_bank(self, bank_id): """Gets the ``OsidSession`` associated with the assessment offered lookup service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the bank return: (osid.assessment.AssessmentOfferedLookupSession) - an ``AssessmentOfferedLookupSession`` rais...
def get_assessment_offered_query_session(self): """Gets the ``OsidSession`` associated with the assessment offered query service. return: (osid.assessment.AssessmentOfferedQuerySession) - an ``AssessmentOfferedQuerySession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_assessmen...
def get_assessment_offered_query_session_for_bank(self, bank_id): """Gets the ``OsidSession`` associated with the assessment offered query service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the bank return: (osid.assessment.AssessmentOfferedQuerySession) - an ``AssessmentOfferedQuerySession`` raise: N...
def get_assessment_taken_lookup_session(self): """Gets the ``OsidSession`` associated with the assessment taken lookup service. return: (osid.assessment.AssessmentTakenLookupSession) - an ``AssessmentTakenLookupSession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_assessment_ta...
def get_assessment_taken_lookup_session_for_bank(self, bank_id): """Gets the ``OsidSession`` associated with the assessment taken lookup service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the bank return: (osid.assessment.AssessmentTakenLookupSession) - an ``AssessmentTakenLookupSession`` raise: NotFo...
def get_assessment_taken_query_session(self): """Gets the ``OsidSession`` associated with the assessment taken query service. return: (osid.assessment.AssessmentTakenQuerySession) - an ``AssessmentTakenQuerySession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_assessment_taken_...
def get_assessment_taken_query_session_for_bank(self, bank_id): """Gets the ``OsidSession`` associated with the assessment taken query service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the bank return: (osid.assessment.AssessmentTakenQuerySession) - an ``AssessmentTakenQuerySession`` raise: NotFound ...
def get_bank_lookup_session(self): """Gets the OsidSession associated with the bank lookup service. return: (osid.assessment.BankLookupSession) - a ``BankLookupSession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_bank_lookup() is false`` *compliance: optional -- This method mu...
def get_bank_query_session(self): """Gets the OsidSession associated with the bank query service. return: (osid.assessment.BankQuerySession) - a ``BankQuerySession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_bank_query() is false`` *compliance: optional -- This method must be...
def get_bank_admin_session(self): """Gets the OsidSession associated with the bank administration service. return: (osid.assessment.BankAdminSession) - a ``BankAdminSession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_bank_admin() is false`` *compliance: optional -- This metho...
def get_bank_hierarchy_session(self): """Gets the session traversing bank hierarchies. return: (osid.assessment.BankHierarchySession) - a ``BankHierarchySession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_bank_hierarchy() is false`` *compliance: optional -- This method must b...
def get_assessment_session(self, proxy): """Gets an ``AssessmentSession`` which is responsible for taking assessments and examining responses from assessments taken. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.AssessmentSession) - an assessment session for this service raise: NullArgument - ``proxy`...
def get_assessment_session_for_bank(self, bank_id, proxy): """Gets an ``AssessmentSession`` which is responsible for performing assessments for the given bank ``Id``. arg: bank_id (osid.id.Id): the ``Id`` of a bank arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.AssessmentSession) - an assessment sessio...
def get_assessment_results_session(self, proxy): """Gets an ``AssessmentResultsSession`` to retrieve assessment results. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.AssessmentResultsSession) - an assessment results session for this service raise: NullArgument - ``proxy`` is ``null`` raise: Operation...
def get_assessment_results_session_for_bank(self, bank_id, proxy): """Gets an ``AssessmentResultsSession`` to retrieve assessment results for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the assessment taken arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.AssessmentResultsSession) - an asses...
def get_item_search_session(self, proxy): """Gets the ``OsidSession`` associated with the item search service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.ItemSearchSession) - an ``ItemSearchSession`` raise: NullArgument - ``proxy`` is ``null`` raise: OperationFailed - unable to complete request rai...
def get_item_search_session_for_bank(self, bank_id, proxy): """Gets the ``OsidSession`` associated with the item search service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the bank arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.ItemSearchSession) - ``an _item_search_session`` raise: No...
def get_item_admin_session(self, proxy): """Gets the ``OsidSession`` associated with the item administration service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.ItemAdminSession) - an ``ItemAdminSession`` raise: NullArgument - ``proxy`` is ``null`` raise: OperationFailed - unable to complete reques...
def get_item_admin_session_for_bank(self, bank_id, proxy): """Gets the ``OsidSession`` associated with the item admin service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the bank arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.ItemAdminSession) - ``an _item_admin_session`` raise: NotFou...
def get_assessment_lookup_session(self, proxy): """Gets the ``OsidSession`` associated with the assessment lookup service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.AssessmentLookupSession) - an ``AssessmentLookupSession`` raise: NullArgument - ``proxy`` is ``null`` raise: OperationFailed - unable...
def get_assessment_lookup_session_for_bank(self, bank_id, proxy): """Gets the ``OsidSession`` associated with the assessment lookup service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the bank arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.AssessmentLookupSession) - ``an _assessment_lo...
def get_assessment_query_session(self, proxy): """Gets the ``OsidSession`` associated with the assessment query service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.AssessmentQuerySession) - an ``AssessmentQuerySession`` raise: NullArgument - ``proxy`` is ``null`` raise: OperationFailed - unable to ...
def get_assessment_query_session_for_bank(self, bank_id, proxy): """Gets the ``OsidSession`` associated with the assessment query service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the bank arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.AssessmentQuerySession) - ``an _assessment_query...
def get_assessment_bank_session(self, proxy): """Gets the ``OsidSession`` associated with the assessment banking service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.AssessmentBankSession) - an ``AssessmentBankSession`` raise: NullArgument - ``proxy`` is ``null`` raise: OperationFailed - unable to c...
def get_assessment_bank_assignment_session(self, proxy): """Gets the ``OsidSession`` associated with the assessment bank assignment service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.AssessmentBankAssignmentSession) - an ``AssessmentBankAssignmentSession`` raise: NullArgument - ``proxy`` is ``null...
def get_assessment_basic_authoring_session(self, proxy): """Gets the ``OsidSession`` associated with the assessment authoring service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.AssessmentBasicAuthoringSession) - an ``AssessmentBasicAuthoringSession`` raise: NullArgument - ``proxy`` is ``null`` rai...
def get_assessment_basic_authoring_session_for_bank(self, bank_id, proxy): """Gets the ``OsidSession`` associated with the assessment authoring service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of a bank arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.AssessmentBasicAuthoringSession) - a...
def get_assessment_offered_admin_session(self, proxy): """Gets the ``OsidSession`` associated with the assessment offered administration service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.AssessmentOfferedAdminSession) - an ``AssessmentOfferedAdminSession`` raise: NullArgument - ``proxy`` is ``nul...
def get_assessment_offered_admin_session_for_bank(self, bank_id, proxy): """Gets the ``OsidSession`` associated with the assessment offered admin service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the bank arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.AssessmentOfferedAdminSession) -...
def get_assessment_offered_bank_session(self, proxy): """Gets the session for retrieving offered assessments to bank mappings. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.AssessmentOfferedBankSession) - an ``AssessmentOfferedBankSession`` raise: NullArgument - ``proxy`` is ``null`` raise: OperationF...
def get_assessment_offered_bank_assignment_session(self, proxy): """Gets the session for assigning offered assessments to bank mappings. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.AssessmentOfferedBankAssignmentSession) - an ``AssessmentOfferedBankAssignmentSession`` raise: NullArgument - ``proxy``...
def get_assessment_taken_admin_session(self, proxy): """Gets the ``OsidSession`` associated with the assessment taken administration service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.AssessmentTakenAdminSession) - an ``AssessmentTakenAdminSession`` raise: NullArgument - ``proxy`` is ``null`` rais...
def get_assessment_taken_admin_session_for_bank(self, bank_id, proxy): """Gets the ``OsidSession`` associated with the assessment taken admin service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the bank arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.AssessmentTakenAdminSession) - an ``...
def get_assessment_taken_bank_session(self, proxy): """Gets the session for retrieving taken assessments to bank mappings. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.AssessmentTakenBankSession) - an ``AssessmentTakenBankSession`` raise: NullArgument - ``proxy`` is ``null`` raise: OperationFailed - ...
def get_assessment_taken_bank_assignment_session(self, proxy): """Gets the session for assigning taken assessments to bank mappings. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.AssessmentTakenBankAssignmentSession) - an ``AssessmentTakenBankAssignmentSession`` raise: NullArgument - ``proxy`` is ``nu...
def get_bank_hierarchy_design_session(self, proxy): """Gets the session designing bank hierarchies. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.BankHierarchyDesignSession) - a ``BankHierarchySession`` raise: NullArgument - ``proxy`` is ``null`` raise: OperationFailed - unable to complete request rai...
def env(self, **kw): ''' Allows adding/overriding env vars in the execution context. :param kw: Key-value pairs :return: self ''' self._original_env = kw if self._env is None: self._env = dict(os.environ) self._env.update({k: unicode(v) for k, v in kw.iteritems()}) return self
def expand(self, expand): ''' Turn off argument expansion, useful for 'grep'. Example: Sh('grep .*').expand(False) > 'tango' :param expand: True or False :return: self ''' self._expand = expand cmd = self._original_cmd if len(cmd) == 1: if not type(cmd[0]) in (str, unicode): cmd = cmd[0] else: cmd = shlex.split(cmd[0])...
def returncode(self): ''' Runs the command if it has not yet run (redirecting output to stdout). :return: The returncode of the last executed command in the chain. ''' if not self._pop: self > sys.stdout link = self while link is not None: if link._pop: return link._pop.returncode return None
def reset(self): ''' Allows you to re-run the command chain. :return: self ''' t = self while t._output is not None: t = t._output while t is not None: if t._pop and t._pop.returncode is None: t._pop.kill() t._pop.wait() del t._pop t._pop = None t = t._input return self
def _append(self, sh): ''' Internal. Chains a command after this. :param sh: Next command. ''' sh._input = self self._output = sh if self._env: sh._env = dict(self._env) if self._cwd: sh._cwd = self._cwd
def _run(self, stdout=subprocess.PIPE): ''' Internal. Starts running this command and those before it. Can only be called once. :param stdout: Where to send stdout for this link in the chain. ''' assert self._pop is None if self._input is not None: self._input._run() cwd = (self._cwd if self._cwd else os.getcwd()) + '/...
if stdin is not None and getattr(stdin, 'fileno', None) is None: stdin = subprocess.PIPE cmd = [self._cmd] + list(itertools.chain.from_iterable(args)) if self.debug: print "*** DEBUG: Run", cmd try: self._pop = subprocess.Popen(cmd, stdin=stdin, stdout=stdout, stderr=stderr, close_fds=True, cwd=self._cwd, env=self._env...
def _stream_out(self, outfile, append=False): ''' Internal. Writes all stdout into outfile. :param outfile: Filename or file-like object for writing. :param append: Opens filename with append. :return: This command's returncode. ''' if type(outfile) in (str, unicode): outfile = os.path.expanduser(os.path.expandvars(out...
def pipe(cls, input): ''' Creates a stdin source for Sh object chains. :param input: If string; open as filename, if iterable, send iterated content into next command, if none of the above assume file like object. To input a string as content source, wrap in iterable: print 'Lines in "my_input_string":', Sh.pipe([my_st...
def helper_import(module_name, class_name=None): """ Return class or module object. if the argument is only a module name and return a module object. if the argument is a module and class name, and return a class object. """ try: module = __import__(module_name, globals(), locals(), [class_name]) except (BlackbirdError...
def global_import(mod_name): """ This function search sys.path[1:], return specified module. sys.path[1:] means the directories other than current directory('./'). 'mod_name' as an argument is string type object. """ mod_tuple = imp.find_module(mod_name, sys.path[1:]) mod = imp.load_module(mod_name, mod_tuple[0], mod_t...
def gather_repositories(): """ Collects all of the repositories. The current implementation searches for them in the current working directory. """ for (root, dirs, files) in os.walk('.', topdown=True): if '.git' not in dirs: continue for dir in list(dirs): dirs.remove(dir) path = os.path.split(root)[1] repo = os.path....
def run(command, exit, silent, check): """ Runs given command on all repos and checks status $ maintain repo run -- git checkout master """ status = 0 for (repo, path) in gather_repositories(): if check and not check_repo(repo, path): status = 1 if exit: break continue with chdir(path): result = subprocess.run(command,...
def parse(inp, format=None, encoding='utf-8', force_types=True): """Parse input from file-like object, unicode string or byte string. Args: inp: file-like object, unicode string or byte string with the markup format: explicitly override the guessed `inp` markup format encoding: `inp` encoding, defaults to utf-8 force_t...
= inp.name fmt = _get_format(format, fname, proper_inp) # make it look like file-like bytes-yielding object proper_inp = six.BytesIO(proper_inp) try: res = _do_parse(proper_inp, fmt, encoding, force_types) except Exception as e: # I wish there was only Python 3 and I could just use "raise ... from e" raise AnyMarkupErr...
def parse_file(path, format=None, encoding='utf-8', force_types=True): """A convenience wrapper of parse, which accepts path of file to parse. Args: path: path to file to parse format: explicitly override the guessed `inp` markup format encoding: file encoding, defaults to utf-8 force_types: if `True`, integers, floats...
def serialize(struct, format, target=None, encoding='utf-8'): """Serialize given structure and return it as encoded string or write it to file-like object. Args: struct: structure (dict or list) with unicode members to serialize; note that list can only be serialized to json format: specify markup format to serialize s...