Skip to content

Commit faaa174

Browse files
committed
Improve code readability by replacing vague variable names with descriptive identifiers
1 parent 6431e72 commit faaa174

1 file changed

Lines changed: 23 additions & 23 deletions

File tree

scripts/1-fetch/arxiv_fetch.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -437,69 +437,69 @@ def save_count_data(
437437

438438
# Save license counts
439439
data = []
440-
for lic, c in license_counts.items():
441-
data.append({"TOOL_IDENTIFIER": lic, "COUNT": c})
440+
for license_name, count in license_counts.items():
441+
data.append({"TOOL_IDENTIFIER": license_name, "COUNT": count})
442442
data.sort(key=itemgetter("TOOL_IDENTIFIER"))
443-
with open(FILE_ARXIV_COUNT, "w", encoding="utf-8", newline="\n") as fh:
444-
writer = csv.DictWriter(fh, fieldnames=HEADER_COUNT, dialect="unix")
443+
with open(FILE_ARXIV_COUNT, "w", encoding="utf-8", newline="\n") as file_handle:
444+
writer = csv.DictWriter(file_handle, fieldnames=HEADER_COUNT, dialect="unix")
445445
writer.writeheader()
446446
for row in data:
447447
writer.writerow(row)
448448

449449
# Save category report with labels
450450
data = []
451-
for lic, cats in category_counts.items():
452-
for code, c in cats.items():
451+
for license_name, categories in category_counts.items():
452+
for code, count in categories.items():
453453
label = CATEGORIES.get(code, code)
454454
data.append(
455455
{
456-
"TOOL_IDENTIFIER": lic,
456+
"TOOL_IDENTIFIER": license_name,
457457
"CATEGORY_CODE": code,
458458
"CATEGORY_LABEL": label,
459-
"COUNT": c,
459+
"COUNT": count,
460460
}
461461
)
462462
data.sort(key=itemgetter("TOOL_IDENTIFIER", "CATEGORY_CODE"))
463463
with open(
464464
FILE_ARXIV_CATEGORY_REPORT, "w", encoding="utf-8", newline="\n"
465-
) as fh:
465+
) as file_handle:
466466
writer = csv.DictWriter(
467-
fh, fieldnames=HEADER_CATEGORY_REPORT, dialect="unix"
467+
file_handle, fieldnames=HEADER_CATEGORY_REPORT, dialect="unix"
468468
)
469469
writer.writeheader()
470470
for row in data:
471471
writer.writerow(row)
472472

473473
# Save year counts
474474
data = []
475-
for lic, years in year_counts.items():
476-
for year, c in years.items():
477-
data.append({"TOOL_IDENTIFIER": lic, "YEAR": year, "COUNT": c})
475+
for license_name, years in year_counts.items():
476+
for year, count in years.items():
477+
data.append({"TOOL_IDENTIFIER": license_name, "YEAR": year, "COUNT": count})
478478
data.sort(key=itemgetter("TOOL_IDENTIFIER", "YEAR"))
479-
with open(FILE_ARXIV_YEAR, "w", encoding="utf-8", newline="\n") as fh:
480-
writer = csv.DictWriter(fh, fieldnames=HEADER_YEAR, dialect="unix")
479+
with open(FILE_ARXIV_YEAR, "w", encoding="utf-8", newline="\n") as file_handle:
480+
writer = csv.DictWriter(file_handle, fieldnames=HEADER_YEAR, dialect="unix")
481481
writer.writeheader()
482482
for row in data:
483483
writer.writerow(row)
484484

485485
# Save author buckets summary
486486
data = []
487-
for lic, acs in author_counts.items():
487+
for license_name, author_count_data in author_counts.items():
488488
# build buckets across licenses
489489
bucket_counts = Counter()
490-
for ac, c in acs.items():
491-
b = bucket_author_count(ac)
492-
bucket_counts[b] += c
493-
for b, c in bucket_counts.items():
490+
for author_count, count in author_count_data.items():
491+
bucket = bucket_author_count(author_count)
492+
bucket_counts[bucket] += count
493+
for bucket, count in bucket_counts.items():
494494
data.append(
495-
{"TOOL_IDENTIFIER": lic, "AUTHOR_BUCKET": b, "COUNT": c}
495+
{"TOOL_IDENTIFIER": license_name, "AUTHOR_BUCKET": bucket, "COUNT": count}
496496
)
497497
data.sort(key=itemgetter("TOOL_IDENTIFIER", "AUTHOR_BUCKET"))
498498
with open(
499499
FILE_ARXIV_AUTHOR_BUCKET, "w", encoding="utf-8", newline="\n"
500-
) as fh:
500+
) as file_handle:
501501
writer = csv.DictWriter(
502-
fh, fieldnames=HEADER_AUTHOR_BUCKET, dialect="unix"
502+
file_handle, fieldnames=HEADER_AUTHOR_BUCKET, dialect="unix"
503503
)
504504
writer.writeheader()
505505
for row in data:

0 commit comments

Comments
 (0)