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

@@ -1,6 +1,6 @@
"""pm3py - Python wire protocol library for Proxmark3."""
from .client import Proxmark3
from .transport import PM3Error, PM3Response
from .protocol import PM3Status, Cmd
from .core.client import Proxmark3
from .core.transport import PM3Error, PM3Response
from .core.protocol import PM3Status, Cmd
__all__ = ["Proxmark3", "PM3Error", "PM3Response", "PM3Status", "Cmd"]

10
pm3py/core/__init__.py Normal file
View File

@@ -0,0 +1,10 @@
"""pm3py.core — Wire protocol, transport, and device commands."""
from .client import Proxmark3, FirmwareInfo
from .transport import PM3Transport, PM3Error, PM3Response
from .protocol import PM3Status, Cmd
__all__ = [
"Proxmark3", "FirmwareInfo",
"PM3Transport", "PM3Error", "PM3Response",
"PM3Status", "Cmd",
]

View File

@@ -10,9 +10,9 @@ from .transport import PM3Transport, PM3Response, PM3Error, ProgressCallback
from .hw import HWCommands
from .lf import LFCommands
from .hf import HFCommands
from .hf_14a import HF14ACommands
from .hf_15 import HF15Commands
from .hf_mf import HFMFCommands
from .hf_iso14a import HF14ACommands
from .hf_iso15 import HF15Commands
from .hf_mfc import HFMFCommands
log = logging.getLogger(__name__)
@@ -68,9 +68,9 @@ class Proxmark3:
self.hw = HWCommands(self._transport)
self.lf = LFCommands(self._transport)
self.hf = HFCommands(self._transport)
self.hf.a14 = HF14ACommands(self._transport)
self.hf.iso14a = HF14ACommands(self._transport)
self.hf.iso15 = HF15Commands(self._transport)
self.hf.mf = HFMFCommands(self._transport)
self.hf.mfc = HFMFCommands(self._transport)
self.firmware = FirmwareInfo()
async def connect(self) -> None:
@@ -157,7 +157,7 @@ class _SyncProxy:
if isinstance(attr, (HWCommands, LFCommands, HFCommands,
HF14ACommands, HF15Commands, HFMFCommands)):
return _SyncProxy(attr, self._loop)
# Sub-modules attached dynamically (e.g. hf.a14, hf.mf)
# Sub-modules attached dynamically (e.g. hf.iso14a, hf.mfc)
if hasattr(attr, '_t'):
return _SyncProxy(attr, self._loop)
if callable(attr) and inspect.iscoroutinefunction(attr):

View File

@@ -11,9 +11,9 @@ class HFCommands:
def __init__(self, transport: PM3Transport):
self._t = transport
# Sub-modules attached by client.py
self.a14 = None # type: ignore
self.iso14a = None # type: ignore
self.iso15 = None # type: ignore
self.mf = None # type: ignore
self.mfc = None # type: ignore
async def tune(self, on_progress: ProgressCallback = None) -> dict:
"""Measure HF antenna voltage."""
@@ -38,9 +38,9 @@ class HFCommands:
if asyncio.iscoroutine(ret):
await ret
if self.a14:
if self.iso14a:
try:
card = await self.a14.scan()
card = await self.iso14a.scan()
if card.get("uid"):
results["iso14443a"] = card
except PM3Error: