本文整理汇总了Python中tardis.tardis_portal.ParameterSetManager.ParameterSetManager类的典型用法代码示例。如果您正苦于以下问题:Python ParameterSetManager类的具体用法?Python ParameterSetManager怎么用?Python ParameterSetManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ParameterSetManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: save_datafile_edit_form
def save_datafile_edit_form(parameterset, request):
psm = ParameterSetManager(parameterset=parameterset)
psm.delete_all_params()
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:IntersectAustralia,项目名称:mytardis,代码行数:11,代码来源:forms.py
示例17: _get_param
def _get_param(self, key, namespace, experiment):
parameterset = ExperimentParameterSet.objects.filter(
schema__namespace=namespace,
experiment__id=experiment.id)
if len(parameterset) > 0:
psm = ParameterSetManager(parameterset=parameterset[0])
try:
return psm.get_param(key, True)
except MultipleObjectsReturned:
return psm.get_params(key, True)
except ObjectDoesNotExist:
return None
开发者ID:TheGoodRob,项目名称:mytardis,代码行数:12,代码来源:schemarifcsprovider.py
示例18: testPersisterStoresEntryMetadata
def testPersisterStoresEntryMetadata(self):
# Create user to associate with dataset
user = User(username="tatkins")
user.save()
feed, entry = self._getTestEntry()
p = AtomPersister()
dataset = p.process(feed, entry)
parameterset = dataset.getParameterSets().get(schema=AtomImportSchemas.get_schema(Schema.DATASET))
expect(parameterset) != None
psm = ParameterSetManager(parameterset)
expect(psm.get_param("EntryID").get()).to_equal(entry.id)
expect(psm.get_param("Updated").name.isDateTime()).to_be_truthy()
# Compare against non-timezoned update time
expect(psm.get_param("Updated", True)).to_equal(iso8601.parse_date(entry.updated))
开发者ID:UQ-CMM-Mirage,项目名称:mytardis-app-atom,代码行数:14,代码来源:test_atom_ingest.py
示例19: testFilter
def testFilter(self):
DataGrabberFilter()(None, instance=self.datafiles[0])
# Check a DATASET parameter set was created
dataset = Dataset.objects.get(id=self.dataset.id)
expect(dataset.getParameterSets().count()).to_equal(1)
# Check all the expected parameters are there
psm = ParameterSetManager(dataset.getParameterSets()[0])
expect(psm.get_param('admin-filename', True))\
.to_equal(self.datafiles[0].filename)
expect(psm.get_param('user_name', True)).to_equal('s.crawley')
expect(psm.get_param('facility_name', True)).to_equal('QBP NIKON TIE')
expect(psm.get_param('account_name', True)).to_equal('200 - CMM STAFF')
expect(psm.get_param('session_uuid', True)).to_equal(
'cbc86da5-e143-4a11-9951-abaffef70efa')
expect(psm.get_param('record_uuid', True)).to_equal(
'ddf0df63-d985-4ffa-9102-e34a78b3fd1f')
# Repeat for the datafile parameters
expect(self.datafiles[0].getParameterSets().count()).to_equal(0)
expect(self.datafiles[1].getParameterSets().count()).to_equal(1)
psm = ParameterSetManager(self.datafiles[1].getParameterSets()[0])
expect(psm.get_param('instrument_pathname', True)).to_equal(
'S:\\Garry\\testfile.txt')
# Check we won't create a duplicate dataset
DataGrabberFilter()(None, instance=self.datafiles[0])
dataset = Dataset.objects.get(id=self.dataset.id)
expect(dataset.getParameterSets().count()).to_equal(1)
开发者ID:UQ-CMM-Mirage,项目名称:mytardis-app-datagrabber,代码行数:30,代码来源:test_datagrabber.py
示例20: _get_or_create_publish_parameterset
def _get_or_create_publish_parameterset(self, create):
parameterset = ExperimentParameterSet.objects.filter(
schema__namespace=self.schema,
experiment__id=self.experiment_id)
if len(parameterset) == 1:
psm = ParameterSetManager(parameterset=parameterset[0])
elif create:
experiment = Experiment.objects.get(id=self.experiment_id)
psm = ParameterSetManager(schema=self.schema,
parentObject=experiment)
psm.new_param(self.access_type_key, UNPUBLISHED)
else:
psm = None
return psm
开发者ID:ANSTO,项目名称:ands_register,代码行数:16,代码来源:publishing.py
注:本文中的tardis.tardis_portal.ParameterSetManager.ParameterSetManager类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论