Created
February 14, 2013 14:28
-
-
Save EdwardIII/4953151 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from linklooker.linklooker import Links, Link | |
import argparse | |
import csv | |
def output_results(results, output_file): | |
if not results: | |
exit("Couldn't find any results!") | |
# Write out header | |
header = results[0].keys() | |
# Write out dictionary | |
data = csv.DictWriter(output_file, header, delimiter=',') | |
data.writeheader() | |
for r in results: | |
data.writerow(r) | |
output_file.flush() | |
output_file.close() | |
parser = argparse.ArgumentParser() | |
parser.add_argument('--csv', help='Provide a CSV to scan links from with the format: link, link to look for') | |
parser.add_argument('--prcsv', help='Provide a CSV to scan links in sho\'s format') | |
parser.add_argument('--output', type=argparse.FileType('w'), help='Path to output CSV') | |
links = Links() | |
output_file = parser.parse_args().output | |
if parser.parse_args().csv: | |
print "Parsing CSV..." | |
results = links.status_table_from_csv(parser.parse_args().csv) | |
output_results(results, output_file) | |
if parser.parse_args().prcsv: | |
print "Parsing pr CSV..." | |
results = links.status_table_from_pr_csv(parser.parse_args().prcsv) | |
output_results(results, output_file) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment