当前位置: 首页>>代码示例>>Python>>正文


Python ParameterSetManager.ParameterSetManager类代码示例

本文整理汇总了Python中tardis.tardis_portal.ParameterSetManager.ParameterSetManager的典型用法代码示例。如果您正苦于以下问题:Python ParameterSetManager类的具体用法?Python ParameterSetManager怎么用?Python ParameterSetManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ParameterSetManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_or_create_unique_parameterset

    def get_or_create_unique_parameterset(self, schema, parametername, value):
        parameterset = ExperimentParameterSet.objects.filter(
        schema__namespace=schema,
        experiment__id=self.experiment_id)

        experiment = Experiment.objects.get(id=self.experiment_id)

        psm = None

        if not len(parameterset):
            psm = ParameterSetManager(schema=schema,
                    parentObject=experiment)
            return psm
        else:
            for ps in parameterset:
                psm = ParameterSetManager(parameterset=ps)
                try:
                    ps_value = psm.get_param("party_id",
                        True)
                    if value == ps_value:
                        return psm
                except ExperimentParameter.DoesNotExist:
                    pass # keep going

        psm = ParameterSetManager(schema=schema,
                parentObject=experiment)

        return psm
开发者ID:aaryani,项目名称:aa-migration-test1,代码行数:28,代码来源:MonashANDSService.py

示例2: get_or_create_cc_parameterset

    def get_or_create_cc_parameterset(self, create=True):
        """
        Gets the creative commons parameterset for the experiment
        :param create: If true, creates a new parameterset object to
        hold the cc license if one doesn't exist
        :type create: boolean
        :return: The parameterset manager for the cc parameterset
        :rtype: :class:`tardis.tardis_portal.ParameterSetManager.
        ParameterSetManager`
        """
        parameterset = ExperimentParameterSet.objects.filter(
        schema__namespace=self.schema,
        experiment__id=self.experiment_id)

        if not len(parameterset):
            if create:
                experiment = Experiment.objects.get(id=self.experiment_id)
                self.psm = ParameterSetManager(schema=self.schema,
                        parentObject=experiment)
            else:
                return None
        else:
            self.psm = ParameterSetManager(parameterset=parameterset[0])

        return self.psm
开发者ID:IntersectAustralia,项目名称:mytardis,代码行数:25,代码来源:creativecommonshandler.py

示例3: _create_experiment_id_parameter_set

 def _create_experiment_id_parameter_set(self, experiment, experimentId):
     '''
     Adds ExperimentID field to dataset schema
     '''
     namespace = AtomImportSchemas.get_schema(Schema.EXPERIMENT).namespace
     mgr = ParameterSetManager(parentObject=experiment, schema=namespace)
     mgr.new_param(IngestOptions.PARAM_EXPERIMENT_ID, experimentId)
开发者ID:grischa,项目名称:mytardis-app-atom,代码行数:7,代码来源:atom_ingest.py

示例4: testHandlesMultipleEntries

    def testHandlesMultipleEntries(self):
        from ..views import SCHEMA_URI
        param_list = ({'type': 'website',
                       'identifier': 'https://www.example.test/%d' % i,
                       'title': 'Title #%d' % i,
                       'notes': 'This is note #%d.' % i} for i in range(10))
        for params in param_list:
            psm = ParameterSetManager(parentObject=self.experiment,
                                      schema=SCHEMA_URI)
            for k, v in params.items():
                psm.set_param(k, v)

        response = self.client.get(
            reverse('tardis.apps.related_info.views.'
                    + 'list_or_create_related_info',
                    args=[self.experiment.id]))
        expect(response.status_code).to_equal(200)
        expect(response['Content-Type'])\
            .to_equal('application/json; charset=utf-8')

        objs = json.loads(response.content)
        expect(len(objs)).to_be(10)

        for obj in objs:
            expect(obj['type']).to_equal('website')
            expect(obj['identifier']).to_match(r'www.example.test/\d+$')
            expect(obj['title']).to_match(r'^Title #\d+$')
            expect(obj['notes']).to_match(r'note #\d+\.$')
开发者ID:IntersectAustralia,项目名称:mytardis,代码行数:28,代码来源:tests.py

示例5: _test_metadata

 def _test_metadata(self,schema,name,dataset,fields):
     """ Check that metadata is correct"""
     try:
         sch = models.Schema.objects.get(namespace__exact=schema,name=name)
     except Schema.DoesNotExist:
         self.assertTrue(False)
     self.assertEqual(schema,sch.namespace)
     self.assertEqual(name,sch.name)
     try:
         datasetparameterset = models.DatasetParameterSet.objects.get(schema=sch, dataset=dataset)
     except DatasetParameterSet.DoesNotExist:
         self.assertTrue(False) 
     psm = ParameterSetManager(parameterset=datasetparameterset)
     for key, field_type, value in fields:
         logger.debug("key=%s,field_type=%s,value=%s" % (key,field_type, value))
         try:
             # First check stringed value
             param = psm.get_param(key,value=True)
             self.assertEquals(str(param),str(value))
             # Then correct type
             param = psm.get_param(key,value=False)
             self.assertEquals(param.name.data_type,field_type)
         except DatasetParameter.DoesNotExist:
             logger.error("cannot find %s" % key)
             self.assertTrue(False)
开发者ID:mytardis,项目名称:hpctardis,代码行数:25,代码来源:tests.py

示例6: testPersisterAgainstPicasa

 def testPersisterAgainstPicasa(self):
     '''
     Test against Picasa - useful for development testing
     '''
     # Build a persister with "make_local_copy" mocked out
     # (file transfer isn't part of this test)
     persister = flexmock(AtomPersister())
     persister.should_receive('make_local_copy').times(50)
     doc = feedparser.parse('picasa_example.atom')
     # Process the first twenty entries
     for entry in list(reversed(doc.entries))[0:20]:
         persister.process(doc.feed, entry)
     # We processed 20 images (Picasa only has one image per dataset)
     eq_(Dataset.objects.count(), 20)
     # This part has 2 users
     eq_(User.objects.count(), 2)
     # This part covers 6 albums
     eq_(Experiment.objects.count(), 6)
     for experiment in Experiment.objects.all():
         pset = experiment.getParameterSets().get(schema=AtomImportSchemas. \
                         get_schema(Schema.EXPERIMENT))
         pset_mgr = ParameterSetManager(pset)
         assert experiment.title != pset_mgr.get_param('ExperimentID')
         # Change the experiment titles, to check this won't be a problem
         experiment.title = "Title removed for testing"
         experiment.save()
     # Process the rest of the entries
     for entry in list(reversed(doc.entries))[20:]:
         persister.process(doc.feed, entry)
     # We processed 50 images (Picasa only has one image per dataset)
     eq_(Dataset.objects.count(), 50)
     # This part has 2 users
     eq_(User.objects.count(), 4)
     # This part covers 6 albums
     eq_(Experiment.objects.count(), 9)
开发者ID:VeRSI-Australia,项目名称:RMIT-MicroTardis-Atom-ingest,代码行数:35,代码来源:test_atom_ingest.py

示例7: _get_params

 def _get_params(self, key, namespace, experiment):
     parameterset = ExperimentParameterSet.objects.filter(
                         schema__namespace=namespace,
                         experiment__id=experiment.id)
     if parameterset:
         psm = ParameterSetManager(parameterset=parameterset[0])
         return psm.get_params(key, True)
     return []
开发者ID:keithschulze,项目名称:mytardis,代码行数:8,代码来源:schemarifcsprovider.py

示例8: _get_dict_from_ps

 def _get_dict_from_ps(self, ps):
     '''
     Build dictionary by getting the parameter values from the keys, then
     zipping it all together.
     '''
     psm = ParameterSetManager(ps)
     return dict([('id', ps.id)]+ # Use set ID
                 zip(self.parameter_names,
                     (psm.get_param(k, True) for k in self.parameter_names)))
开发者ID:crawley,项目名称:mytardis,代码行数:9,代码来源:shortcuts.py

示例9: get_related_info

 def get_related_info(ps):
     psm = ParameterSetManager(ps)
     parameter_names = ['type','identifier','title','notes']
     try:
         return dict([('id', ps.id)] + # Use set ID
                     zip(parameter_names,
                         (psm.get_param(k, True) \
                              for k in parameter_names)))
     except ExperimentParameter.DoesNotExist:
         return dict() # drop Related_Info record with missing fields
开发者ID:keithschulze,项目名称:mytardis,代码行数:10,代码来源:experiment.py

示例10: save_datafile_add_form

def save_datafile_add_form(schema, parentObject, request):

    psm = ParameterSetManager(schema=schema, parentObject=parentObject)

    for key, value in sorted(request.POST.iteritems()):
        if value:
            stripped_key = key.replace("_s47_", "/")
            stripped_key = stripped_key.rpartition("__")[0]

            psm.new_param(stripped_key, value)
开发者ID:aaryani,项目名称:aa-migration-test1,代码行数:10,代码来源:forms.py

示例11: get_related_info

 def get_related_info(ps):
     psm = ParameterSetManager(ps)
     parameter_names = ["type", "identifier", "title", "notes"]
     try:
         return dict(
             [("id", ps.id)]
             + zip(parameter_names, (psm.get_param(k, True) for k in parameter_names))  # Use set ID
         )
     except ExperimentParameter.DoesNotExist:
         return dict()  # drop Related_Info record with missing fields
开发者ID:JMSS-IT-11-2012,项目名称:mytardis,代码行数:10,代码来源:experiment.py

示例12: test_existing_parameterset

    def test_existing_parameterset(self):

        psm = ParameterSetManager(parameterset=self.datafileparameterset)

        self.assertTrue(psm.get_schema().namespace ==
                        "http://localhost/psmtest/df/")

        self.assertTrue(psm.get_param("parameter1").string_value == "test1")

        self.assertTrue(psm.get_param("parameter2", True) == 2)
开发者ID:IntersectAustralia,项目名称:mytardis,代码行数:10,代码来源:test_parametersetmanager.py

示例13: test_tz_naive_date_handling

    def test_tz_naive_date_handling(self):
        """
        Ensure that dates are handling in a timezone-aware way.
        """
        psm = ParameterSetManager(parameterset=self.datafileparameterset)

        psm.new_param("parameter3", str(datetime(1970, 01, 01, 10, 0, 0)))

        expect(psm.get_param("parameter3", True))\
            .to_equal(datetime(1970, 01, 01, 0, 0, 0, tzinfo=pytz.utc))
开发者ID:IntersectAustralia,项目名称:mytardis,代码行数:10,代码来源:test_parametersetmanager.py

示例14: test_link_parameter_type

    def test_link_parameter_type(self):
        """
        Test that Parameter.link_gfk (GenericForeignKey) is correctly
        assigned after using Parameter.set_value(some_url) for a LINK Parameter.
        """
        psm = ParameterSetManager(parameterset=self.datafileparameterset)

        # Check link to experiment
        exp_url = self.exp.get_absolute_url()  # /experiment/view/1/
        self.assertTrue(psm.get_param("exp_link").string_value ==
                        exp_url)

        self.assertTrue(psm.get_param("exp_link").link_id ==
                        self.exp.id)

        exp_ct = ContentType.objects.get(model__iexact="experiment")
        self.assertTrue(psm.get_param("exp_link").link_ct == exp_ct)

        self.assertTrue(psm.get_param("exp_link").link_gfk == self.exp)

        # Check link to dataset
        dataset_url = self.dataset.get_absolute_url()  # /dataset/1/
        self.assertTrue(psm.get_param("dataset_link").string_value ==
                        dataset_url)

        self.assertTrue(psm.get_param("dataset_link").link_id ==
                        self.dataset.id)

        dataset_ct = ContentType.objects.get(model__iexact="dataset")
        self.assertTrue(psm.get_param("dataset_link").link_ct == dataset_ct)

        self.assertTrue(psm.get_param("dataset_link").link_gfk == self.dataset)
开发者ID:IntersectAustralia,项目名称:mytardis,代码行数:32,代码来源:test_parametersetmanager.py

示例15: test_tz_aware_date_handling

    def test_tz_aware_date_handling(self):
        '''
        Ensure that dates are handling in a timezone-aware way.
        '''
        psm = ParameterSetManager(parameterset=self.datafileparameterset)

        psm.new_param("parameter3",
                      iso8601.parse_date('1970-01-01T08:00:00+08:00'))

        expect(psm.get_param("parameter3", True))\
            .to_equal(datetime(1970,01,01,0,0,0,tzinfo=pytz.utc))
开发者ID:TheGoodRob,项目名称:mytardis,代码行数:11,代码来源:test_parametersetmanager.py


注:本文中的tardis.tardis_portal.ParameterSetManager.ParameterSetManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。