summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorHimanshu Shekhar <himanshushekharb16@gmail.com>2017-04-30 20:23:12 +0530
committerHimanshu Shekhar <himanshushekharb16@gmail.com>2017-04-30 20:23:12 +0530
commit130c62eb1f2e024d974deccbe7ad845663424d04 (patch)
tree2836e1be15fbbd11a1412be58d573743006b6352 /scripts
parenta267c772eef1b762430e6aa831f7ce0d97dd9c9a (diff)
downloadpsutil-130c62eb1f2e024d974deccbe7ad845663424d04.tar.gz
implement good coding styles
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/internal/check_broken_links.py14
1 files changed, 5 insertions, 9 deletions
diff --git a/scripts/internal/check_broken_links.py b/scripts/internal/check_broken_links.py
index f628bc4d..76ed8da7 100755
--- a/scripts/internal/check_broken_links.py
+++ b/scripts/internal/check_broken_links.py
@@ -65,19 +65,15 @@ def get_urls(filename):
"""
# fname = os.path.abspath(os.path.join(HERE, filename))
# expecting absolute path
- fname = os.path.abspath(filename)
- text = ''
- with open(fname) as f:
- text = f.read()
+ with open(filename) as fs:
+ text = fs.read()
urls = re.findall(REGEX, text)
# remove duplicates, list for sets are not iterable
urls = list(set(urls))
# correct urls which are between < and/or >
- i = 0
- while i < len(urls):
- urls[i] = re.sub("[\*<>\(\)\)]", '', urls[i])
- i += 1
+ for i, url in enumerate(urls):
+ urls[i] = re.sub("[\*<>\(\)\)]", '', url)
return urls
@@ -140,7 +136,7 @@ def main():
all_urls.append((fname, url))
fails = parallel_validator(all_urls)
- if len(fails) == 0:
+ if not fails:
print("all links are valid. cheers!")
else:
print("total :", len(fails), "fails!")