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


Python ParameterSetManager.delete_params方法代码示例

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


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

示例1: test_new_parameterset

# 需要导入模块: from tardis.tardis_portal.ParameterSetManager import ParameterSetManager [as 别名]
# 或者: from tardis.tardis_portal.ParameterSetManager.ParameterSetManager import delete_params [as 别名]
    def test_new_parameterset(self):

        psm = ParameterSetManager(parentObject=self.datafile,
                                  schema="http://localhost/psmtest/df2/")

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

        psm.set_param("newparam1", "test3", "New Parameter 1")

        self.assertTrue(psm.get_param("newparam1").string_value ==
                        "test3")

        self.assertTrue(psm.get_param("newparam1").name.full_name ==
                        "New Parameter 1")

        psm.new_param("newparam1", "test4")

        self.assertTrue(len(psm.get_params("newparam1", True)) == 2)

        psm.set_param_list("newparam2", ("a", "b", "c", "d"))

        self.assertTrue(len(psm.get_params("newparam2")) == 4)

        psm.set_params_from_dict(
            {"newparam2": "test5", "newparam3": 3})

        self.assertTrue(psm.get_param("newparam2", True) == "test5")

        # the newparam3 gets created and '3' is set to a string_value
        # since once cannot assume that an initial numeric value
        # will imply continuing numeric type for this new param
        self.assertTrue(psm.get_param("newparam3").string_value == '3')

        psm.delete_params("newparam1")

        self.assertTrue(len(psm.get_params("newparam1", True)) == 0)
开发者ID:IntersectAustralia,项目名称:mytardis,代码行数:39,代码来源:test_parametersetmanager.py

示例2: CreativeCommonsHandler

# 需要导入模块: from tardis.tardis_portal.ParameterSetManager import ParameterSetManager [as 别名]
# 或者: from tardis.tardis_portal.ParameterSetManager.ParameterSetManager import delete_params [as 别名]
class CreativeCommonsHandler():

    psm = None
    schema = "http://www.tardis.edu.au/schemas" +\
    "/creative_commons/2011/05/17"
    experiment_id = None

    def __init__(self, experiment_id=experiment_id, create=True):
        """
        :param experiment_id: The id of the experiment
        :type experiment_id: integer
        :param create: If true, creates a new parameterset object to
        hold the cc license
        :type create: boolean
        """

        self.experiment_id = experiment_id

        if create:
            self.psm = self.get_or_create_cc_parameterset(create=True)
        else:
            self.psm = self.get_or_create_cc_parameterset(create=False)

    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

    def has_cc_license(self):

        """
        :return: True if there's a cc license parameterset for the experiment
        :rtype: boolean
        """
        parameterset = ExperimentParameterSet.objects.filter(
        schema__namespace=self.schema,
        experiment__id=self.experiment_id)

        self.psm = None
        if not len(parameterset):
            return False
        else:
            return True

    def save_license(self, request):
        """
        Saves a license parameterset with the POST variables from the
        creative commons form
        :param request: a HTTP Request instance
        :type request: :class:`django.http.HttpRequest`
        """
        if request.POST['cc_js_want_cc_license'] == \
           'sure':
            cc_js_result_img = request.POST['cc_js_result_img']
            cc_js_result_name = request.POST['cc_js_result_name']
            cc_js_result_uri = request.POST['cc_js_result_uri']

            self.psm.set_param("license_image", cc_js_result_img,
                "License Image")
            self.psm.set_param("license_name", cc_js_result_name,
                "License Name")
            self.psm.set_param("license_uri", cc_js_result_uri,
                "License URI")
        else:
            self.psm.delete_params('license_image')
            self.psm.delete_params('license_name')
            self.psm.delete_params('license_uri')

            parametersets = ExperimentParameterSet.objects.filter(
            schema__namespace=self.schema,
            experiment__id=self.experiment_id)

            for parameterset in parametersets:
                parameterset.delete()
开发者ID:IntersectAustralia,项目名称:mytardis,代码行数:97,代码来源:creativecommonshandler.py

示例3: CreativeCommonsHandler

# 需要导入模块: from tardis.tardis_portal.ParameterSetManager import ParameterSetManager [as 别名]
# 或者: from tardis.tardis_portal.ParameterSetManager.ParameterSetManager import delete_params [as 别名]
class CreativeCommonsHandler():

    psm = None
    schema = "http://www.tardis.edu.au/schemas" +\
    "/creative_commons/2011/05/17"
    experiment_id = None

    def __init__(self, experiment_id=experiment_id, create=True):

        self.experiment_id = experiment_id

        if create:
            self.psm = self.get_or_create_cc_parameterset(create=True)
        else:
            self.psm = self.get_or_create_cc_parameterset(create=False)

    def get_or_create_cc_parameterset(self, create=True):

        # get cc license parameterset, if any
        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

    def has_cc_license(self):

        # get cc license parameterset, if any

        parameterset = ExperimentParameterSet.objects.filter(
        schema__namespace=self.schema,
        experiment__id=self.experiment_id)

        self.psm = None
        if not len(parameterset):
            return False
        else:
            return True

    def save_license(self, request):
            # if cc license then save params
        if request.POST['cc_js_want_cc_license'] ==\
            'sure':
            cc_js_result_img = request.POST['cc_js_result_img']
            cc_js_result_name = request.POST['cc_js_result_name']
            cc_js_result_uri = request.POST['cc_js_result_uri']

            self.psm.set_param("license_image", cc_js_result_img,
                "License Image")
            self.psm.set_param("license_name", cc_js_result_name,
                "License Name")
            self.psm.set_param("license_uri", cc_js_result_uri,
                "License URI")
        else:
            self.psm.delete_params('license_image')
            self.psm.delete_params('license_name')
            self.psm.delete_params('license_uri')

            parametersets = ExperimentParameterSet.objects.filter(
            schema__namespace=self.schema,
            experiment__id=self.experiment_id)

            for parameterset in parametersets:
                parameterset.delete()
开发者ID:aaryani,项目名称:aa-migration-test1,代码行数:76,代码来源:creativecommonshandler.py


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