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


Python expression.Expression类代码示例

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


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

示例1: test_5

    def test_5(self):
        import datetime

        expression = Expression("len($xxx) le 9")
        values = {"xxx": u"abcdefghi"}
        result = expression.evaluate(values)
        self.assertEqual(result, True)
开发者ID:ringo-framework,项目名称:brabbel,代码行数:7,代码来源:test_expressions.py

示例2: __init__

    def __init__(self, expression, msg=None, mode="post", triggers="error", desired=False, required=False):
        """Initialize the rule with the expression and mode.

        :expr: string represention of the expression which will be
        checked.
        :msg: string error msg for the rule. If not provied use the
        string represention of the provided expression.
        :mode: string of the mode when to evaluate this rule. Defaults
        to 'post'
        :triggers: string of the type of "effect" this rule should
        generate if the evaluation fails. Can either be a error message
        or a warning. In case of a warning the validation of the form
        will fail. In case of a warning only a warning message will be
        displayer. Defaults to 'error'
        """
        Expression.__init__(self, expression)
        self.msg = msg
        if msg is None:
            self.msg = 'Expression "%s" failed' % self._expression
        self.mode = mode
        if mode is None:
            self.mode = "post"
        self.triggers = triggers
        if triggers is None:
            self.triggers = "error"
        self.required = required
        self.desired = desired
开发者ID:ringo-framework,项目名称:formbar,代码行数:27,代码来源:rules.py

示例3: test_4

    def test_4(self):
        import datetime

        expression = Expression(
            "( ( ( $ap_ausb eq '1' ) and ( $pp_phase in ['1','2'] ) ) or ( ( $ap_ausb eq '3' ) and ( $pp_phase in ['3','4'] ) ) or ( ( $ap_ausb in ['2','4'] ) or ( not bool($ap_ausb) ) ) )"
        )
        values = {
            "ap_austritt": u"1",
            "pp_phase_s": u"",
            "ap_q1": u"Rechtsanwalt und Notarfachangestellte",
            "ap_geschlecht": u"0",
            "ap_austritt_ja": u"ja",
            "programm_info": "",
            "bericht_state_id": 2,
            "pp_austritt_ca": datetime.date(2014, 3, 14),
            "ap_ausb": u"1",
            "pp_phase": u"",
            "pp_ga": [u"2", u""],
            "ap_austritt_date": datetime.date(2014, 3, 14),
            "proj_kommentar": u"",
            "proj_fkz": u"09.00101.13",
            "ap_bj1": u"",
            "ap_bj2": u"",
            "ap_bj3": u"",
            "pp_beginn": u"seit",
            "updated": datetime.datetime(2014, 10, 23, 12, 41, 39),
            "_roles": "",
            "ap_quer": u"1",
            "ap_quali": u"1",
            "pp_gesamtst": u"275",
            "form_info": "",
            "pp_kinder": [u"1", u""],
            "created": datetime.datetime(2014, 9, 23, 14, 5, 30),
            "projekt": None,
            "ausbildungsformat": None,
            "pp_eintritt_ps": datetime.date(2014, 1, 6),
            "logo_einbindung": None,
            "pp_eintritt_vb": None,
            "ap_code": u"A.CB257",
            "ap_q2": u"",
            "ap_austritt_s": u"",
            "ap_mhg": u"0",
            "ap_q3": u"",
        }
        result = expression.evaluate(values)
        self.assertEqual(result, False)
开发者ID:ringo-framework,项目名称:brabbel,代码行数:46,代码来源:test_expressions.py

示例4: test_8

 def test_8(self):
     expression = Expression("bool($x) and ($x == 1)")
     result = expression.evaluate({"x": 0})
     self.assertEqual(result, False)
开发者ID:ringo-framework,项目名称:brabbel,代码行数:4,代码来源:test_expressions.py

示例5: test_boolempty

 def test_boolempty(self):
     expression = Expression("bool($string)")
     result = expression.evaluate({"string": ""})
     self.assertEqual(result, False)
开发者ID:ringo-framework,项目名称:brabbel,代码行数:4,代码来源:test_expressions.py

示例6: test_addmulpar

 def test_addmulpar(self):
     expression = Expression("(4 + 3) * 7")
     result = expression.evaluate()
     self.assertEqual(result, 49.0)
开发者ID:ringo-framework,项目名称:brabbel,代码行数:4,代码来源:test_expressions.py

示例7: test_div

 def test_div(self):
     expression = Expression("49 / 7")
     result = expression.evaluate()
     self.assertEqual(result, 7.0)
开发者ID:ringo-framework,项目名称:brabbel,代码行数:4,代码来源:test_expressions.py

示例8: test_mul

 def test_mul(self):
     expression = Expression("7 * 7")
     result = expression.evaluate()
     self.assertEqual(result, 49.0)
开发者ID:ringo-framework,项目名称:brabbel,代码行数:4,代码来源:test_expressions.py

示例9: test_plusplus

 def test_plusplus(self):
     expression = Expression("1 + 1 + 1")
     result = expression.evaluate()
     self.assertEqual(result, 3.0)
开发者ID:ringo-framework,项目名称:brabbel,代码行数:4,代码来源:test_expressions.py

示例10: test_nottrue

 def test_nottrue(self):
     expression = Expression("not True")
     result = expression.evaluate()
     self.assertEqual(result, False)
开发者ID:ringo-framework,项目名称:brabbel,代码行数:4,代码来源:test_expressions.py

示例11: test_variable

 def test_variable(self):
     expression = Expression("$string")
     result = expression.evaluate({"string": "string"})
     self.assertEqual(result, "string")
开发者ID:ringo-framework,项目名称:brabbel,代码行数:4,代码来源:test_expressions.py

示例12: test_1

 def test_1(self):
     expression = Expression(
         "( 'antragsteller' in       ['institutionen_einsicht', 'user', 'antragsteller']   ) == False"
     )
     result = expression.evaluate()
     self.assertEqual(result, False)
开发者ID:ringo-framework,项目名称:brabbel,代码行数:6,代码来源:test_expressions.py

示例13: test_sum_smaller

 def test_sum_smaller(self):
     expression = Expression("(timedelta($a) +  timedelta($b)) < timedelta($c)")
     result = expression.evaluate({"a": "04:00:00", "b": "05:00:00", "c": "08:00:00"})
     self.assertEqual(result, False)
开发者ID:ringo-framework,项目名称:brabbel,代码行数:4,代码来源:test_expressions.py

示例14: test_equal

 def test_equal(self):
     expression = Expression("timedelta($a) == timedelta($b)")
     result = expression.evaluate({"a": "01:30:00", "b": "00:90:00"})
     self.assertEqual(result, True)
开发者ID:ringo-framework,项目名称:brabbel,代码行数:4,代码来源:test_expressions.py

示例15: test_smaller

    def test_smaller(self):
        import datetime

        expression = Expression("$a > timedelta($b)")
        result = expression.evaluate({"a": datetime.timedelta(seconds=100), "b": "00:00:120"})
        self.assertEqual(result, False)
开发者ID:ringo-framework,项目名称:brabbel,代码行数:6,代码来源:test_expressions.py


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