open-case 1.1.2__tar.gz → 2.0.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.
- open_case-2.0.0/PKG-INFO +19 -0
- open_case-2.0.0/pyproject.toml +21 -0
- open_case-2.0.0/pyproject.toml.orig +20 -0
- open_case-2.0.0/src/open_case/main.py +68 -0
- {open_case-1.1.2 → open_case-2.0.0}/src/open_case/utils.py +2 -18
- open_case-1.1.2/PKG-INFO +0 -21
- open_case-1.1.2/pyproject.toml +0 -16
- open_case-1.1.2/src/open_case/config.py +0 -54
- open_case-1.1.2/src/open_case/main.py +0 -51
- {open_case-1.1.2 → open_case-2.0.0}/README.md +0 -0
- {open_case-1.1.2 → open_case-2.0.0}/src/open_case/__init__.py +0 -0
open_case-2.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: open-case
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: Add your description here
|
|
5
|
+
Author: 6vi7ms
|
|
6
|
+
Author-email: 6vi7ms <6vi7ms@gmail.com>
|
|
7
|
+
Requires-Dist: click>=8.5.1
|
|
8
|
+
Requires-Dist: pyyaml>=6.0.3
|
|
9
|
+
Requires-Python: >=3.13
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
open-case -y 2025 1
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
# ลบ Temp
|
|
17
|
+
```sh
|
|
18
|
+
Remove-Item "$env:APPDATA\opencase\opencase.yaml"
|
|
19
|
+
```
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "open-case"
|
|
3
|
+
version = "2.0.0"
|
|
4
|
+
description = "Add your description here"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.13"
|
|
7
|
+
dependencies = [
|
|
8
|
+
"click>=8.5.1",
|
|
9
|
+
"pyyaml>=6.0.3",
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
[[project.authors]]
|
|
13
|
+
name = "6vi7ms"
|
|
14
|
+
email = "6vi7ms@gmail.com"
|
|
15
|
+
|
|
16
|
+
[project.scripts]
|
|
17
|
+
open-case = "open_case.main:main"
|
|
18
|
+
|
|
19
|
+
[build-system]
|
|
20
|
+
requires = ["uv_build>=0.12.18,<0.13.0"]
|
|
21
|
+
build-backend = "uv_build"
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "open-case"
|
|
3
|
+
version = "2.0.0"
|
|
4
|
+
description = "Add your description here"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
authors = [
|
|
7
|
+
{ name = "6vi7ms", email = "6vi7ms@gmail.com" }
|
|
8
|
+
]
|
|
9
|
+
requires-python = ">=3.13"
|
|
10
|
+
dependencies = [
|
|
11
|
+
"click>=8.5.1",
|
|
12
|
+
"pyyaml>=6.0.3",
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
[project.scripts]
|
|
16
|
+
open-case = "open_case.main:main"
|
|
17
|
+
|
|
18
|
+
[build-system]
|
|
19
|
+
requires = ["uv_build>=0.12.18,<0.13.0"]
|
|
20
|
+
build-backend = "uv_build"
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import getpass
|
|
2
|
+
from datetime import datetime
|
|
3
|
+
|
|
4
|
+
import click
|
|
5
|
+
|
|
6
|
+
from .utils import find_case_in_drives, render_path, try_open_paths
|
|
7
|
+
|
|
8
|
+
LOCATIONS = [
|
|
9
|
+
{
|
|
10
|
+
"name": "OneDrive",
|
|
11
|
+
"enabled": True,
|
|
12
|
+
"paths": [r"C:\Users\{user}\OneDrive\Documents\Forensic Reports\{year}\{case_folder}"],
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"name": "192.168.9.10",
|
|
16
|
+
"enabled": True,
|
|
17
|
+
"paths": [r"\\192.168.9.10\Case {year}\{case_folder}"],
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"name": "192.168.9.127",
|
|
21
|
+
"enabled": True,
|
|
22
|
+
"paths": [
|
|
23
|
+
r"\\192.168.9.127\dfu\System DFU Evidence\Case-{thai_year_short}\{case_folder}",
|
|
24
|
+
r"\\192.168.9.127\dfu\System DFU Evidence\Case-{thai_year_short}\{short_case}",
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def load_locations():
|
|
31
|
+
return [loc for loc in LOCATIONS if loc.get("enabled", True)]
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@click.command()
|
|
35
|
+
@click.argument("case", type=int, default=1, required=False)
|
|
36
|
+
@click.option("-y", "--year", type=int, default=datetime.now().year, help="Year of the case")
|
|
37
|
+
@click.option("-t", "--type", "case_type", default="F", help="Case type (F/C)")
|
|
38
|
+
def main(case, year, case_type):
|
|
39
|
+
"""โปรแกรมค้นหาและเปิดโฟลเดอร์เคสอัตโนมัติ"""
|
|
40
|
+
case_no = str(case).zfill(3)
|
|
41
|
+
prefix = case_type.upper()
|
|
42
|
+
user = getpass.getuser()
|
|
43
|
+
|
|
44
|
+
target_folder = f"{prefix}-{year}-{case_no}"
|
|
45
|
+
locations = load_locations()
|
|
46
|
+
|
|
47
|
+
click.echo(f"Target: {target_folder}")
|
|
48
|
+
|
|
49
|
+
menu = {}
|
|
50
|
+
for i, loc in enumerate(locations, start=1):
|
|
51
|
+
click.echo(f"{i}. {loc['name']}")
|
|
52
|
+
menu[str(i)] = [render_path(p, year, case_no, user, prefix) for p in loc.get("paths", [])]
|
|
53
|
+
|
|
54
|
+
ext_idx = len(menu) + 1
|
|
55
|
+
click.echo(f"{ext_idx}. External Drive Scan")
|
|
56
|
+
|
|
57
|
+
choice = input("Choose location: ").strip()
|
|
58
|
+
|
|
59
|
+
if choice == str(ext_idx):
|
|
60
|
+
try_open_paths(find_case_in_drives(target_folder))
|
|
61
|
+
elif choice in menu:
|
|
62
|
+
try_open_paths(menu[choice])
|
|
63
|
+
else:
|
|
64
|
+
click.echo("Invalid selection.")
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
if __name__ == "__main__":
|
|
68
|
+
main()
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import string
|
|
3
3
|
import subprocess
|
|
4
|
-
from .config import CONFIG_FILE, ensure_config
|
|
5
4
|
|
|
6
5
|
|
|
7
6
|
def open_folder(path: str):
|
|
@@ -12,14 +11,6 @@ def open_folder(path: str):
|
|
|
12
11
|
print(f"Error opening folder: {e}")
|
|
13
12
|
|
|
14
13
|
|
|
15
|
-
def open_config():
|
|
16
|
-
ensure_config()
|
|
17
|
-
try:
|
|
18
|
-
subprocess.run(["notepad.exe", str(CONFIG_FILE)])
|
|
19
|
-
except Exception as e:
|
|
20
|
-
print(f"Error opening config: {e}")
|
|
21
|
-
|
|
22
|
-
|
|
23
14
|
def ensure_and_open(path: str):
|
|
24
15
|
if os.path.exists(path):
|
|
25
16
|
return open_folder(path)
|
|
@@ -51,10 +42,7 @@ def try_open_paths(paths: list):
|
|
|
51
42
|
def find_case_in_drives(target_name: str) -> list:
|
|
52
43
|
found = []
|
|
53
44
|
print(f"Searching for '{target_name}'...")
|
|
54
|
-
roots = [
|
|
55
|
-
f"{d}:\\" for d in string.ascii_uppercase
|
|
56
|
-
if d.upper() != "C" and os.path.exists(f"{d}:\\")
|
|
57
|
-
]
|
|
45
|
+
roots = [f"{d}:\\" for d in string.ascii_uppercase if d.upper() != "C" and os.path.exists(f"{d}:\\")]
|
|
58
46
|
for root in roots:
|
|
59
47
|
try:
|
|
60
48
|
for current, dirs, _ in os.walk(root):
|
|
@@ -69,8 +57,4 @@ def find_case_in_drives(target_name: str) -> list:
|
|
|
69
57
|
def render_path(template: str, year: int, case_no: str, user: str, prefix: str) -> str:
|
|
70
58
|
thai_yr = str(year + 543)
|
|
71
59
|
folder = f"{prefix}-{year}-{case_no}"
|
|
72
|
-
return template.format(
|
|
73
|
-
user=user, year=year, case=case_no, prefix=prefix,
|
|
74
|
-
folder=folder, case_folder=folder, short_case=f"{prefix}{case_no}",
|
|
75
|
-
thai_year=thai_yr, thai_year_short=thai_yr[2:]
|
|
76
|
-
)
|
|
60
|
+
return template.format(user=user, year=year, case=case_no, prefix=prefix, folder=folder, case_folder=folder, short_case=f"{prefix}{case_no}", thai_year=thai_yr, thai_year_short=thai_yr[2:])
|
open_case-1.1.2/PKG-INFO
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: open-case
|
|
3
|
-
Version: 1.1.2
|
|
4
|
-
Summary:
|
|
5
|
-
Author: 6vi7ms
|
|
6
|
-
Author-email: 6vi7ms@gmail.com
|
|
7
|
-
Requires-Python: >=3.13
|
|
8
|
-
Classifier: Programming Language :: Python :: 3
|
|
9
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
10
|
-
Classifier: Programming Language :: Python :: 3.14
|
|
11
|
-
Requires-Dist: pyyaml (>=6.0.3,<7.0.0)
|
|
12
|
-
Description-Content-Type: text/markdown
|
|
13
|
-
|
|
14
|
-
```sh
|
|
15
|
-
open-case -y 2025 1
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
# ลบ Temp
|
|
19
|
-
```sh
|
|
20
|
-
Remove-Item "$env:APPDATA\opencase\opencase.yaml"
|
|
21
|
-
```
|
open_case-1.1.2/pyproject.toml
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
[project]
|
|
2
|
-
name = "open-case"
|
|
3
|
-
version = "1.1.2"
|
|
4
|
-
description = ""
|
|
5
|
-
authors = [{ name = "6vi7ms", email = "6vi7ms@gmail.com" }]
|
|
6
|
-
readme = "README.md"
|
|
7
|
-
requires-python = ">=3.13"
|
|
8
|
-
dependencies = ["pyyaml (>=6.0.3,<7.0.0)"]
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
[build-system]
|
|
12
|
-
requires = ["poetry-core>=2.0.0,<3.0.0"]
|
|
13
|
-
build-backend = "poetry.core.masonry.api"
|
|
14
|
-
|
|
15
|
-
[tool.poetry.scripts]
|
|
16
|
-
open-case = "open_case.main:main"
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
from pathlib import Path
|
|
3
|
-
import yaml
|
|
4
|
-
|
|
5
|
-
CONFIG_DIR = Path(os.environ["APPDATA"]) / "opencase"
|
|
6
|
-
CONFIG_FILE = CONFIG_DIR / "opencase.yaml"
|
|
7
|
-
|
|
8
|
-
DEFAULT_CONFIG = {
|
|
9
|
-
"locations": [
|
|
10
|
-
{
|
|
11
|
-
"name": "OneDrive",
|
|
12
|
-
"enabled": True,
|
|
13
|
-
"paths": [r"C:\Users\{user}\OneDrive\Documents\Forensic Reports\{year}\{case_folder}"]
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
"name": "192.168.9.10",
|
|
17
|
-
"enabled": True,
|
|
18
|
-
"paths": [r"\\192.168.9.10\Case - 2025 - 2026\Cases\{year}\{case_folder}"]
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
"name": "192.168.9.127",
|
|
22
|
-
"enabled": True,
|
|
23
|
-
"paths": [
|
|
24
|
-
r"\\192.168.9.127\dfu\System DFU Evidence\Case-{thai_year_short}\{case_folder}",
|
|
25
|
-
r"\\192.168.9.127\dfu\System DFU Evidence\Case-{thai_year_short}\{short_case}"
|
|
26
|
-
]
|
|
27
|
-
}
|
|
28
|
-
]
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
def ensure_config():
|
|
33
|
-
CONFIG_DIR.mkdir(parents=True, exist_ok=True)
|
|
34
|
-
if not CONFIG_FILE.exists():
|
|
35
|
-
save_raw_config(DEFAULT_CONFIG)
|
|
36
|
-
print(f"Created config: {CONFIG_FILE}")
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
def save_raw_config(cfg: dict):
|
|
40
|
-
with open(CONFIG_FILE, "w", encoding="utf-8") as f:
|
|
41
|
-
yaml.safe_dump(cfg, f, allow_unicode=True, sort_keys=False)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
def reset_config():
|
|
45
|
-
if input("Are you sure you want to reset config to default? (y/n): ").strip().lower() == "y":
|
|
46
|
-
save_raw_config(DEFAULT_CONFIG)
|
|
47
|
-
print("Config reset to default settings successfully.")
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
def load_locations():
|
|
51
|
-
ensure_config()
|
|
52
|
-
with open(CONFIG_FILE, "r", encoding="utf-8") as f:
|
|
53
|
-
cfg = yaml.safe_load(f) or {}
|
|
54
|
-
return [loc for loc in cfg.get("locations", []) if loc.get("enabled", True)]
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import argparse
|
|
2
|
-
import getpass
|
|
3
|
-
from datetime import datetime
|
|
4
|
-
|
|
5
|
-
from .config import CONFIG_FILE, ensure_config, load_locations, reset_config
|
|
6
|
-
from .utils import open_config, render_path, try_open_paths, find_case_in_drives
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def main():
|
|
10
|
-
parser = argparse.ArgumentParser()
|
|
11
|
-
parser.add_argument("case", nargs="?", type=int, default=1, help="Case number")
|
|
12
|
-
parser.add_argument("-y", "--year", type=int, default=datetime.now().year)
|
|
13
|
-
parser.add_argument("-t", "--type", default="F", help="Case type (F/C)")
|
|
14
|
-
parser.add_argument("-e", "--edit", "--config", dest="edit", action="store_true", help="Edit config")
|
|
15
|
-
parser.add_argument("--show-config", action="store_true", help="Show config path")
|
|
16
|
-
parser.add_argument("-r", "--reset", action="store_true", help="Reset config to default")
|
|
17
|
-
args = parser.parse_args()
|
|
18
|
-
|
|
19
|
-
ensure_config()
|
|
20
|
-
|
|
21
|
-
if args.edit:
|
|
22
|
-
return open_config()
|
|
23
|
-
if args.show_config:
|
|
24
|
-
return print(CONFIG_FILE)
|
|
25
|
-
if args.reset:
|
|
26
|
-
return reset_config()
|
|
27
|
-
|
|
28
|
-
year, case_no, prefix, user = args.year, str(args.case).zfill(3), args.type.upper(), getpass.getuser()
|
|
29
|
-
target_folder = f"{prefix}-{year}-{case_no}"
|
|
30
|
-
locations = load_locations()
|
|
31
|
-
|
|
32
|
-
print(f"Target: {target_folder}")
|
|
33
|
-
menu = {}
|
|
34
|
-
for i, loc in enumerate(locations, start=1):
|
|
35
|
-
print(f"{i}. {loc['name']}")
|
|
36
|
-
menu[str(i)] = [render_path(p, year, case_no, user, prefix) for p in loc.get("paths", [])]
|
|
37
|
-
|
|
38
|
-
ext_idx = len(menu) + 1
|
|
39
|
-
print(f"{ext_idx}. External Drive Scan")
|
|
40
|
-
|
|
41
|
-
choice = input("Choose location: ").strip()
|
|
42
|
-
if choice == str(ext_idx):
|
|
43
|
-
try_open_paths(find_case_in_drives(target_folder))
|
|
44
|
-
elif choice in menu:
|
|
45
|
-
try_open_paths(menu[choice])
|
|
46
|
-
else:
|
|
47
|
-
print("Invalid selection.")
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if __name__ == "__main__":
|
|
51
|
-
main()
|
|
File without changes
|
|
File without changes
|