code stringlengths 1 18.2k |
|---|
def dependent_images(self): """ Determine the dependent images from these commands This includes all the FROM statements and any external image from a complex ADD instruction that copies from another container """ found = [] for command in self.commands: dep = command.dependent_image if dep: if dep not in found: yield ... |
def validate(self): """ Validates whether the ODE equations provided make sense i.e. the number of right-hand side equations match the number of left-hand side equations. """ if self.left_hand_side.rows != self.right_hand_side.rows: raise ValueError("There are {0} left hand side equations and {1} right hand side equati... |
def right_hand_side_as_function(self): """ Generates and returns the right hand side of the model as a callable function that takes two parameters: values for variables and values for constants, e.g. `f(values_for_variables=[1,2,3], values_for_constants=[3,4,5]) This function is directly used in `means.simulation.Simul... |
def descriptor_for_symbol(self, symbol): """ Given the symbol associated with the problem. Returns the :class:`~means.core.descriptors.Descriptor` associated with that symbol :param symbol: Symbol :type symbol: basestring|:class:`sympy.Symbol` :return: """ if isinstance(symbol, basestring): symbol = sympy.Symbol(symbol... |
def _repr_latex_(self): """ This is used in IPython notebook it allows us to render the ODEProblem object in LaTeX. How Cool is this? """ # TODO: we're mixing HTML with latex here. That is not necessarily a good idea, but works # with IPython 1.2.0. Once IPython 2.0 is released, this needs to be changed to _ipython_dis... |
def decensor_iter(posts_info: Iterable[dict], site_url: str = DEFAULT_SITE ) -> Generator[dict, None, None]: """Apply decensoring on an iterable of posts info dicts from Danbooru API. Any censored post is automatically decensored if needed.""" for info in posts_info: yield decensor(info, site_url) |
def decensor(post_info: dict, site_url: str = DEFAULT_SITE) -> dict: "Decensor a post info dict from Danbooru API if needed." return post_info \ if "md5" in post_info else fill_missing_info(post_info, site_url) |
def fill_missing_info(info: dict, site_url: str = DEFAULT_SITE) -> dict: "Add missing info in a censored post info dict." try: md5, ext = find_censored_md5ext(info["id"]) except TypeError: # None returned by find_.. return info sample_ext = "jpg" if ext != "zip" else "webm" if info["id"] > 2_800_000: site_url = site_ur... |
def find_censored_md5ext(post_id: int) -> Optional[str]: "Find MD5 for a censored post's ID, return None if can't find." try: last_pull_date = LAST_PULL_DATE_FILE.read_text().strip() except FileNotFoundError: last_pull_date = "" date = datetime.utcnow() date = f"{date.year}{date.month}{date.day}" if last_pull_date != d... |
def update_batches() -> None: "Update id:md5.ext batches from Dencensooru's repository." batches_data = requests.get(BATCHES_API_URL).json() batches_url = {i["name"]: i["download_url"] for i in batches_data if i["type"] == "file"} order_batches = sorted(batches_url, key=int) try: existing = set(os.listdir(BATCHES_DIR))... |
def _init_map(self): """stub""" super(IRTItemFormRecord, self)._init_map() self.my_osid_object_form._my_map['decimalValues']['difficulty'] = \ self._decimal_value_metadata['default_decimal_values'][1] self.my_osid_object_form._my_map['decimalValues']['discrimination'] = \ self._decimal_value_metadata['default_decimal_v... |
def set_difficulty_value(self, difficulty): """stub""" if not isinstance(difficulty, float): raise InvalidArgument('difficulty value must be a decimal') self.add_decimal_value(difficulty, 'difficulty') |
def set_discrimination_value(self, discrimination): """stub""" if not isinstance(discrimination, float): raise InvalidArgument('discrimination value must be a decimal') self.add_decimal_value(discrimination, 'discrimination') |
def set_pseudo_guessing_value(self, pseudo_guessing): """stub""" if not isinstance(pseudo_guessing, float): raise InvalidArgument('pseudo-guessing value must be a decimal') self.add_decimal_value(pseudo_guessing, 'pseudoGuessing') |
def _view_filter(self): """ Overrides OsidSession._view_filter to add sequestering filter. """ view_filter = OsidSession._view_filter(self) if self._sequestered_view == SEQUESTERED: view_filter['sequestered'] = False return view_filter |
def get_assessment_part(self, assessment_part_id): """Gets the ``AssessmentPart`` specified by its ``Id``. arg: assessment_part_id (osid.id.Id): the ``Id`` of the ``AssessmentPart`` to retrieve return: (osid.assessment.authoring.AssessmentPart) - the returned ``AssessmentPart`` raise: NotFound - no ``AssessmentPart`` f... |
def get_assessment_parts_by_ids(self, assessment_part_ids): """Gets an ``AssessmentPartList`` corresponding to the given ``IdList``. arg: assessment_part_ids (osid.id.IdList): the list of ``Ids`` to retrieve return: (osid.assessment.authoring.AssessmentPartList) - the returned ``AssessmentPart`` list raise: NotFound - ... |
def get_assessment_parts_by_genus_type(self, assessment_part_genus_type): """Gets an ``AssessmentPartList`` corresponding to the given assessment part genus ``Type`` which does not include assessment parts of types derived from the specified ``Type``. arg: assessment_part_genus_type (osid.type.Type): an assessment part... |
def get_assessment_parts_for_assessment(self, assessment_id): """Gets an ``AssessmentPart`` for the given assessment. arg: assessment_id (osid.id.Id): an assessment ``Id`` return: (osid.assessment.authoring.AssessmentPartList) - the returned ``AssessmentPart`` list raise: NullArgument - ``assessment_id`` is ``null`` ra... |
def get_assessment_parts(self): """Gets all ``AssessmentParts``. return: (osid.assessment.authoring.AssessmentPartList) - a list of ``AssessmentParts`` raise: OperationFailed - unable to complete request raise: PermissionDenied - authorization failure *compliance: mandatory -- This method must be implemented.* """ # Im... |
def get_assessment_parts_for_assessment_part(self, assessment_part_id): """Gets an ``AssessmentPart`` for the given assessment part. arg: assessment_part_id (osid.id.Id): an assessment part ``Id`` return: (osid.assessment.authoring.AssessmentPartList) - the returned ``AssessmentPart`` list raise: NullArgument - ``asses... |
def get_assessment_parts_by_query(self, assessment_part_query): """Gets a list of ``AssessmentParts`` matching the given assessment part query. arg: assessment_part_query (osid.assessment.authoring.AssessmentPartQuery): the assessment part query return: (osid.assessment.authoring.AssessmentPartList) - the returned ``As... |
collection.find(query_terms).sort('_id', DESCENDING) else: result = [] return objects.AssessmentPartList(result, runtime=self._runtime, proxy=self._proxy) |
def get_assessment_part_form_for_create_for_assessment(self, assessment_id, assessment_part_record_types): """Gets the assessment part form for creating new assessment parts for an assessment. A new form should be requested for each create transaction. arg: assessment_id (osid.id.Id): an assessment ``Id`` arg: assessme... |
Id') for arg in assessment_part_record_types: if not isinstance(arg, ABCType): raise errors.InvalidArgument('one or more argument array elements is not a valid OSID Type') if assessment_part_record_types == []: # WHY are we passing bank_id = self._catalog_id below, seems redundant: obj_form = objects.AssessmentPartForm... |
def create_assessment_part_for_assessment(self, assessment_part_form): """Creates a new assessment part. arg: assessment_part_form (osid.assessment.authoring.AssessmentPartForm): assessment part form return: (osid.assessment.authoring.AssessmentPart) - the new part raise: IllegalState - ``assessment_part_form`` already... |
this session') if not assessment_part_form.is_valid(): raise errors.InvalidArgument('one or more of the form elements is invalid') insert_result = collection.insert_one(assessment_part_form._my_map) self._forms[assessment_part_form.get_id().get_identifier()] = CREATED result = objects.AssessmentPart( osid_object_map=co... |
def get_assessment_part_form_for_create_for_assessment_part(self, assessment_part_id, assessment_part_record_types): """Gets the assessment part form for creating new assessment parts under another assessment part. A new form should be requested for each create transaction. arg: assessment_part_id (osid.id.Id): an asse... |
if not isinstance(arg, ABCType): raise errors.InvalidArgument('one or more argument array elements is not a valid OSID Type') if assessment_part_record_types == []: assessment_part_record_types = None mgr = self._get_provider_manager('ASSESSMENT_AUTHORING', local=True) lookup_session = mgr.get_assessment_part_lookup_se... |
def get_assessment_part_form_for_update(self, assessment_part_id): """Gets the assessment part form for updating an existing assessment part. A new assessment part form should be requested for each update transaction. arg: assessment_part_id (osid.id.Id): the ``Id`` of the ``AssessmentPart`` return: (osid.assessment.au... |
lookup_session.get_assessment_parts_for_assessment_part(parent_part_id).available() > 1: mdata['sequestered']['is_read_only'] = True mdata['sequestered']['is_required'] = True obj_form = objects.AssessmentPartForm(osid_object_map=result, runtime=self._runtime, proxy=self._proxy, mdata=mdata) self._forms[obj_form.get_id... |
def update_assessment_part(self, assessment_part_id, assessment_part_form): """Updates an existing assessment part. arg: assessment_part_id (osid.id.Id): the ``Id`` of the ``AssessmentPart`` arg: assessment_part_form (osid.assessment.authoring.AssessmentPartForm): part form raise: NotFound - ``assessment_part_id`` not ... |
or more of the form elements is invalid') collection.save(assessment_part_form._my_map) self._forms[assessment_part_form.get_id().get_identifier()] = UPDATED # Note: this is out of spec. The OSIDs don't require an object to be returned: return objects.AssessmentPart( osid_object_map=assessment_part_form._my_map, runtim... |
def delete_assessment_part(self, assessment_part_id): """Removes an asessment part and all mapped items. arg: assessment_part_id (osid.id.Id): the ``Id`` of the ``AssessmentPart`` raise: NotFound - ``assessment_part_id`` not found raise: NullArgument - ``assessment_part_id`` is ``null`` raise: OperationFailed - unable ... |
def alias_assessment_part(self, assessment_part_id, alias_id): """Adds an ``Id`` to an ``AssessmentPart`` for the purpose of creating compatibility. The primary ``Id`` of the ``AssessmentPart`` is determined by the provider. The new ``Id`` is an alias to the primary ``Id``. If the alias is a pointer to another assessme... |
def get_assessment_part_ids_by_bank(self, bank_id): """Gets the list of ``AssessmentPartIds`` associated with an ``Bank``. arg: bank_id (osid.id.Id): ``Id`` of the ``Bank`` return: (osid.id.IdList) - list of related assessment part ``Ids`` raise: NotFound - ``bank_id`` is not found raise: NullArgument - ``bank_id`` is ... |
def get_assessment_parts_by_bank(self, bank_id): """Gets the list of assessment parts associated with an ``Bank``. arg: bank_id (osid.id.Id): ``Id`` of the ``Bank`` return: (osid.assessment.authoring.AssessmentPartList) - list of related assessment parts raise: NotFound - ``bank_id`` is not found raise: NullArgument - ... |
def get_assessment_part_ids_by_banks(self, bank_ids): """Gets the list of ``AssessmentPart Ids`` corresponding to a list of ``Banks``. arg: bank_ids (osid.id.IdList): list of bank ``Ids`` return: (osid.id.IdList) - list of assessment part ``Ids`` raise: NullArgument - ``bank_ids`` is ``null`` raise: OperationFailed - u... |
def get_assessment_parts_by_banks(self, bank_ids): """Gets the list of assessment part corresponding to a list of ``Banks``. arg: bank_ids (osid.id.IdList): list of bank ``Ids`` return: (osid.assessment.authoring.AssessmentPartList) - list of assessment parts raise: NullArgument - ``bank_ids`` is ``null`` raise: Operat... |
def get_bank_ids_by_assessment_part(self, assessment_part_id): """Gets the ``Bank`` ``Ids`` mapped to an ``AssessmentPart``. arg: assessment_part_id (osid.id.Id): ``Id`` of an ``AssessmentPart`` return: (osid.id.IdList) - list of banks raise: NotFound - ``assessment_part_id`` is not found raise: NullArgument - ``assess... |
def get_banks_by_assessment_part(self, assessment_part_id): """Gets the ``Banks`` mapped to an ``AssessmentPart``. arg: assessment_part_id (osid.id.Id): ``Id`` of an ``AssessmentPart`` return: (osid.assessment.BankList) - list of banks raise: NotFound - ``assessment_part_id`` is not found raise: NullArgument - ``assess... |
def get_assignable_bank_ids(self, bank_id): """Gets a list of bank including and under the given bank node in which any assessment part can be assigned. arg: bank_id (osid.id.Id): the ``Id`` of the ``Bank`` return: (osid.id.IdList) - list of assignable bank ``Ids`` raise: NullArgument - ``bank_id`` is ``null`` raise: O... |
def assign_assessment_part_to_bank(self, assessment_part_id, bank_id): """Adds an existing ``AssessmentPart`` to an ``Bank``. arg: assessment_part_id (osid.id.Id): the ``Id`` of the ``AssessmentPart`` arg: bank_id (osid.id.Id): the ``Id`` of the ``Bank`` raise: AlreadyExists - ``assessment_part_id`` is already assigned... |
def unassign_assessment_part_from_bank(self, assessment_part_id, bank_id): """Removes an ``AssessmentPart`` from an ``Bank``. arg: assessment_part_id (osid.id.Id): the ``Id`` of the ``AssessmentPart`` arg: bank_id (osid.id.Id): the ``Id`` of the ``Bank`` raise: NotFound - ``assessment_part_id`` or ``bank_id`` not found... |
def reassign_assessment_part_to_bank(self, assessment_part_id, from_biank_id, to_bank_id): """Moves an ``AssessmentPart`` from one ``Bank`` to another. Mappings to other ``Banks`` are unaffected. arg: assessment_part_id (osid.id.Id): the ``Id`` of the ``AssessmentPart`` arg: from_biank_id (osid.id.Id): the ``Id`` of th... |
def get_assessment_part_items(self, assessment_part_id): """Gets the list of items mapped to the given ``AssessmentPart``. In plenary mode, the returned list contains all known items or an error results. Otherwise, the returned list may contain only those items that are accessible through this session. arg: assessment_... |
def get_assessment_parts_by_item(self, item_id): """Gets the assessment parts containing the given item. In plenary mode, the returned list contains all known assessment parts or an error results. Otherwise, the returned list may contain only those assessment parts that are accessible through this session. arg: item_id... |
def add_item(self, item_id, assessment_part_id): """Appends an item to an assessment part. arg: item_id (osid.id.Id): ``Id`` of the ``Item`` arg: assessment_part_id (osid.id.Id): ``Id`` of the ``AssessmentPart`` raise: AlreadyExists - ``item_id`` already part of ``assessment_part_id`` raise: NotFound - ``item_id`` or `... |
'assessment.Item': if item_id.get_authority() != self._authority: raise errors.InvalidArgument() else: mgr = self._get_provider_manager('ASSESSMENT') admin_session = mgr.get_item_admin_session_for_bank(self._catalog_id, proxy=self._proxy) item_id = admin_session._get_item_id_with_enclosure(item_id) collection = JSONCli... |
def move_item_ahead(self, item_id, assessment_part_id, reference_id): """Reorders items in an assessment part by moving the specified item in front of a reference item. arg: item_id (osid.id.Id): ``Id`` of the ``Item`` arg: assessment_part_id (osid.id.Id): ``Id`` of the ``AssessmentPartId`` arg: reference_id (osid.id.I... |
def move_item_behind(self, item_id, assessment_part_id, reference_id): """Reorders items in an assessment part by moving the specified item behind of a reference item. arg: item_id (osid.id.Id): ``Id`` of the ``Item`` arg: assessment_part_id (osid.id.Id): ``Id of the AssessmentPartId`` arg: reference_id (osid.id.Id): `... |
def order_items(self, item_ids, assessment_part_id): """Reorders a set of items in an assessment part. arg: item_ids (osid.id.Id[]): ``Ids`` for a set of ``Items`` arg: assessment_part_id (osid.id.Id): ``Id`` of the ``AssessmentPartId`` raise: NotFound - ``assessment_part_id`` not found or, an ``item_id`` not related t... |
def remove_item(self, item_id, assessment_part_id): """Removes an ``Item`` from an ``AssessmentPartId``. arg: item_id (osid.id.Id): ``Id`` of the ``Item`` arg: assessment_part_id (osid.id.Id): ``Id`` of the ``AssessmentPartId`` raise: NotFound - ``item_id`` ``not found in assessment_part_id`` raise: NullArgument - ``it... |
def _get_assessment_part_collection(self, assessment_part_id): """Returns a Mongo Collection and AssessmentPart given a AssessmentPart Id""" collection = JSONClientValidated('assessment_authoring', collection='AssessmentPart', runtime=self._runtime) assessment_part_map = collection.find_one({'_id': ObjectId(assessment_... |
def get_sequence_rule(self, sequence_rule_id): """Gets the ``SequenceRule`` specified by its ``Id``. arg: sequence_rule_id (osid.id.Id): ``Id`` of the ``SequenceRule`` return: (osid.assessment.authoring.SequenceRule) - the sequence rule raise: NotFound - ``sequence_rule_id`` not found raise: NullArgument - ``sequence_r... |
def get_sequence_rules_by_ids(self, sequence_rule_ids): """Gets a ``SequenceRuleList`` corresponding to the given ``IdList``. arg: sequence_rule_ids (osid.id.IdList): the list of ``Ids`` to retrieve return: (osid.assessment.authoring.SequenceRuleList) - the returned ``SequenceRule`` list raise: NotFound - a ``Id was`` ... |
def get_sequence_rules_by_genus_type(self, sequence_rule_genus_type): """Gets a ``SequenceRuleList`` corresponding to the given sequence rule genus ``Type`` which does not include sequence rule of genus types derived from the specified ``Type``. arg: sequence_rule_genus_type (osid.type.Type): a sequence rule genus type... |
def get_sequence_rules_for_assessment_part(self, assessment_part_id): """Gets a ``SequenceRuleList`` for the given source assessment part. arg: assessment_part_id (osid.id.Id): an assessment part ``Id`` return: (osid.assessment.authoring.SequenceRuleList) - the returned ``SequenceRule`` list raise: NullArgument - ``ass... |
def get_sequence_rules_for_assessment(self, assessment_id): """Gets a ``SequenceRuleList`` for an entire assessment. arg: assessment_id (osid.id.Id): an assessment ``Id`` return: (osid.assessment.authoring.SequenceRuleList) - the returned ``SequenceRule`` list raise: NullArgument - ``assessment_id`` is ``null`` raise: ... |
result = collection.find( dict({'assessmentPartId': {'$in': id_strs}}, **self._view_filter())) return objects.SequenceRuleList(result, runtime=self._runtime) |
def get_sequence_rules(self): """Gets all ``SequenceRules``. return: (osid.assessment.authoring.SequenceRuleList) - the returned ``SequenceRule`` list raise: OperationFailed - unable to complete request raise: PermissionDenied - authorization failure *compliance: mandatory -- This method must be implemented.* """ # Imp... |
def get_sequence_rule_form_for_create(self, assessment_part_id, next_assessment_part_id, sequence_rule_record_types): """Gets the sequence rule form for creating new sequence rules between two assessment parts. A new form should be requested for each create transaction. arg: assessment_part_id (osid.id.Id): the source ... |
not isinstance(arg, ABCId): raise errors.InvalidArgument('one or more argument array elements is not a valid OSID ${arg0_type}') if sequence_rule_record_types == []: obj_form = objects.SequenceRuleForm( bank_id=self._catalog_id, runtime=self._runtime, effective_agent_id=self.get_effective_agent_id(), proxy=self._proxy,... |
def create_sequence_rule(self, sequence_rule_form): """Creates a new ``SequenceRule``. arg: sequence_rule_form (osid.assessment.authoring.SequenceRuleForm): the form for this ``SequenceRule`` return: (osid.assessment.authoring.SequenceRule) - the new ``SequenceRule`` raise: IllegalState - ``sequence_rule_form`` already... |
raise errors.Unsupported('sequence_rule_form did not originate from this session') if not sequence_rule_form.is_valid(): raise errors.InvalidArgument('one or more of the form elements is invalid') insert_result = collection.insert_one(sequence_rule_form._my_map) self._forms[sequence_rule_form.get_id().get_identifier()]... |
def update_sequence_rule(self, sequence_rule_form): """Updates an existing sequence rule. arg: sequence_rule_form (osid.assessment.authoring.SequenceRuleForm): the form containing the elements to be updated raise: IllegalState - ``sequence_rule_form`` already used in an update transaction raise: InvalidArgument - the f... |
originate from this session') if not sequence_rule_form.is_valid(): raise errors.InvalidArgument('one or more of the form elements is invalid') collection.save(sequence_rule_form._my_map) self._forms[sequence_rule_form.get_id().get_identifier()] = UPDATED # Note: this is out of spec. The OSIDs don't require an object t... |
def delete_sequence_rule(self, sequence_rule_id): """Deletes a ``SequenceRule``. arg: sequence_rule_id (osid.id.Id): the ``Id`` of the ``SequenceRule`` to remove raise: NotFound - ``sequence_rule_id`` not found raise: NullArgument - ``sequence_rule_id`` is ``null`` raise: OperationFailed - unable to complete request ra... |
def alias_sequence_rule(self, sequence_rule_id, alias_id): """Adds a ``Id`` to a ``SequenceRule`` for the purpose of creating compatibility. The primary ``Id`` of the ``SequenceRule`` is determined by the provider. The new ``Id`` performs as an alias to the primary ``Id`` . If the alias is a pointer to another sequence... |
def get_agent_id(self): """Gets the ``Id`` of the ``Agent`` identified in this authentication credential. :return: the ``Agent Id`` :rtype: ``osid.id.Id`` *compliance: mandatory -- This method must be implemented.* *implementation notes*: The Agent should be determined at the time this credential is created. """ if sel... |
def get_agent(self): """Gets the ``Agent`` identified in this authentication credential. :return: the ``Agent`` :rtype: ``osid.authentication.Agent`` :raise: ``OperationFailed`` -- unable to complete request *compliance: mandatory -- This method must be implemented.* """ agent_id = self.get_agent_id() return Agent(iden... |
def spectrogram_image(mediafile, dpi=72, outdir=None, outfile=None): # TODO: Add some of the constants below as parameters """ Create spectrogram image from audio data. Return path to created image file. """ import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import scipy.io.wavfile import numpy as ... |
Limit data to 10 second window from the middle, else the FFT needs ages data_window = sample_rate * 2 # secs waveform = [i[0] for i in waveform[(len(waveform) - data_window) // 2 : (len(waveform) + data_window) // 2]] # TODO: combine / add the channels to mono # Calculate FFT inputs nstep = int(sample_rate * 0.001) # 1... |
"85", outfile + ".png", outfile] subprocess.check_call(cmd, stdout=black_hole, stderr=subprocess.STDOUT) finally: if os.path.exists(outfile + ".png"): os.remove(outfile + ".png") return outfile |
def _main(): """ Command line interface for testing. """ if len(sys.argv) != 2: print("Usage: python -m auvyon.imaging.spectrograms <mediafile>") else: try: print("Created %s" % spectrogram_image(sys.argv[1], dpi=103, outfile="spectrogram.jpg")) except subprocess.CalledProcessError, exc: print("Conversion error: %s" % ... |
def get_genus_type(self): """Overrides get_genus_type of extended object""" enclosed_object_id = self.get_enclosed_object_id() package = enclosed_object_id.get_identifier_namespace().split('.')[0] obj = enclosed_object_id.get_identifier_namespace().split('.')[1] return Type( authority='OSID.ORG', namespace=package, ide... |
def get_enclosed_object(self): """Return the enclosed object""" if self._enclosed_object is None: enclosed_object_id = self.get_enclosed_object_id() package_name = enclosed_object_id.get_identifier_namespace().split('.')[0] obj_name = enclosed_object_id.get_identifier_namespace().split('.')[1] mgr = self.my_osid_object... |
def clone_to(self, target_catalog): """need to clone both the enclosed object + the wrapping asset""" def _clone(obj_id): package_name = obj_id.get_identifier_namespace().split('.')[0] obj_name = obj_id.get_identifier_namespace().split('.')[1].lower() catalogs = { 'assessment': 'bank', 'repository': 'repository' } my_c... |
# Let's do the asset here enclosure_id = self.my_osid_object.ident new_asset = _clone(enclosure_id) package_name = enclosure_id.get_identifier_namespace().split('.')[0] obj_name = enclosure_id.get_identifier_namespace().split('.')[1].lower() catalogs = { 'assessment': 'bank', 'repository': 'repository' } my_catalog_nam... |
def _init_metadata(self): """Initialize metadata for this record""" self._enclosed_object_metadata = { 'element_id': Id(self.my_osid_object_form._authority, self.my_osid_object_form._namespace, 'enclosed_object'), 'element_label': 'Enclosed Object', 'instructions': 'accepts an osid object Id', 'required': False, 'read_... |
def get_display_name_metadata(self): """Overrides get_display_name_metadata of extended object""" metadata = dict(self.my_osid_object_form._mdata['display_name']) metadata.update({'read_only': True}) return Metadata(**metadata) |
def get_description_metadata(self): """Overrides get_description_metadata of extended object""" metadata = dict(self.my_osid_object_form._description_metadata) metadata.update({'read_only': True}) return Metadata(**metadata) |
def get_genus_type_metadata(self): """Overrides get_genus_type_metadata of extended object""" metadata = dict(self.my_osid_object_form._genus_type_metadata) metadata.update({'read_only': True}) return Metadata(**metadata) |
def _initialize_manager(self, runtime): """Sets the runtime, configuration and json client""" if self._runtime is not None: raise errors.IllegalState('this manager has already been initialized.') self._runtime = runtime self._config = runtime.get_configuration() set_json_client(runtime) |
def get_display_name(self): """Gets a display name for this service implementation. return: (osid.locale.DisplayText) - a display name *compliance: mandatory -- This method must be implemented.* """ return DisplayText( text=profile.DISPLAYNAME, language_type=Type(**profile.LANGUAGETYPE), script_type=Type(**profile.SCRI... |
def get_description(self): """Gets a description of this service implementation. return: (osid.locale.DisplayText) - a description *compliance: mandatory -- This method must be implemented.* """ return DisplayText( text=profile.DESCRIPTION, language_type=Type(**profile.LANGUAGETYPE), script_type=Type(**profile.SCRIPTTY... |
def get_args(): u""" ./main --config /etc/blackbird/etc/default.cfg --debug ... Return command-line options(arguments). """ description = "The Daemon send various value for zabbix_sender." parser = argparse.ArgumentParser(description) parser.add_argument('--config', '-c', default='conf/defaults.cfg', help='Specify "def... |
def is_pid(value): """ This function checks whether file path that is specified at "pid_file" option eixsts, whether write permission to the file path. Return the following value: case1: exists path and write permission is_pid('/tmp') '/tmp/hogehoge.pid' case2: non-exists path and write permission is_pid('/tmp/hogehoge... |
including the pid file name. """ value = os.path.expanduser(value) value = os.path.expandvars(value) value = os.path.abspath(value) pid_file = 'blackbird.pid' if os.path.exists(value): if os.path.isdir(value): if os.access(value, os.W_OK): return os.path.join(value, pid_file) else: err_message = ('{path}: Permission de... |
def add_field(self, field_instance_or_string): """ Appends a field, can be a :class:`~es_fluent.fields.Field` or string. """ if isinstance(field_instance_or_string, basestring): field_instance = Field(field_instance_or_string) elif isinstance(field_instance_or_string, Field): field_instance_or_string = field_instance e... |
def run(self): """ Run the schedule """ self.main_task.thread.start() self.main_task.thread.join() |
def dfs(node, expand=expansion_all, callback=None, silent=True): """ Perform a depth-first search on the node graph :param node: GraphNode :param expand: Returns the list of Nodes to explore from a Node :param callback: Callback to run in each node :param silent: Don't throw exception on circular dependency :return: ""... |
def explore(node): """ Given a node, explores on relatives, siblings and children :param node: GraphNode from which to explore :return: set of explored GraphNodes """ explored = set() explored.add(node) dfs(node, callback=lambda n: explored.add(n)) return explored |
def depends(self, *nodes): """ Adds nodes as relatives to this one, and updates the relatives with self as children. :param nodes: GraphNode(s) """ for node in nodes: self.add_relative(node) node.add_children(self) |
def add(self, *nodes): """ Adds nodes as siblings :param nodes: GraphNode(s) """ for node in nodes: node.set_parent(self) self.add_sibling(node) |
def get_hierarchies(self): """Gets the hierarchy list resulting from the search. return: (osid.hierarchy.HierarchyList) - the hierarchy list raise: IllegalState - the hierarchy list was already retrieved *compliance: mandatory -- This method must be implemented.* """ if self.retrieved: raise errors.IllegalState('List h... |
def _set_seq(self,sequence,start=0): """Set the sequence from a start position for the length of the sequence""" if start+len(sequence) > self._slen: sys.stderr.write("Error not long enough to add\n") sys.exit() z = 0 for i in xrange(start, start+len(sequence)): self._set_nt(sequence[z],i) z+=1 |
def get_agent(self, agent_id): """Gets the ``Agent`` specified by its ``Id``. In plenary mode, the exact ``Id`` is found or a ``NotFound`` results. Otherwise, the returned ``Agent`` may have a different ``Id`` than requested, such as the case where a duplicate ``Id`` was assigned to an ``Agent`` and retained for compat... |
return objects.Agent(osid_object_map=result, runtime=self._runtime, proxy=self._proxy) |
def get_agents_by_ids(self, agent_ids): """Gets an ``AgentList`` corresponding to the given ``IdList``. In plenary mode, the returned list contains all of the agents specified in the ``Id`` list, in the order of the list, including duplicates, or an error results if an ``Id`` in the supplied list is not found or inacce... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.