浏览代码

fix python 3 issue.

Brian Levin 8 年之前
父节点
当前提交
aac9388ac2
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      photos/photos.py

+ 2 - 1
photos/photos.py

@@ -6,6 +6,7 @@ import logging
 import os
 import pprint
 import re
+import sys
 
 from pelican.generators import ArticlesGenerator
 from pelican.generators import PagesGenerator
@@ -235,7 +236,7 @@ def detect_content(content):
 def galleries_string_decompose(gallery_string):
     splitter_regex = re.compile(r'[\s,]*?({photo}|{filename})')
     title_regex = re.compile(r'{(.+)}')
-    galleries = map(unicode.strip, filter(None, splitter_regex.split(gallery_string)))
+    galleries = map(unicode.strip if sys.version_info.major == 2 else str.strip, filter(None, splitter_regex.split(gallery_string)))
     galleries = [gallery[1:] if gallery.startswith('/') else gallery for gallery in galleries]
     if len(galleries) % 2 == 0 and u' ' not in galleries:
         galleries = zip(zip(['type'] * len(galleries[0::2]), galleries[0::2]), zip(['location'] * len(galleries[0::2]), galleries[1::2]))