mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 09:27:43 +00:00
Cleanup remaining usage of % comprehensions without explicit tuples.
This commit is contained in:
@@ -37,7 +37,7 @@ class Command(BaseCommand):
|
|||||||
user_info[last_presence.user_profile.realm.domain][bucket].append(last_presence.user_profile.email)
|
user_info[last_presence.user_profile.realm.domain][bucket].append(last_presence.user_profile.email)
|
||||||
|
|
||||||
for realm, buckets in user_info.items():
|
for realm, buckets in user_info.items():
|
||||||
print("Realm %s" % realm)
|
print("Realm %s" % (realm,))
|
||||||
for hr, users in sorted(buckets.items()):
|
for hr, users in sorted(buckets.items()):
|
||||||
print("\tUsers for %s: %s" % (hr, len(users)))
|
print("\tUsers for %s: %s" % (hr, len(users)))
|
||||||
statsd.gauge("users.active.%s.%shr" % (statsd_key(realm, True), statsd_key(hr, True)), 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):
|
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)
|
user_info[activity.user_profile.realm.domain][bucket].append(activity.user_profile.email)
|
||||||
for realm, buckets in user_info.items():
|
for realm, buckets in user_info.items():
|
||||||
print("Realm %s" % realm)
|
print("Realm %s" % (realm,))
|
||||||
for hr, users in sorted(buckets.items()):
|
for hr, users in sorted(buckets.items()):
|
||||||
print("\tUsers reading for %s: %s" % (hr, len(users)))
|
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))
|
statsd.gauge("users.reading.%s.%shr" % (statsd_key(realm, True), statsd_key(hr, True)), len(users))
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ def handle_event(event):
|
|||||||
project_name = raw_props.get('name')
|
project_name = raw_props.get('name')
|
||||||
project_repo_type = raw_props.get('scm_type')
|
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 ""
|
scm = "of type %s" % (project_repo_type,) if project_repo_type else ""
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ for device in macs.values():
|
|||||||
|
|
||||||
if address_of(device_number) is None:
|
if address_of(device_number) is None:
|
||||||
# If the device was not autoconfigured, do so now.
|
# 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])
|
subprocess.check_call(['/sbin/dhcpcd', 'eth%i' % device_number])
|
||||||
|
|
||||||
# Horrible hack to route return packets on the correct interface
|
# Horrible hack to route return packets on the correct interface
|
||||||
|
|||||||
@@ -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
|
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
|
be used to mail the review request. Otherwise, msmtp will be used by
|
||||||
default.
|
default.
|
||||||
""".strip() % CC_EMAIL
|
""".strip() % (CC_EMAIL,)
|
||||||
|
|
||||||
|
|
||||||
def parse_options(args):
|
def parse_options(args):
|
||||||
@@ -126,7 +126,7 @@ def get_reponame(repo):
|
|||||||
remote = get_default_remote(repo)
|
remote = get_default_remote(repo)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
url = repo.git.config('--get', 'remote.%s.url' % remote)
|
url = repo.git.config('--get', 'remote.%s.url' % (remote,))
|
||||||
except git.exc.GitCommandError:
|
except git.exc.GitCommandError:
|
||||||
url = repo.wd
|
url = repo.wd
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ def get_changed_source_files(other_checkout):
|
|||||||
# regenerate everything.
|
# regenerate everything.
|
||||||
print "Warning: git returned an error when comparing to the previous"
|
print "Warning: git returned an error when comparing to the previous"
|
||||||
print ("deploy in %s. Will re-minify JavaScript instead of reusing"
|
print ("deploy in %s. Will re-minify JavaScript instead of reusing"
|
||||||
% other_checkout)
|
% (other_checkout,))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
changed = set()
|
changed = set()
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ class ConnectionHandler:
|
|||||||
return
|
return
|
||||||
|
|
||||||
self._connect_target()
|
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
|
buf = payload
|
||||||
try:
|
try:
|
||||||
headers, rest = self.client_buffer.split('\r\n\r\n')
|
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 = socket.socket(soc_type)
|
||||||
soc.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
soc.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||||
soc.bind((host, port))
|
soc.bind((host, port))
|
||||||
print "Serving on %s:%d."%(host, port)#debug
|
print "Serving on %s:%d." % (host, port) #debug
|
||||||
soc.listen(0)
|
soc.listen(0)
|
||||||
while 1:
|
while 1:
|
||||||
thread.start_new_thread(handler, soc.accept()+(timeout,))
|
thread.start_new_thread(handler, soc.accept()+(timeout,))
|
||||||
|
|||||||
@@ -2756,17 +2756,17 @@ def handle_push_notification(user_profile_id, missed_message):
|
|||||||
except UserMessage.DoesNotExist:
|
except UserMessage.DoesNotExist:
|
||||||
logging.error("Could not find UserMessage with message_id %s" %(missed_message['message_id'],))
|
logging.error("Could not find UserMessage with message_id %s" %(missed_message['message_id'],))
|
||||||
|
|
||||||
def is_inactive(value):
|
def is_inactive(email):
|
||||||
try:
|
try:
|
||||||
if get_user_profile_by_email(value).is_active:
|
if get_user_profile_by_email(email).is_active:
|
||||||
raise ValidationError(u'%s is already active' % value)
|
raise ValidationError(u'%s is already active' % (email,))
|
||||||
except UserProfile.DoesNotExist:
|
except UserProfile.DoesNotExist:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def user_email_is_unique(value):
|
def user_email_is_unique(email):
|
||||||
try:
|
try:
|
||||||
get_user_profile_by_email(value)
|
get_user_profile_by_email(email)
|
||||||
raise ValidationError(u'%s is already registered' % value)
|
raise ValidationError(u'%s is already registered' % (email,))
|
||||||
except UserProfile.DoesNotExist:
|
except UserProfile.DoesNotExist:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@@ -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):
|
def test_table_row_count(self, row_counter, model):
|
||||||
table_name = model._meta.db_table
|
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
|
expected_count = row_counter.get(table_name) or 0
|
||||||
actual_count = model.objects.count()
|
actual_count = model.objects.count()
|
||||||
status = "PASSED" if expected_count == actual_count else "FAILED"
|
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" %
|
||||||
sys.stdout.write("expected %d rows, got %d. %s\n" % params)
|
(expected_count, actual_count, status))
|
||||||
|
|
||||||
|
|
||||||
def import_table(self, database_dump, realm_notification_map, model):
|
def import_table(self, database_dump, realm_notification_map, model):
|
||||||
table_name = model._meta.db_table
|
table_name = model._meta.db_table
|
||||||
if table_name in database_dump:
|
if table_name in database_dump:
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
sys.stdout.write("Importing %s: " % table_name)
|
sys.stdout.write("Importing %s: " % (table_name,))
|
||||||
accumulator = [ ]
|
accumulator = [ ]
|
||||||
for row in database_dump[table_name]:
|
for row in database_dump[table_name]:
|
||||||
# hack to filter out notifications_stream_id circular reference
|
# hack to filter out notifications_stream_id circular reference
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class Command(BaseCommand):
|
|||||||
addr = '127.0.0.1'
|
addr = '127.0.0.1'
|
||||||
|
|
||||||
if not port.isdigit():
|
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)
|
xheaders = options.get('xheaders', True)
|
||||||
no_keep_alive = options.get('no_keep_alive', False)
|
no_keep_alive = options.get('no_keep_alive', False)
|
||||||
|
|||||||
@@ -26,9 +26,9 @@ def minified_js(parser, token):
|
|||||||
try:
|
try:
|
||||||
tag_name, sourcefile = token.split_contents()
|
tag_name, sourcefile = token.split_contents()
|
||||||
except ValueError:
|
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 ('"', "'")):
|
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]
|
sourcefile = sourcefile[1:-1]
|
||||||
if sourcefile not in settings.JS_SPECS:
|
if sourcefile not in settings.JS_SPECS:
|
||||||
|
|||||||
@@ -338,7 +338,7 @@ dave-test@zulip.com
|
|||||||
|
|
||||||
earl-test@zulip.com""", ["Denmark"]))
|
earl-test@zulip.com""", ["Denmark"]))
|
||||||
for user in ("bob", "carol", "dave", "earl"):
|
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",
|
self.check_sent_emails(["bob-test@zulip.com", "carol-test@zulip.com",
|
||||||
"dave-test@zulip.com", "earl-test@zulip.com"])
|
"dave-test@zulip.com", "earl-test@zulip.com"])
|
||||||
|
|
||||||
|
|||||||
@@ -333,7 +333,7 @@ def json_invite_users(request, user_profile, invitee_emails=REQ):
|
|||||||
for stream_name in stream_names:
|
for stream_name in stream_names:
|
||||||
stream = get_stream(stream_name, user_profile.realm)
|
stream = get_stream(stream_name, user_profile.realm)
|
||||||
if stream is None:
|
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)
|
streams.append(stream)
|
||||||
|
|
||||||
ret_error, error_data = do_invite_users(user_profile, invitee_emails, streams)
|
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':
|
if email['type'] == 'account':
|
||||||
break
|
break
|
||||||
else:
|
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']
|
email_address = email['value']
|
||||||
user_profile = authenticate(username=email_address, use_dummy_backend=True)
|
user_profile = authenticate(username=email_address, use_dummy_backend=True)
|
||||||
return login_or_register_remote_user(request, email_address, user_profile, full_name)
|
return login_or_register_remote_user(request, email_address, user_profile, full_name)
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ def get_ticket_number():
|
|||||||
ticket_number = int(open(fn).read()) + 1
|
ticket_number = int(open(fn).read()) + 1
|
||||||
except:
|
except:
|
||||||
ticket_number = 1
|
ticket_number = 1
|
||||||
open(fn, 'w').write('%d' % ticket_number)
|
open(fn, 'w').write('%d' % (ticket_number,))
|
||||||
return ticket_number
|
return ticket_number
|
||||||
|
|
||||||
@has_request_variables
|
@has_request_variables
|
||||||
|
|||||||
Reference in New Issue
Block a user