Fix errors with Python3
This commit is contained in:
parent
4ece9e9079
commit
0d5d5ce535
|
@ -102,7 +102,7 @@ except ImportError:
|
|||
import optparse
|
||||
from random import random, randint
|
||||
import codecs
|
||||
|
||||
import urllib.parse
|
||||
|
||||
# ---- Python version compat
|
||||
|
||||
|
@ -1273,7 +1273,7 @@ class Markdown(object):
|
|||
if is_inline_img:
|
||||
img_class_str = ' class="inlineimage"'
|
||||
result = '<img src="%s" alt="%s"%s%s%s' \
|
||||
% (url.replace('"', '"'),
|
||||
% (urllib.parse.quote(url),
|
||||
_xml_escape_attr(link_text),
|
||||
title_str, img_class_str, self.empty_element_suffix)
|
||||
if "smarty-pants" in self.extras:
|
||||
|
@ -1323,7 +1323,7 @@ class Markdown(object):
|
|||
if is_img:
|
||||
img_class_str = self._html_class_str_from_tag("img")
|
||||
result = '<img src="%s" alt="%s"%s%s%s' \
|
||||
% (url.replace('"', '"'),
|
||||
% (urllib.parse.quote(url),
|
||||
link_text.replace('"', '"'),
|
||||
title_str, img_class_str, self.empty_element_suffix)
|
||||
if "smarty-pants" in self.extras:
|
||||
|
|
|
@ -116,7 +116,7 @@ class Blog(models.Model):
|
|||
if os.path.isdir(srcname):
|
||||
if not os.path.exists(dstname):
|
||||
os.makedirs(dstname)
|
||||
self.copytree(srcname, dstname, ignore=True)
|
||||
shutil.copytree(srcname, dstname, ignore=True)
|
||||
else:
|
||||
return self.copytree(srcname, dstname)
|
||||
else:
|
||||
|
@ -187,7 +187,11 @@ class Blog(models.Model):
|
|||
if obj.__module__ in generated: continue
|
||||
e = obj(hash_posts, hash_posts_content)
|
||||
print('Go for {}'.format(e))
|
||||
r = e.generate(self, self.src_path, self.output_path)
|
||||
try:
|
||||
r = e.generate(self, self.src_path, self.output_path)
|
||||
except Exception as err:
|
||||
self.report += err
|
||||
continue
|
||||
generated.append(obj.__module__)
|
||||
if not r is None:
|
||||
self.report = self.report + '<br/>\n' + r
|
||||
|
|
|
@ -192,7 +192,7 @@ class Search:
|
|||
def search(self, blog, string):
|
||||
hashtable = self._loadDatabase(blog)
|
||||
|
||||
string = self._prepare_string(string.encode('utf-8'))
|
||||
string = self._prepare_string(string)
|
||||
|
||||
wordlist = string.split(' ')
|
||||
|
||||
|
@ -207,8 +207,7 @@ class Search:
|
|||
for post in hashtable[key]:
|
||||
res[post[0]] = res.get(post[0],0) + post[1]
|
||||
|
||||
sorted_res = sorted(res.iteritems(), key=operator.itemgetter(1))
|
||||
sorted_res.reverse()
|
||||
sorted_res = sorted(res.items(), key=operator.itemgetter(1), reverse=True)
|
||||
|
||||
res = [sorted_res[i][0] for i in range(len(sorted_res))]
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user