Skip to content

Commit 9615146

Browse files
committed
v0.0.6: corrected handling of custom symbols
1 parent 6c1de01 commit 9615146

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

PyRandomString/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,9 @@ def get_strings(self, count: int = 10, max_length: int = 10, random_length: bool
124124
if count > 0 and max_length > 0:
125125
list_of_input_strings = self.__get_input_strings_from_string_type(string_type)
126126

127-
# checking if user have specified any custom symbols, then the default symbols will be overridden
128-
list_of_input_strings = ['{}{}'.format(_temp_string, symbols) if '@' in _temp_string else _temp_string for _temp_string in list_of_input_strings]
127+
if symbols:
128+
# checking if user have specified any custom symbols, then the default symbols will be overridden
129+
list_of_input_strings = [symbols if '@' in entry else entry for entry in list_of_input_strings]
129130

130131
input_characters = list_of_input_strings if must_include_all_type else ''.join(list_of_input_strings)
131132
list_of_strings = self.__get_strings(count, max_length, random_length, input_characters)
@@ -184,7 +185,7 @@ def __validate_input(self, count: int, max_length: int, random_length: bool, str
184185
if symbols and not isinstance(symbols, str):
185186
raise UnsupportedTypeException('symbols', f'symbols should be either None or of string type instead of current {type(symbols)} type')
186187

187-
if symbols and not re.match('[{}]'.format({StringType.SYMBOLS.value}), symbols):
188+
if symbols and not re.match('[{}]'.format(StringType.SYMBOLS.value), symbols):
188189
raise InvalidInputSymbolsException(symbols)
189190

190191
def __get_input_strings_from_string_type(self, string_type: StringType) -> list:

0 commit comments

Comments
 (0)