소스 검색

Merge pull request #754 from bnice5000/photos_py3_patch

Photos: Fix Python 3 incompatibility
Justin Mayer 8 년 전
부모
커밋
73fc03524d
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]))