Add option to print unique licenses used by The Stack
parent
29e9146847
commit
df6a972c29
|
@ -29,6 +29,12 @@ def print_records(dataframe, color):
|
||||||
print(row)
|
print(row)
|
||||||
|
|
||||||
|
|
||||||
|
def print_unique_licenses(dataframe):
|
||||||
|
licenses = dataframe["license"].unique().tolist()
|
||||||
|
for license in licenses:
|
||||||
|
print(license)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description="Specify the directory and record range to use"
|
description="Specify the directory and record range to use"
|
||||||
|
@ -53,6 +59,12 @@ def main():
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--color", "-c", action="store_true", help="Colorize the output"
|
"--color", "-c", action="store_true", help="Colorize the output"
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--list-licenses",
|
||||||
|
"-l",
|
||||||
|
action="store_true",
|
||||||
|
help="List unique licenses in the file",
|
||||||
|
)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
directory = os.path.join(args.directory, "data/")
|
directory = os.path.join(args.directory, "data/")
|
||||||
|
@ -76,8 +88,11 @@ def main():
|
||||||
else:
|
else:
|
||||||
df = pd.read_parquet(os.path.join(directory, "lic.parquet"))
|
df = pd.read_parquet(os.path.join(directory, "lic.parquet"))
|
||||||
|
|
||||||
records = get_records(df, args)
|
if args.list_licenses:
|
||||||
print_records(records, args.color)
|
print_unique_licenses(df)
|
||||||
|
else:
|
||||||
|
records = get_records(df, args)
|
||||||
|
print_records(records, args.color)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Reference in New Issue