add docstrings

This commit is contained in:
meejah 2019-06-17 18:55:26 -06:00
parent d0296b9ae8
commit c2fbbe4f46

View File

@ -1,12 +1,21 @@
class BadSignature(Exception):
pass
"""
An alleged signature did not match
"""
class BadPrefixError(Exception):
pass
"""
A key did not start with the required prefix
"""
def remove_prefix(s_bytes, prefix):
"""
Removes `prefix` from `s_bytes` safely
"""
if not s_bytes.startswith(prefix):
raise BadPrefixError("did not see expected '%s' prefix" % (prefix,))
raise BadPrefixError(
"did not see expected '{}' prefix".format(prefix)
)
return s_bytes[len(prefix):]