hexathon

Common and uncommon hex string operations for python3
git clone git://git.defalsify.org/python-hexathon.git
Log | Files | Refs | LICENSE

commit 621204566fc1e9cf226d2cbb90e17192948898e7
parent 726e03b2fe0421454bb8cc8ee7c81c6811970532
Author: lash <dev@holbrook.no>
Date:   Wed,  4 May 2022 18:01:11 +0000

Allow non-compacting pad skip for 0x handling

Diffstat:
Mhexathon/parse.py | 8++++----
Msetup.cfg | 2+-
2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/hexathon/parse.py b/hexathon/parse.py @@ -25,7 +25,7 @@ def uniform(hx): return even(hx).lower() -def strip_0x(hx, allow_empty=False, compact_value=False): +def strip_0x(hx, allow_empty=False, compact_value=False, pad=True): if len(hx) == 0 and not allow_empty: raise ValueError('invalid hex') elif len(hx) > 1: @@ -36,12 +36,12 @@ def strip_0x(hx, allow_empty=False, compact_value=False): if compact_value: v = compact(hx, allow_empty=allow_empty) - else: + elif pad: v = even(hx, allow_empty=allow_empty, allow_compact=True) return v -def add_0x(hx, allow_empty=False, compact_value=False): +def add_0x(hx, allow_empty=False, compact_value=False, pad=True): if len(hx) == 0 and not allow_empty: raise ValueError('invalid hex') if hx[:2] == '0x': @@ -49,7 +49,7 @@ def add_0x(hx, allow_empty=False, compact_value=False): v = '' if compact_value: v = compact(hx, allow_empty=allow_empty) - else: + elif pad: v = even(hx, allow_empty=allow_empty, allow_compact=True) return '0x' + v diff --git a/setup.cfg b/setup.cfg @@ -5,6 +5,6 @@ url=https://gitlab.com/nolash/python-hexathon author_email=dev@holbrook.no name=hexathon -version=0.1.5 +version=0.1.6 description=Common and uncommon hex string operations author=Louis Holbrook