當前位置: 首頁>>代碼示例>>Python>>正文


Python Expression.evaluate方法代碼示例

本文整理匯總了Python中brabbel.expression.Expression.evaluate方法的典型用法代碼示例。如果您正苦於以下問題:Python Expression.evaluate方法的具體用法?Python Expression.evaluate怎麽用?Python Expression.evaluate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在brabbel.expression.Expression的用法示例。


在下文中一共展示了Expression.evaluate方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_5

# 需要導入模塊: from brabbel.expression import Expression [as 別名]
# 或者: from brabbel.expression.Expression import evaluate [as 別名]
    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,代碼行數:9,代碼來源:test_expressions.py

示例2: test_4

# 需要導入模塊: from brabbel.expression import Expression [as 別名]
# 或者: from brabbel.expression.Expression import evaluate [as 別名]
    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,代碼行數:48,代碼來源:test_expressions.py

示例3: test_8

# 需要導入模塊: from brabbel.expression import Expression [as 別名]
# 或者: from brabbel.expression.Expression import evaluate [as 別名]
 def test_8(self):
     expression = Expression("bool($x) and ($x == 1)")
     result = expression.evaluate({"x": 0})
     self.assertEqual(result, False)
開發者ID:ringo-framework,項目名稱:brabbel,代碼行數:6,代碼來源:test_expressions.py

示例4: test_boolvar

# 需要導入模塊: from brabbel.expression import Expression [as 別名]
# 或者: from brabbel.expression.Expression import evaluate [as 別名]
 def test_boolvar(self):
     expression = Expression("bool($float)")
     result = expression.evaluate({"float": 1})
     self.assertEqual(result, True)
開發者ID:ringo-framework,項目名稱:brabbel,代碼行數:6,代碼來源:test_expressions.py

示例5: test_6

# 需要導入模塊: from brabbel.expression import Expression [as 別名]
# 或者: from brabbel.expression.Expression import evaluate [as 別名]
 def test_6(self):
     expression = Expression("( 'LOP-PM' in ['admins'] ) or ( 'False' == 'True' )")
     result = expression.evaluate({})
     self.assertEqual(result, False)
開發者ID:ringo-framework,項目名稱:brabbel,代碼行數:6,代碼來源:test_expressions.py

示例6: test_mul

# 需要導入模塊: from brabbel.expression import Expression [as 別名]
# 或者: from brabbel.expression.Expression import evaluate [as 別名]
 def test_mul(self):
     expression = Expression("7 * 7")
     result = expression.evaluate()
     self.assertEqual(result, 49.0)
開發者ID:ringo-framework,項目名稱:brabbel,代碼行數:6,代碼來源:test_expressions.py

示例7: test_boolempty

# 需要導入模塊: from brabbel.expression import Expression [as 別名]
# 或者: from brabbel.expression.Expression import evaluate [as 別名]
 def test_boolempty(self):
     expression = Expression("bool($string)")
     result = expression.evaluate({"string": ""})
     self.assertEqual(result, False)
開發者ID:ringo-framework,項目名稱:brabbel,代碼行數:6,代碼來源:test_expressions.py

示例8: test_nottrue

# 需要導入模塊: from brabbel.expression import Expression [as 別名]
# 或者: from brabbel.expression.Expression import evaluate [as 別名]
 def test_nottrue(self):
     expression = Expression("not True")
     result = expression.evaluate()
     self.assertEqual(result, False)
開發者ID:ringo-framework,項目名稱:brabbel,代碼行數:6,代碼來源:test_expressions.py

示例9: test_plusplus

# 需要導入模塊: from brabbel.expression import Expression [as 別名]
# 或者: from brabbel.expression.Expression import evaluate [as 別名]
 def test_plusplus(self):
     expression = Expression("1 + 1 + 1")
     result = expression.evaluate()
     self.assertEqual(result, 3.0)
開發者ID:ringo-framework,項目名稱:brabbel,代碼行數:6,代碼來源:test_expressions.py

示例10: test_1

# 需要導入模塊: from brabbel.expression import Expression [as 別名]
# 或者: from brabbel.expression.Expression import evaluate [as 別名]
 def test_1(self):
     expression = Expression(
         "( 'antragsteller' in       ['institutionen_einsicht', 'user', 'antragsteller']   ) == False"
     )
     result = expression.evaluate()
     self.assertEqual(result, False)
開發者ID:ringo-framework,項目名稱:brabbel,代碼行數:8,代碼來源:test_expressions.py

示例11: test_variable

# 需要導入模塊: from brabbel.expression import Expression [as 別名]
# 或者: from brabbel.expression.Expression import evaluate [as 別名]
 def test_variable(self):
     expression = Expression("$string")
     result = expression.evaluate({"string": "string"})
     self.assertEqual(result, "string")
開發者ID:ringo-framework,項目名稱:brabbel,代碼行數:6,代碼來源:test_expressions.py

示例12: test_equal

# 需要導入模塊: from brabbel.expression import Expression [as 別名]
# 或者: from brabbel.expression.Expression import evaluate [as 別名]
 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,代碼行數:6,代碼來源:test_expressions.py

示例13: test_sum_smaller

# 需要導入模塊: from brabbel.expression import Expression [as 別名]
# 或者: from brabbel.expression.Expression import evaluate [as 別名]
 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,代碼行數:6,代碼來源:test_expressions.py

示例14: test_smaller

# 需要導入模塊: from brabbel.expression import Expression [as 別名]
# 或者: from brabbel.expression.Expression import evaluate [as 別名]
    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,代碼行數:8,代碼來源:test_expressions.py

示例15: test_len4ticks

# 需要導入模塊: from brabbel.expression import Expression [as 別名]
# 或者: from brabbel.expression.Expression import evaluate [as 別名]
 def test_len4ticks(self):
     expression = Expression("len($a)")
     result = expression.evaluate({"a": "''''"})
     self.assertEqual(result, 4)
開發者ID:ringo-framework,項目名稱:brabbel,代碼行數:6,代碼來源:test_expressions.py


注:本文中的brabbel.expression.Expression.evaluate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。