Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scapy
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor 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
CodeLinaro
public-release-test-restored
platform
external
scapy
Commits
2e4c7ef0
Commit
2e4c7ef0
authored
9 years ago
by
Pierre LALET
Browse files
Options
Downloads
Patches
Plain Diff
Implement a binrepr() function working with both Python 2.5 and 2.6+
parent
a814731c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scapy/utils.py
+16
-0
16 additions, 0 deletions
scapy/utils.py
with
16 additions
and
0 deletions
scapy/utils.py
+
16
−
0
View file @
2e4c7ef0
...
@@ -426,6 +426,22 @@ def incremental_label(label="tag%05i", start=0):
...
@@ -426,6 +426,22 @@ def incremental_label(label="tag%05i", start=0):
yield
label
%
start
yield
label
%
start
start
+=
1
start
+=
1
# Python <= 2.5 do not provide bin() built-in function
try
:
bin
(
0
)
except
NameError
:
def
_binrepr
(
val
):
while
val
:
yield
val
&
1
val
>>=
1
binrepr
=
lambda
val
:
""
.
join
(
reversed
([
str
(
bit
)
for
bit
in
_binrepr
(
val
)]))
or
"
0
"
else
:
binrepr
=
lambda
val
:
bin
(
val
)[
2
:]
#########################
#########################
#### Enum management ####
#### Enum management ####
#########################
#########################
...
...
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