" tags, the fourth such pair will contain the desired information,
# the 5th will contain updated versions
def get_dep_from_row(html_string, row_start_index, row_end_index):
start_index = row_start_index
end_index = row_end_index
start_index = html_string.find(table_row_cell_open_string, start_index, row_end_index)
end_index = html_string.find(table_row_cell_close_string, start_index, row_end_index)\
+ len(table_row_cell_close_string)
#set the indecies for the fourth "" element
for i in range(3):
start_index = html_string.find(table_row_cell_open_string, end_index, row_end_index)
end_index = html_string.find(table_row_cell_close_string, start_index, row_end_index)\
+ len(table_row_cell_close_string)
return get_dep_from_cell(html_string, start_index, end_index)
def get_dep_from_cell(html_string, cell_start_index, cell_end_index):
start_index = html_string.find(unique_identified_prefix, cell_start_index, cell_end_index)\
+ len(unique_identified_prefix)
end_index = html_string.find("\"", start_index, cell_end_index)
if start_index == (len(unique_identified_prefix) - 1):
return None
return html_string[start_index:end_index]
# Produces the dependency set but returns them in mvn coord style
def get_mvn_coordinates_deps(url):
mvn_coords = set()
for elem in get_deps_for_artifact(url):
artifact_start_index = elem.find("/", 0)
org_id = elem[:artifact_start_index]
version_start_index = elem.find("/", artifact_start_index + 1)
artifact_id = elem[artifact_start_index + 1: version_start_index]
version = elem[version_start_index + 1:]
mvn_coords.add("mvn:" + org_id + ":" +artifact_id + ":" + version)
return mvn_coords
# Prints out the complete set of deps for the specified package(s)
def print_collection(lst):
for elem in lst:
print(elem)
return
def main():
url = input("Please enter the url of the repo whose dependencies you would like?" +
"\n(this should be a fully qualified url\nex: https://mvnrepository." +
"com/artifact/com.google.guava/guava/19.0)")
mvn_coords = input("Would you like maven coordinate output, enter 'y' for yes? (alternately url style paths will be provided)")
if mvn_coords == "y" or mvn_coords == "Y":
print_collection(get_mvn_coordinates_deps(url))
else:
print_collection(get_deps_for_artifact(url))
if __name__ == '__main__':
main()
|