API Reference
Here you can find all sept interfaces.
Sept
Parser
Token
Operator
- class sept.operator.Operator(args=None)
- The docstring of your Operator is used as the documentation for your
Operator.
- You should include any freeform text that you would like as well as some
examples of how your Operator works.
This docstring should be treated as html code.
If you wanted to bold your text, you could just do <b>this!</b>
- name
alias of
NotImplementedError
- __init__(args=None)
- execute(input_data)
execute does the actual work of your custom Operator. It will take in the data passed and return the transformed data as
output.
- Parameters
input_data (Any) –
- Returns
The transformed data according to whatever the Operator is supposed to do.
- Return type
Any
- is_invalid(token_value)
is_invalid will check the value the is about to be operated on. If the value will not work for some reason (wrong datatype, etc),
this method should return an error message as a string.
If it looks good to go, just return None
- Parameters
token_value (Any) – Data that would be operated on
- Returns
A Falsey value if everything is ok, or an error string if not.
- Return type
None|str
- class sept.operator.Operator(args=None)
- The docstring of your Operator is used as the documentation for your
Operator.
- You should include any freeform text that you would like as well as some
examples of how your Operator works.
This docstring should be treated as html code.
If you wanted to bold your text, you could just do <b>this!</b>
- name
alias of
NotImplementedError
- __init__(args=None)
- execute(input_data)
execute does the actual work of your custom Operator. It will take in the data passed and return the transformed data as
output.
- Parameters
input_data (Any) –
- Returns
The transformed data according to whatever the Operator is supposed to do.
- Return type
Any
- is_invalid(token_value)
is_invalid will check the value the is about to be operated on. If the value will not work for some reason (wrong datatype, etc),
this method should return an error message as a string.
If it looks good to go, just return None
- Parameters
token_value (Any) – Data that would be operated on
- Returns
A Falsey value if everything is ok, or an error string if not.
- Return type
None|str
- class sept.builtin.operators.lower.LowerOperator(args=None)
The <code>lower</code> Operator will convert your Token to lowercase. <br> <br>Examples: <br> <code>”Alex” -> “alex”</code> <br> <code>”alex” -> “alex”</code> <br> <code>”ALEX11” -> “alex11”</code>
- is_invalid(token_value)
is_invalid will check the value the is about to be operated on. If the value will not work for some reason (wrong datatype, etc),
this method should return an error message as a string.
If it looks good to go, just return None
- Parameters
token_value (Any) – Data that would be operated on
- Returns
A Falsey value if everything is ok, or an error string if not.
- Return type
None|str
- execute(input_data)
execute does the actual work of your custom Operator. It will take in the data passed and return the transformed data as
output.
- Parameters
input_data (Any) –
- Returns
The transformed data according to whatever the Operator is supposed to do.
- Return type
Any
- class sept.builtin.operators.lower.LowerOperator(args=None)
The <code>lower</code> Operator will convert your Token to lowercase. <br> <br>Examples: <br> <code>”Alex” -> “alex”</code> <br> <code>”alex” -> “alex”</code> <br> <code>”ALEX11” -> “alex11”</code>
- is_invalid(token_value)
is_invalid will check the value the is about to be operated on. If the value will not work for some reason (wrong datatype, etc),
this method should return an error message as a string.
If it looks good to go, just return None
- Parameters
token_value (Any) – Data that would be operated on
- Returns
A Falsey value if everything is ok, or an error string if not.
- Return type
None|str
- execute(input_data)
execute does the actual work of your custom Operator. It will take in the data passed and return the transformed data as
output.
- Parameters
input_data (Any) –
- Returns
The transformed data according to whatever the Operator is supposed to do.
- Return type
Any
- class sept.builtin.operators.null.NullOperator(args=None)
The <code>null</code> Operator will do nothing to you Token. <br> <br>Examples: <br> <code>”Alex” -> “Alex”</code> <br> <code>”alex” -> “alex”</code> <br> <code>”ALEX11” -> “ALEX11”</code>
- is_invalid(token_value)
is_invalid will check the value the is about to be operated on. If the value will not work for some reason (wrong datatype, etc),
this method should return an error message as a string.
If it looks good to go, just return None
- Parameters
token_value (Any) – Data that would be operated on
- Returns
A Falsey value if everything is ok, or an error string if not.
- Return type
None|str
- execute(input_data)
execute does the actual work of your custom Operator. It will take in the data passed and return the transformed data as
output.
- Parameters
input_data (Any) –
- Returns
The transformed data according to whatever the Operator is supposed to do.
- Return type
Any
- class sept.builtin.operators.null.NullOperator(args=None)
The <code>null</code> Operator will do nothing to you Token. <br> <br>Examples: <br> <code>”Alex” -> “Alex”</code> <br> <code>”alex” -> “alex”</code> <br> <code>”ALEX11” -> “ALEX11”</code>
- is_invalid(token_value)
is_invalid will check the value the is about to be operated on. If the value will not work for some reason (wrong datatype, etc),
this method should return an error message as a string.
If it looks good to go, just return None
- Parameters
token_value (Any) – Data that would be operated on
- Returns
A Falsey value if everything is ok, or an error string if not.
- Return type
None|str
- execute(input_data)
execute does the actual work of your custom Operator. It will take in the data passed and return the transformed data as
output.
- Parameters
input_data (Any) –
- Returns
The transformed data according to whatever the Operator is supposed to do.
- Return type
Any
- class sept.builtin.operators.replace.ReplaceOperator(args=None)
The <code>replace</code> Operator allows you to find and replace characters in your Token. <br> <br>Examples (name = “alex”): <br> <code>{{replace[ex,an]:name}} -> “alan”</code> <br> <code>{{replace[kite,dog:name}} -> “alex”</code>
- is_invalid(token_value)
is_invalid will check the value the is about to be operated on. If the value will not work for some reason (wrong datatype, etc),
this method should return an error message as a string.
If it looks good to go, just return None
- Parameters
token_value (Any) – Data that would be operated on
- Returns
A Falsey value if everything is ok, or an error string if not.
- Return type
None|str
- execute(input_data)
execute does the actual work of your custom Operator. It will take in the data passed and return the transformed data as
output.
- Parameters
input_data (Any) –
- Returns
The transformed data according to whatever the Operator is supposed to do.
- Return type
Any
- class sept.builtin.operators.replace.ReplaceOperator(args=None)
The <code>replace</code> Operator allows you to find and replace characters in your Token. <br> <br>Examples (name = “alex”): <br> <code>{{replace[ex,an]:name}} -> “alan”</code> <br> <code>{{replace[kite,dog:name}} -> “alex”</code>
- is_invalid(token_value)
is_invalid will check the value the is about to be operated on. If the value will not work for some reason (wrong datatype, etc),
this method should return an error message as a string.
If it looks good to go, just return None
- Parameters
token_value (Any) – Data that would be operated on
- Returns
A Falsey value if everything is ok, or an error string if not.
- Return type
None|str
- execute(input_data)
execute does the actual work of your custom Operator. It will take in the data passed and return the transformed data as
output.
- Parameters
input_data (Any) –
- Returns
The transformed data according to whatever the Operator is supposed to do.
- Return type
Any
- class sept.builtin.operators.substr.SubStringOperator(args=None)
The <code>substr</code> Operator allows you to return a subset of the Token. <br>This Operator supports the arguments “start” and “end” as well as numerical indexes from zero. <br> <br>Examples (name = “alex”): <br> <code>{{substr[start,2]:name}} -> “al”</code> <br> <code>{{substr[0,2]:name}} -> “al”</code> <br> <code>{{substr[0,end]:name}} -> “alex”</code> <br> <code>{{substr[1,3]:name}} -> “le”</code>
- is_invalid(token_value)
is_invalid will check the value the is about to be operated on. If the value will not work for some reason (wrong datatype, etc),
this method should return an error message as a string.
If it looks good to go, just return None
- Parameters
token_value (Any) – Data that would be operated on
- Returns
A Falsey value if everything is ok, or an error string if not.
- Return type
None|str
- execute(input_data)
execute does the actual work of your custom Operator. It will take in the data passed and return the transformed data as
output.
- Parameters
input_data (Any) –
- Returns
The transformed data according to whatever the Operator is supposed to do.
- Return type
Any
- class sept.builtin.operators.substr.SubStringOperator(args=None)
The <code>substr</code> Operator allows you to return a subset of the Token. <br>This Operator supports the arguments “start” and “end” as well as numerical indexes from zero. <br> <br>Examples (name = “alex”): <br> <code>{{substr[start,2]:name}} -> “al”</code> <br> <code>{{substr[0,2]:name}} -> “al”</code> <br> <code>{{substr[0,end]:name}} -> “alex”</code> <br> <code>{{substr[1,3]:name}} -> “le”</code>
- is_invalid(token_value)
is_invalid will check the value the is about to be operated on. If the value will not work for some reason (wrong datatype, etc),
this method should return an error message as a string.
If it looks good to go, just return None
- Parameters
token_value (Any) – Data that would be operated on
- Returns
A Falsey value if everything is ok, or an error string if not.
- Return type
None|str
- execute(input_data)
execute does the actual work of your custom Operator. It will take in the data passed and return the transformed data as
output.
- Parameters
input_data (Any) –
- Returns
The transformed data according to whatever the Operator is supposed to do.
- Return type
Any
- class sept.builtin.operators.upper.UpperOperator(args=None)
The <code>upper</code> Operator will convert your Token to uppercase. <br> <br>Examples: <br> <code>”Alex” -> “ALEX”</code> <br> <code>”alex” -> “ALEX”</code> <br> <code>”alex11” -> “ALEX11”</code>
- is_invalid(token_value)
is_invalid will check the value the is about to be operated on. If the value will not work for some reason (wrong datatype, etc),
this method should return an error message as a string.
If it looks good to go, just return None
- Parameters
token_value (Any) – Data that would be operated on
- Returns
A Falsey value if everything is ok, or an error string if not.
- Return type
None|str
- execute(input_data)
execute does the actual work of your custom Operator. It will take in the data passed and return the transformed data as
output.
- Parameters
input_data (Any) –
- Returns
The transformed data according to whatever the Operator is supposed to do.
- Return type
Any
- class sept.builtin.operators.upper.UpperOperator(args=None)
The <code>upper</code> Operator will convert your Token to uppercase. <br> <br>Examples: <br> <code>”Alex” -> “ALEX”</code> <br> <code>”alex” -> “ALEX”</code> <br> <code>”alex11” -> “ALEX11”</code>
- is_invalid(token_value)
is_invalid will check the value the is about to be operated on. If the value will not work for some reason (wrong datatype, etc),
this method should return an error message as a string.
If it looks good to go, just return None
- Parameters
token_value (Any) – Data that would be operated on
- Returns
A Falsey value if everything is ok, or an error string if not.
- Return type
None|str
- execute(input_data)
execute does the actual work of your custom Operator. It will take in the data passed and return the transformed data as
output.
- Parameters
input_data (Any) –
- Returns
The transformed data according to whatever the Operator is supposed to do.
- Return type
Any
Template
Errors
- exception sept.errors.SeptError
- exception sept.errors.TokenNotFoundError
- exception sept.errors.OperatorError
- exception sept.errors.LocationAwareSeptError(location, message, length=0)
- __init__(location, message, length=0)
- exception sept.errors.ParsingError(location, message, length=0)
- __init__(location, message, length=0)
- exception sept.errors.InvalidCharacterParsingError(expression, expected_char, actual_char, start_col, end_col)
- __init__(expression, expected_char, actual_char, start_col, end_col)
- exception sept.errors.BalancingParenthesisError(missing_token, substr, start_location, end_location)
- __init__(missing_token, substr, start_location, end_location)
- exception sept.errors.OpeningBalancingParenthesisError(missing_token, substr, start_location, end_location)
- exception sept.errors.ClosingBalancingParenthesisError(missing_token, substr, start_location, end_location)
- exception sept.errors.OperatorNotFoundError
- exception sept.errors.TokenNameAlreadyExists
- exception sept.errors.OperatorNameAlreadyExists
- exception sept.errors.InvalidOperatorArgumentsError
- exception sept.errors.InvalidOperatorInputDataError
Other
- class sept.balancer.ParenthesisBalancer(template_str)
The ParenthesisBalancer class runs a stack based pairing lookup against the “{{” and “}}” pairs.
It will check for any unbalanced pairs and return a record of those in addition to any successfuly found pairs
Successfully matched pairs get returned as a list of [start_index, end_index] values which can be used to generate substrings of only the “Token Expression” chunks.
- __init__(template_str)
- execute()
execute the template parsing. This method runs the token balancing check and will store any errors as either sept.errors.OpeningBalancingParenthesisError or sept.errors.ClosingBalancingParenthesisError exceptions, unthrown.
It returns any successfully found “Token Expressions” at the root level. Any nested “Token Expressions” get validated but not returned as locations from this method.
- Returns
Returns a list of “Token Expression” locations as index start:end values and a list of any errors that were encountered.
- Return type
list[list,list]
- classmethod parse_string(template_str)
Standard entrypoint into usage of the ParenthesisBalancer class
- Parameters
template_str (str) – Template string that we want to validate.
- Returns
Tuple of expression_locations and errors. See execute for definition.
- Return type
list[list,list]
- class sept.balancer.ParenthesisBalancer(template_str)
The ParenthesisBalancer class runs a stack based pairing lookup against the “{{” and “}}” pairs.
It will check for any unbalanced pairs and return a record of those in addition to any successfuly found pairs
Successfully matched pairs get returned as a list of [start_index, end_index] values which can be used to generate substrings of only the “Token Expression” chunks.
- __init__(template_str)
- execute()
execute the template parsing. This method runs the token balancing check and will store any errors as either sept.errors.OpeningBalancingParenthesisError or sept.errors.ClosingBalancingParenthesisError exceptions, unthrown.
It returns any successfully found “Token Expressions” at the root level. Any nested “Token Expressions” get validated but not returned as locations from this method.
- Returns
Returns a list of “Token Expression” locations as index start:end values and a list of any errors that were encountered.
- Return type
list[list,list]
- classmethod parse_string(template_str)
Standard entrypoint into usage of the ParenthesisBalancer class
- Parameters
template_str (str) – Template string that we want to validate.
- Returns
Tuple of expression_locations and errors. See execute for definition.
- Return type
list[list,list]
- sept.template_tokenizer.Tokenizer
alias of Forward: {{{“{{” [{{W:(ABCD…) [{{“[” {W:(0123…, ABC…)}… [, {W:(0123…, ABC…)}…]…} “]”}]} “:”}]} {: … | W:(0123…)}} “}}”}