-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
93 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class MachoApiMixin: | ||
def macho_info(self, path=None, arch=None): | ||
""" | ||
Display MachO header information. Identical to the ``ipsw macho info --json`` | ||
command. | ||
Returns: | ||
(dict): The info as a dict | ||
Raises: | ||
:py:class:`ipsw.errors.APIError` | ||
If the server returns an error. | ||
""" | ||
return self._result(self._get(self._url("/macho/info"), params={"path": path, "arch": arch}), True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import os | ||
|
||
from ..api import APIClient | ||
from .resource import Collection, Model | ||
|
||
|
||
class Macho(Model): | ||
""" | ||
MachO info. | ||
""" | ||
|
||
def __repr__(self): | ||
return "<{}: '{} {} ({})'>".format( | ||
self.__class__.__name__, | ||
self.magic, | ||
self.cpu, | ||
self.sub_cpu, | ||
) | ||
|
||
@property | ||
def magic(self): | ||
""" | ||
The header magic. | ||
""" | ||
return self.attrs["info"]['header'].get("magic", None) | ||
|
||
@property | ||
def cpu(self): | ||
""" | ||
The header CPU. | ||
""" | ||
return self.attrs["info"]['header'].get("cpu", None) | ||
|
||
@property | ||
def sub_cpu(self): | ||
""" | ||
The header sub CPU. | ||
""" | ||
return self.attrs["info"]['header'].get("subcpu", None) | ||
|
||
|
||
class MachoCollection(Collection): | ||
model = Macho | ||
|
||
def get(self, path=None, arch=None): | ||
""" | ||
Get MachO info. | ||
""" | ||
return self.prepare_model(self.client.api.macho_info(path, arch)) |