Refactor add_appointment cli code

This commit is contained in:
Turtle
2019-11-30 00:42:36 -05:00
parent 49657ccbfc
commit 40d7ca1912
5 changed files with 162 additions and 106 deletions

View File

@@ -1,4 +1,5 @@
import re
from common.constants import LOCATOR_LEN_HEX
def check_sha256_hex_format(value):
@@ -12,3 +13,15 @@ def check_sha256_hex_format(value):
:mod:`bool`: Whether or not the value matches the format.
"""
return isinstance(value, str) and re.match(r"^[0-9A-Fa-f]{64}$", value) is not None
def compute_locator(tx_id):
"""
Computes an appointment locator given a transaction id.
Args:
tx_id (:obj:`str`): the transaction id used to compute the locator.
Returns:
(:obj:`str`): The computed locator.
"""
return tx_id[:LOCATOR_LEN_HEX]