.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.answerers.random.answerer Namespace Reference

Functions

 random_characters ()
 
 random_string ()
 
 random_float ()
 
 random_int ()
 
 random_sha256 ()
 
 random_uuid ()
 
 random_color ()
 
 answer (query)
 
 self_info ()
 

Variables

tuple keywords = ('random',)
 
int random_int_max = 2**31
 
 random_string_letters = string.ascii_lowercase + string.digits + string.ascii_uppercase
 
dict random_types
 

Function Documentation

◆ answer()

searx.answerers.random.answerer.answer ( query)

Definition at line 61 of file answerer.py.

61def answer(query):
62 parts = query.query.split()
63 if len(parts) != 2:
64 return []
65
66 if parts[1] not in random_types:
67 return []
68
69 return [{'answer': random_types[parts[1]]()}]
70
71
72# required answerer function
73# returns information about the answerer

◆ random_characters()

searx.answerers.random.answerer.random_characters ( )

Definition at line 18 of file answerer.py.

18def random_characters():
19 return [random.choice(random_string_letters) for _ in range(random.randint(8, 32))]
20
21

Referenced by searx.answerers.random.answerer.random_sha256(), and searx.answerers.random.answerer.random_string().

+ Here is the caller graph for this function:

◆ random_color()

searx.answerers.random.answerer.random_color ( )

Definition at line 44 of file answerer.py.

44def random_color():
45 color = "%06x" % random.randint(0, 0xFFFFFF)
46 return f"#{color.upper()}"
47
48

◆ random_float()

searx.answerers.random.answerer.random_float ( )

Definition at line 26 of file answerer.py.

26def random_float():
27 return str(random.random())
28
29

◆ random_int()

searx.answerers.random.answerer.random_int ( )

Definition at line 30 of file answerer.py.

30def random_int():
31 return str(random.randint(-random_int_max, random_int_max))
32
33

◆ random_sha256()

searx.answerers.random.answerer.random_sha256 ( )

Definition at line 34 of file answerer.py.

34def random_sha256():
35 m = hashlib.sha256()
36 m.update(''.join(random_characters()).encode())
37 return str(m.hexdigest())
38
39

References searx.answerers.random.answerer.random_characters().

+ Here is the call graph for this function:

◆ random_string()

searx.answerers.random.answerer.random_string ( )

Definition at line 22 of file answerer.py.

22def random_string():
23 return ''.join(random_characters())
24
25

References searx.answerers.random.answerer.random_characters().

+ Here is the call graph for this function:

◆ random_uuid()

searx.answerers.random.answerer.random_uuid ( )

Definition at line 40 of file answerer.py.

40def random_uuid():
41 return str(uuid.uuid4())
42
43

◆ self_info()

searx.answerers.random.answerer.self_info ( )

Definition at line 74 of file answerer.py.

74def self_info():
75 return {
76 'name': gettext('Random value generator'),
77 'description': gettext('Generate different random values'),
78 'examples': ['random {}'.format(x) for x in random_types],
79 }

References searx.format.

Variable Documentation

◆ keywords

tuple searx.answerers.random.answerer.keywords = ('random',)

Definition at line 12 of file answerer.py.

◆ random_int_max

int searx.answerers.random.answerer.random_int_max = 2**31

Definition at line 14 of file answerer.py.

◆ random_string_letters

searx.answerers.random.answerer.random_string_letters = string.ascii_lowercase + string.digits + string.ascii_uppercase

Definition at line 15 of file answerer.py.

◆ random_types

dict searx.answerers.random.answerer.random_types
Initial value:
1= {
2 'string': random_string,
3 'int': random_int,
4 'float': random_float,
5 'sha256': random_sha256,
6 'uuid': random_uuid,
7 'color': random_color,
8}

Definition at line 49 of file answerer.py.