11# fmt: off
22def a_plus_b (a , b ):
3+ """Calculate the sum of two numbers.
4+
5+ Args:
6+ a (int or float): The first number.
7+ b (int or float): The second number.
8+
9+ Returns:
10+ int or float: The sum of the two numbers.
11+ """
312 return a + b
413
514
615def sqlite (db , query ):
16+ """Executes a SQL query on a given SQLite database and retrieves all results.
17+
18+ Args:
19+ db (sqlite3.Connection): The SQLite database connection object.
20+ query (str): The SQL query string to be executed.
21+
22+ Returns:
23+ list: A list of tuples containing the rows returned by the query.
24+ """
25+
726 cursor = db .cursor ()
827 cursor .execute (query )
928 return cursor .fetchall ()
1029
1130
1231def compare (key_map , item1 , item2 ):
32+ """Compares two items using a key mapping function and returns an integer based on the comparison.
33+
34+ Args:
35+ key_map (Callable): A function that takes an item as input and returns a comparable key.
36+ item1 (Any): The first item to compare.
37+ item2 (Any): The second item to compare.
38+
39+ Returns:
40+ int: Returns -1 if the key of item1 is less than the key of item2, 1 if it's greater, or 0 if they are equal.
41+ """
42+
1343 if key_map (item1 ) < key_map (item2 ):
1444 return - 1
1545 elif key_map (item1 ) > key_map (item2 ):
@@ -21,4 +51,13 @@ def compare(key_map, item1, item2):
2151def random_alphabets (
2252 length : int
2353):
54+ """Generate a random string of alphabets of specified length.
55+
56+ Args:
57+ length (int): The length of the random alphabet string to generate.
58+
59+ Returns:
60+ str: A string consisting of random alphabets with the specified length.
61+ """
62+
2463 return '' .join (random .choices (string .ascii_letters , k = length ))
0 commit comments