mirror of https://github.com/zulip/zulip.git
pep8: Fix E128 violations.
With some line-wrapping tweaks by tabbott.
This commit is contained in:
parent
fae59502ab
commit
94b28e0afb
|
@ -43,7 +43,7 @@ def do_send_message(client, message_data):
|
|||
|
||||
if message_data['type'] == 'stream':
|
||||
log.info('Sending message to stream "%s", subject "%s"... ' %
|
||||
(message_data['to'], message_data['subject']))
|
||||
(message_data['to'], message_data['subject']))
|
||||
else:
|
||||
log.info('Sending message to %s... ' % message_data['to'])
|
||||
response = client.send_message(message_data)
|
||||
|
|
|
@ -74,14 +74,14 @@ parser = optparse.OptionParser(r"""
|
|||
""")
|
||||
|
||||
parser.add_option('--twitter-id',
|
||||
help='Twitter username to poll for new tweets from"',
|
||||
metavar='URL')
|
||||
help='Twitter username to poll for new tweets from"',
|
||||
metavar='URL')
|
||||
parser.add_option('--stream',
|
||||
help='Default zulip stream to write tweets to')
|
||||
help='Default zulip stream to write tweets to')
|
||||
parser.add_option('--limit-tweets',
|
||||
default=15,
|
||||
type='int',
|
||||
help='Maximum number of tweets to push at once')
|
||||
default=15,
|
||||
type='int',
|
||||
help='Maximum number of tweets to push at once')
|
||||
|
||||
parser.add_option_group(zulip.generate_option_group(parser))
|
||||
(options, args) = parser.parse_args()
|
||||
|
|
|
@ -313,7 +313,7 @@ class Client(object):
|
|||
if self.verbose:
|
||||
if not query_state["had_error_retry"]:
|
||||
sys.stdout.write("zulip API(%s): connection error%s -- retrying." %
|
||||
(url.split(API_VERSTRING, 2)[0], error_string,))
|
||||
(url.split(API_VERSTRING, 2)[0], error_string,))
|
||||
query_state["had_error_retry"] = True
|
||||
else:
|
||||
sys.stdout.write(".")
|
||||
|
|
|
@ -329,11 +329,11 @@ for key in all_keys:
|
|||
if key in zhkeys:
|
||||
(stream, test) = zhkeys[key]
|
||||
logger.warning("%10s: z got %s, h got %s. Sent via Zephyr(%s): class %s" %
|
||||
(key, z_key_counts[key], h_key_counts[key], test, stream))
|
||||
(key, z_key_counts[key], h_key_counts[key], test, stream))
|
||||
if key in hzkeys:
|
||||
(stream, test) = hzkeys[key]
|
||||
logger.warning("%10s: z got %s. h got %s. Sent via Zulip(%s): class %s" %
|
||||
(key, z_key_counts[key], h_key_counts[key], test, stream))
|
||||
(key, z_key_counts[key], h_key_counts[key], test, stream))
|
||||
logger.error("")
|
||||
logger.error("Summary of specific problems:")
|
||||
|
||||
|
|
|
@ -34,17 +34,17 @@ parser = optparse.OptionParser(r"""
|
|||
""")
|
||||
|
||||
parser.add_option('--calendar',
|
||||
dest='calendar',
|
||||
action='store',
|
||||
help='Google Calendar XML "Private Address"',
|
||||
metavar='URL')
|
||||
dest='calendar',
|
||||
action='store',
|
||||
help='Google Calendar XML "Private Address"',
|
||||
metavar='URL')
|
||||
parser.add_option('--interval',
|
||||
dest='interval',
|
||||
default=10,
|
||||
type=int,
|
||||
action='store',
|
||||
help='Minutes before event for reminder [default: 10]',
|
||||
metavar='MINUTES')
|
||||
dest='interval',
|
||||
default=10,
|
||||
type=int,
|
||||
action='store',
|
||||
help='Minutes before event for reminder [default: 10]',
|
||||
metavar='MINUTES')
|
||||
parser.add_option_group(zulip.generate_option_group(parser))
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
|
@ -65,7 +65,7 @@ def get_calendar_url():
|
|||
parser.error('The --calendar URL should be the XML "Private Address" ' +
|
||||
'from your calendar settings')
|
||||
return urllib.parse.urlunparse((parts.scheme, parts.netloc, pat[0] + '/full',
|
||||
'', 'futureevents=true&orderby=startdate', ''))
|
||||
'', 'futureevents=true&orderby=startdate', ''))
|
||||
|
||||
calendar_url = get_calendar_url()
|
||||
|
||||
|
|
|
@ -322,28 +322,28 @@ def config_error(msg):
|
|||
sys.exit(2)
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = optparse.OptionParser(epilog=
|
||||
'''Most general and Jabber configuration options may also be specified in the
|
||||
parser = optparse.OptionParser(
|
||||
epilog='''Most general and Jabber configuration options may also be specified in the
|
||||
zulip configuration file under the jabber_mirror section (exceptions are noted
|
||||
in their help sections). Keys have the same name as options with hyphens
|
||||
replaced with underscores. Zulip configuration options go in the api section,
|
||||
as normal.'''.replace("\n", " ")
|
||||
)
|
||||
parser.add_option('--mode',
|
||||
default=None,
|
||||
action='store',
|
||||
help=
|
||||
'''Which mode to run in. Valid options are "personal" and "public". In
|
||||
parser.add_option(
|
||||
'--mode',
|
||||
default=None,
|
||||
action='store',
|
||||
help='''Which mode to run in. Valid options are "personal" and "public". In
|
||||
"personal" mode, the mirror uses an individual users' credentials and mirrors
|
||||
all messages they send on Zulip to Jabber and all private Jabber messages to
|
||||
Zulip. In "public" mode, the mirror uses the credentials for a dedicated mirror
|
||||
user and mirrors messages sent to Jabber rooms to Zulip. Defaults to
|
||||
"personal"'''.replace("\n", " "))
|
||||
parser.add_option('--zulip-email-suffix',
|
||||
default=None,
|
||||
action='store',
|
||||
help=
|
||||
'''Add the specified suffix to the local part of email addresses constructed
|
||||
parser.add_option(
|
||||
'--zulip-email-suffix',
|
||||
default=None,
|
||||
action='store',
|
||||
help='''Add the specified suffix to the local part of email addresses constructed
|
||||
from JIDs and nicks before sending requests to the Zulip server, and remove the
|
||||
suffix before sending requests to the Jabber server. For example, specifying
|
||||
"+foo" will cause messages that are sent to the "bar" room by nickname "qux" to
|
||||
|
@ -357,14 +357,15 @@ option does not affect login credentials.'''.replace("\n", " "))
|
|||
default=logging.INFO)
|
||||
|
||||
jabber_group = optparse.OptionGroup(parser, "Jabber configuration")
|
||||
jabber_group.add_option('--jid',
|
||||
default=None,
|
||||
action='store',
|
||||
help="Your Jabber JID. If a resource is specified, "
|
||||
+ "it will be used as the nickname when joining MUCs. "
|
||||
+ "Specifying the nickname is mostly useful if you want "
|
||||
+ "to run the public mirror from a regular user instead of "
|
||||
+ "from a dedicated account.")
|
||||
jabber_group.add_option(
|
||||
'--jid',
|
||||
default=None,
|
||||
action='store',
|
||||
help="Your Jabber JID. If a resource is specified, "
|
||||
+ "it will be used as the nickname when joining MUCs. "
|
||||
+ "Specifying the nickname is mostly useful if you want "
|
||||
+ "to run the public mirror from a regular user instead of "
|
||||
+ "from a dedicated account.")
|
||||
jabber_group.add_option('--jabber-password',
|
||||
default=None,
|
||||
action='store',
|
||||
|
@ -380,12 +381,12 @@ option does not affect login credentials.'''.replace("\n", " "))
|
|||
jabber_group.add_option('--jabber-server-address',
|
||||
default=None,
|
||||
action='store',
|
||||
help="The hostname of your Jabber server. This is only needed if "
|
||||
help="The hostname of your Jabber server. This is only needed if "
|
||||
"your server is missing SRV records")
|
||||
jabber_group.add_option('--jabber-server-port',
|
||||
default='5222',
|
||||
action='store',
|
||||
help="The port of your Jabber server. This is only needed if "
|
||||
help="The port of your Jabber server. This is only needed if "
|
||||
"your server is missing SRV records")
|
||||
|
||||
parser.add_option_group(jabber_group)
|
||||
|
|
|
@ -631,7 +631,7 @@ Feedback button or at support@zulipchat.com."""
|
|||
|
||||
wrapper = textwrap.TextWrapper(break_long_words=False, break_on_hyphens=False)
|
||||
wrapped_content = "\n".join("\n".join(wrapper.wrap(line))
|
||||
for line in message["content"].replace("@", "@@").split("\n"))
|
||||
for line in message["content"].replace("@", "@@").split("\n"))
|
||||
|
||||
zwrite_args = ["zwrite", "-n", "-s", message["sender_full_name"],
|
||||
"-F", "Zephyr error: See http://zephyr.1ts.org/wiki/df",
|
||||
|
|
|
@ -89,11 +89,11 @@ def run():
|
|||
|
||||
parser = optparse.OptionParser(usage=usage)
|
||||
parser.add_option('--quiet', '-q',
|
||||
action='store_true',
|
||||
help='Turn off logging output.')
|
||||
action='store_true',
|
||||
help='Turn off logging output.')
|
||||
parser.add_option('--config-file',
|
||||
action='store',
|
||||
help='(alternate config file to ~/.zuliprc)')
|
||||
action='store',
|
||||
help='(alternate config file to ~/.zuliprc)')
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
if len(args) == 0:
|
||||
|
|
|
@ -22,5 +22,5 @@ for i in range(1, 100):
|
|||
|
||||
# Convert to PNG
|
||||
subprocess.check_call(['inkscape', '--without-gui', '--export-area-page',
|
||||
'--export-png=../../static/images/favicon/favicon-%d.png' % (i,),
|
||||
'tmp.svg'])
|
||||
'--export-png=../../static/images/favicon/favicon-%d.png' % (i,),
|
||||
'tmp.svg'])
|
||||
|
|
|
@ -19,8 +19,8 @@ def check_our_files():
|
|||
# type: () -> None
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-m', '--modified',
|
||||
action='store_true', default=False,
|
||||
help='only check modified files')
|
||||
action='store_true', default=False,
|
||||
help='only check modified files')
|
||||
args = parser.parse_args()
|
||||
|
||||
by_lang = cast(
|
||||
|
|
|
@ -20,14 +20,14 @@ STATIC_PATH = 'static/'
|
|||
def get_templates():
|
||||
# type: () -> List[str]
|
||||
return (glob.glob(os.path.join(STATIC_PATH, 'templates/*.handlebars')) +
|
||||
glob.glob(os.path.join(STATIC_PATH, 'templates/settings/*.handlebars')))
|
||||
glob.glob(os.path.join(STATIC_PATH, 'templates/settings/*.handlebars')))
|
||||
|
||||
def run():
|
||||
# type: () -> None
|
||||
subprocess.check_call(['node', 'node_modules/.bin/handlebars']
|
||||
+ get_templates()
|
||||
+ ['--output', os.path.join(STATIC_PATH, 'templates/compiled.js'),
|
||||
'--known', 'if,unless,each,with'])
|
||||
+ get_templates()
|
||||
+ ['--output', os.path.join(STATIC_PATH, 'templates/compiled.js'),
|
||||
'--known', 'if,unless,each,with'])
|
||||
|
||||
def run_forever():
|
||||
# type: () -> None
|
||||
|
|
|
@ -33,8 +33,8 @@ def process_files():
|
|||
|
||||
parser = argparse.ArgumentParser(description=description)
|
||||
parser.add_argument('-v', '--verbose',
|
||||
action='store_true', default=False,
|
||||
help='show where calls are')
|
||||
action='store_true', default=False,
|
||||
help='show where calls are')
|
||||
args = parser.parse_args()
|
||||
|
||||
fns = glob.glob('static/js/*.js')
|
||||
|
|
|
@ -55,12 +55,12 @@ def check_our_files():
|
|||
|
||||
parser = optparse.OptionParser(usage=USAGE)
|
||||
parser.add_option('--modified', '-m',
|
||||
action='store_true', default=False,
|
||||
help='Only check modified files')
|
||||
action='store_true', default=False,
|
||||
help='Only check modified files')
|
||||
parser.add_option('--no-filter', '-a',
|
||||
dest='show_all',
|
||||
action='store_true', default=False,
|
||||
help='Show all HTML files (no filtering)')
|
||||
dest='show_all',
|
||||
action='store_true', default=False,
|
||||
help='Show all HTML files (no filtering)')
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
if options.show_all:
|
||||
|
|
|
@ -219,7 +219,7 @@ def validate(fn=None, text=None, check_indent=True):
|
|||
def is_special_html_tag(s, tag):
|
||||
# type: (str, str) -> bool
|
||||
return (s.startswith('<!--') or
|
||||
tag in ['link', 'meta', '!DOCTYPE'])
|
||||
tag in ['link', 'meta', '!DOCTYPE'])
|
||||
|
||||
def is_django_block_tag(tag):
|
||||
# type: (str) -> bool
|
||||
|
|
|
@ -55,9 +55,9 @@ def check_pyflakes(options, by_lang):
|
|||
return False
|
||||
failed = False
|
||||
pyflakes = subprocess.Popen(['pyflakes'] + by_lang['py'],
|
||||
stdout = subprocess.PIPE,
|
||||
stderr = subprocess.PIPE,
|
||||
universal_newlines = True)
|
||||
stdout = subprocess.PIPE,
|
||||
stderr = subprocess.PIPE,
|
||||
universal_newlines = True)
|
||||
|
||||
# pyflakes writes some output (like syntax errors) to stderr. :/
|
||||
for pipe in (pyflakes.stdout, pyflakes.stderr):
|
||||
|
@ -82,7 +82,7 @@ def check_pep8(files):
|
|||
# type: (List[str]) -> bool
|
||||
failed = False
|
||||
ignored_rules = [
|
||||
'E402', 'E501', 'W503', 'E711', 'E128', 'E226',
|
||||
'E402', 'E501', 'W503', 'E711', 'E226',
|
||||
'E126', 'E121', 'E123', 'E266', 'E265', 'E261', 'E221',
|
||||
'E241', 'E712', 'E702', 'E401', 'E115', 'E114', 'E731', 'E302',
|
||||
'E741', 'E714', 'W391', 'E713', 'E305', 'E251', 'E306',
|
||||
|
@ -331,7 +331,7 @@ def build_custom_checkers(by_lang):
|
|||
{'pattern': 'self\.client\.(get|post|patch|put|delete)',
|
||||
'exclude': set(['zilencer/tests.py']),
|
||||
'description': \
|
||||
'''Do not call self.client directly for put/patch/post/get.
|
||||
'''Do not call self.client directly for put/patch/post/get.
|
||||
See WRAPPER_COMMENT in test_helpers.py for details.
|
||||
'''},
|
||||
|
||||
|
@ -427,20 +427,20 @@ def run():
|
|||
# type: () -> None
|
||||
parser = optparse.OptionParser()
|
||||
parser.add_option('--force', default=False,
|
||||
action="store_true",
|
||||
help='Run tests despite possible problems.')
|
||||
action="store_true",
|
||||
help='Run tests despite possible problems.')
|
||||
parser.add_option('--full',
|
||||
action='store_true',
|
||||
help='Check some things we typically ignore')
|
||||
action='store_true',
|
||||
help='Check some things we typically ignore')
|
||||
parser.add_option('--pep8',
|
||||
action='store_true',
|
||||
help='Run the pep8 checker')
|
||||
action='store_true',
|
||||
help='Run the pep8 checker')
|
||||
parser.add_option('--modified', '-m',
|
||||
action='store_true',
|
||||
help='Only check modified files')
|
||||
action='store_true',
|
||||
help='Only check modified files')
|
||||
parser.add_option('--verbose', '-v',
|
||||
action='store_true',
|
||||
help='Print verbose timing output')
|
||||
action='store_true',
|
||||
help='Print verbose timing output')
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
tools_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
|
@ -460,9 +460,11 @@ def run():
|
|||
print('If you really know what you are doing, use --force to run anyway.')
|
||||
sys.exit(1)
|
||||
|
||||
by_lang = cast(Dict[str, List[str]], lister.list_files(args, modified_only=options.modified,
|
||||
ftypes=['py', 'sh', 'js', 'pp', 'css', 'handlebars', 'html', 'json', 'md', 'txt', 'text'],
|
||||
use_shebang=True, group_by_ftype=True, exclude=EXCLUDED_FILES))
|
||||
by_lang = cast(Dict[str, List[str]],
|
||||
lister.list_files(args, modified_only=options.modified,
|
||||
ftypes=['py', 'sh', 'js', 'pp', 'css', 'handlebars',
|
||||
'html', 'json', 'md', 'txt', 'text'],
|
||||
use_shebang=True, group_by_ftype=True, exclude=EXCLUDED_FILES))
|
||||
|
||||
# Invoke the appropriate lint checker for each language,
|
||||
# and also check files for extra whitespace.
|
||||
|
|
|
@ -15,7 +15,7 @@ from typing import Optional, Set
|
|||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--prev-deploy', metavar='DIR',
|
||||
help='a previous deploy from which to reuse files if possible')
|
||||
help='a previous deploy from which to reuse files if possible')
|
||||
args = parser.parse_args()
|
||||
prev_deploy = args.prev_deploy
|
||||
|
||||
|
|
|
@ -169,7 +169,7 @@ if __name__ == "__main__":
|
|||
TestRunner = get_runner(settings)
|
||||
test_runner = TestRunner()
|
||||
failures = test_runner.run_tests(suites, fatal_errors=options.fatal_errors,
|
||||
full_suite=full_suite)
|
||||
full_suite=full_suite)
|
||||
|
||||
templates_not_rendered = test_runner.get_shallow_tested_templates()
|
||||
if templates_not_rendered and full_suite:
|
||||
|
|
|
@ -11,8 +11,8 @@ import unittest
|
|||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--coverage', dest='coverage',
|
||||
action="store_true",
|
||||
default=False, help='compute test coverage')
|
||||
action="store_true",
|
||||
default=False, help='compute test coverage')
|
||||
args = parser.parse_args()
|
||||
|
||||
def dir_join(dir1, dir2):
|
||||
|
|
|
@ -18,7 +18,7 @@ from scripts.lib.node_cache import setup_node_modules
|
|||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--prev-deploy', metavar='DIR',
|
||||
help='a previous deploy from which to reuse files if possible')
|
||||
help='a previous deploy from which to reuse files if possible')
|
||||
args = parser.parse_args()
|
||||
prev_deploy = args.prev_deploy
|
||||
|
||||
|
|
|
@ -17,21 +17,21 @@ def run():
|
|||
# type: () -> None
|
||||
"""Builds for production, writing the output to disk"""
|
||||
subprocess.check_call(['node', 'node_modules/.bin/webpack'] +
|
||||
['--config', 'tools/webpack.production.config.js'])
|
||||
['--config', 'tools/webpack.production.config.js'])
|
||||
|
||||
def run_watch(port):
|
||||
# type: (str) -> None
|
||||
"""watches and rebuilds on changes, serving files from memory via webpack-dev-server"""
|
||||
subprocess.Popen(['node', 'node_modules/.bin/webpack-dev-server'] +
|
||||
['--config', 'tools/webpack.config.js', '--watch-poll', '--port', port])
|
||||
['--config', 'tools/webpack.config.js', '--watch-poll', '--port', port])
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--watch',
|
||||
action='store_true', dest='watch', default=False,
|
||||
help='watch for changes to source files (for development)')
|
||||
action='store_true', dest='watch', default=False,
|
||||
help='watch for changes to source files (for development)')
|
||||
parser.add_argument('--port',
|
||||
action='store', dest='port',
|
||||
default='9994', help='set the port for the webpack server to run on')
|
||||
action='store', dest='port',
|
||||
default='9994', help='set the port for the webpack server to run on')
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.watch:
|
||||
|
|
|
@ -122,8 +122,8 @@ def log_event(event):
|
|||
os.mkdir(settings.EVENT_LOG_DIR)
|
||||
|
||||
template = os.path.join(settings.EVENT_LOG_DIR,
|
||||
'%s.' + platform.node()
|
||||
+ datetime.datetime.now().strftime('.%Y-%m-%d'))
|
||||
'%s.' + platform.node()
|
||||
+ datetime.datetime.now().strftime('.%Y-%m-%d'))
|
||||
|
||||
with lockfile(template % ('lock',)):
|
||||
with open(template % ('events',), 'a') as log:
|
||||
|
@ -227,21 +227,26 @@ def send_signup_message(sender, signups_stream, user_profile,
|
|||
# Send notification to realm notifications stream if it exists
|
||||
# Don't send notification for the first user in a realm
|
||||
if user_profile.realm.notifications_stream is not None and user_count > 1:
|
||||
internal_send_message(sender, "stream",
|
||||
user_profile.realm.notifications_stream.name,
|
||||
"New users", "%s just signed up for Zulip. Say hello!" %
|
||||
(user_profile.full_name,),
|
||||
realm=user_profile.realm)
|
||||
internal_send_message(
|
||||
sender,
|
||||
"stream",
|
||||
user_profile.realm.notifications_stream.name,
|
||||
"New users", "%s just signed up for Zulip. Say hello!" % (
|
||||
user_profile.full_name,),
|
||||
realm=user_profile.realm)
|
||||
|
||||
internal_send_message(sender,
|
||||
"stream", signups_stream, user_profile.realm.domain,
|
||||
"%s <`%s`> just signed up for Zulip!%s(total: **%i**)" % (
|
||||
user_profile.full_name,
|
||||
user_profile.email,
|
||||
internal_blurb,
|
||||
user_count,
|
||||
)
|
||||
)
|
||||
internal_send_message(
|
||||
sender,
|
||||
"stream",
|
||||
signups_stream,
|
||||
user_profile.realm.domain,
|
||||
"%s <`%s`> just signed up for Zulip!%s(total: **%i**)" % (
|
||||
user_profile.full_name,
|
||||
user_profile.email,
|
||||
internal_blurb,
|
||||
user_count,
|
||||
)
|
||||
)
|
||||
|
||||
def notify_new_user(user_profile, internal=False):
|
||||
# type: (UserProfile, bool) -> None
|
||||
|
@ -303,13 +308,16 @@ def process_new_human_user(user_profile, prereg_user=None, newsletter_data=None)
|
|||
if not mit_beta_user and prereg_user is not None and prereg_user.referred_by is not None \
|
||||
and settings.NOTIFICATION_BOT is not None:
|
||||
# This is a cross-realm private message.
|
||||
internal_send_message(settings.NOTIFICATION_BOT,
|
||||
"private", prereg_user.referred_by.email, user_profile.realm.domain,
|
||||
"%s <`%s`> accepted your invitation to join Zulip!" % (
|
||||
user_profile.full_name,
|
||||
user_profile.email,
|
||||
)
|
||||
)
|
||||
internal_send_message(
|
||||
settings.NOTIFICATION_BOT,
|
||||
"private",
|
||||
prereg_user.referred_by.email,
|
||||
user_profile.realm.domain,
|
||||
"%s <`%s`> accepted your invitation to join Zulip!" % (
|
||||
user_profile.full_name,
|
||||
user_profile.email,
|
||||
)
|
||||
)
|
||||
# Mark any other PreregistrationUsers that are STATUS_ACTIVE as
|
||||
# inactive so we can keep track of the PreregistrationUser we
|
||||
# actually used for analytics
|
||||
|
@ -1508,7 +1516,7 @@ def notify_subscriptions_added(user_profile, sub_pairs, stream_emails, no_log=Fa
|
|||
description=stream.description,
|
||||
pin_to_top=subscription.pin_to_top,
|
||||
subscribers=stream_emails(stream))
|
||||
for (subscription, stream) in sub_pairs]
|
||||
for (subscription, stream) in sub_pairs]
|
||||
event = dict(type="subscription", op="add",
|
||||
subscriptions=payload)
|
||||
send_event(event, [user_profile.id])
|
||||
|
@ -2862,7 +2870,7 @@ def gather_subscriptions_helper(user_profile):
|
|||
stream_ids = set([sub["recipient__type_id"] for sub in sub_dicts])
|
||||
all_streams = get_active_streams(user_profile.realm).select_related(
|
||||
"realm").values("id", "name", "invite_only", "realm_id",
|
||||
"realm__domain", "email_token", "description")
|
||||
"realm__domain", "email_token", "description")
|
||||
|
||||
stream_dicts = [stream for stream in all_streams if stream['id'] in stream_ids]
|
||||
stream_hash = {}
|
||||
|
|
|
@ -1053,13 +1053,13 @@ class Bugdown(markdown.Extension):
|
|||
|
||||
# Custom bold syntax: **foo** but not __foo__
|
||||
md.inlinePatterns.add('strong',
|
||||
markdown.inlinepatterns.SimpleTagPattern(r'(\*\*)([^\n]+?)\2', 'strong'),
|
||||
'>not_strong')
|
||||
markdown.inlinepatterns.SimpleTagPattern(r'(\*\*)([^\n]+?)\2', 'strong'),
|
||||
'>not_strong')
|
||||
|
||||
# Custom strikethrough syntax: ~~foo~~
|
||||
md.inlinePatterns.add('del',
|
||||
markdown.inlinepatterns.SimpleTagPattern(r'(?<!~)(\~\~)([^~{0}\n]+?)\2(?!~)', 'del'),
|
||||
'>strong')
|
||||
markdown.inlinepatterns.SimpleTagPattern(r'(?<!~)(\~\~)([^~{0}\n]+?)\2(?!~)', 'del'),
|
||||
'>strong')
|
||||
|
||||
# Text inside ** must start and end with a word character
|
||||
# it need for things like "const char *x = (char *)y"
|
||||
|
@ -1078,7 +1078,7 @@ class Bugdown(markdown.Extension):
|
|||
md.inlinePatterns.add('gravatar', Avatar(r'!gravatar\((?P<email>[^)]*)\)'), '>backtick')
|
||||
|
||||
md.inlinePatterns.add('stream_subscribe_button',
|
||||
StreamSubscribeButton(r'!_stream_subscribe_button\((?P<stream_name>(?:[^)\\]|\\\)|\\)*)\)'), '>backtick')
|
||||
StreamSubscribeButton(r'!_stream_subscribe_button\((?P<stream_name>(?:[^)\\]|\\\)|\\)*)\)'), '>backtick')
|
||||
md.inlinePatterns.add(
|
||||
'modal_link',
|
||||
ModalLink(r'!modal_link\((?P<relative_url>[^)]*), (?P<text>[^)]*)\)'),
|
||||
|
@ -1229,7 +1229,7 @@ def make_realm_filters(domain, filters):
|
|||
# Because of how the Markdown config API works, this has confusing
|
||||
# large number of layers of dicts/arrays :(
|
||||
make_md_engine(domain, {"realm_filters": [filters, "Realm-specific filters for %s" % (domain,)],
|
||||
"realm": [domain, "Realm name"]})
|
||||
"realm": [domain, "Realm name"]})
|
||||
|
||||
def maybe_update_realm_filters(domain):
|
||||
# type: (Optional[Text]) -> None
|
||||
|
@ -1326,11 +1326,11 @@ def do_convert(content, realm_domain=None, message=None, possible_words=None):
|
|||
|
||||
# Output error to log as well as sending a zulip and email
|
||||
log_bugdown_error('Exception in Markdown parser: %sInput (sanitized) was: %s'
|
||||
% (traceback.format_exc(), cleaned))
|
||||
% (traceback.format_exc(), cleaned))
|
||||
subject = "Markdown parser failure on %s" % (platform.node(),)
|
||||
if settings.ERROR_BOT is not None:
|
||||
internal_send_message(settings.ERROR_BOT, "stream",
|
||||
"errors", subject, "Markdown parser failed, email sent with details.")
|
||||
"errors", subject, "Markdown parser failed, email sent with details.")
|
||||
mail.mail_admins(subject, "Failed message: %s\n\n%s\n\n" % (
|
||||
cleaned, traceback.format_exc()),
|
||||
fail_silently=False)
|
||||
|
|
|
@ -100,8 +100,8 @@ class FencedCodeExtension(markdown.Extension):
|
|||
# Newer versions of Python-Markdown (starting at 2.3?) have
|
||||
# a normalize_whitespace preprocessor that needs to go first.
|
||||
position = ('>normalize_whitespace'
|
||||
if 'normalize_whitespace' in md.preprocessors
|
||||
else '_begin')
|
||||
if 'normalize_whitespace' in md.preprocessors
|
||||
else '_begin')
|
||||
|
||||
md.preprocessors.add('fenced_code_block',
|
||||
FencedBlockPreprocessor(md),
|
||||
|
@ -259,13 +259,13 @@ class FencedBlockPreprocessor(markdown.preprocessors.Preprocessor):
|
|||
# is enabled, so we call it to highlite the code
|
||||
if self.codehilite_conf:
|
||||
highliter = CodeHilite(text,
|
||||
linenums=self.codehilite_conf['linenums'][0],
|
||||
guess_lang=self.codehilite_conf['guess_lang'][0],
|
||||
css_class=self.codehilite_conf['css_class'][0],
|
||||
style=self.codehilite_conf['pygments_style'][0],
|
||||
use_pygments=self.codehilite_conf['use_pygments'][0],
|
||||
lang=(lang or None),
|
||||
noclasses=self.codehilite_conf['noclasses'][0])
|
||||
linenums=self.codehilite_conf['linenums'][0],
|
||||
guess_lang=self.codehilite_conf['guess_lang'][0],
|
||||
css_class=self.codehilite_conf['css_class'][0],
|
||||
style=self.codehilite_conf['pygments_style'][0],
|
||||
use_pygments=self.codehilite_conf['use_pygments'][0],
|
||||
lang=(lang or None),
|
||||
noclasses=self.codehilite_conf['noclasses'][0])
|
||||
|
||||
code = highliter.hilite()
|
||||
else:
|
||||
|
|
|
@ -88,7 +88,7 @@ def gather_hot_conversations(user_profile, stream_messages):
|
|||
|
||||
# We'll display up to 2 messages from the conversation.
|
||||
first_few_messages = [user_message.message for user_message in
|
||||
stream_messages.filter(
|
||||
stream_messages.filter(
|
||||
message__recipient__type_id=stream_id,
|
||||
message__subject=subject)[:2]]
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ Usage: ./manage.py import [--destroy-rebuild-database] [--import-into-nonempty]
|
|||
count = model.objects.count()
|
||||
if count:
|
||||
print("Zulip instance is not empty, found %d rows in %s table. "
|
||||
% (count, model._meta.db_table))
|
||||
% (count, model._meta.db_table))
|
||||
print("You may use --destroy-rebuild-database to destroy and rebuild the database prior to import.")
|
||||
exit(1)
|
||||
|
||||
|
@ -60,8 +60,8 @@ Usage: ./manage.py import [--destroy-rebuild-database] [--import-into-nonempty]
|
|||
def handle(self, *args, **options):
|
||||
# type: (*Any, **Any) -> None
|
||||
models_to_import = [Realm, Stream, UserProfile, Recipient, Subscription,
|
||||
Client, Message, UserMessage, Huddle, DefaultStream, RealmAlias,
|
||||
RealmFilter]
|
||||
Client, Message, UserMessage, Huddle, DefaultStream, RealmAlias,
|
||||
RealmFilter]
|
||||
|
||||
if len(args) == 0:
|
||||
print("Please provide at least one realm dump to import.")
|
||||
|
|
|
@ -241,7 +241,7 @@ class LoginTest(ZulipTestCase):
|
|||
# type: () -> None
|
||||
realm = get_realm_by_string_id("zulip")
|
||||
stream_dict = {"stream_"+str(i): {"description": "stream_%s_description" % i, "invite_only": False}
|
||||
for i in range(40)} # type: Dict[Text, Dict[Text, Any]]
|
||||
for i in range(40)} # type: Dict[Text, Dict[Text, Any]]
|
||||
for stream_name in stream_dict.keys():
|
||||
self.make_stream(stream_name, realm=realm)
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ class MentionHookTests(WebhookTestCase):
|
|||
|
||||
# use fixture named mention_webfeeds
|
||||
self.send_and_test_stream_message('webfeeds', expected_topic, expected_message,
|
||||
content_type="application/x-www-form-urlencoded")
|
||||
content_type="application/x-www-form-urlencoded")
|
||||
|
||||
def get_body(self, fixture_name):
|
||||
# type: (Text) -> Text
|
||||
|
|
|
@ -23,7 +23,7 @@ class StripeHookTests(WebhookTestCase):
|
|||
|
||||
# use fixture named stripe_charge_dispute_created
|
||||
self.send_and_test_stream_message('charge_dispute_created', expected_subject, expected_message,
|
||||
content_type="application/x-www-form-urlencoded")
|
||||
content_type="application/x-www-form-urlencoded")
|
||||
|
||||
def test_charge_failed(self):
|
||||
# type: () -> None
|
||||
|
@ -32,7 +32,7 @@ class StripeHookTests(WebhookTestCase):
|
|||
|
||||
# use fixture named stripe_charge_failed
|
||||
self.send_and_test_stream_message('charge_failed', expected_subject, expected_message,
|
||||
content_type="application/x-www-form-urlencoded")
|
||||
content_type="application/x-www-form-urlencoded")
|
||||
|
||||
def test_charge_succeeded(self):
|
||||
# type: () -> None
|
||||
|
@ -41,7 +41,7 @@ class StripeHookTests(WebhookTestCase):
|
|||
|
||||
# use fixture named stripe_charge_succeeded
|
||||
self.send_and_test_stream_message('charge_succeeded', expected_subject, expected_message,
|
||||
content_type="application/x-www-form-urlencoded")
|
||||
content_type="application/x-www-form-urlencoded")
|
||||
|
||||
def test_customer_created_email(self):
|
||||
# type: () -> None
|
||||
|
@ -50,7 +50,7 @@ class StripeHookTests(WebhookTestCase):
|
|||
|
||||
# use fixture named stripe_customer_created_email
|
||||
self.send_and_test_stream_message('customer_created_email', expected_subject, expected_message,
|
||||
content_type="application/x-www-form-urlencoded")
|
||||
content_type="application/x-www-form-urlencoded")
|
||||
|
||||
def test_customer_created(self):
|
||||
# type: () -> None
|
||||
|
@ -59,7 +59,7 @@ class StripeHookTests(WebhookTestCase):
|
|||
|
||||
# use fixture named stripe_customer_created
|
||||
self.send_and_test_stream_message('customer_created', expected_subject, expected_message,
|
||||
content_type="application/x-www-form-urlencoded")
|
||||
content_type="application/x-www-form-urlencoded")
|
||||
|
||||
def test_customer_deleted(self):
|
||||
# type: () -> None
|
||||
|
@ -68,7 +68,7 @@ class StripeHookTests(WebhookTestCase):
|
|||
|
||||
# use fixture named stripe_customer_deleted
|
||||
self.send_and_test_stream_message('customer_deleted', expected_subject, expected_message,
|
||||
content_type="application/x-www-form-urlencoded")
|
||||
content_type="application/x-www-form-urlencoded")
|
||||
|
||||
def test_customer_subscription_created(self):
|
||||
# type: () -> None
|
||||
|
@ -77,7 +77,7 @@ class StripeHookTests(WebhookTestCase):
|
|||
|
||||
# use fixture named stripe_customer_subscription_created
|
||||
self.send_and_test_stream_message('customer_subscription_created', expected_subject, expected_message,
|
||||
content_type="application/x-www-form-urlencoded")
|
||||
content_type="application/x-www-form-urlencoded")
|
||||
|
||||
def test_customer_subscription_deleted(self):
|
||||
# type: () -> None
|
||||
|
@ -86,7 +86,7 @@ class StripeHookTests(WebhookTestCase):
|
|||
|
||||
# use fixture named stripe_customer_subscription_deleted
|
||||
self.send_and_test_stream_message('customer_subscription_deleted', expected_subject, expected_message,
|
||||
content_type="application/x-www-form-urlencoded")
|
||||
content_type="application/x-www-form-urlencoded")
|
||||
|
||||
def test_customer_subscription_trial_will_end(self):
|
||||
# type: () -> None
|
||||
|
@ -95,7 +95,7 @@ class StripeHookTests(WebhookTestCase):
|
|||
|
||||
# use fixture named stripe_customer_subscription_trial_will_end
|
||||
self.send_and_test_stream_message('customer_subscription_trial_will_end', expected_subject, expected_message,
|
||||
content_type="application/x-www-form-urlencoded")
|
||||
content_type="application/x-www-form-urlencoded")
|
||||
|
||||
def test_invoice_payment_failed(self):
|
||||
# type: () -> None
|
||||
|
@ -104,7 +104,7 @@ class StripeHookTests(WebhookTestCase):
|
|||
|
||||
# use fixture named stripe_invoice_payment_failed
|
||||
self.send_and_test_stream_message('invoice_payment_failed', expected_subject, expected_message,
|
||||
content_type="application/x-www-form-urlencoded")
|
||||
content_type="application/x-www-form-urlencoded")
|
||||
|
||||
def test_order_payment_failed(self):
|
||||
# type: () -> None
|
||||
|
@ -113,7 +113,7 @@ class StripeHookTests(WebhookTestCase):
|
|||
|
||||
# use fixture named stripe_order_payment_failed
|
||||
self.send_and_test_stream_message('order_payment_failed', expected_subject, expected_message,
|
||||
content_type="application/x-www-form-urlencoded")
|
||||
content_type="application/x-www-form-urlencoded")
|
||||
|
||||
def test_order_payment_succeeded(self):
|
||||
# type: () -> None
|
||||
|
@ -122,7 +122,7 @@ class StripeHookTests(WebhookTestCase):
|
|||
|
||||
# use fixture named stripe_order_payment_succeeded
|
||||
self.send_and_test_stream_message('order_payment_succeeded', expected_subject, expected_message,
|
||||
content_type="application/x-www-form-urlencoded")
|
||||
content_type="application/x-www-form-urlencoded")
|
||||
|
||||
def test_order_updated(self):
|
||||
# type: () -> None
|
||||
|
@ -131,7 +131,7 @@ class StripeHookTests(WebhookTestCase):
|
|||
|
||||
# use fixture named stripe_order_updated
|
||||
self.send_and_test_stream_message('order_updated', expected_subject, expected_message,
|
||||
content_type="application/x-www-form-urlencoded")
|
||||
content_type="application/x-www-form-urlencoded")
|
||||
|
||||
def test_transfer_failed(self):
|
||||
# type: () -> None
|
||||
|
@ -140,7 +140,7 @@ class StripeHookTests(WebhookTestCase):
|
|||
|
||||
# use fixture named stripe_transfer_failed
|
||||
self.send_and_test_stream_message('transfer_failed', expected_subject, expected_message,
|
||||
content_type="application/x-www-form-urlencoded")
|
||||
content_type="application/x-www-form-urlencoded")
|
||||
|
||||
def test_transfer_paid(self):
|
||||
# type: () -> None
|
||||
|
@ -149,7 +149,7 @@ class StripeHookTests(WebhookTestCase):
|
|||
|
||||
# use fixture named stripe_transfer_paid
|
||||
self.send_and_test_stream_message('transfer_paid', expected_subject, expected_message,
|
||||
content_type="application/x-www-form-urlencoded")
|
||||
content_type="application/x-www-form-urlencoded")
|
||||
|
||||
def get_body(self, fixture_name):
|
||||
# type: (Text) -> Text
|
||||
|
|
|
@ -63,12 +63,13 @@ def api_pivotal_webhook_v3(request, user_profile, stream):
|
|||
if estimate != '':
|
||||
estimate = " worth %s story points" % (estimate,)
|
||||
subject = name
|
||||
content = "%s (%s %s%s):\n\n~~~ quote\n%s\n~~~\n\n%s" % (description,
|
||||
issue_status,
|
||||
issue_type,
|
||||
estimate,
|
||||
issue_desc,
|
||||
more_info)
|
||||
content = "%s (%s %s%s):\n\n~~~ quote\n%s\n~~~\n\n%s" % (
|
||||
description,
|
||||
issue_status,
|
||||
issue_type,
|
||||
estimate,
|
||||
issue_desc,
|
||||
more_info)
|
||||
return subject, content
|
||||
|
||||
def api_pivotal_webhook_v5(request, user_profile, stream):
|
||||
|
|
Loading…
Reference in New Issue