1- import json
1+ # Standard library
22import os
33import os .path
44import sys
55import traceback
6- from urllib import request
76
87sys .path .append ("." )
98
9+ # Third-party
1010import requests
11- import quantify
12- import pandas as pd
1311from requests .adapters import HTTPAdapter
1412from urllib3 .util .retry import Retry
1513
14+ # First-party/Local
15+ import quantify
16+
1617PATH_REPO_ROOT , PATH_WORK_DIR , PATH_DOTENV , DATETIME_TODAY = quantify .setup (
1718 __file__
1819)
2324 f"{ DATETIME_TODAY .year } _{ DATETIME_TODAY .month } _{ DATETIME_TODAY .day } .csv" ,
2425)
2526
27+
2628def set_up_data_file ():
2729 """Writes the header row of the data file."""
2830 header_title = "LICENSE_TYPE,Repository Count"
2931 with open (DATA_WRITE_FILE , "w" ) as f :
3032 f .write (header_title + "\n " )
3133
32- # def get_license_list():
33- # """Provides the list of license from a Creative Commons provided tool list.
34- # Returns:
35- # np.array: An np array containing all license types that should be
36- # searched via Programmable Search Engine.
37- # """
38- # cc_license_data = pd.read_csv(
39- # os.path.join(PATH_WORK_DIR, "legal-tool-paths.txt"), header=None
40- # )
41- # license_list = cc_license_data[0].unique()
42- # return license_list
4334
4435def get_response_elems (license ):
4536 """Provides the metadata for query of specified parameters
@@ -69,7 +60,8 @@ def get_response_elems(license):
6960 return {"totalResults" : search_data ["total_count" ]}
7061 except Exception as e :
7162 raise e
72-
63+
64+
7365def record_license_data (license_type ):
7466 """Writes the row for LICENSE_TYPE to file to contain Github Query data.
7567 Args:
@@ -86,12 +78,14 @@ def record_license_data(license_type):
8678 with open (DATA_WRITE_FILE , "a" ) as f :
8779 f .write (f"{ data_log } \n " )
8880
81+
8982def record_all_licenses ():
9083 """Records the data of all license types findable in the license list and
9184 records these data into the DATA_WRITE_FILE as specified in that constant.
9285 """
9386 record_license_data ("CC" )
9487
88+
9589def main ():
9690 set_up_data_file ()
9791 record_all_licenses ()
0 commit comments