refactor: move modules into core/ sub-package, normalize naming

Phase 1 of package refactor. Moves all source modules into pm3py/core/
with file renames (hf_14a→hf_iso14a, hf_15→hf_iso15, hf_mf→hf_mfc)
and client attribute normalization (hf.a14→hf.iso14a, hf.mf→hf.mfc).
pm3py/__init__.py re-exports from core for backward compat.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
michael
2026-03-18 19:24:05 -07:00
parent ab3d37e7b3
commit 42e6b54f29
21 changed files with 108 additions and 46 deletions

View File

@@ -3,7 +3,7 @@ import struct
import asyncio
from unittest.mock import AsyncMock, MagicMock
from pm3py import Proxmark3, Cmd
from pm3py.client import FirmwareInfo
from pm3py.core.client import FirmwareInfo
def test_full_api_surface():
@@ -14,9 +14,9 @@ def test_full_api_surface():
assert hasattr(pm3, "lf")
assert hasattr(pm3, "hf")
assert hasattr(pm3.lf, "t55")
assert hasattr(pm3.hf, "a14")
assert hasattr(pm3.hf, "iso14a")
assert hasattr(pm3.hf, "iso15")
assert hasattr(pm3.hf, "mf")
assert hasattr(pm3.hf, "mfc")
assert hasattr(pm3, "send_ng")
assert hasattr(pm3, "send_mix")
assert hasattr(pm3, "firmware")
@@ -27,7 +27,7 @@ def test_hw_ping_roundtrip():
"""Test ping returns structured dict."""
pm3 = Proxmark3("/dev/null")
mock_transport = AsyncMock()
from pm3py.transport import PM3Response
from pm3py.core.transport import PM3Response
ping_data = bytes(range(32))
mock_transport.send_ng.return_value = PM3Response(
cmd=Cmd.PING, status=0, reason=0, ng=True, data=ping_data)
@@ -41,21 +41,21 @@ def test_mf_rdbl_returns_hex():
"""Verify MIFARE read returns hex string data."""
pm3 = Proxmark3("/dev/null")
mock_transport = AsyncMock()
from pm3py.transport import PM3Response
from pm3py.core.transport import PM3Response
block = bytes(range(16))
mock_transport.send_ng.return_value = PM3Response(
cmd=Cmd.HF_MIFARE_READBL, status=0, reason=0, ng=True, data=block)
pm3.hf.mf._t = mock_transport
pm3.hf.mfc._t = mock_transport
result = asyncio.get_event_loop().run_until_complete(
pm3.hf.mf.rdbl(block=4, key="FFFFFFFFFFFF"))
pm3.hf.mfc.rdbl(block=4, key="FFFFFFFFFFFF"))
assert result["data"] == "000102030405060708090a0b0c0d0e0f"
assert result["raw"] == block
def test_sync_proxy():
"""Verify sync proxy wraps async calls."""
from pm3py.transport import PM3Response
from pm3py.client import _SyncProxy
from pm3py.core.transport import PM3Response
from pm3py.core.client import _SyncProxy
pm3 = Proxmark3("/dev/null")
loop = asyncio.new_event_loop()
@@ -83,7 +83,7 @@ def test_firmware_probe_compatible():
pm3._transport = mock_transport
pm3.hw._t = mock_transport
from pm3py.transport import PM3Response
from pm3py.core.transport import PM3Response
ping_data = bytes(range(32))
vstr = b"Proxmark3 RDV4.0 FW v4.18000\x00"
@@ -109,7 +109,7 @@ def test_firmware_probe_ping_fails():
pm3._transport = mock_transport
pm3.hw._t = mock_transport
from pm3py.transport import PM3Response, PM3Error
from pm3py.core.transport import PM3Response, PM3Error
vstr = b"Proxmark3 OLD\x00"
version_payload = struct.pack("<III", 0x270B0A40, 256*1024, len(vstr)) + vstr