summaryrefslogtreecommitdiff
path: root/sphinx/web/antispam.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2008-01-16 20:27:25 +0000
committerGeorg Brandl <georg@python.org>2008-01-16 20:27:25 +0000
commitb09e628b0f33614e81521ad60e94472a0db09a4d (patch)
tree9fde04d85255a2f7569f8f10def1f2cfe70f303e /sphinx/web/antispam.py
parent1fbdc410b71ab6515ad576ef277700b9dba92d47 (diff)
downloadsphinx-git-b09e628b0f33614e81521ad60e94472a0db09a4d.tar.gz
A few refactorings in Sphinx.
Diffstat (limited to 'sphinx/web/antispam.py')
-rw-r--r--sphinx/web/antispam.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/sphinx/web/antispam.py b/sphinx/web/antispam.py
index ab9f5f666..3c14d9e41 100644
--- a/sphinx/web/antispam.py
+++ b/sphinx/web/antispam.py
@@ -9,7 +9,7 @@
:copyright: 2007-2008 by Armin Ronacher.
:license: BSD.
"""
-from __future__ import with_statement
+
import re
import urllib
import time
@@ -43,14 +43,20 @@ class AntiSpam(object):
else:
lines = [l.strip() for l in data.splitlines()
if not l.startswith('#')]
- with file(bad_content_file, 'w') as f:
+ f = open(bad_content_file, 'w')
+ try:
f.write('\n'.join(lines))
+ finally:
+ f.close()
last_change = int(time.time())
if lines is None:
try:
- with file(bad_content_file) as f:
+ f = open(bad_content_file)
+ try:
lines = [l.strip() for l in f]
+ finally:
+ f.close()
except:
lines = []
self.rules = [re.compile(rule) for rule in lines if rule]