Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Convert or-ed startswith()s to tuples elsewhere

  • Loading branch information...
commit a182078fcd8a1aeedcdb4603ab426ad5ddaa9648 1 parent 9354da7
@Deimos Deimos authored
View
2  r2/r2/lib/scraper.py
@@ -96,7 +96,7 @@ def fetch_url(url, referer = None, retries = 1, dimension = False):
nothing = None if dimension else (None, None)
url = clean_url(url)
#just basic urls
- if not (url.startswith('http://') or url.startswith('https://')):
+ if not url.startswith(('http://', 'https://')):
return nothing
while True:
try:
View
2  r2/r2/lib/template_helpers.py
@@ -378,7 +378,7 @@ def add_sr(path, sr_path = True, nocname=False, force_hostname = False, retain_e
c.cname, c.render_style, c.site.name
"""
# don't do anything if it is just an anchor
- if path.startswith('#') or path.startswith('javascript:'):
+ if path.startswith(('#', 'javascript:')):
return path
u = UrlParser(path)
View
2  r2/r2/lib/utils/utils.py
@@ -251,7 +251,7 @@ def path_component(s):
def get_title(url):
"""Fetches the contents of url and extracts (and utf-8 encodes)
the contents of <title>"""
- if not url or not (url.startswith('http://') or url.startswith('https://')):
+ if not url or not url.startswith(('http://', 'https://')):
return None
try:
View
5 r2/r2/lib/validator/validator.py
@@ -1808,10 +1808,7 @@ def run(self, dest):
dest = request.referer or self.default or "/"
ld = dest.lower()
- if (ld.startswith("/") or
- ld.startswith("http://") or
- ld.startswith("https://")):
-
+ if ld.startswith(('/', 'http://', 'http://')):
u = UrlParser(dest)
if u.is_reddit_url(c.site):
Please sign in to comment.
Something went wrong with that request. Please try again.