Cleanup remaining usage of % comprehensions without explicit tuples.

This commit is contained in:
Tim Abbott 2015-12-01 08:11:16 -08:00
parent 74853709a8
commit a79e89b28f
13 changed files with 26 additions and 26 deletions

View File

@ -37,7 +37,7 @@ class Command(BaseCommand):
user_info[last_presence.user_profile.realm.domain][bucket].append(last_presence.user_profile.email)
for realm, buckets in user_info.items():
print("Realm %s" % realm)
print("Realm %s" % (realm,))
for hr, users in sorted(buckets.items()):
print("\tUsers for %s: %s" % (hr, len(users)))
statsd.gauge("users.active.%s.%shr" % (statsd_key(realm, True), statsd_key(hr, True)), len(users))
@ -52,7 +52,7 @@ class Command(BaseCommand):
if datetime.now(activity.last_visit.tzinfo) - activity.last_visit < timedelta(hours=bucket):
user_info[activity.user_profile.realm.domain][bucket].append(activity.user_profile.email)
for realm, buckets in user_info.items():
print("Realm %s" % realm)
print("Realm %s" % (realm,))
for hr, users in sorted(buckets.items()):
print("\tUsers reading for %s: %s" % (hr, len(users)))
statsd.gauge("users.reading.%s.%shr" % (statsd_key(realm, True), statsd_key(hr, True)), len(users))

View File

@ -110,7 +110,7 @@ def handle_event(event):
project_name = raw_props.get('name')
project_repo_type = raw_props.get('scm_type')
url = make_url("projects/%s" % project_link)
url = make_url("projects/%s" % (project_link,))
scm = "of type %s" % (project_repo_type,) if project_repo_type else ""

View File

@ -93,7 +93,7 @@ for device in macs.values():
if address_of(device_number) is None:
# If the device was not autoconfigured, do so now.
log.info("Device eth%i not configured, starting dhcpd" % device_number)
log.info("Device eth%i not configured, starting dhcpd" % (device_number,))
subprocess.check_call(['/sbin/dhcpcd', 'eth%i' % device_number])
# Horrible hack to route return packets on the correct interface

View File

@ -66,7 +66,7 @@ Name a range of commits, or name a single commit (e.g., 'HEAD^' or
If you set REVIEW_USE_SENDMAIL to be nonempty, /usr/bin/sendmail will
be used to mail the review request. Otherwise, msmtp will be used by
default.
""".strip() % CC_EMAIL
""".strip() % (CC_EMAIL,)
def parse_options(args):
@ -126,7 +126,7 @@ def get_reponame(repo):
remote = get_default_remote(repo)
try:
url = repo.git.config('--get', 'remote.%s.url' % remote)
url = repo.git.config('--get', 'remote.%s.url' % (remote,))
except git.exc.GitCommandError:
url = repo.wd

View File

@ -50,7 +50,7 @@ def get_changed_source_files(other_checkout):
# regenerate everything.
print "Warning: git returned an error when comparing to the previous"
print ("deploy in %s. Will re-minify JavaScript instead of reusing"
% other_checkout)
% (other_checkout,))
return None
changed = set()

View File

@ -148,7 +148,7 @@ class ConnectionHandler:
return
self._connect_target()
payload = '%s %s %s\n'%(self.method, self.path, self.protocol)
payload = '%s %s %s\n' % (self.method, self.path, self.protocol)
buf = payload
try:
headers, rest = self.client_buffer.split('\r\n\r\n')
@ -235,7 +235,7 @@ def start_server(host='localhost', port=PORT, IPv6=False, timeout=60,
soc = socket.socket(soc_type)
soc.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
soc.bind((host, port))
print "Serving on %s:%d."%(host, port)#debug
print "Serving on %s:%d." % (host, port) #debug
soc.listen(0)
while 1:
thread.start_new_thread(handler, soc.accept()+(timeout,))

View File

@ -2756,17 +2756,17 @@ def handle_push_notification(user_profile_id, missed_message):
except UserMessage.DoesNotExist:
logging.error("Could not find UserMessage with message_id %s" %(missed_message['message_id'],))
def is_inactive(value):
def is_inactive(email):
try:
if get_user_profile_by_email(value).is_active:
raise ValidationError(u'%s is already active' % value)
if get_user_profile_by_email(email).is_active:
raise ValidationError(u'%s is already active' % (email,))
except UserProfile.DoesNotExist:
pass
def user_email_is_unique(value):
def user_email_is_unique(email):
try:
get_user_profile_by_email(value)
raise ValidationError(u'%s is already registered' % value)
get_user_profile_by_email(email)
raise ValidationError(u'%s is already registered' % (email,))
except UserProfile.DoesNotExist:
pass

View File

@ -59,19 +59,19 @@ Usage: python2.7 manage.py import_dump [--destroy-rebuild-database] [--chunk-siz
def test_table_row_count(self, row_counter, model):
table_name = model._meta.db_table
sys.stdout.write("%s: " % table_name)
sys.stdout.write("%s: " % (table_name,))
expected_count = row_counter.get(table_name) or 0
actual_count = model.objects.count()
status = "PASSED" if expected_count == actual_count else "FAILED"
params = (expected_count, actual_count, status)
sys.stdout.write("expected %d rows, got %d. %s\n" % params)
sys.stdout.write("expected %d rows, got %d. %s\n" %
(expected_count, actual_count, status))
def import_table(self, database_dump, realm_notification_map, model):
table_name = model._meta.db_table
if table_name in database_dump:
cursor = connection.cursor()
sys.stdout.write("Importing %s: " % table_name)
sys.stdout.write("Importing %s: " % (table_name,))
accumulator = [ ]
for row in database_dump[table_name]:
# hack to filter out notifications_stream_id circular reference

View File

@ -59,7 +59,7 @@ class Command(BaseCommand):
addr = '127.0.0.1'
if not port.isdigit():
raise CommandError("%r is not a valid port number." % port)
raise CommandError("%r is not a valid port number." % (port,))
xheaders = options.get('xheaders', True)
no_keep_alive = options.get('no_keep_alive', False)

View File

@ -26,9 +26,9 @@ def minified_js(parser, token):
try:
tag_name, sourcefile = token.split_contents()
except ValueError:
raise TemplateSyntaxError("%s tag requires an argument" % tag_name)
raise TemplateSyntaxError("%s tag requires an argument" % (tag_name,))
if not (sourcefile[0] == sourcefile[-1] and sourcefile[0] in ('"', "'")):
raise TemplateSyntaxError("%s tag should be quoted" % tag_name)
raise TemplateSyntaxError("%s tag should be quoted" % (tag_name,))
sourcefile = sourcefile[1:-1]
if sourcefile not in settings.JS_SPECS:

View File

@ -338,7 +338,7 @@ dave-test@zulip.com
earl-test@zulip.com""", ["Denmark"]))
for user in ("bob", "carol", "dave", "earl"):
self.assertTrue(find_key_by_email("%s-test@zulip.com" % user))
self.assertTrue(find_key_by_email("%s-test@zulip.com" % (user,)))
self.check_sent_emails(["bob-test@zulip.com", "carol-test@zulip.com",
"dave-test@zulip.com", "earl-test@zulip.com"])

View File

@ -333,7 +333,7 @@ def json_invite_users(request, user_profile, invitee_emails=REQ):
for stream_name in stream_names:
stream = get_stream(stream_name, user_profile.realm)
if stream is None:
return json_error("Stream does not exist: %s. No invites were sent." % stream_name)
return json_error("Stream does not exist: %s. No invites were sent." % (stream_name,))
streams.append(stream)
ret_error, error_data = do_invite_users(user_profile, invitee_emails, streams)
@ -515,7 +515,7 @@ def finish_google_oauth2(request):
if email['type'] == 'account':
break
else:
raise Exception('Google oauth2 account email not found %r' % body)
raise Exception('Google oauth2 account email not found %r' % (body,))
email_address = email['value']
user_profile = authenticate(username=email_address, use_dummy_backend=True)
return login_or_register_remote_user(request, email_address, user_profile, full_name)

View File

@ -37,7 +37,7 @@ def get_ticket_number():
ticket_number = int(open(fn).read()) + 1
except:
ticket_number = 1
open(fn, 'w').write('%d' % ticket_number)
open(fn, 'w').write('%d' % (ticket_number,))
return ticket_number
@has_request_variables