import re


def _extract_parameters(s:str)->dict:
    """
    The functions parses all parameters from a ShipFlow Motions indata file.
    The function searches for:
    x = ...
    and saves all those occurences as a key value pair in a dict.
    
    Parameters
    ----------
    s : str
        Motions indata file content as string.
    
    Returns
    ----------
    parameters : dict
    
    """
    # matching: x = ....
    key_value_pairs = re.findall(pattern='(\w+) *= *"*([^ ^, ^" ^ ^\n ^)]+)', string=s)
    
    # matching x (jadadajada...)  : ....
    key_value_pairs_2 = re.findall(pattern='(\w+) *\([^\)]+\) *: *([^\n]+)', string=s)

    # adding the key_value_pairs_2 to the list:
    key_value_pairs+=key_value_pairs_2  # (This list may contain duplicates so that certain value are overwritten below)

    parameters = {}
    for key_value_pair in key_value_pairs:
        key = key_value_pair[0]
        value = key_value_pair[1]
        
        try:
            value=float(value)
        except:
            pass
        else:
            if value%1 == 0:  # if no decimals...
                value=int(value)
            pass
        
        parameters[key]=value
    
    return parameters