Skip to content

Commit

Permalink
i #314 Use get() for execs
Browse files Browse the repository at this point in the history
Signed-off-by: Dao McGill <[email protected]>
  • Loading branch information
daomcgill committed Dec 9, 2024
1 parent 84693ce commit d28e59d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 26 deletions.
14 changes: 9 additions & 5 deletions exec/annotate.R
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,16 @@ if(arguments[["annotate"]] & arguments[["help"]]){
conf_path <- arguments[["<maven.yml>"]]
srcml_filepath <- arguments[["<srcml_filepath>"]]

tool <- yaml::read_yaml(tools_path)
conf <- yaml::read_yaml(conf_path)
tool_conf <- parse_config(tools_path)
maven_conf <- parse_config(conf_path)

srcml_path <- path.expand(tool[["srcml"]])
src_folder <- path.expand(conf[["srcml"]][["src_folder"]])
srcml_filepath <- path.expand(conf[["srcml"]][["srcml_filepath"]])
srcml_path <- get_tool_project("srcml", tool_conf)
src_folder <- get_src_folder(maven_conf)
srcml_output_path <- get_srcml_filepath(maven_conf)

srcml_path <- path.expand(srcml_path)
src_folder <- path.expand(src_folder)
srcml_output_path <- path.expand(srcml_output_path)

annotated_file <- annotate_src_text(
srcml_path = srcml_path,
Expand Down
31 changes: 10 additions & 21 deletions exec/src_content_parser.R
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,18 @@ OPTIONS:

arguments <- docopt::docopt(doc, version = 'Kaiaulu 0.0.0.9600')

tools_path <- path.expand(arguments[["<tools.yml>"]])
conf_path <- path.expand(arguments[["<project_conf.yml>"]])
srcml_filepath <- path.expand(arguments[["<srcml_filepath>"]])
output_dir <- path.expand(arguments[["<output_dir>"]])
tools_conf <- parse_config(arguments[["<tools.yml>"]])
project_conf <- parse_config(arguments[["<project_conf.yml>"]])

# Read configuration
tool <- yaml::read_yaml(tools_path)
conf <- yaml::read_yaml(conf_path)
srcml_path <- tools_conf[["tool"]][["srcml"]][["srcml_path"]]
src_folder <- get_src_folder(project_conf)
srcml_filepath <- arguments[["<srcml_filepath>"]]
output_dir <- arguments[["<output_dir>"]]

# Get the directory of the conf file
conf_dir <- dirname(conf_path)

# Resolve src_folder relative to conf_dir
src_folder <- path.expand(file.path(conf_dir, conf[["srcml"]][["src_folder"]]))

srcml_path <- path.expand(tool[["srcml"]])

# Check if srcml_filepath exists; if not, generate it
if (!file.exists(srcml_filepath)) {
cli_alert_info(paste0("srcml_filepath does not exist. Generating srcML XML at: ", srcml_filepath))
annotate_src_text(srcml_path, src_folder, srcml_filepath)
}
srcml_path <- path.expand(srcml_path)
src_folder <- path.expand(src_folder)
srcml_filepath <- path.expand(srcml_filepath)
output_dir <- path.expand(output_dir)

# Set output folder path
output_folder <- output_dir
Expand Down Expand Up @@ -90,7 +80,6 @@ if (arguments[["--namespace"]]) {
}

# Save to file
# Save to file with proper quoting
write.table(
query_result,
output_file,
Expand Down

0 comments on commit d28e59d

Please sign in to comment.