nemoguardrails.colang.v1_0.lang.utils
nemoguardrails.colang.v1_0.lang.utils
Module Contents
Functions
API
Helper method to split a string by a given character.
:param text: The text to split. :param c: The character to use as the separator :param ignore_parenthesis: If set, it will now account for lists i.e. starting with [], () or {} :param ignore_strings: If set, it will not take into account strings.
Helper to extract the main token from a line
Helper to extract the object from the definition of a topic.
Supported expressions is_open_source is_open_source for @roboself is_open_source for roboself) is_open_source(@roboself)
Helper to get the first key, which transpiles correctly.
Helper to returned numbered lines.
Comments and empty lines are ignored.
Tokenizer specific to the params parsing.
Helper to extract a normalized package name.
Helper to remove a token
Split a string that represents arguments for a function.
It supports keyword arguments and also correctly handles strings and lists/dicts.
Parameters:
The string with the arguments e.g. ‘name=“John”, colors=[“blue”, “red”]’
Returns: List[str]
The string that correspond to each individual argument value.
Helper to simulate the behavior of .split(…, max_instances).
This implementation is meant to transpile correctly to the JS>
A simple string hash with an equivalent implementation in javascript.
module.exports.string_hash = function(s){ let hash = 0; if (s.length === 0) return hash; for (let i = 0; i < s.length; i++) { let char = s.charCodeAt(i); hash = ((hash<<5)-hash)+char; hash = hash & hash; // Convert to 32bit integer } if (hash < 0) hash *= -1;
return hash.toString(16); }
A simple logic that splits by word but takes strings into accounts.
Tokenize a text by whitespace and taking strings into account.