Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
# -------------------------------------------------------------------------

# Converts all valid HTTP links to HTTPS, where the fed
# HTTP links are found in Report_AlterableUrls_FindHttpURLs.csv, which
# is generated by FindHttpURLs.py
# usage: python3 changeHttpURLsToHttps.py [PATH_TO_Report_FindHttpURLs.txt] [PATH_TO_ROOT_OF_NIMBUSML_DIRECTORY]
# output: Report_ReplaceHttpsURLs.txt
# HTTP links are found in report_alterable_urls_find_http_urls.csv, which
# is generated by find_http_urls.py
# usage: python3 change_http_urls_to_https.py [PATH_TO_report_alterable_urls_find_http_urls.csv] [PATH_TO_ROOT_OF_NIMBUSML_DIRECTORY]
Comment thread
mstfbl marked this conversation as resolved.
Outdated

import sys
import os
Expand Down Expand Up @@ -36,7 +35,7 @@ def changeUrls(pathToReportCsv, pathToRootDirectory):

def main():
if len(sys.argv) < 3:
print("Usage: python3 changeHttpURLsToHttps.py [PATH_TO_Report_FindHttpURLs.txt] [PATH_TO_ORIGINAL_NIMBUSML_DIRECTORY]")
print("Usage: python3 change_http_urls_to_https.py [PATH_TO_report_alterable_urls_find_http_urls.csv] [PATH_TO_ORIGINAL_NIMBUSML_DIRECTORY]")
exit(1)
changeUrls(sys.argv[1], sys.argv[2])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

# Finds all HTTP URLs found in the NimbusML repository
# Converts all valid HTTP links to HTTPS
# Usage: python3 findHttpURLs.py [PATH_TO_NimbusML_REPOSITORY]
# Output: Report_AlterableUrls_FindHttpURLs.csv, [Report_NonAlterableUrls_FindHttpURLs.csv, Report_InvalidUrls_FindHttpURLs.csv]
# Usage: python3 find_http_urls.py [PATH_TO_NimbusML_REPOSITORY]
Comment thread
mstfbl marked this conversation as resolved.
Outdated
# Output: report_alterable_urls_find_http_urls.csv, report_non_alterable_urls_find_http_urls.csv, report_invalid_urls_find_http_urls.csv

# Required non-standard pip library: urlextract

Expand Down Expand Up @@ -73,19 +73,19 @@ def findHttpUrls(searchRootDirectory):
makeReports(alterableUrlsStore, nonAlterableUrlsStore, invalidUrlsStore)

def makeReports(alterableUrlsStore, nonAlterableUrlsStore, invalidUrlsStore):
with open('Report_AlterableUrls_FindHttpURLs.csv', mode='w', newline='') as csv_file:
with open('report_alterable_urls_find_http_urls.csv', mode='w', newline='') as csv_file:
Comment thread
mstfbl marked this conversation as resolved.
Outdated
writer1 = csv.writer(csv_file, delimiter='\t', quotechar='|', quoting=csv.QUOTE_MINIMAL)
writer1.writerow(["url", "relativeFilepath"])
for urlKey in alterableUrlsStore:
for fileValue in alterableUrlsStore[urlKey]:
writer1.writerow([urlKey, fileValue])
with open('Report_NonAlterableUrls_FindHttpURLs.csv', mode='w', newline='') as csv_file:
with open('report_non_alterable_urls_find_http_urls.csv', mode='w', newline='') as csv_file:
Comment thread
mstfbl marked this conversation as resolved.
Outdated
writer2 = csv.writer(csv_file, delimiter='\t', quotechar='|', quoting=csv.QUOTE_MINIMAL)
writer2.writerow(["url", "relativeFilepath"])
for urlKey in nonAlterableUrlsStore:
for fileValue in nonAlterableUrlsStore[urlKey]:
writer2.writerow([urlKey, fileValue])
with open('Report_InvalidUrls_FindHttpURLs.csv', mode='w', newline='') as csv_file:
with open('report_invalid_urls_find_http_urls.csv', mode='w', newline='') as csv_file:
Comment thread
mstfbl marked this conversation as resolved.
Outdated
writer3 = csv.writer(csv_file, delimiter='\t', quotechar='|', quoting=csv.QUOTE_MINIMAL)
writer3.writerow(["url", "relativeFilepath"])
for urlKey in invalidUrlsStore:
Expand All @@ -95,7 +95,7 @@ def makeReports(alterableUrlsStore, nonAlterableUrlsStore, invalidUrlsStore):

def main():
if len(sys.argv) < 2:
print("Usage: python3 findHttpURLs.py [PATH_TO_NimbusML_REPOSITORY]")
print("Usage: python3 find_http_urls.py [PATH_TO_NimbusML_REPOSITORY]")
Comment thread
mstfbl marked this conversation as resolved.
Outdated
exit(1)
findHttpUrls(sys.argv[1])

Expand Down