From a79e89b28f6b8bf9e9d4860536fba3845a17b0db Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Tue, 1 Dec 2015 08:11:16 -0800 Subject: [PATCH] Cleanup remaining usage of % comprehensions without explicit tuples. --- analytics/management/commands/active_user_stats.py | 4 ++-- api/integrations/codebase/zulip_codebase_mirror | 2 +- .../files/zulip-ec2-configure-interfaces | 2 +- tools/deprecated/review | 4 ++-- tools/minify-js | 2 +- tools/python-proxy | 4 ++-- zerver/lib/actions.py | 12 ++++++------ zerver/management/commands/import_dump.py | 8 ++++---- zerver/management/commands/runtornado.py | 2 +- zerver/templatetags/minified_js.py | 4 ++-- zerver/test_signup.py | 2 +- zerver/views/__init__.py | 4 ++-- zilencer/views.py | 2 +- 13 files changed, 26 insertions(+), 26 deletions(-) diff --git a/analytics/management/commands/active_user_stats.py b/analytics/management/commands/active_user_stats.py index c6b32e48ec..8c6e6beff9 100644 --- a/analytics/management/commands/active_user_stats.py +++ b/analytics/management/commands/active_user_stats.py @@ -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)) diff --git a/api/integrations/codebase/zulip_codebase_mirror b/api/integrations/codebase/zulip_codebase_mirror index c3e7863619..847cef6aed 100755 --- a/api/integrations/codebase/zulip_codebase_mirror +++ b/api/integrations/codebase/zulip_codebase_mirror @@ -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 "" diff --git a/puppet/zulip_internal/files/zulip-ec2-configure-interfaces b/puppet/zulip_internal/files/zulip-ec2-configure-interfaces index 497bc4e2f1..7ca7b1c120 100755 --- a/puppet/zulip_internal/files/zulip-ec2-configure-interfaces +++ b/puppet/zulip_internal/files/zulip-ec2-configure-interfaces @@ -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 diff --git a/tools/deprecated/review b/tools/deprecated/review index 0b87077828..6597522e44 100755 --- a/tools/deprecated/review +++ b/tools/deprecated/review @@ -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 diff --git a/tools/minify-js b/tools/minify-js index a2d1f058a6..e9326f6b7e 100755 --- a/tools/minify-js +++ b/tools/minify-js @@ -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() diff --git a/tools/python-proxy b/tools/python-proxy index 90ccf9271f..070e137095 100755 --- a/tools/python-proxy +++ b/tools/python-proxy @@ -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,)) diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py index 167c0329cd..9fc400853f 100644 --- a/zerver/lib/actions.py +++ b/zerver/lib/actions.py @@ -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 diff --git a/zerver/management/commands/import_dump.py b/zerver/management/commands/import_dump.py index d518d698be..227cdcd463 100644 --- a/zerver/management/commands/import_dump.py +++ b/zerver/management/commands/import_dump.py @@ -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 diff --git a/zerver/management/commands/runtornado.py b/zerver/management/commands/runtornado.py index 68f96c9691..bafe6fccbb 100644 --- a/zerver/management/commands/runtornado.py +++ b/zerver/management/commands/runtornado.py @@ -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) diff --git a/zerver/templatetags/minified_js.py b/zerver/templatetags/minified_js.py index 2579611ba2..f941813668 100644 --- a/zerver/templatetags/minified_js.py +++ b/zerver/templatetags/minified_js.py @@ -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: diff --git a/zerver/test_signup.py b/zerver/test_signup.py index baa61a0112..2489a81329 100644 --- a/zerver/test_signup.py +++ b/zerver/test_signup.py @@ -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"]) diff --git a/zerver/views/__init__.py b/zerver/views/__init__.py index 0377924e4b..c209219fea 100644 --- a/zerver/views/__init__.py +++ b/zerver/views/__init__.py @@ -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) diff --git a/zilencer/views.py b/zilencer/views.py index 14f4548883..03586be426 100644 --- a/zilencer/views.py +++ b/zilencer/views.py @@ -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