Skip to content

Commit

Permalink
Merge branch 'main' into 1.0.0-wip
Browse files Browse the repository at this point in the history
  • Loading branch information
GhostofGoes committed Jun 1, 2024
2 parents 72884a7 + 9d415d1 commit 535e42e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
* Remove all `requirement.txt` files
* Remove `setup.py` and `MANIFEST.in`

## 0.9.5 ()

### Changed
* Fixed macOS arp when MAC has one character sections in specific cases (Fixes issue #92)

## 0.9.4 (06/01/2023)

### Added
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ The [Python Discord server](https://discord.gg/python) is a good place to ask qu
- Ville Skyttä (@scop) - arping lookup support
- Tomasz Duda (@tomaszduda23) - support for docker in network bridge mode
- Steven Looman (@StevenLooman) - Windows 11 testing
- Reimund Renner (@raymanP) - macOS fixes

## Sources
Many of the methods used to acquire an address and the core logic framework are attributed to the CPython project's UUID implementation.
Expand Down
19 changes: 2 additions & 17 deletions getmac/getmac.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ class ArpVariousArgs(Method):
)
_args_tested: bool = False
_good_pair: Union[Tuple, Tuple[str, bool]] = ()
_good_regex: str = ""
_good_regex: str = _regex_darwin if DARWIN else _regex_std

def test(self) -> bool:
return check_command("arp")
Expand Down Expand Up @@ -397,22 +397,7 @@ def get(self, arg: str) -> Optional[str]:
command_output = _popen("arp", " ".join(cmd_args))

escaped = re.escape(arg)
if self._good_regex:
return _search(r"\(" + escaped + self._good_regex, command_output)

# try linux regex first
# try darwin regex next
# if a regex succeeds the first time, cache the successful regex
# otherwise, don't bother, since it's a miss anyway
for regex in (self._regex_std, self._regex_darwin):
# NOTE: Darwin regex will return MACs without leading zeroes,
# e.g. "58:6d:8f:7:c9:94" instead of "58:6d:8f:07:c9:94"
found = _search(r"\(" + escaped + regex, command_output)
if found:
self._good_regex = regex
return found

return None
return _search(r"\(" + escaped + self._good_regex, command_output)


class ArpExe(Method):
Expand Down

0 comments on commit 535e42e

Please sign in to comment.