Skip to content
Snippets Groups Projects
Verified Commit 1f281132 authored by Philip Gaber's avatar Philip Gaber
Browse files

fix: Consistent boolean parameter checking

parent bca3240d
No related branches found
No related tags found
1 merge request!5fix: Consistent type checking
......@@ -7,6 +7,7 @@ import glob
import base64
import random
import string
import sys
class RandomUser:
......@@ -41,11 +42,21 @@ class RandomUser:
person["email"] = password_reset_mail
person['is_admin'] = False
callback(person)
if create_admins:
if self.__option2bool(create_admins):
person['username'] = self.__get_username(person["firstname"], person["lastname"], admin=True)
person['is_admin'] = True
callback(person)
def __option2bool(self, string):
if isinstance(string, (bool)):
return string
elif string.lower() in ['true', 'yes', 'ok']:
return True
elif string.lower() in ['false', 'no', 'nok']:
return False
else:
sys.exit(f"Cannot convert {string} into a boolean value.")
def __get_firstname_and_gender(self):
to_split_result = self.__get_random_list_entry("firstname")
return to_split_result.split('\t')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment

Consent

On this website, we use the web analytics service Matomo to analyze and review the use of our website. Through the collected statistics, we can improve our offerings and make them more appealing for you. Here, you can decide whether to allow us to process your data and set corresponding cookies for these purposes, in addition to technically necessary cookies. Further information on data protection—especially regarding "cookies" and "Matomo"—can be found in our privacy policy. You can withdraw your consent at any time.