Cookies Manager Backend
Functions | Variables
rulegen.templates Namespace Reference

Functions

def create_default_template (str CMP_name, str selector)
 
def create_multistage_template (str CMP_name, str selector_01, str selector_02)
 
def get_detectors (str selector)
 
def save_json (str name, str template)
 

Variables

string schema
 
def template = create_default_template("Asus", ".selector")
 

Function Documentation

◆ create_default_template()

def rulegen.templates.create_default_template ( str  CMP_name,
str  selector 
)
Creates a JSON template for rule definitions with a single stage.

Args:
    CMP_name (str): The name of the Consent Management Platform.
    selector (str): The CSS selector used for targeting the element.
    
Returns:
    str: A JSON formatted string of the rule template.

◆ create_multistage_template()

def rulegen.templates.create_multistage_template ( str  CMP_name,
str  selector_01,
str  selector_02 
)
Creates a JSON template for rule definitions with multiple stages using different selectors.

Args:
    CMP_name (str): The name of the Consent Management Platform.
    selector_01 (str): The CSS selector used for the first interaction stage.
    selector_02 (str): The CSS selector used for the second interaction stage.
    
Returns:
    str: A JSON formatted string of the multistage rule template.

◆ get_detectors()

def rulegen.templates.get_detectors ( str  selector)
Generates JSON strings for the 'presentMatcher' and 'showingMatcher' configurations.

Args:
    selector (str): The CSS selector used to identify elements for the detectors.
    
Returns:
    str: A JSON formatted string containing the configurations for both matchers.

◆ save_json()

def rulegen.templates.save_json ( str  name,
str  template 
)
Saves a JSON template to a file.

Args:
    name (str): The filename to save the JSON template under.
    template (str): The JSON formatted template string to save.

Variable Documentation

◆ schema

string schema
Initial value:
1 = """
2 "$schema": "https://raw.githubusercontent.com/cavi-au/Consent-O-Matic/master/rules.schema.json",
3 """

◆ template

template = create_default_template("Asus", ".selector")