
.. _script_nodes: 

Script Nodes
################

A |popy| script file is in |yaml| format, which consists of nested dictionaries that form a tree structure.

Each node of the tree is either:-

* a dictionary (:term:`dict`) with sub nodes
* or a leave node

A leave node has to be one of the script node types listed below. 

.. glossary::
    :sorted:
    
    str
        A string.
        
    int
        An integer (whole number)
        
    float
        Any number
        
    bool
        A boolean: "true"/"yes"/"y"/"1" or "False"/"no"/"n"/"0"
        
    list
        A list of values of unspecified type.
        
    dict
        A dictionary of unspecified structure - the user chooses the keys.
        
        Many of the elements of a script file are known as dictionaries (also known as mappings or associative arrays). These are key:value pairs that can be written as follows using curly brackets:-
        
        .. code-block:: pyml

            my_dictionary1: { key1: value1, key2: value2 }
            
        or alternatively using spacing:-
        
        .. code-block:: pyml
        
            my_dictionary2:
                key1: value1
                key2: value2
                
        Whichever you use is a matter of convenience and space.
        
    one_of
        A string, limited to one of the options given in brackets.
        
    list_of
        A list of one or more strings taken from the list of options in brackets.
        
    verbatim
        Several blocks in the script file (namely :ref:`model_params`, :ref:`states`, :ref:`derivatives` and :ref:`predictions`) are reserved for :term:`pseudocode` of a relatively unstructured kind. This is translated into executable code.
       
    pseudocode
        :term:`verbatim` sections of the script file accept |python| code with extra |popy| syntax added. For example special variable names such as |fx|, |rx| etc. We refer to this code as 'pseudocode'. Pseudocode is automatically translated into runnable |python| functions that are executed by |popy| to process your script.
       
    auto
        The word "auto", indicating a preference for default behaviour.
             
    star
        The "*" character, shorthand for "all possibilities".
        
    none
        The word "none", indicating a file that does not exist.
        
    input_file
        The path to a file that already exists. (An error occurs if it does not.)
        
    input_file_as_glob
        A pattern (e.g. :python:`*.csv`) that has only a single match. (An error occurs if there are multiple matching filenames.)
        
    input_files_as_glob
        A pattern (e.g. ``"*.csv"``) that has at least one match. (An error occurs only if there are no matching filenames.)
        
    output_file
        The path to a file that may not yet exist (in contrast to :term:`input_file`).
    
    input_folder
        The path to a folder that already exists. (An error occurs if it does not.)

    output_folder
        The path to a folder that may not yet exist (in contrast to :term:`input_folder`).

    list_record
        A list
        
    dict_record
        A dictionary with a pre-determined structure (i.e. key names and corresponding types)
        
    one_of_record
        One from a selection of dict_records
        
    repeat_record
        One or more of a selection of dict_records