diff options
author | Steven Michalske <smichalske@gmail.com> | 2015-08-12 23:27:14 -0700 |
---|---|---|
committer | Steven Michalske <smichalske@gmail.com> | 2015-08-12 23:27:14 -0700 |
commit | 0f82012106e5ec9f62feed5f1d819c1c9dfa12df (patch) | |
tree | 652880b94afb131ec486f1a3dd00eed4527b1317 | |
parent | 7af7c75527cfb862052b41f9f31e0fb9a8136005 (diff) | |
download | pyserial-git-0f82012106e5ec9f62feed5f1d819c1c9dfa12df.tar.gz |
Add class that will pretty print hex numbers.
Mostly a throw away class but makes the numbers easier to manage in interactive terminals.
Do any math on the numbers and the magic disappears.
-rw-r--r-- | serial/tools/list_ports_osx.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/serial/tools/list_ports_osx.py b/serial/tools/list_ports_osx.py index a451ae6..deb2fcf 100644 --- a/serial/tools/list_ports_osx.py +++ b/serial/tools/list_ports_osx.py @@ -66,6 +66,15 @@ cf.CFStringGetCStringPtr.restype = ctypes.c_char_p cf.CFNumberGetValue.argtypes = [ctypes.c_void_p, ctypes.c_uint32, ctypes.c_void_p] cf.CFNumberGetValue.restype = ctypes.c_void_p + +class HexInt(int): + + """Class to pretty print a integer in a hex representation.""" + + def __repr__(self): + return "0x{0:X}".format(self) + + def get_string_property(device_t, property): """ Search the given device for the specified string property |