Skip to content

Commit

Permalink
Merge branch 'master' into mbranch
Browse files Browse the repository at this point in the history
  • Loading branch information
boulais01 authored Nov 14, 2023
2 parents d3d9ba2 + 69e3f9a commit 63bdd68
Show file tree
Hide file tree
Showing 13 changed files with 366 additions and 183 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,21 @@ CSV files that correspond to each of the tables inside of the database.
You can learn more about the `integrate` sub-command by typing `chasten
integrate --help`.

## 💠 Verbose Output

When utilizing the `chasten` command, appending this `--verbose` flag can significantly enhance your troubleshooting experience and provide a detailed understanding of the tool's functionality. Here is an example with `chasten analyze lazytracker`:

```shell
chasten analyze lazytracker \
--config <path to the chasten-configuration/ directory> \
--search-path <path to the lazytracker/ directory> \
--save-directory <path to the subject-data/lazytracker/ directory> \
--save
--verbose
```

Upon executing this command, you can expect the output to contain informative messages such as `✨ Matching source code:` indicating that the tool is actively comparing the source code against the specified patterns. Additionally, you will receive detailed match results, providing insights into the identified checks.

## 🌄 Results

If you want to create an interactive analysis dashboard that uses 📦
Expand Down
1 change: 1 addition & 0 deletions chasten-test
Submodule chasten-test added at 2d8478
3 changes: 3 additions & 0 deletions chasten/constants.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
"""Define constants with dataclasses for use in chasten."""

from dataclasses import dataclass
from pathlib import Path


# chasten constant
@dataclass(frozen=True)
class Chasten:
"""Define the Chasten dataclass for constant(s)."""

Analyze_Storage: Path
Application_Name: str
Application_Author: str
Chasten_Database_View: str
Expand All @@ -26,6 +28,7 @@ class Chasten:


chasten = Chasten(
Analyze_Storage=Path("analysis.md"),
Application_Name="chasten",
Application_Author="ChastenedTeam",
Chasten_Database_View="chasten_complete",
Expand Down
43 changes: 27 additions & 16 deletions chasten/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from sqlite_utils import Database

from chasten import constants, enumerations, filesystem, output
from chasten import constants, enumerations, filesystem, output, util

CHASTEN_SQL_SELECT_QUERY = """
SELECT
Expand Down Expand Up @@ -66,7 +66,6 @@ def enable_full_text_search(chasten_database_name: str) -> None:
database["sources"].enable_fts(
[
"filename",
"filelines",
"check_id",
"check_name",
"check_description",
Expand Down Expand Up @@ -129,18 +128,6 @@ def display_datasette_details(
output.console.print()


def executable_name(OpSystem: str = "Linux") -> str:
"""Get the executable directory depending on OS"""
exe_directory = "/bin/"
executable_name = constants.datasette.Datasette_Executable
# Checks if the OS is windows and changed where to search if true
if OpSystem == "Windows":
exe_directory = "/Scripts/"
executable_name += ".exe"
virtual_env_location = sys.prefix
return virtual_env_location + exe_directory + executable_name


def start_datasette_server( # noqa: PLR0912, PLR0913
database_path: Path,
datasette_metadata: Path,
Expand All @@ -160,7 +147,9 @@ def start_datasette_server( # noqa: PLR0912, PLR0913
# chasten will exist in a bin directory. For instance, the "datasette"
# executable that is a dependency of chasten can be found by starting
# the search from this location for the virtual environment.
full_executable_name = executable_name(OpSystem)
full_executable_name = util.executable_name(
constants.datasette.Datasette_Executable, OpSystem
)
(found_executable, executable_path) = filesystem.can_find_executable(
full_executable_name
)
Expand Down Expand Up @@ -224,7 +213,7 @@ def start_datasette_server( # noqa: PLR0912, PLR0913
# datasette-publish-fly plugin) and thus need to exit and not proceed
if not found_publish_platform_executable:
output.console.print(
":person_shrugging: Was not able to find '{datasette_platform}'"
f":person_shrugging: Was not able to find '{datasette_platform}'"
)
return None
# was able to find the fly or vercel executable that will support the
Expand Down Expand Up @@ -276,3 +265,25 @@ def start_datasette_server( # noqa: PLR0912, PLR0913
# there is debugging output in the console to indicate this option.
proc = subprocess.Popen(cmd)
proc.wait()


def display_results_frog_mouth(result_file, OpSystem) -> None:
"""Run frogmouth as a subprocess of chasten"""
cmd = [
"frogmouth",
result_file,
]
executable = util.executable_name("frogmouth", OpSystem)
exec_found, executable_path = filesystem.can_find_executable(executable)
if exec_found:
# run frogmouth with specified path
output.console.print("\n🐸 Frogmouth Information\n")
output.console.print(f" {small_bullet_unicode} Venv: {sys.prefix}")
output.console.print(f" {small_bullet_unicode} Program: {executable_path}")
proc = subprocess.Popen(cmd)
proc.wait()
else:
output.console.print(
":person_shrugging: Was not able to find frogmouth executable try installing it separately"
)
return None
4 changes: 2 additions & 2 deletions chasten/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def write_dict_results(
# using indentation to ensure that JSON file is readable
results_path_with_file = results_path / complete_results_file_name
# use the built-in method from pathlib Path to write the JSON contents
results_path_with_file.write_text(results_json)
results_path_with_file.write_text(results_json, "utf-8")
# return the name of the file that contains the JSON dictionary contents
return complete_results_file_name

Expand Down Expand Up @@ -293,7 +293,7 @@ def get_json_results(json_paths: List[Path]) -> List[Dict[Any, Any]]:
# iterate through each of the provided paths to a JSON file
for json_path in json_paths:
# turn the contents of the current JSON file into a dictionary
json_dict = json.loads(json_path.read_text())
json_dict = json.loads(json_path.read_text("utf-8"))
# add the current dictionary to the list of dictionaries
json_dicts_list.append(json_dict)
# return the list of JSON dictionaries
Expand Down
Loading

0 comments on commit 63bdd68

Please sign in to comment.