From 61f00a0d333aeb1cb45e98ab4c1902ff1981ad6a Mon Sep 17 00:00:00 2001 From: Bernardo Innocenti Date: Tue, 8 Jan 2008 22:20:13 +0100 Subject: [PATCH] Simplify code in a few places --- geekigeeki.css | 12 ++++++------ geekigeeki.py | 30 +++++++++--------------------- 2 files changed, 15 insertions(+), 27 deletions(-) diff --git a/geekigeeki.css b/geekigeeki.css index d600b7c..0673313 100755 --- a/geekigeeki.css +++ b/geekigeeki.css @@ -124,18 +124,18 @@ h4:hover .heading, h5:hover .heading, h6:hover .heading { visibility: visible; } -strong.success { - padding-left: 0.1em; +strong.DONE { + padding-left: 0.1em; background-color: #22ee22; } -strong.notice { - padding-left: 0.1em; +strong.TODO { + padding-left: 0.1em; background-color: #ffdd44; } -strong.error { - padding-left: 0.1em; +strong.FIXME { + padding-left: 0.1em; background-color: #ee2222; } diff --git a/geekigeeki.py b/geekigeeki.py index 84f1db5..5340646 100755 --- a/geekigeeki.py +++ b/geekigeeki.py @@ -325,11 +325,11 @@ def _macro_TitleIndex(*vargs): for name in pages: letter = string.lower(name[0]) if letter != current_letter: - s = s + '

%s

' % (letter, letter) + s += '

%s

' % (letter, letter) current_letter = letter else: - s = s + '
' - s = s + Page(name).link_to() + s += '
' + s += Page(name).link_to() return s @@ -437,13 +437,7 @@ class PageFormatter: return '' def _hi_repl(self, word): - if word == 'FIXME': - cl = 'error' - elif word == 'DONE': - cl = 'success' - elif word == 'TODO': - cl = 'notice' - return '' + word + '' + return '' + word + '' def _tr_repl(self, word): out = '' @@ -531,6 +525,7 @@ class PageFormatter: pre_re = re.compile( r"(?:" + r"(?P
\s*\}\}\})"
+            + r"|(?P[<>&])"
             + r")")
         blank_re = re.compile(r"^\s*$")
         indent_re = re.compile(r"^\s*")
@@ -579,7 +574,7 @@ class Page:
         return path.join(data_dir, self.page_name)
 
     def _tmp_filename(self):
-        return path.join(data_dir, ('#' + self.page_name + '.' + `os.getpid()` + '#'))
+        return path.join(data_dir, ('#' + self.page_name.replace('/','_') + '.' + `os.getpid()` + '#'))
 
     def exists(self):
         try:
@@ -588,8 +583,7 @@ class Page:
         except OSError, er:
             if er.errno == errno.ENOENT:
                 return False
-            else:
-                raise er
+            raise er
 
     def link_to(self):
         word = self.page_name
@@ -625,10 +619,7 @@ class Page:
         return self.attrs
 
     def get_attr(self, name, default):
-        if self.get_attrs().has_key(name):
-            return self.get_attrs()[name]
-        else:
-            return default
+        return self.get_attrs().get(name, default)
 
     def can(self, action, default=True):
         try:
@@ -637,10 +628,7 @@ class Page:
             for rule in acl.split():
                 (user,perms) = rule.split(':')
                 if user == remote_user() or user == "All":
-                    if action in perms.split(','):
-                        return True
-                    else:
-                        return False
+                    return action in perms.split(',')
             return False
         except Exception, er:
             pass
-- 
2.25.1