runway.lookups.handlers.random_string module

Generate a random string.

pydantic model runway.lookups.handlers.random_string.ArgsDataModel[source]

Bases: BaseModel

Arguments data model.

Show JSON schema
{
   "title": "ArgsDataModel",
   "description": "Arguments data model.",
   "type": "object",
   "properties": {
      "digits": {
         "default": true,
         "title": "Digits",
         "type": "boolean"
      },
      "lowercase": {
         "default": true,
         "title": "Lowercase",
         "type": "boolean"
      },
      "punctuation": {
         "default": false,
         "title": "Punctuation",
         "type": "boolean"
      },
      "uppercase": {
         "default": true,
         "title": "Uppercase",
         "type": "boolean"
      }
   }
}

field digits: bool = True
field lowercase: bool = True
field punctuation: bool = False
field uppercase: bool = True
class runway.lookups.handlers.random_string.RandomStringLookup[source]

Bases: LookupHandler[Any]

Random string lookup.

TYPE_NAME: ClassVar[str] = 'random.string'

Name that the Lookup is registered as.

static calculate_char_set(args: ArgsDataModel) str[source]

Calculate character set from the provided arguments.

classmethod ensure_has_one_of(args: ArgsDataModel, value: str) bool[source]

Ensure value has at least one of each required character.

Parameters:
  • args – Hook args.

  • value – Value to check.

static generate_random_string(char_set: Sequence[str], length: int) str[source]

Generate a random string of a set length from a set of characters.

classmethod handle(value: str, *_args: Any, **_kwargs: Any) Any[source]

Generate a random string.

Parameters:

value – The value passed to the Lookup.

Raises:

ValueError – Unable to find a value for the provided query and a default value was not provided.

static has_digit(value: str) bool[source]

Check if value contains a digit.

static has_lowercase(value: str) bool[source]

Check if value contains lowercase.

static has_punctuation(value: str) bool[source]

Check if value contains uppercase.

static has_uppercase(value: str) bool[source]

Check if value contains uppercase.