]> git.phdru.name Git - phdru.name/phdru.name.git/blobdiff - phd.py
Refactor(reindex_blog.py): Get rid of `cgi`
[phdru.name/phdru.name.git] / phd.py
diff --git a/phd.py b/phd.py
index 4aa206c47fc1637a83cc65b1b6955a9efbc1fbdd..5b90ae6c747ec5ee73578a4095e0b97a657a6c7c 100644 (file)
--- 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</p>\n<p>\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)