X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=phd.py;h=5b90ae6c747ec5ee73578a4095e0b97a657a6c7c;hb=1afa1542b43c3400cdf58b66d4c7c1e7c60c2e9a;hp=4aa206c47fc1637a83cc65b1b6955a9efbc1fbdd;hpb=33696afc1063447e40c536da982db78ce3e0f9cd;p=phdru.name%2Fphdru.name.git diff --git a/phd.py b/phd.py index 4aa206c..5b90ae6 100644 --- a/phd.py +++ b/phd.py @@ -1,10 +1,9 @@ import os, re, time -try: - from urllib import quote as url_quote -except ImportError: - from urllib.parse import quote as url_quote +from urllib.parse import quote as url_quote + from Cheetah.Template import Template from Cheetah.compat import PY2 + from blog_db import load_blog @@ -31,7 +30,7 @@ class phd(Template): if dirs_to_root: root = "../"*dirs_to_root else: - root = '' + root = './' self.root = root path = '/'.join(directories) + '/' + \ self._fileBaseName.replace(".tmpl", ".html") @@ -63,8 +62,6 @@ class phd(Template): new_paras = [] for p in paragraphs: - if PY2 and not isinstance(p, bytes): - p = p.encode('utf-8') parts = p.split("\n ") parts[0] = parts[0].strip() new_paras.append('\n

\n

\n'.join(parts)) @@ -95,8 +92,6 @@ class phd(Template): for part in (title, subtitle, body): if not part: continue - if PY2 and not isinstance(part, bytes): - part = part.encode('utf-8') parts.append(part) return "\n\n".join(parts) @@ -171,8 +166,4 @@ class phd(Template): def quote_string(s, to_encoding="utf-8", ext_safe=''): - if isinstance(s, bytes): - s = s.decode("utf-8") - if PY2: - s = s.encode(to_encoding) return url_quote(s, '/' + ext_safe)