Skip to content
Open
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
2 changes: 1 addition & 1 deletion devel/site-list.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# Removes schema-specific keywords for proper processing
social_networks = data.copy()
social_networks.pop('$schema', None)
social_networks.pop("$schema", None)

# Sort the social networks in alphanumeric order
social_networks = sorted(social_networks.items())
Expand Down
42 changes: 27 additions & 15 deletions devel/summarize_site_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
import sys
from pathlib import Path


def summarize_junit_xml(xml_path: Path) -> str:
tree = ET.parse(xml_path)
root = tree.getroot()
suite = root.find('testsuite')
suite = root.find("testsuite")

pass_message: str = ":heavy_check_mark:   Pass"
fail_message: str = ":x:   Fail"
Expand All @@ -22,42 +23,53 @@ def summarize_junit_xml(xml_path: Path) -> str:
summary_lines.append("| Target | F+ Check | F- Check |")
summary_lines.append("|---|---|---|")

failures = int(suite.get('failures', 0))
failures = int(suite.get("failures", 0))
errors_detected: bool = False

results: dict[str, dict[str, str]] = {}

for testcase in suite.findall('testcase'):
test_name = testcase.get('name').split('[')[0]
site_name = testcase.get('name').split('[')[1].rstrip(']')
failure = testcase.find('failure')
error = testcase.find('error')
for testcase in suite.findall("testcase"):
test_name = testcase.get("name").split("[")[0]
site_name = testcase.get("name").split("[")[1].rstrip("]")
failure = testcase.find("failure")
error = testcase.find("error")

if site_name not in results:
results[site_name] = {}

if test_name == "test_false_neg":
results[site_name]['F- Check'] = pass_message if failure is None and error is None else fail_message
results[site_name]["F- Check"] = (
pass_message if failure is None and error is None else fail_message
)
elif test_name == "test_false_pos":
results[site_name]['F+ Check'] = pass_message if failure is None and error is None else fail_message
results[site_name]["F+ Check"] = (
pass_message if failure is None and error is None else fail_message
)

if error is not None:
errors_detected = True

for result in results:
summary_lines.append(f"| {result} | {results[result].get('F+ Check', 'Error!')} | {results[result].get('F- Check', 'Error!')} |")
summary_lines.append(
f"| {result} | {results[result].get('F+ Check', 'Error!')} | {results[result].get('F- Check', 'Error!')} |"
)

if failures > 0:
summary_lines.append("\n___\n" +
"\nFailures were detected on at least one updated target. Commits containing accuracy failures" +
" will often not be merged (unless a rationale is provided, such as false negatives due to regional differences).")
summary_lines.append(
"\n___\n"
+ "\nFailures were detected on at least one updated target. Commits containing accuracy failures"
+ " will often not be merged (unless a rationale is provided, such as false negatives due to regional differences)."
)

if errors_detected:
summary_lines.append("\n___\n" +
"\n**Errors were detected during validation. Please review the workflow logs.**")
summary_lines.append(
"\n___\n"
+ "\n**Errors were detected during validation. Please review the workflow logs.**"
)

return "\n".join(summary_lines)


if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: summarize_site_validation.py <junit-xml-file>")
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ stem = "^1.8.0"
pandas = "^2.2.1"
openpyxl = "^3.0.10"
tomli = "^2.2.1"
tqdm = "^4.66.0"

[tool.poetry.group.dev.dependencies]
jsonschema = "^4.0.0"
Expand Down
17 changes: 11 additions & 6 deletions sherlock_project/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""" Sherlock Module
"""Sherlock Module

This module contains the main logic to search for usernames at social
networks.
Expand All @@ -15,16 +15,21 @@ def get_version() -> str:
try:
return pkg_version("sherlock_project")
except PackageNotFoundError:
pyproject_path: pathlib.Path = pathlib.Path(__file__).resolve().parent.parent / "pyproject.toml"
pyproject_path: pathlib.Path = (
pathlib.Path(__file__).resolve().parent.parent / "pyproject.toml"
)
with pyproject_path.open("rb") as f:
pyproject_data = tomli.load(f)
return pyproject_data["tool"]["poetry"]["version"]


# This variable is only used to check for ImportErrors induced by users running as script rather than as module or package
import_error_test_var = None

__shortname__ = "Sherlock"
__longname__ = "Sherlock: Find Usernames Across Social Networks"
__version__ = get_version()
__shortname__ = "Sherlock"
__longname__ = "Sherlock: Find Usernames Across Social Networks"
__version__ = get_version()

forge_api_latest_release = "https://api.github.com/repos/sherlock-project/sherlock/releases/latest"
forge_api_latest_release = (
"https://api.github.com/repos/sherlock-project/sherlock/releases/latest"
)
6 changes: 4 additions & 2 deletions sherlock_project/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@

import sys


if __name__ == "__main__":
# Check if the user is using the correct version of Python
python_version = sys.version.split()[0]

if sys.version_info < (3, 9):
print(f"Sherlock requires Python 3.9+\nYou are using Python {python_version}, which is not supported by Sherlock.")
print(
f"Sherlock requires Python 3.9+\nYou are using Python {python_version}, which is not supported by Sherlock."
)
sys.exit(1)

from sherlock_project import sherlock

sherlock.main()
Loading