lawkit-python 2.1.2__tar.gz → 2.3.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.
- {lawkit_python-2.1.2 → lawkit_python-2.3.0}/PKG-INFO +2 -4
- {lawkit_python-2.1.2 → lawkit_python-2.3.0}/pyproject.toml +4 -5
- {lawkit_python-2.1.2 → lawkit_python-2.3.0}/src/lawkit/__init__.py +1 -5
- lawkit_python-2.1.2/src/lawkit/compat.py +0 -204
- {lawkit_python-2.1.2 → lawkit_python-2.3.0}/.gitignore +0 -0
- {lawkit_python-2.1.2 → lawkit_python-2.3.0}/README.md +0 -0
- {lawkit_python-2.1.2 → lawkit_python-2.3.0}/src/lawkit/installer.py +0 -0
- {lawkit_python-2.1.2 → lawkit_python-2.3.0}/src/lawkit/lawkit.py +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: lawkit-python
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3.0
|
|
4
4
|
Summary: Python wrapper for lawkit - Statistical law analysis toolkit for fraud detection and data quality assessment
|
|
5
5
|
Project-URL: Homepage, https://github.com/kako-jun/lawkit
|
|
6
6
|
Project-URL: Repository, https://github.com/kako-jun/lawkit
|
|
7
7
|
Project-URL: Issues, https://github.com/kako-jun/lawkit/issues
|
|
8
8
|
Project-URL: Documentation, https://github.com/kako-jun/lawkit/tree/main/docs
|
|
9
|
-
Author
|
|
9
|
+
Author: kako-jun
|
|
10
10
|
License-Expression: MIT
|
|
11
11
|
Keywords: anomaly-detection,audit,benford,compliance,data-quality,forensic-accounting,fraud-detection,normal,outlier-detection,pareto,poisson,statistical-analysis,statistics,zipf
|
|
12
12
|
Classifier: Development Status :: 4 - Beta
|
|
@@ -31,11 +31,9 @@ Provides-Extra: dev
|
|
|
31
31
|
Requires-Dist: black; extra == 'dev'
|
|
32
32
|
Requires-Dist: isort; extra == 'dev'
|
|
33
33
|
Requires-Dist: mypy; extra == 'dev'
|
|
34
|
-
Requires-Dist: pytest-asyncio; extra == 'dev'
|
|
35
34
|
Requires-Dist: pytest-cov; extra == 'dev'
|
|
36
35
|
Requires-Dist: pytest>=6.0; extra == 'dev'
|
|
37
36
|
Requires-Dist: ruff; extra == 'dev'
|
|
38
|
-
Requires-Dist: types-requests; extra == 'dev'
|
|
39
37
|
Description-Content-Type: text/markdown
|
|
40
38
|
|
|
41
39
|
# lawkit-python
|
|
@@ -4,12 +4,12 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "lawkit-python"
|
|
7
|
-
version = "2.
|
|
7
|
+
version = "2.3.0"
|
|
8
8
|
description = "Python wrapper for lawkit - Statistical law analysis toolkit for fraud detection and data quality assessment"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT"
|
|
11
11
|
authors = [
|
|
12
|
-
{ name = "kako-jun"
|
|
12
|
+
{ name = "kako-jun" }
|
|
13
13
|
]
|
|
14
14
|
classifiers = [
|
|
15
15
|
"Development Status :: 4 - Beta",
|
|
@@ -59,12 +59,10 @@ Documentation = "https://github.com/kako-jun/lawkit/tree/main/docs"
|
|
|
59
59
|
dev = [
|
|
60
60
|
"pytest >= 6.0",
|
|
61
61
|
"pytest-cov",
|
|
62
|
-
"pytest-asyncio",
|
|
63
62
|
"black",
|
|
64
63
|
"isort",
|
|
65
64
|
"mypy",
|
|
66
|
-
"ruff"
|
|
67
|
-
"types-requests"
|
|
65
|
+
"ruff"
|
|
68
66
|
]
|
|
69
67
|
|
|
70
68
|
[project.scripts]
|
|
@@ -76,6 +74,7 @@ packages = ["src/lawkit"]
|
|
|
76
74
|
[tool.hatch.build.targets.sdist]
|
|
77
75
|
include = [
|
|
78
76
|
"/src",
|
|
77
|
+
"/scripts",
|
|
79
78
|
"/README.md"
|
|
80
79
|
]
|
|
81
80
|
|
|
@@ -30,10 +30,8 @@ from .lawkit import (
|
|
|
30
30
|
LawType,
|
|
31
31
|
)
|
|
32
32
|
|
|
33
|
-
# For backward compatibility and convenience
|
|
34
|
-
from .compat import run_lawkit
|
|
35
33
|
|
|
36
|
-
__version__ = "2.
|
|
34
|
+
__version__ = "2.3.0"
|
|
37
35
|
__all__ = [
|
|
38
36
|
# Main analysis functions
|
|
39
37
|
"analyze_benford",
|
|
@@ -61,6 +59,4 @@ __all__ = [
|
|
|
61
59
|
"OutputFormat",
|
|
62
60
|
"LawType",
|
|
63
61
|
|
|
64
|
-
# Backward compatibility
|
|
65
|
-
"run_lawkit",
|
|
66
62
|
]
|
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Backward compatibility module for lawkit-python
|
|
3
|
-
|
|
4
|
-
This module provides compatibility functions for users migrating from
|
|
5
|
-
other statistical analysis tools or expecting different API patterns.
|
|
6
|
-
"""
|
|
7
|
-
|
|
8
|
-
import subprocess
|
|
9
|
-
import platform
|
|
10
|
-
from pathlib import Path
|
|
11
|
-
from typing import List, Union
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class LawkitProcess:
|
|
15
|
-
"""Compatibility class that mimics subprocess.CompletedProcess"""
|
|
16
|
-
def __init__(self, returncode: int, stdout: str, stderr: str):
|
|
17
|
-
self.returncode = returncode
|
|
18
|
-
self.stdout = stdout
|
|
19
|
-
self.stderr = stderr
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
def run_lawkit(args: List[str], input_data: Union[str, None] = None) -> LawkitProcess:
|
|
23
|
-
"""
|
|
24
|
-
Run lawkit command with arguments (legacy compatibility function)
|
|
25
|
-
|
|
26
|
-
Args:
|
|
27
|
-
args: Command line arguments (without 'lawkit' prefix)
|
|
28
|
-
input_data: Optional input data to pass via stdin
|
|
29
|
-
|
|
30
|
-
Returns:
|
|
31
|
-
LawkitProcess object with returncode, stdout, stderr
|
|
32
|
-
|
|
33
|
-
Examples:
|
|
34
|
-
>>> result = run_lawkit(["benf", "data.csv"])
|
|
35
|
-
>>> if result.returncode == 0:
|
|
36
|
-
... print("Analysis successful")
|
|
37
|
-
... print(result.stdout)
|
|
38
|
-
... else:
|
|
39
|
-
... print("Analysis failed")
|
|
40
|
-
... print(result.stderr)
|
|
41
|
-
|
|
42
|
-
>>> # With input data
|
|
43
|
-
>>> csv_data = "amount\\n123\\n456\\n789"
|
|
44
|
-
>>> result = run_lawkit(["benf", "-"], input_data=csv_data)
|
|
45
|
-
"""
|
|
46
|
-
# Get the path to the lawkit binary
|
|
47
|
-
package_dir = Path(__file__).parent.parent.parent
|
|
48
|
-
binary_name = "lawkit.exe" if platform.system() == "Windows" else "lawkit"
|
|
49
|
-
local_binary_path = package_dir / "bin" / binary_name
|
|
50
|
-
|
|
51
|
-
if local_binary_path.exists():
|
|
52
|
-
lawkit_path = str(local_binary_path)
|
|
53
|
-
else:
|
|
54
|
-
lawkit_path = "lawkit"
|
|
55
|
-
|
|
56
|
-
try:
|
|
57
|
-
# Run the command
|
|
58
|
-
result = subprocess.run(
|
|
59
|
-
[lawkit_path] + args,
|
|
60
|
-
input=input_data,
|
|
61
|
-
capture_output=True,
|
|
62
|
-
text=True,
|
|
63
|
-
timeout=300 # 5 minute timeout
|
|
64
|
-
)
|
|
65
|
-
|
|
66
|
-
return LawkitProcess(
|
|
67
|
-
returncode=result.returncode,
|
|
68
|
-
stdout=result.stdout,
|
|
69
|
-
stderr=result.stderr
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
except subprocess.TimeoutExpired:
|
|
73
|
-
return LawkitProcess(
|
|
74
|
-
returncode=-1,
|
|
75
|
-
stdout="",
|
|
76
|
-
stderr="Command timed out after 5 minutes"
|
|
77
|
-
)
|
|
78
|
-
except FileNotFoundError:
|
|
79
|
-
return LawkitProcess(
|
|
80
|
-
returncode=-1,
|
|
81
|
-
stdout="",
|
|
82
|
-
stderr="lawkit command not found. Please install lawkit CLI tool."
|
|
83
|
-
)
|
|
84
|
-
except Exception as e:
|
|
85
|
-
return LawkitProcess(
|
|
86
|
-
returncode=-1,
|
|
87
|
-
stdout="",
|
|
88
|
-
stderr=f"Error running lawkit: {e}"
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
def run_benford_analysis(file_path: str, **kwargs) -> LawkitProcess:
|
|
93
|
-
"""
|
|
94
|
-
Legacy function for Benford's Law analysis
|
|
95
|
-
|
|
96
|
-
Args:
|
|
97
|
-
file_path: Path to input file
|
|
98
|
-
**kwargs: Additional options (format, output, etc.)
|
|
99
|
-
|
|
100
|
-
Returns:
|
|
101
|
-
LawkitProcess object
|
|
102
|
-
|
|
103
|
-
Examples:
|
|
104
|
-
>>> result = run_benford_analysis("data.csv", format="csv", output="json")
|
|
105
|
-
"""
|
|
106
|
-
args = ["benf", file_path]
|
|
107
|
-
|
|
108
|
-
if "format" in kwargs:
|
|
109
|
-
args.extend(["--format", kwargs["format"]])
|
|
110
|
-
|
|
111
|
-
if "output" in kwargs:
|
|
112
|
-
args.extend(["--output", kwargs["output"]])
|
|
113
|
-
|
|
114
|
-
if "min_count" in kwargs:
|
|
115
|
-
args.extend(["--min-count", str(kwargs["min_count"])])
|
|
116
|
-
|
|
117
|
-
if "threshold" in kwargs:
|
|
118
|
-
args.extend(["--threshold", str(kwargs["threshold"])])
|
|
119
|
-
|
|
120
|
-
if kwargs.get("verbose", False):
|
|
121
|
-
args.append("--verbose")
|
|
122
|
-
|
|
123
|
-
if kwargs.get("optimize", False):
|
|
124
|
-
args.append("--optimize")
|
|
125
|
-
|
|
126
|
-
return run_lawkit(args)
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
def run_pareto_analysis(file_path: str, **kwargs) -> LawkitProcess:
|
|
130
|
-
"""
|
|
131
|
-
Legacy function for Pareto principle analysis
|
|
132
|
-
|
|
133
|
-
Args:
|
|
134
|
-
file_path: Path to input file
|
|
135
|
-
**kwargs: Additional options
|
|
136
|
-
|
|
137
|
-
Returns:
|
|
138
|
-
LawkitProcess object
|
|
139
|
-
|
|
140
|
-
Examples:
|
|
141
|
-
>>> result = run_pareto_analysis("sales.csv", gini_coefficient=True)
|
|
142
|
-
"""
|
|
143
|
-
args = ["pareto", file_path]
|
|
144
|
-
|
|
145
|
-
if "format" in kwargs:
|
|
146
|
-
args.extend(["--format", kwargs["format"]])
|
|
147
|
-
|
|
148
|
-
if "output" in kwargs:
|
|
149
|
-
args.extend(["--output", kwargs["output"]])
|
|
150
|
-
|
|
151
|
-
if kwargs.get("gini_coefficient", False):
|
|
152
|
-
args.append("--gini-coefficient")
|
|
153
|
-
|
|
154
|
-
if "percentiles" in kwargs:
|
|
155
|
-
args.extend(["--percentiles", kwargs["percentiles"]])
|
|
156
|
-
|
|
157
|
-
if kwargs.get("business_analysis", False):
|
|
158
|
-
args.append("--business-analysis")
|
|
159
|
-
|
|
160
|
-
if kwargs.get("verbose", False):
|
|
161
|
-
args.append("--verbose")
|
|
162
|
-
|
|
163
|
-
return run_lawkit(args)
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
def check_lawkit_installation() -> bool:
|
|
167
|
-
"""
|
|
168
|
-
Check if lawkit is properly installed
|
|
169
|
-
|
|
170
|
-
Returns:
|
|
171
|
-
True if lawkit is available, False otherwise
|
|
172
|
-
|
|
173
|
-
Examples:
|
|
174
|
-
>>> if not check_lawkit_installation():
|
|
175
|
-
... print("Please install lawkit first")
|
|
176
|
-
... exit(1)
|
|
177
|
-
"""
|
|
178
|
-
result = run_lawkit(["--version"])
|
|
179
|
-
return result.returncode == 0
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
def get_lawkit_help(subcommand: str = None) -> str:
|
|
183
|
-
"""
|
|
184
|
-
Get help text for lawkit or a specific subcommand
|
|
185
|
-
|
|
186
|
-
Args:
|
|
187
|
-
subcommand: Optional subcommand name
|
|
188
|
-
|
|
189
|
-
Returns:
|
|
190
|
-
Help text as string
|
|
191
|
-
|
|
192
|
-
Examples:
|
|
193
|
-
>>> help_text = get_lawkit_help()
|
|
194
|
-
>>> print(help_text)
|
|
195
|
-
|
|
196
|
-
>>> benf_help = get_lawkit_help("benf")
|
|
197
|
-
>>> print(benf_help)
|
|
198
|
-
"""
|
|
199
|
-
if subcommand:
|
|
200
|
-
result = run_lawkit([subcommand, "--help"])
|
|
201
|
-
else:
|
|
202
|
-
result = run_lawkit(["--help"])
|
|
203
|
-
|
|
204
|
-
return result.stdout if result.returncode == 0 else result.stderr
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|