Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
24 changes: 23 additions & 1 deletion scripts/3-report/gcs_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ def parse_arguments():
help="Enable git actions such as fetch, merge, add, commit, and push"
" (default: False)",
)
parser.add_argument(
"--force",
action="store_true",
help="Regenerate data even if report files exist",
)
args = parser.parse_args()
if not args.enable_save and args.enable_git:
parser.error("--enable-git requires --enable-save")
Expand All @@ -70,6 +75,23 @@ def parse_arguments():
return args


def check_report_completion(args):
""" "
The function checks for the last plot and image
caption created in this script. This helps to
immediately know if all plots in the script have
been created and should not be regenerated.

"""
if args.force:
return
last_entry = shared.path_join(PATHS["data_phase"], "gcs_free_culture.png")
if os.path.exists(last_entry):
raise shared.QuantifyingException(
f"{last_entry} already exists. Report script completed", 0
)


def gcs_intro(args):
"""
Write Google Custom Search (GCS) introduction.
Expand Down Expand Up @@ -491,7 +513,7 @@ def main():
args = parse_arguments()
shared.paths_log(LOGGER, PATHS)
shared.git_fetch_and_merge(args, PATHS["repo"])

check_report_completion(args)
gcs_intro(args)
plot_products(args)
plot_tool_status(args)
Expand Down
25 changes: 25 additions & 0 deletions scripts/3-report/github_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ def parse_arguments():
action="store_true",
help="Regenerate data even if images files already exist",
)
parser.add_argument(
"--force",
action="store_true",
help="Regenerate data even if report files exist",
)
args = parser.parse_args()
if not args.enable_save and args.enable_git:
parser.error("--enable-git requires --enable-save")
Expand All @@ -73,6 +78,25 @@ def parse_arguments():
return args


def check_report_completion(args):
""" "
The function checks for the last plot and image
caption created in this script. This helps to
immediately know if all plots in the script have
been created and should not be regenerated.

"""
if args.force:
return
last_entry = shared.path_join(
PATHS["data_phase"], "github_restriction.png"
)
if os.path.exists(last_entry):
raise shared.QuantifyingException(
f"{last_entry} already exists. Report script completed", 0
)


def load_data(args):
"""
Load the collected data from the CSV file.
Expand Down Expand Up @@ -243,6 +267,7 @@ def main():
args = parse_arguments()
shared.paths_log(LOGGER, PATHS)
shared.git_fetch_and_merge(args, PATHS["repo"])
check_report_completion(args)
github_intro(args)
plot_totals_by_license_type(args)
plot_totals_by_restriction(args)
Expand Down
25 changes: 25 additions & 0 deletions scripts/3-report/wikipedia_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ def parse_arguments():
help="Enable git actions such as fetch, merge, add, commit, and push"
" (default: False)",
)
parser.add_argument(
"--force",
action="store_true",
help="Regenerate data even if report files exist",
)
args = parser.parse_args()
if not args.enable_save and args.enable_git:
parser.error("--enable-git requires --enable-save")
Expand All @@ -68,6 +73,25 @@ def parse_arguments():
return args


def check_report_completion(args):
""" "
The function checks for the last plot and image
caption created in this script. This helps to
immediately know if all plots in the script have
been created and should not be regenerated.

"""
if args.force:
return
last_entry = shared.path_join(
PATHS["data_phase"], "wikipedia_least_language_usage.png"
)
if os.path.exists(last_entry):
raise shared.QuantifyingException(
f"{last_entry} already exists. Report script completed", 0
)


def wikipedia_intro(args):
"""
Write Wikipedia introduction.
Expand Down Expand Up @@ -261,6 +285,7 @@ def main():
args = parse_arguments()
shared.paths_log(LOGGER, PATHS)
shared.git_fetch_and_merge(args, PATHS["repo"])
check_report_completion(args)
wikipedia_intro(args)
plot_language_representation(args)
plot_highest_language_usage(args)
Expand Down