metripy 0.3.2__py3-none-any.whl → 0.3.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of metripy might be problematic. Click here for more details.
- metripy/Application/Info.py +29 -4
- metripy/Report/Html/Reporter.py +34 -7
- metripy/templates/html_report/css/styles.css +1386 -0
- metripy/templates/html_report/dependencies.html +441 -0
- metripy/templates/html_report/files.html +1080 -0
- metripy/templates/html_report/git_analysis.html +325 -0
- metripy/templates/html_report/images/logo.svg +31 -0
- metripy/templates/html_report/index.html +385 -0
- metripy/templates/html_report/js/charts.js +313 -0
- metripy/templates/html_report/js/dashboard.js +546 -0
- metripy/templates/html_report/js/git_analysis.js +383 -0
- metripy/templates/html_report/top_offenders.html +267 -0
- metripy/templates/html_report/trends.html +468 -0
- {metripy-0.3.2.dist-info → metripy-0.3.4.dist-info}/METADATA +1 -1
- {metripy-0.3.2.dist-info → metripy-0.3.4.dist-info}/RECORD +19 -8
- {metripy-0.3.2.dist-info → metripy-0.3.4.dist-info}/WHEEL +0 -0
- {metripy-0.3.2.dist-info → metripy-0.3.4.dist-info}/entry_points.txt +0 -0
- {metripy-0.3.2.dist-info → metripy-0.3.4.dist-info}/licenses/LICENSE +0 -0
- {metripy-0.3.2.dist-info → metripy-0.3.4.dist-info}/top_level.txt +0 -0
metripy/Application/Info.py
CHANGED
|
@@ -1,17 +1,42 @@
|
|
|
1
|
+
from importlib.metadata import version, metadata
|
|
1
2
|
import toml
|
|
2
3
|
|
|
3
4
|
|
|
4
5
|
class Info:
|
|
5
6
|
def __init__(self):
|
|
6
|
-
|
|
7
|
-
self.
|
|
8
|
-
self.url = data["project"]["urls"]["Homepage"]
|
|
7
|
+
self.version = self._get_version()
|
|
8
|
+
self.url = self._get_homepage_url()
|
|
9
9
|
|
|
10
|
-
def
|
|
10
|
+
def _get_pyproject_data(self) -> dict:
|
|
11
11
|
with open("pyproject.toml", "r") as file:
|
|
12
12
|
data = toml.load(file)
|
|
13
13
|
return data
|
|
14
14
|
|
|
15
|
+
def _get_version(self) -> str:
|
|
16
|
+
"""Get version from installed package metadata"""
|
|
17
|
+
try:
|
|
18
|
+
return version("metripy")
|
|
19
|
+
except Exception:
|
|
20
|
+
# Fallback for development if not installed
|
|
21
|
+
return self._get_pyproject_data()["project"]["version"]
|
|
22
|
+
|
|
23
|
+
def _get_homepage_url(self) -> str:
|
|
24
|
+
"""Get homepage URL from installed package metadata"""
|
|
25
|
+
try:
|
|
26
|
+
meta = metadata("metripy")
|
|
27
|
+
# Try to get Home-Page from metadata
|
|
28
|
+
homepage = meta.get("Home-Page")
|
|
29
|
+
if not homepage:
|
|
30
|
+
# Try Project-URL field
|
|
31
|
+
for line in meta.get_all("Project-URL") or []:
|
|
32
|
+
if line.startswith("Homepage"):
|
|
33
|
+
homepage = line.split(",", 1)[1].strip()
|
|
34
|
+
break
|
|
35
|
+
return homepage or "no homepage found"
|
|
36
|
+
except Exception:
|
|
37
|
+
# Fallback
|
|
38
|
+
return self._get_pyproject_data()["project"]["urls"]["Homepage"]
|
|
39
|
+
|
|
15
40
|
def get_version(self) -> str:
|
|
16
41
|
return self.version
|
|
17
42
|
|
metripy/Report/Html/Reporter.py
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import shutil
|
|
3
|
+
import sys
|
|
3
4
|
from datetime import datetime
|
|
5
|
+
from pathlib import Path
|
|
4
6
|
|
|
5
7
|
|
|
6
8
|
from metripy.Application.Config.ReportConfig import ReportConfig
|
|
@@ -16,7 +18,16 @@ class Reporter(ReporterInterface):
|
|
|
16
18
|
):
|
|
17
19
|
self.config: ReportConfig = config
|
|
18
20
|
self.output = output
|
|
19
|
-
|
|
21
|
+
|
|
22
|
+
# Find templates directory - works both in development and when installed
|
|
23
|
+
template_dir = self._find_template_dir()
|
|
24
|
+
if not template_dir.exists():
|
|
25
|
+
raise FileNotFoundError(
|
|
26
|
+
f"Could not find templates directory. Searched in: "
|
|
27
|
+
f"{template_dir}"
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
self.template_dir = str(template_dir)
|
|
20
31
|
self.project_name = project_name
|
|
21
32
|
|
|
22
33
|
self.page_renderer_factory = PageRendererFactory(
|
|
@@ -27,6 +38,28 @@ class Reporter(ReporterInterface):
|
|
|
27
38
|
"project_name": project_name,
|
|
28
39
|
"last_updated": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
|
|
29
40
|
}
|
|
41
|
+
|
|
42
|
+
def _find_template_dir(self) -> Path:
|
|
43
|
+
"""Find the templates directory, checking multiple possible locations"""
|
|
44
|
+
package_dir = Path(__file__).parent.parent.parent # metripy package root
|
|
45
|
+
|
|
46
|
+
# List of possible locations to check
|
|
47
|
+
possible_locations = [
|
|
48
|
+
# Development: templates at project root
|
|
49
|
+
package_dir.parent / "templates" / "html_report",
|
|
50
|
+
# Alternative: templates inside metripy package
|
|
51
|
+
package_dir / "templates" / "html_report",
|
|
52
|
+
# System install location
|
|
53
|
+
Path(sys.prefix) / "share" / "metripy" / "templates" / "html_report",
|
|
54
|
+
# Fallback to cwd (for development)
|
|
55
|
+
Path.cwd() / "metripy" / "templates" / "html_report",
|
|
56
|
+
]
|
|
57
|
+
|
|
58
|
+
for location in possible_locations:
|
|
59
|
+
if location.exists() and (location / "index.html").exists():
|
|
60
|
+
return location
|
|
61
|
+
|
|
62
|
+
return possible_locations[0]
|
|
30
63
|
|
|
31
64
|
def generate(self, metrics: ProjectMetrics):
|
|
32
65
|
|
|
@@ -63,12 +96,6 @@ class Reporter(ReporterInterface):
|
|
|
63
96
|
)
|
|
64
97
|
# shutil.copytree(os.path.join(self.template_dir, "fonts"), os.path.join(self.config.path, "fonts"), dirs_exist_ok=True)
|
|
65
98
|
|
|
66
|
-
# copy logo, lies 2 down from the templates directory
|
|
67
|
-
shutil.copy(
|
|
68
|
-
os.path.join(self.template_dir, "../..", "logo.svg"),
|
|
69
|
-
os.path.join(self.config.path, "images", "logo.svg"),
|
|
70
|
-
)
|
|
71
|
-
|
|
72
99
|
# Render main pages
|
|
73
100
|
self.render_index_page(metrics)
|
|
74
101
|
self.render_files_page(metrics)
|