Skip to content

Commit

Permalink
Fixed a bunch of errors detected by pychecker -- unneeded imports and…
Browse files Browse the repository at this point in the history
… shadows of builtin variable names

git-svn-id: http://code.djangoproject.com/svn/django/trunk@2058 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
adrianholovaty committed Jan 19, 2006
1 parent ce40c4a commit c12c225
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 20 deletions.
8 changes: 4 additions & 4 deletions django/bin/compile-messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ def compile_messages():
sys.exit(1)

for (dirpath, dirnames, filenames) in os.walk(basedir):
for file in filenames:
if file.endswith('.po'):
sys.stderr.write('processing file %s in %s\n' % (file, dirpath))
pf = os.path.splitext(os.path.join(dirpath, file))[0]
for f in filenames:
if f.endswith('.po'):
sys.stderr.write('processing file %s in %s\n' % (f, dirpath))
pf = os.path.splitext(os.path.join(dirpath, f))[0]
cmd = 'msgfmt -o "%s.mo" "%s.po"' % (pf, pf)
os.system(cmd)

Expand Down
9 changes: 4 additions & 5 deletions django/bin/unique-messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import os
import sys
import getopt

def unique_messages():
basedir = None
Expand All @@ -16,10 +15,10 @@ def unique_messages():
sys.exit(1)

for (dirpath, dirnames, filenames) in os.walk(basedir):
for file in filenames:
if file.endswith('.po'):
sys.stderr.write('processing file %s in %s\n' % (file, dirpath))
pf = os.path.splitext(os.path.join(dirpath, file))[0]
for f in filenames:
if f.endswith('.po'):
sys.stderr.write('processing file %s in %s\n' % (f, dirpath))
pf = os.path.splitext(os.path.join(dirpath, f))[0]
cmd = 'msguniq "%s.po"' % pf
stdout = os.popen(cmd)
msg = stdout.read()
Expand Down
7 changes: 4 additions & 3 deletions django/utils/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
unencoded_ampersands_re = re.compile(r'&(?!(\w+|#\d+);)')
word_split_re = re.compile(r'(\s+)')
punctuation_re = re.compile('^(?P<lead>(?:%s)*)(?P<middle>.*?)(?P<trail>(?:%s)*)$' % \
('|'.join([re.escape(p) for p in LEADING_PUNCTUATION]),
'|'.join([re.escape(p) for p in TRAILING_PUNCTUATION])))
('|'.join([re.escape(x) for x in LEADING_PUNCTUATION]),
'|'.join([re.escape(x) for x in TRAILING_PUNCTUATION])))
simple_email_re = re.compile(r'^\S+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+$')
link_target_attribute_re = re.compile(r'(<a [^>]*?)target=[^\s>]+')
html_gunk_re = re.compile(r'(?:<br clear="all">|<i><\/i>|<b><\/b>|<em><\/em>|<strong><\/strong>|<\/?smallcaps>|<\/?uppercase>)', re.IGNORECASE)
hard_coded_bullets_re = re.compile(r'((?:<p>(?:%s).*?[a-zA-Z].*?</p>\s*)+)' % '|'.join([re.escape(d) for d in DOTS]), re.DOTALL)
hard_coded_bullets_re = re.compile(r'((?:<p>(?:%s).*?[a-zA-Z].*?</p>\s*)+)' % '|'.join([re.escape(x) for x in DOTS]), re.DOTALL)
trailing_empty_content_re = re.compile(r'(?:<p>(?:&nbsp;|\s|<br \/>)*?</p>\s*)+\Z')
del x # Temporary variable

def escape(html):
"Returns the given HTML with ampersands, quotes and carets encoded"
Expand Down
2 changes: 1 addition & 1 deletion django/views/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from django.core.template import Template, Context, TemplateDoesNotExist
from django.utils.html import escape
from django.utils.httpwrappers import HttpResponseServerError, HttpResponseNotFound
import inspect, os, re, sys
import os, re
from itertools import count, izip
from os.path import dirname, join as pathjoin

Expand Down
11 changes: 4 additions & 7 deletions django/views/i18n.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import re
import os

import gettext as gettext_module

from django.utils import httpwrappers
from django.utils.translation import check_for_language, activate, to_locale, get_language
from django.utils.text import javascript_quote
from django.conf import settings
import os
import gettext as gettext_module

def set_language(request):
"""
Expand Down Expand Up @@ -145,7 +142,7 @@ def javascript_catalog(request, domain='djangojs', packages=None):
for path in paths:
try:
catalog = gettext_module.translation(domain, path, [default_locale])
except IOError, e:
except IOError:
catalog = None
if catalog is not None:
t.update(catalog._catalog)
Expand All @@ -154,7 +151,7 @@ def javascript_catalog(request, domain='djangojs', packages=None):
for path in paths:
try:
catalog = gettext_module.translation(domain, path, [locale])
except IOError, e:
except IOError:
catalog = None
if catalog is not None:
t.update(catalog._catalog)
Expand Down

0 comments on commit c12c225

Please sign in to comment.