Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
django-gateway
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Agustin Dorda
django-gateway
Commits
601ab089
Commit
601ab089
authored
6 years ago
by
angdmz
Browse files
Options
Downloads
Patches
Plain Diff
hexbyte dict decoder
parent
d583c394
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gateway/utils.py
+17
-0
17 additions, 0 deletions
gateway/utils.py
with
17 additions
and
0 deletions
gateway/utils.py
+
17
−
0
View file @
601ab089
...
@@ -36,3 +36,20 @@ def hex32bytes_string(some_hex32bytes):
...
@@ -36,3 +36,20 @@ def hex32bytes_string(some_hex32bytes):
return
Web3
.
toText
(
some_hex32bytes
.
decode
().
strip
(
'
\\\u0000
'
))
return
Web3
.
toText
(
some_hex32bytes
.
decode
().
strip
(
'
\\\u0000
'
))
except
UnicodeDecodeError
as
ude
:
except
UnicodeDecodeError
as
ude
:
return
some_hex32bytes
return
some_hex32bytes
class
HexBytesToDict
:
def
dehex_dict
(
self
,
dictionary
):
for
k
,
v
in
dictionary
.
items
():
if
isinstance
(
v
,
dict
):
self
.
dehex_dict
(
dictionary
[
k
])
elif
isinstance
(
v
,
list
):
self
.
dehex_list
(
dictionary
[
k
])
elif
isinstance
(
v
,
HexBytes
):
dictionary
[
k
]
=
v
.
hex
()
def
dehex_list
(
self
,
sequence
):
i
=
0
while
i
<
len
(
sequence
):
sequence
[
i
]
=
sequence
[
i
].
decode
()
i
=
i
+
1
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment