X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=phd.py;h=4aa206c47fc1637a83cc65b1b6955a9efbc1fbdd;hb=HEAD;hp=a68db56e5cb2b4f601bdc84f398ab7ecd93c4cd3;hpb=0f441641cea7980190fc22b97bc6779a5e96f1aa;p=phdru.name%2Fphdru.name.git diff --git a/phd.py b/phd.py index a68db56..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) @@ -166,13 +161,9 @@ class phd(Template): % quote_string(query) def lurkmoar(self, query): - return "https://lurkmore.to/%s" % quote_string( + return "http://lurklurk.com/%s" % quote_string( query.replace(' ', '_'), ext_safe=',') 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)