forked from LBRYCommunity/lbry-sdk
small cleanups
This commit is contained in:
parent
4a07b56e8a
commit
d5f0001950
1 changed files with 8 additions and 5 deletions
|
@ -18,13 +18,15 @@ blobhash_length = get_lbry_hash_obj().digest_size * 2
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# defining this here allows for easier overriding in testing
|
||||
# defining these time functions here allows for easier overriding in testing
|
||||
def now():
|
||||
return datetime.datetime.now()
|
||||
|
||||
|
||||
def utcnow():
|
||||
return datetime.datetime.utcnow()
|
||||
|
||||
|
||||
def isonow():
|
||||
"""Return utc now in isoformat with timezone"""
|
||||
return utcnow().isoformat() + 'Z'
|
||||
|
@ -42,6 +44,10 @@ def generate_id(num=None):
|
|||
return h.digest()
|
||||
|
||||
|
||||
def is_valid_hashcharacter(char):
|
||||
return char in "0123456789abcdef"
|
||||
|
||||
|
||||
def is_valid_blobhash(blobhash):
|
||||
"""
|
||||
@param blobhash: string, the blobhash to check
|
||||
|
@ -50,10 +56,7 @@ def is_valid_blobhash(blobhash):
|
|||
"""
|
||||
if len(blobhash) != blobhash_length:
|
||||
return False
|
||||
for l in blobhash:
|
||||
if l not in "0123456789abcdef":
|
||||
return False
|
||||
return True
|
||||
return all(is_valid_hashcharacter(l) for l in blobhash)
|
||||
|
||||
|
||||
def version_is_greater_than(a, b):
|
||||
|
|
Loading…
Reference in a new issue