Skip to content
Permalink
Browse files
Fix section color hashing when using Python 2
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Jul 3, 2016
1 parent b90364e commit 01b65f882a533906730b36f58433ff3f9aafb304
Showing with 9 additions and 1 deletion.
  1. +1 −0 CHANGES.txt
  2. +8 −1 nikola/utils.py
@@ -11,6 +11,7 @@ Features
Bugfixes
--------

* Fix section color hashing when using Python 2
* Use ``en_US`` dictionary name with pyphen for better compatibility
* Fix graceful degradation if ``pyphen`` lacks dictionaries
* Add horizontal scrollbar to listings (via getnikola/nikola-themes#86)
@@ -1801,7 +1801,14 @@ def colorize_str_from_base_color(string, base_color):
lightness and saturation untouched using HUSL colorspace.
"""
def hash_str(string, pos):
return hashlib.md5(string.encode('utf-8')).digest()[pos]
x = hashlib.md5(string.encode('utf-8')).digest()[pos]
try:
# Python 2: a string
# TODO: remove in v8
return ord(x)
except TypeError:
# Python 3: already an integer
return x

def degreediff(dega, degb):
return min(abs(dega - degb), abs((degb - dega) + 360))

0 comments on commit 01b65f8

Please sign in to comment.