MCPcopy Create free account
hub / github.com/Keeper-Security/Commander / resolve_gen_password_algorithm

Function resolve_gen_password_algorithm

keepercommander/generator.py:227–243  ·  view source on GitHub ↗

Resolve $GEN password algorithm; return (algorithm, error_message).

(parameters)

Source from the content-addressed store, hash-verified

225
226
227def resolve_gen_password_algorithm(parameters):
228 # type: (Optional[Sequence[str]]) -> Tuple[Optional[str], Optional[str]]
229 """Resolve $GEN password algorithm; return (algorithm, error_message)."""
230 if not parameters:
231 return 'rand', None
232 first = parameters[0].strip()
233 first_lower = first.lower()
234 if first_lower in GEN_PASSWORD_ALGORITHMS:
235 return first_lower, None
236 if first.isdigit():
237 return 'rand', None
238 suggestions = difflib.get_close_matches(first_lower, GEN_PASSWORD_ALGORITHMS, n=1, cutoff=0.6)
239 message = f'Unknown $GEN password algorithm "{first}".'
240 if suggestions:
241 message += f' Did you mean "{suggestions[0]}"?'
242 message += f' Valid algorithms: {", ".join(GEN_PASSWORD_ALGORITHMS)}.'
243 return None, message
244
245
246def _parse_gen_bool(value):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected