pip_services3_commons.random.RandomString module

pip_services3_commons.random.RandomString

RandomString implementation

copyright

Conceptual Vision Consulting LLC 2018-2019, see AUTHORS for more details.

license

MIT, see LICENSE for more details.

class pip_services3_commons.random.RandomString.RandomString

Bases: object

Random generator for string values.

Example:

value1 = RandomString.pickChar("ABC")     # Possible result: "C"
value2 = RandomString.pick(["A","B","C"]) # Possible result: "gBW"
static distort(value: str)str

Distorts a string by randomly replacing characters in it.

Parameters

value – a string to distort.

Returns

a distored string.

static next_alpha_char()str

Generates random alpha characted [A-Za-z] :return: a random characted.

static next_string(min_size: int, max_size: int)str

Generates a random string, consisting of upper and lower case letters (of the English alphabet), digits (0-9), and symbols (“_,.:-/.[].{},#-!,$=%.+^.&*-() “).

Parameters
  • min_size – (optional) minimum string length.

  • max_size – maximum string length.

Returns

a random string.

static pick(values: List[str])str

Picks a random string from an array of string.

Parameters

values – a string to pick from

Returns

a randomly picked string.

static pick_char(values: str)str

Picks a random character from a string.

Parameters

values – a string to pick a char from

Returns

a randomly picked char.