Decision evaluation
- class bast3st.decisions.Criterion[source]
Bases:
DecisionEntity[Features]- __init__(*, failure_explaination)[source]
- Parameters:
failure_explaination (IntoTextValue[Features] | None)
- Return type:
None
- catch(error: err, *, fallback: Criterion[Features2], only_if: Criterion[Features3] | None = None) Criterion[Features | Features2 | Features3][source]
- catch(error: err, *, action: Action[Features2], only_if: Criterion[Features3] | None = None) Criterion[Features | Features2 | Features3]
- catch(error: err, *, only_if: Criterion[Features2] | None = None, fallback: Criterion[Features3] | None, action: Action[Features4] | None) Criterion[Features | Features2 | Features3 | Features4]
- negate(*, failure_explaination=None)[source]
Create criterion with the success condition negated
- Parameters:
failure_explaination (IntoTextValue[Features2] | None)
- Return type:
Criterion[Features | Features2]
- with_failure_explaination(val)[source]
- Parameters:
val (IntoTextValue[Features2])
- Return type:
Criterion[Features | Features2]
- class bast3st.decisions.FutureArray[source]
Bases:
Protocol[Features]A
FutureArrayrepresents a specific source of multiple values that are available – somewhere in the future – during the evaluation of a submission.- Examples are:
INPUT: access the input a submission got in the current testOUTPUT: access the output a submission producedLIST(name): access the list with the provided name
This type can be used similarily to a list of
Selector’s:>>> first_input = INPUT.first # or INPUT[0] >>> first_input INPUT[0] >>> last_output = OUTPUT.last # or OUTPUT[-1] >>> last_output OUTPUT[-1] >>> mylist = LIST("mylist") >>> second_item = mylist[1] # or mylist.index1(2) >>> second_item LIST("mylist")[1] >>> length_of_mylist = mylist.length # don't use len(mylist) >>> length_of_mylist LIST("mylist").length
Attention
The values you receive are special instances of
Selectorand can be understood as placeholders. For more see Placeholders live in the future.(This type should not be instantiated directly)
- __init__(*args, **kwargs)
- class bast3st.decisions.FutureMapItem[source]
Bases:
Selector[Features|Features2],FutureMapping[Features|Features2]
- class bast3st.decisions.FutureMapping[source]
Bases:
DecisionEntity[Features]This is a key-value-mapping that lives in the future. (See
FutureArray)- keys()[source]
Array of all keys of the mapping (indexed by numbers), in their sorting order
- Return type:
FutureArray[Features]
- sum()[source]
Sum all values of the mapping, texts and collections count as zeros
- Return type:
Value[Features]
- values()[source]
Array of all values of the mapping (indexed by numbers), in the order of the sorted keys
- Return type:
FutureArray[Features]
- property first: Value[Features]
On arrays this will return the first element (index 0), but on mappings this will be the element with the smallest key (sort order)
- class bast3st.decisions.NetworkRequest[source]
Bases:
FutureMapping[Features|Features2|Features3]A network request to a specific server. The server’s domain has to be a static string and must be explicitly whitelisted by the server administrator
- Parameters:
server (str) – The server to contact
route (str) – The part after the first slash that specifies the route on the server
method – The HTTP Method to use for the request. Only GET and POST are supported
json – A
dictof values that should be sent as json to the specified url. The json attribute is not available for GET requests.allowed_status – The HTTP status codes of the response that are considered normal behaviour of the API. This can be a single number or a
tupleof status codes. If the server responds with a code that isn’t listed here, it will be considered one of the Catchable errors, but only if a map item is used that is expected to require a successful response.
Catchable errors
- __init__(*, server: str, route: IntoTextValue[Features], method: Literal['GET'], allowed_status: int | tuple[int, ...] = 200) None[source]
- __init__(*, server: str, route: IntoTextValue[Features], method: Literal['POST'], json: dict[str, IntoValue[Features3]] | list[tuple[IntoValue[Features2], IntoValue[Features3]]] | None = None, allowed_status: int | tuple[int, ...] = 200) None
- class bast3st.decisions.Selector[source]
Bases:
Value[Features]- __init__(opcode, *args)[source]
- Parameters:
opcode (SelectorOpcodeT)
- Return type:
None
- class bast3st.decisions.TransformSingleNoParam[source]
Bases:
Transformation[Features]
- class bast3st.decisions.Transformation[source]
Bases:
DecisionEntity[Features],ABC
- class bast3st.decisions.Value[source]
Bases:
DecisionEntity[Features],ABC- classmethod of(val: IntoValue[Features]) Value[Features][source]
- classmethod of(val: IntoValue[Features] | None) Value[Features] | None
Exactly like
ofStrictbut returns None if input is None
- catch(error: err, *, default_value: IntoValue[Features2], only_if: Criterion[Features3] | None = None) Value[Features | Features2 | Features3][source]
- catch(error: err, *, action: Action[Features2], only_if: Criterion[Features3] | None = None) Value[Features | Features2 | Features3]
- catch(error: err, *, only_if: Criterion[Features2] | None = None, default_value: IntoValue[Features3] | None, action: Action[Features4] | None) Value[Features | Features2 | Features3 | Features4]
- contains_only_this_number(val, *, failure_explaination=None)[source]
- Parameters:
val (IntoValue[Features2])
failure_explaination (IntoTextValue[Features3] | None)
- Return type:
Criterion[Features | Features2 | Features3]
- contains_text(val, *, failure_explaination=None)[source]
- Parameters:
val (IntoTextValue[Features2])
failure_explaination (IntoTextValue[Features3] | None)
- Return type:
Criterion[Features | Features2 | Features3]
- contains_this_number(val, *, failure_explaination=None)[source]
- Parameters:
val (IntoValue[Features2])
failure_explaination (IntoTextValue[Features3] | None)
- Return type:
Criterion[Features | Features2 | Features3]
- contains_with_gaps(*val, failure_explaination=None)[source]
If this contains a specific sequence of fragments, with arbitraty gaps inbetween
- Parameters:
val (IntoValue[Features2])
failure_explaination (IntoTextValue[Features3] | None)
- Return type:
Criterion[Features | Features2 | Features3]
- first_capture(pattern)[source]
Tries to match a Rust regex regular expression and returns a mapping of the first match that allows accessing the captured parts.
Warning
As Placeholders live in the future the pattern will be evaluated not by the Python
reregular expression library, but by the one that is used by the server implementation. The required syntax can be found in the regex crate- Parameters:
pattern (IntoTextValue[Features2])
- Return type:
FutureMapping[Features | Features2]
- matches(pattern, failure_explaination=None)[source]
If this matches a Rust regex regular expression.
Warning
As Placeholders live in the future the pattern will be evaluated not by the Python
reregular expression library, but by the one that is used by the server implementation. The required syntax can be found in the regex crate- Parameters:
pattern (IntoTextValue[Features2])
failure_explaination (IntoTextValue[Features3] | None)
- Return type:
Criterion[Features | Features2 | Features3]
- pipe(*operations)[source]
Execute a sequence of transformations in order on this value and return the final result. The value itself is the input to the first
Transformationand every furtherTransformationgets the output of the last as input. The lastTransformation’s output will be returned.- Parameters:
operations (Transformation[Features2])
- Return type:
Value[Features | Features2]
- text_is_contained_in(val, *, failure_explaination=None)[source]
- Parameters:
val (IntoTextValue[Features2])
failure_explaination (IntoTextValue[Features3] | None)
- Return type:
Criterion[Features | Features2 | Features3]
- class bast3st.decisions.all_of[source]
Bases:
SerCrit[Features|Features2]- __init__(*clauses, failure_explaination=None)[source]
- Parameters:
clauses (Criterion[Features])
failure_explaination (IntoTextValue[Features2] | None)
- Return type:
None
- class bast3st.decisions.any_of[source]
Bases:
SerCrit[Features|Features2]- __init__(*clauses, failure_explaination=None)[source]
- Parameters:
clauses (Criterion[Features])
failure_explaination (IntoTextValue[Features2] | None)
- Return type:
None
- class bast3st.decisions.compare[source]
Bases:
SerCrit[Features|Features2|Features3]- __init__(left, relation, right, *, failure_explaination=None)[source]
Compare two future values with a given relation
- Parameters:
left (Value) – first future value
relation (RelationT) – the comparison relation to use
right (Value) – second future value
failure_explaination (IntoTextValue[Features3] | None)
- Return type:
None
- property relation
- bast3st.decisions.LIST(name)[source]
- Parameters:
name (str)
- Return type:
FutureArray[Literal[‘f-read-rundata’]]
- bast3st.decisions.if_then_else(if_: Criterion[Features], then_: Criterion[Features2], else_: Criterion[Features3]) Criterion[Features | Features2 | Features3][source]
- bast3st.decisions.if_then_else(if_: Criterion[Features], then_: IntoValue[Features2], else_: IntoValue[Features3]) Value[Features | Features2 | Features3]
- bast3st.decisions.if_then_else(if_: Criterion[Features], then_: Action[Features2], else_: Action[Features3]) Action[Features | Features2 | Features3]
- bast3st.decisions.negated(criterion, *, failure_explaination=None)[source]
Negate a criterion so that it accepts exactly when the original one didn’t accept
- Parameters:
criterion (Criterion[Features])
failure_explaination (IntoTextValue[Features2] | None)
- Return type:
Criterion[Features | Features2]
- bast3st.decisions.ALWAYS_FULFILLED: Criterion = ALWAYS_FULFILLED
a special criterion that is always fulfilled
- bast3st.decisions.FLAGS: FutureMapping = FLAGS
FutureMappingthat allows reading arbitraty flags, see Setting and reading flags for details
- bast3st.decisions.INPUT: FutureArray[Literal['f-read-rundata']] = INPUT
FutureArraythat represents the output a submission got during the current test
- bast3st.decisions.NEVER_FULFILLED: Criterion = NEVER_FULFILLED
a special criterion that is never fulfilled
- bast3st.decisions.OUTPUT: FutureArray[Literal['f-read-rundata']] = OUTPUT
FutureArraythat represents the output a submission produced during the current test
- bast3st.decisions.PARAM = PARAM
FutureMappingthat allows reading set parameters, see Parameters for details
- bast3st.decisions.RANDOMS: FutureArray[Literal['f-read-rundata']] = RANDOMS
FutureArraythat represents the random numbers a submission requested and got during the current test
- bast3st.decisions.to_lower = <bast3st.decisions.TransformSingleNoParam object>
Transformationconverting a value to lowercase
- bast3st.decisions.to_upper = <bast3st.decisions.TransformSingleNoParam object>
Transformationconverting a value to uppercase
- bast3st.decisions.trim = <bast3st.decisions.TransformSingleNoParam object>
Transformationremoving all whitespace from start and end of the stringified value
- bast3st.decisions.trim_end = <bast3st.decisions.TransformSingleNoParam object>
Transformationremoving all whitespace from the end of the stringified value
- bast3st.decisions.trim_start = <bast3st.decisions.TransformSingleNoParam object>
Transformationremoving all whitespace from the start of the stringified value
- type bast3st.decisions.ArrayScopeT = Literal['arrayview'] | StdArrayScopeT
- type bast3st.decisions.IntoTextValue = str | Template | Value
Any type that can be converted into a
Valueand is likely a text
- type bast3st.decisions.IntoValue = IntoTextValue | float | int | bool
Any type that can be converted into a
Value
- type bast3st.decisions.MapScopeT = Literal['network', 'first-capture', 'read-input', 'read-output', 'read-lists', 'read-randoms', 'read-variables', 'read-param', 'read-flags', 'mapitem', 'view']
- type bast3st.decisions.RelationT = Literal['==', '!=', '<=', '>=', '<', '>']
A comparison operator string to specify the desired relation