From 1fcfe145a10548ae0e0093bbb93d243402c9a413 Mon Sep 17 00:00:00 2001 From: Dao McGill <77309217+daomcgill@users.noreply.github.com> Date: Mon, 9 Dec 2024 11:38:33 -1000 Subject: [PATCH] i #314 Fixed exec script configs Signed-off-by: Dao McGill --- exec/annotate.R | 17 +++--- exec/mailinglist.R | 106 -------------------------------------- exec/src_content_parser.R | 14 ++--- 3 files changed, 12 insertions(+), 125 deletions(-) delete mode 100755 exec/mailinglist.R diff --git a/exec/annotate.R b/exec/annotate.R index 7f2a003b..289349cb 100755 --- a/exec/annotate.R +++ b/exec/annotate.R @@ -19,7 +19,7 @@ require(gt,quietly=TRUE) doc <- " USAGE: annotate.R annotate help - annotate.R annotate + annotate.R annotate annotate.R (-h | --help) annotate.R --version @@ -27,7 +27,7 @@ DESCRIPTION: Provides a function to interact with Kaiaulu's Syntax Extractor, to generate an annotated XML file. Please see Kaiaulu's README.md for instructions on how to create - and . + and . OPTIONS: @@ -35,25 +35,24 @@ OPTIONS: --version Show version. " -arguments <- docopt::docopt(doc, version = 'Kaiaulu 0.0.0.9600') +arguments <- docopt::docopt(doc, version = 'Kaiaulu 0.0.0.9700') if(arguments[["annotate"]] & arguments[["help"]]){ cli_alert_info("Annotates source code using srcML.") }else if(arguments[["annotate"]]){ tools_path <- arguments[[""]] - conf_path <- arguments[[""]] - srcml_filepath <- arguments[[""]] + conf_path <- arguments[[""]] tool_conf <- parse_config(tools_path) - maven_conf <- parse_config(conf_path) + project_conf <- parse_config(conf_path) srcml_path <- get_tool_project("srcml", tool_conf) - src_folder <- get_src_folder(maven_conf) - srcml_output_path <- get_srcml_filepath(maven_conf) + src_folder <- get_src_folder(project_conf) + srcml_filepath <- get_srcml_filepath(project_conf) srcml_path <- path.expand(srcml_path) src_folder <- path.expand(src_folder) - srcml_output_path <- path.expand(srcml_output_path) + srcml_filepath <- path.expand(srcml_filepath) annotated_file <- annotate_src_text( srcml_path = srcml_path, diff --git a/exec/mailinglist.R b/exec/mailinglist.R deleted file mode 100755 index 278edbdd..00000000 --- a/exec/mailinglist.R +++ /dev/null @@ -1,106 +0,0 @@ -#!/usr/local/bin/Rscript - -# Kaiaulu - https://github.com/sailuh/kaiaulu -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at https://mozilla.org/MPL/2.0/. - -require(yaml,quietly=TRUE) -require(cli,quietly=TRUE) -require(docopt,quietly=TRUE) -require(kaiaulu,quietly=TRUE) -require(data.table,quietly=TRUE) - - - -doc <- " -USAGE: - mailinglist.R tabulate help - mailinglist.R tabulate - mailinglist.R download modmbox help - mailinglist.R download modmbox - mailinglist.R download modmboxmonth help - mailinglist.R download modmboxmonth - mailinglist.R (-h | --help) - mailinglist.R --version - -DESCRIPTION: - Provides a suite of functions to interact with Mailing Lists. Please see - Kaiaulu's README.md for instructions on how to create - and . - - -OPTIONS: - -h --help Show this screen. - --version Show version. -" - - - -arguments <- docopt::docopt(doc, version = 'Kaiaulu 0.0.0.9600') -if(arguments[["tabulate"]] & arguments[["help"]]){ - cli_alert_info("Tabulates a mailing list using parse_mbox().") -}else if(arguments[["tabulate"]]){ - - tools_path <- arguments[[""]] - conf_path <- arguments[[""]] - save_path <- arguments[[""]] - - tool <- yaml::read_yaml(tools_path) - conf <- yaml::read_yaml(conf_path) - - perceval_path <- path.expand(tool[["perceval"]]) - mbox_path <- path.expand(conf[["mailing_list"]][["mbox"]]) - - project_mbox <- parse_mbox(perceval_path,mbox_path) - - cli_alert_success(paste0("Tabulated mailing list was saved at: ",save_path)) - - data.table::fwrite(project_mbox,save_path) -}else if(arguments[["download"]] & arguments[["modmbox"]] & arguments[["help"]]){ - cli_alert_info("Saves a mailing list archive from mod_mbox as a .mbox file - using download_mod_mbox().") -}else if(arguments[["download"]] & arguments[["modmbox"]]){ - - - conf_path <- arguments[[""]] - save_path <- arguments[[""]] - conf <- yaml::read_yaml(conf_path) - - mod_mbox_url <- conf[["mailing_list"]][["domain"]] - mailing_list <- conf[["mailing_list"]][["list_key"]][1] - - start_year <- arguments[[""]] - end_year <- arguments[[""]] - - mbox <- download_mod_mbox(base_url = mod_mbox_url, - mailing_list = mailing_list, - from_year=start_year, - to_year=end_year, - save_file_path = save_path, - verbose = TRUE) - - cli_alert_success(paste0("Downloaded mailing list was saved at: ",save_path)) -}else if(arguments[["download"]] & arguments[["modmboxmonth"]]){ - - - conf_path <- arguments[[""]] - save_path <- arguments[[""]] - conf <- yaml::read_yaml(conf_path) - - mod_mbox_url <- conf[["mailing_list"]][["domain"]] - mailing_list <- conf[["mailing_list"]][["list_key"]][1] - - start_year <- arguments[[""]] - end_year <- arguments[[""]] - - mbox <- download_mod_mbox_per_month(base_url = mod_mbox_url, - mailing_list = mailing_list, - from_year=start_year, - to_year=end_year, - save_folder_path = save_path, - verbose = TRUE) - - cli_alert_success(paste0("Downloaded mailing list was saved at: ",save_path)) -} diff --git a/exec/src_content_parser.R b/exec/src_content_parser.R index 6da3a2fb..cf238eeb 100755 --- a/exec/src_content_parser.R +++ b/exec/src_content_parser.R @@ -13,7 +13,7 @@ source('../../kaiaulu/R/src.R') doc <- " USAGE: - src_content_parser.R query [--namespace | --file-docs | --class-docs | --variables | --packages | --functions | --imports | --class-names] + src_content_parser.R query [--namespace | --file-docs | --class-docs | --variables | --packages | --functions | --imports | --class-names] DESCRIPTION: Uses srcML to parse a source code folder, as specified on the project configuration file, to parse selected content and generate structured tables (e.g., classes, functions, variables) as CSV files. Each query option produces a table with a specific structure. See OPTIONS for details. @@ -29,21 +29,15 @@ OPTIONS: --class-names Returns a 2-column table (filepath, classname) where each row is defined by a class name. " -arguments <- docopt::docopt(doc, version = 'Kaiaulu 0.0.0.9600') +arguments <- docopt::docopt(doc, version = 'Kaiaulu 0.0.0.9700') tools_conf <- parse_config(arguments[[""]]) project_conf <- parse_config(arguments[[""]]) srcml_path <- get_tool_project("srcml", tools_conf) src_folder <- get_src_folder(project_conf) -srcml_filepath <- arguments[[""]] -output_dir <- arguments[[""]] - -# Set output folder path -output_folder <- output_dir -if (!dir.exists(output_folder)) { - dir.create(output_folder, recursive = TRUE) -} +srcml_filepath <- get_srcml_filepath(project_conf) +output_folder <- arguments[[""]] # Determine which query to run and save output if (arguments[["--namespace"]]) {