lint: Clean up W503 PEP-8 warning.

This commit is contained in:
Tim Abbott 2017-01-23 20:50:04 -08:00
parent 4b015ecdff
commit 07cdd69e42
5 changed files with 27 additions and 27 deletions

View file

@ -75,9 +75,9 @@ def jid_to_zulip(jid):
def zulip_to_jid(email, jabber_domain): def zulip_to_jid(email, jabber_domain):
# type: (str, str) -> JID # type: (str, str) -> JID
jid = JID(email, domain=jabber_domain) jid = JID(email, domain=jabber_domain)
if (options.zulip_email_suffix if (options.zulip_email_suffix and
and options.zulip_email_suffix in jid.username options.zulip_email_suffix in jid.username and
and not jid.username.endswith("-bot")): not jid.username.endswith("-bot")):
jid.username = jid.username.rpartition(options.zulip_email_suffix)[0] jid.username = jid.username.rpartition(options.zulip_email_suffix)[0]
return jid return jid
@ -366,10 +366,10 @@ option does not affect login credentials.'''.replace("\n", " "))
default=None, default=None,
action='store', action='store',
help="Your Jabber JID. If a resource is specified, " help="Your Jabber JID. If a resource is specified, "
+ "it will be used as the nickname when joining MUCs. " "it will be used as the nickname when joining MUCs. "
+ "Specifying the nickname is mostly useful if you want " "Specifying the nickname is mostly useful if you want "
+ "to run the public mirror from a regular user instead of " "to run the public mirror from a regular user instead of "
+ "from a dedicated account.") "from a dedicated account.")
jabber_group.add_option('--jabber-password', jabber_group.add_option('--jabber-password',
default=None, default=None,
action='store', action='store',
@ -378,7 +378,7 @@ option does not affect login credentials.'''.replace("\n", " "))
default=None, default=None,
action='store', action='store',
help="Your Jabber conference domain (E.g. conference.jabber.example.com). " help="Your Jabber conference domain (E.g. conference.jabber.example.com). "
+ "If not specifed, \"conference.\" will be prepended to your JID's domain.") "If not specifed, \"conference.\" will be prepended to your JID's domain.")
jabber_group.add_option('--no-use-tls', jabber_group.add_option('--no-use-tls',
default=None, default=None,
action='store_true') action='store_true')
@ -413,8 +413,8 @@ option does not affect login credentials.'''.replace("\n", " "))
pass pass
for option in ("jid", "jabber_password", "conference_domain", "mode", "zulip_email_suffix", for option in ("jid", "jabber_password", "conference_domain", "mode", "zulip_email_suffix",
"jabber_server_address", "jabber_server_port"): "jabber_server_address", "jabber_server_port"):
if (getattr(options, option) is None if (getattr(options, option) is None and
and config.has_option("jabber_mirror", option)): config.has_option("jabber_mirror", option)):
setattr(options, option, config.get("jabber_mirror", option)) setattr(options, option, config.get("jabber_mirror", option))
for option in ("no_use_tls",): for option in ("no_use_tls",):
@ -435,7 +435,7 @@ option does not affect login credentials.'''.replace("\n", " "))
if None in (options.jid, options.jabber_password): if None in (options.jid, options.jabber_password):
config_error("You must specify your Jabber JID and Jabber password either " config_error("You must specify your Jabber JID and Jabber password either "
+ "in the Zulip configuration file or on the commandline") "in the Zulip configuration file or on the commandline")
zulipToJabber = ZulipToJabberBot(zulip.init_from_options(options, "JabberMirror/" + __version__)) zulipToJabber = ZulipToJabberBot(zulip.init_from_options(options, "JabberMirror/" + __version__))
# This won't work for open realms that don't have a consistent domain # This won't work for open realms that don't have a consistent domain

View file

@ -104,8 +104,8 @@ def unwrap_lines(body):
previous_line = lines[0] previous_line = lines[0]
for line in lines[1:]: for line in lines[1:]:
line = line.rstrip() line = line.rstrip()
if (re.match(r'^\W', line, flags=re.UNICODE) if (re.match(r'^\W', line, flags=re.UNICODE) and
and re.match(r'^\W', previous_line, flags=re.UNICODE)): re.match(r'^\W', previous_line, flags=re.UNICODE)):
result += previous_line + "\n" result += previous_line + "\n"
elif (line == "" or elif (line == "" or
previous_line == "" or previous_line == "" or

View file

@ -171,16 +171,16 @@ class CommuteHandler(object):
# determines if fare information is available # determines if fare information is available
try: try:
fare = ('Fare: ' + variable_list["fare"]["currency"] fare = ('Fare: ' + variable_list["fare"]["currency"] +
+ variable_list["fare"]["text"]) variable_list["fare"]["text"])
output += '\n' + fare output += '\n' + fare
except (KeyError, IndexError): except (KeyError, IndexError):
pass pass
# determines if traffic duration information is available # determines if traffic duration information is available
try: try:
traffic_duration = ('Duration in traffic: ' traffic_duration = ('Duration in traffic: ' +
+ variable_list["duration_in_traffic"] variable_list["duration_in_traffic"]
["text"]) ["text"])
output += '\n' + traffic_duration output += '\n' + traffic_duration
except (KeyError, IndexError): except (KeyError, IndexError):
@ -208,13 +208,13 @@ class CommuteHandler(object):
return request.json() return request.json()
else: else:
self.send_info(message, self.send_info(message,
"Something went wrong. Please try again." "Something went wrong. Please try again." +
+ " Error: {error_num}.\n{error_text}" " Error: {error_num}.\n{error_text}"
.format(error_num=request.status_code, .format(error_num=request.status_code,
error_text=request.text), client) error_text=request.text), client)
return return
r = requests.get('https://maps.googleapis.com/maps/api/' r = requests.get('https://maps.googleapis.com/maps/api/' +
+ 'distancematrix/json', params=params) 'distancematrix/json', params=params)
result = validate_requests(r) result = validate_requests(r)
return result return result

View file

@ -120,9 +120,9 @@ Example Inputs:
return return
if received_json['meta']['code'] == 200: if received_json['meta']['code'] == 200:
response_msg = ('Food nearby ' + params['near'] response_msg = ('Food nearby ' + params['near'] +
+ ' coming right up:\n' ' coming right up:\n' +
+ self.format_json(received_json['response']['venues'])) self.format_json(received_json['response']['venues']))
self.send_info(message, response_msg, client) self.send_info(message, response_msg, client)
return return

View file

@ -79,9 +79,9 @@ class CountingBackoff(object):
def _check_success_timeout(self): def _check_success_timeout(self):
# type: () -> None # type: () -> None
if (self.timeout_success_equivalent is not None if (self.timeout_success_equivalent is not None and
and self.last_attempt_time != 0 self.last_attempt_time != 0 and
and time.time() - self.last_attempt_time > self.timeout_success_equivalent): time.time() - self.last_attempt_time > self.timeout_success_equivalent):
self.number_of_retries = 0 self.number_of_retries = 0
class RandomExponentialBackoff(CountingBackoff): class RandomExponentialBackoff(CountingBackoff):