Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Code Block
languagepy
titleUse key value arguments on node creation
from ecflow import defsDefs,Suite,Variable,Edit

defs = Defs()
s1 = defs.add_suiteSuite("s1") 
s1.add_variable("HELLO","world") # name, value
s1.add_variable({ "NAME":,HELLO="world",FRED="bloggs",BILL=1,NAME="value", "NAME2":="value2", "NAME3":"value3", "NAME4":4 }  ))
defs.s1.add_variable(Variable("FRED","bloggs"))
s1.add_variable(Variable("BILL","1")'NAME4',4)
defs.s1 += Edit(NAME3="value3")

The following examples show alternative styles that produce the same definition:


Code Block
languagepy
titleUsing add() with Edit
defs = Defs().add(
        Suite("s1").add(
          Edit(HELLO="world",
 
FRED="bloggs",BILL=1,
NAME="value",

               NAME="value", NAME2="value2",
               NAME3="value3",NAME4=4)))



Code Block
languagepy
titleUsing += with dictionary
 defs = Defs()
defs
 +
=
 
[
Suite("s1")
]

 defs.s1 += 
[
{ 
Edit(
"HELLO
=
":"world
")
", "NAME":"value",
              
Edit({
"
NAME
NAME2":"
value
value2",
"
NAME2
NAME3":"
value2
value3", 
              "NAME4":4,"BILL":1, "FRED":"bloggs"}  



Code Block
languagepy
titleUsing Edit() on node creation and += with list
 defs = Defs() + Suite("s1", Edit(HELLO="world"))
 defs.s1 += [ Edit({ "
NAME3
NAME":"
value3
value",
"
NAME4
NAME2":
4 },
"value2", 
                     "NAME3":"value3", "NAME4":4 }, BILL=1),
              Edit(FRED="bloggs")]


Note: that although we are using class Edit as a short cut, the objects that are added are still of type Variable.

Warning

In the example above we use 'defs.s1' to reference a node by name. This is useful in small designs but will produce maintenance issues in large designs IF the node names are changed.