Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve logging output of function #111

Merged
merged 15 commits into from
Nov 21, 2023
69 changes: 69 additions & 0 deletions analysis.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@

# PASSED: **ID:** 'C001', **Name:** 'class-definition', **Pattern:** './/ClassDef', min=1, max=None

- /Users/jaclynpham/CMPSCI203/new_chasten/chasten/server.py - 1 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/chasten/results.py - 6 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/chasten/enumerations.py - 3 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/chasten/constants.py - 10 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/chasten/debug.py - 2 matches

# PASSED: **ID:** 'F001', **Name:** 'all-function-definition', **Pattern:** './/FunctionDef', min=1, max=None

- /Users/jaclynpham/CMPSCI203/new_chasten/tests/test_debug.py - 8 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/tests/test_configuration.py - 3 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/tests/test_util.py - 4 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/tests/test_filesystem.py - 16 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/tests/test_process.py - 3 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/tests/test_validate.py - 4 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/tests/test_checks.py - 8 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/tests/test_main.py - 14 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/tests/test_constants.py - 5 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/chasten/configuration.py - 5 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/chasten/server.py - 2 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/chasten/util.py - 6 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/chasten/checks.py - 9 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/chasten/database.py - 6 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/chasten/filesystem.py - 12 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/chasten/validate.py - 3 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/chasten/process.py - 4 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/chasten/main.py - 14 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/chasten/output.py - 12 matches

# PASSED: **ID:** 'F002', **Name:** 'dummy-test-non-test-function-definition', **Pattern:** './/FunctionDef\[not(contains(@name, "test_"))]', min=None, max=None

- /Users/jaclynpham/CMPSCI203/new_chasten/tests/test_main.py - 1 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/chasten/configuration.py - 5 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/chasten/server.py - 2 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/chasten/util.py - 6 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/chasten/checks.py - 9 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/chasten/database.py - 6 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/chasten/filesystem.py - 12 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/chasten/validate.py - 3 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/chasten/process.py - 4 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/chasten/main.py - 14 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/chasten/output.py - 10 matches

# PASSED: **ID:** 'CL001', **Name:** 'dummy-test-single-nested-if', **Pattern:** './/FunctionDef/body//If', min=None, max=None

- /Users/jaclynpham/CMPSCI203/new_chasten/tests/test_util.py - 1 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/tests/test_filesystem.py - 1 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/tests/test_process.py - 1 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/tests/test_checks.py - 1 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/tests/test_constants.py - 1 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/chasten/util.py - 3 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/chasten/checks.py - 13 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/chasten/database.py - 12 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/chasten/filesystem.py - 11 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/chasten/validate.py - 2 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/chasten/process.py - 5 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/chasten/main.py - 33 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/chasten/output.py - 7 matches

# PASSED: **ID:** 'CL002', **Name:** 'dummy-test-double-nested-if', **Pattern:** './/FunctionDef/body//If\[ancestor::If and not(parent::orelse)]', min=None, max=None

- /Users/jaclynpham/CMPSCI203/new_chasten/chasten/checks.py - 3 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/chasten/database.py - 4 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/chasten/filesystem.py - 3 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/chasten/validate.py - 1 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/chasten/main.py - 8 matches
- /Users/jaclynpham/CMPSCI203/new_chasten/chasten/output.py - 1 matches
34 changes: 34 additions & 0 deletions chasten/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,11 @@ def configure( # noqa: PLR0913
config=config,
force=force,
)
# setup the console and the logger through the output module
output.setup(debug_level, debug_destination)
output.logger.debug(f"Display verbose output? {verbose}")
output.logger.debug(f"Debug level? {debug_level.value}")
output.logger.debug(f"Debug destination? {debug_destination.value}")
# display the configuration directory and its contents
if task == enumerations.ConfigureTask.VALIDATE:
# validate the configuration files:
Expand Down Expand Up @@ -467,7 +472,13 @@ def analyze( # noqa: PLR0912, PLR0913, PLR0915
force: bool = typer.Option(False, help="Force creation of new markdown file"),
) -> None:
"""💫 Analyze the AST of Python source code."""
# setup the console and the logger through the output module
output.setup(debug_level, debug_destination)
output.logger.debug(f"Display verbose output? {verbose}")
output.logger.debug(f"Debug level? {debug_level.value}")
output.logger.debug(f"Debug destination? {debug_destination.value}")
start_time = time.time()
output.logger.debug("Analysis Started.")
# output the preamble, including extra parameters specific to this function
output_preamble(
verbose,
Expand All @@ -478,6 +489,7 @@ def analyze( # noqa: PLR0912, PLR0913, PLR0915
)
# extract the current version of the program
chasten_version = util.get_chasten_version()
# display current chasten version
output.logger.debug(f"Current version of chasten: {chasten_version}")
# create the include and exclude criteria
include = results.CheckCriterion(
Expand Down Expand Up @@ -514,6 +526,7 @@ def analyze( # noqa: PLR0912, PLR0913, PLR0915
output.console.print(
"\n:person_shrugging: Cannot perform analysis due to configuration error(s).\n"
)
output.logger.debug("Cannot perform analysis due to configuration error(s)")
sys.exit(constants.markers.Non_Zero_Exit)
# extract the list of the specific patterns (i.e., the XPATH expressions)
# that will be used to analyze all of the XML-based representations of
Expand Down Expand Up @@ -574,6 +587,11 @@ def analyze( # noqa: PLR0912, PLR0913, PLR0915
output.console.print()
# create a check_status list for all of the checks
check_status_list: List[bool] = []
# check XPATH version
if xpath == "1.0":
output.logger.info("Using XPath version 1.0")
else:
output.logger.info("Using XPath version 2.0")
# iterate through and perform each of the checks
for current_check in check_list:
# extract the pattern for the current check
Expand Down Expand Up @@ -772,6 +790,7 @@ def analyze( # noqa: PLR0912, PLR0913, PLR0915
output.console.print(
f"\n:joy: All checks passed. Elapsed Time: {elapsed_time} seconds"
)
output.logger.debug("Analysis complete.")
if store_result:
# writes results of analyze into a markdown file
result_path = os.path.abspath(analysis_file_dir)
Expand Down Expand Up @@ -828,9 +847,11 @@ def integrate( # noqa: PLR0913
json_path=json_path,
force=force,
)
output.logger.debug("Integrate function started.")
# output the list of directories subject to checking
output.console.print()
output.console.print(":sparkles: Combining data file(s) in:")
output.logger.debug(":sparkles: Combining data file(s) in:")
output.console.print()
output.print_list_contents(json_path)
# extract all of the JSON dictionaries from the specified files
Expand All @@ -844,13 +865,15 @@ def integrate( # noqa: PLR0913
# output the name of the saved file if saving successfully took place
if combined_json_file_name:
output.console.print(f"\n:sparkles: Saved the file '{combined_json_file_name}'")
output.logger.debug(f"Saved the file '{combined_json_file_name}'.")
# "flatten" (i.e., "un-nest") the now-saved combined JSON file using flatterer
# create the SQLite3 database and then configure the database for use in datasette
combined_flattened_directory = filesystem.write_flattened_csv_and_database(
combined_json_file_name,
output_directory,
project,
)
output.logger.debug("Flattened JSON and created SQLite database.")
# output the name of the saved file if saving successfully took place
if combined_flattened_directory:
output.console.print(
Expand All @@ -861,6 +884,7 @@ def integrate( # noqa: PLR0913
)
output.console.print()
output.console.print(combined_directory_tree)
output.logger.debug("Integrate function completed successfully.")


@cli.command()
Expand Down Expand Up @@ -916,6 +940,11 @@ def datasette_serve( # noqa: PLR0913
datasette_port=port,
metadata=metadata,
)
# setup the console and the logger through the output module
output.setup(debug_level, debug_destination)
output.logger.debug(f"Display verbose output? {verbose}")
output.logger.debug(f"Debug level? {debug_level.value}")
output.logger.debug(f"Debug destination? {debug_destination.value}")
# display diagnostic information about the datasette instance
label = ":sparkles: Starting a local datasette instance:"
display_serve_or_publish_details(
Expand Down Expand Up @@ -985,6 +1014,11 @@ def datasette_publish( # noqa: PLR0913
database=database_path,
metadata=metadata,
)
# setup the console and the logger through the output module
output.setup(debug_level, debug_destination)
output.logger.debug(f"Display verbose output? {verbose}")
output.logger.debug(f"Debug level? {debug_level.value}")
output.logger.debug(f"Debug destination? {debug_destination.value}")
output.console.print()
output.console.print(
f":wave: Make sure that you have previously logged into the '{datasette_platform.value}' platform"
Expand Down
Loading