mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-17 06:00:42 +01:00
Hashes: remove duplicate check for hashlib.algorithms_available
This code is never wrap()'ed if the attribute is unavailable, so it isn't necessary to check for it in runtime twice.
This commit is contained in:
parent
287610b776
commit
fffe1efa9b
@ -84,10 +84,8 @@ class Hashes(callbacks.Plugin):
|
|||||||
"""<takes no arguments>
|
"""<takes no arguments>
|
||||||
|
|
||||||
Returns the list of available algorithms."""
|
Returns the list of available algorithms."""
|
||||||
try:
|
irc.reply(utils.str.format("%L", hashlib.algorithms_available))
|
||||||
irc.reply(utils.str.format("%L", hashlib.algorithms_available))
|
|
||||||
except AttributeError:
|
|
||||||
pass # allow building but not using, usually python <2.7
|
|
||||||
if hasattr(hashlib, 'algorithms_available'):
|
if hasattr(hashlib, 'algorithms_available'):
|
||||||
algorithms = wrap(algorithms)
|
algorithms = wrap(algorithms)
|
||||||
|
|
||||||
@ -96,12 +94,7 @@ class Hashes(callbacks.Plugin):
|
|||||||
"""<algorithm> <text>
|
"""<algorithm> <text>
|
||||||
|
|
||||||
Returns TEXT after it has been hashed with ALGORITHM. See the 'algorithms' command in this plugin to return the algorithms available on this system."""
|
Returns TEXT after it has been hashed with ALGORITHM. See the 'algorithms' command in this plugin to return the algorithms available on this system."""
|
||||||
algos = []
|
if algorithm not in hashlib.algorithms_available:
|
||||||
try:
|
|
||||||
algos = hashlib.algorithms_available
|
|
||||||
except:
|
|
||||||
pass # allow building but not using, usually python <2.7
|
|
||||||
if algorithm not in algos:
|
|
||||||
irc.error("Algorithm not available.")
|
irc.error("Algorithm not available.")
|
||||||
else:
|
else:
|
||||||
irc.reply(hashlib.new(algorithm, text.encode('utf8')).hexdigest())
|
irc.reply(hashlib.new(algorithm, text.encode('utf8')).hexdigest())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user