safety-metrics-lib 0.1.0__tar.gz

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.
@@ -0,0 +1,8 @@
1
+ Metadata-Version: 2.4
2
+ Name: safety-metrics-lib
3
+ Version: 0.1.0
4
+ Summary: Construction site safety risk scoring and incident metrics utilities.
5
+ Author: Your Name
6
+ Project-URL: Homepage, https://pypi.org/project/safety-metrics-lib/
7
+ Requires-Python: >=3.9
8
+ Description-Content-Type: text/markdown
@@ -0,0 +1,11 @@
1
+ [project]
2
+ name = "safety-metrics-lib"
3
+ version = "0.1.0"
4
+ description = "Construction site safety risk scoring and incident metrics utilities."
5
+ authors = [{ name = "Your Name" }]
6
+ readme = "README.md"
7
+ requires-python = ">=3.9"
8
+ dependencies = []
9
+
10
+ [project.urls]
11
+ Homepage = "https://pypi.org/project/safety-metrics-lib/"
@@ -0,0 +1,9 @@
1
+ from .risk import RiskScoreCalculator
2
+ from .metrics import SiteIncidentMetrics
3
+ from .generators import ObjectKeyGenerator
4
+
5
+ __all__ = [
6
+ "RiskScoreCalculator",
7
+ "SiteIncidentMetrics",
8
+ "ObjectKeyGenerator",
9
+ ]
@@ -0,0 +1,7 @@
1
+ import uuid
2
+
3
+ class ObjectKeyGenerator:
4
+ def create_incident_object_key(self, site_id: int, filename: str) -> str:
5
+ extension = filename.split(".")[-1] if "." in filename else "bin"
6
+ unique_id = uuid.uuid4()
7
+ return f"sites/{site_id}/incidents/{unique_id}.{extension}"
@@ -0,0 +1,21 @@
1
+ from dataclasses import dataclass
2
+ from typing import Iterable
3
+
4
+ @dataclass
5
+ class IncidentRecord:
6
+ severity: str
7
+
8
+ @dataclass
9
+ class SiteIncidentMetrics:
10
+ total_incidents: int
11
+ high_incidents: int
12
+
13
+ @classmethod
14
+ def from_incidents(cls, incidents: Iterable[IncidentRecord]) -> "SiteIncidentMetrics":
15
+ total = 0
16
+ high = 0
17
+ for incident in incidents:
18
+ total += 1
19
+ if incident.severity == "high":
20
+ high += 1
21
+ return cls(total_incidents=total, high_incidents=high)
@@ -0,0 +1,20 @@
1
+ from dataclasses import dataclass
2
+
3
+ @dataclass
4
+ class RiskInput:
5
+ severity: str
6
+ description_length: int
7
+ previous_high_incidents: int
8
+
9
+ class RiskScoreCalculator:
10
+ def calculate(self, risk_input: RiskInput) -> int:
11
+ base = {
12
+ "low": 1,
13
+ "medium": 3,
14
+ "high": 5,
15
+ }.get(risk_input.severity, 1)
16
+
17
+ history_factor = 1 if risk_input.previous_high_incidents >= 3 else 0
18
+ description_factor = 1 if risk_input.description_length > 200 else 0
19
+
20
+ return base + history_factor + description_factor
@@ -0,0 +1,8 @@
1
+ Metadata-Version: 2.4
2
+ Name: safety-metrics-lib
3
+ Version: 0.1.0
4
+ Summary: Construction site safety risk scoring and incident metrics utilities.
5
+ Author: Your Name
6
+ Project-URL: Homepage, https://pypi.org/project/safety-metrics-lib/
7
+ Requires-Python: >=3.9
8
+ Description-Content-Type: text/markdown
@@ -0,0 +1,10 @@
1
+ pyproject.toml
2
+ safety_metrics/__init__.py
3
+ safety_metrics/generators.py
4
+ safety_metrics/metrics.py
5
+ safety_metrics/risk.py
6
+ safety_metrics_lib.egg-info/PKG-INFO
7
+ safety_metrics_lib.egg-info/SOURCES.txt
8
+ safety_metrics_lib.egg-info/dependency_links.txt
9
+ safety_metrics_lib.egg-info/top_level.txt
10
+ tests/test_risk.py
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
File without changes