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
f1e86ef4
Commit
f1e86ef4
authored
16 years ago
by
Phil
Browse files
Options
Downloads
Patches
Plain Diff
Fixed NoTheme and factorized some code (ticket #143)
parent
d7dd2222
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
scapy/plist.py
+5
-5
5 additions, 5 deletions
scapy/plist.py
scapy/themes.py
+15
-19
15 additions, 19 deletions
scapy/themes.py
with
20 additions
and
24 deletions
scapy/plist.py
+
5
−
5
View file @
f1e86ef4
...
@@ -104,7 +104,7 @@ lfilter: truth function to apply to each packet to decide whether it will be dis
...
@@ -104,7 +104,7 @@ lfilter: truth function to apply to each packet to decide whether it will be dis
if
lfilter
is
not
None
:
if
lfilter
is
not
None
:
if
not
lfilter
(
self
.
res
[
i
]):
if
not
lfilter
(
self
.
res
[
i
]):
continue
continue
print
conf
.
color_theme
.
id
(
i
,
"
%04i
"
),
print
conf
.
color_theme
.
id
(
i
,
fmt
=
"
%04i
"
),
if
prn
is
None
:
if
prn
is
None
:
print
self
.
_elt2sum
(
self
.
res
[
i
])
print
self
.
_elt2sum
(
self
.
res
[
i
])
else
:
else
:
...
@@ -187,7 +187,7 @@ lfilter: truth function to apply to each packet to decide whether it will be dis
...
@@ -187,7 +187,7 @@ lfilter: truth function to apply to each packet to decide whether it will be dis
p
=
self
.
_elt2pkt
(
self
.
res
[
i
])
p
=
self
.
_elt2pkt
(
self
.
res
[
i
])
if
lfilter
is
not
None
and
not
lfilter
(
p
):
if
lfilter
is
not
None
and
not
lfilter
(
p
):
continue
continue
print
"
%s %s %s
"
%
(
conf
.
color_theme
.
id
(
i
,
"
%04i
"
),
print
"
%s %s %s
"
%
(
conf
.
color_theme
.
id
(
i
,
fmt
=
"
%04i
"
),
p
.
sprintf
(
"
%.time%
"
),
p
.
sprintf
(
"
%.time%
"
),
self
.
_elt2sum
(
self
.
res
[
i
]))
self
.
_elt2sum
(
self
.
res
[
i
]))
if
p
.
haslayer
(
conf
.
raw_layer
):
if
p
.
haslayer
(
conf
.
raw_layer
):
...
@@ -200,7 +200,7 @@ lfilter: truth function to apply to each packet to decide whether it will be dis
...
@@ -200,7 +200,7 @@ lfilter: truth function to apply to each packet to decide whether it will be dis
p
=
self
.
_elt2pkt
(
self
.
res
[
i
])
p
=
self
.
_elt2pkt
(
self
.
res
[
i
])
if
lfilter
is
not
None
and
not
lfilter
(
p
):
if
lfilter
is
not
None
and
not
lfilter
(
p
):
continue
continue
print
"
%s %s %s
"
%
(
conf
.
color_theme
.
id
(
i
,
"
%04i
"
),
print
"
%s %s %s
"
%
(
conf
.
color_theme
.
id
(
i
,
fmt
=
"
%04i
"
),
p
.
sprintf
(
"
%.time%
"
),
p
.
sprintf
(
"
%.time%
"
),
self
.
_elt2sum
(
self
.
res
[
i
]))
self
.
_elt2sum
(
self
.
res
[
i
]))
hexdump
(
p
)
hexdump
(
p
)
...
@@ -211,7 +211,7 @@ lfilter: truth function to apply to each packet to decide whether it will be dis
...
@@ -211,7 +211,7 @@ lfilter: truth function to apply to each packet to decide whether it will be dis
p
=
self
.
_elt2pkt
(
self
.
res
[
i
])
p
=
self
.
_elt2pkt
(
self
.
res
[
i
])
if
p
.
haslayer
(
Padding
):
if
p
.
haslayer
(
Padding
):
if
lfilter
is
None
or
lfilter
(
p
):
if
lfilter
is
None
or
lfilter
(
p
):
print
"
%s %s %s
"
%
(
conf
.
color_theme
.
id
(
i
,
"
%04i
"
),
print
"
%s %s %s
"
%
(
conf
.
color_theme
.
id
(
i
,
fmt
=
"
%04i
"
),
p
.
sprintf
(
"
%.time%
"
),
p
.
sprintf
(
"
%.time%
"
),
self
.
_elt2sum
(
self
.
res
[
i
]))
self
.
_elt2sum
(
self
.
res
[
i
]))
hexdump
(
p
.
getlayer
(
Padding
).
load
)
hexdump
(
p
.
getlayer
(
Padding
).
load
)
...
@@ -225,7 +225,7 @@ lfilter: truth function to apply to each packet to decide whether it will be dis
...
@@ -225,7 +225,7 @@ lfilter: truth function to apply to each packet to decide whether it will be dis
if
pad
==
pad
[
0
]
*
len
(
pad
):
if
pad
==
pad
[
0
]
*
len
(
pad
):
continue
continue
if
lfilter
is
None
or
lfilter
(
p
):
if
lfilter
is
None
or
lfilter
(
p
):
print
"
%s %s %s
"
%
(
conf
.
color_theme
.
id
(
i
,
"
%04i
"
),
print
"
%s %s %s
"
%
(
conf
.
color_theme
.
id
(
i
,
fmt
=
"
%04i
"
),
p
.
sprintf
(
"
%.time%
"
),
p
.
sprintf
(
"
%.time%
"
),
self
.
_elt2sum
(
self
.
res
[
i
]))
self
.
_elt2sum
(
self
.
res
[
i
]))
hexdump
(
p
.
getlayer
(
Padding
).
load
)
hexdump
(
p
.
getlayer
(
Padding
).
load
)
...
...
This diff is collapsed.
Click to expand it.
scapy/themes.py
+
15
−
19
View file @
f1e86ef4
...
@@ -26,11 +26,21 @@ class Color:
...
@@ -26,11 +26,21 @@ class Color:
invert
=
"
\033
[7m
"
invert
=
"
\033
[7m
"
def
create_styler
(
fmt
=
None
,
before
=
""
,
after
=
""
,
fmt2
=
"
%s
"
):
def
do_style
(
val
,
fmt
=
fmt
,
before
=
before
,
after
=
after
,
fmt2
=
fmt2
):
if
fmt
is
None
:
if
type
(
val
)
is
not
str
:
val
=
str
(
val
)
else
:
val
=
fmt
%
val
return
fmt2
%
(
before
+
val
+
after
)
return
do_style
class
ColorTheme
:
class
ColorTheme
:
def
__repr__
(
self
):
def
__repr__
(
self
):
return
"
<%s>
"
%
self
.
__class__
.
__name__
return
"
<%s>
"
%
self
.
__class__
.
__name__
def
__getattr__
(
self
,
attr
):
def
__getattr__
(
self
,
attr
):
return
lambda
x
:
x
return
create_styler
()
class
NoTheme
(
ColorTheme
):
class
NoTheme
(
ColorTheme
):
...
@@ -48,14 +58,7 @@ class AnsiColorTheme(ColorTheme):
...
@@ -48,14 +58,7 @@ class AnsiColorTheme(ColorTheme):
else
:
else
:
before
=
after
=
""
before
=
after
=
""
def
do_style
(
val
,
fmt
=
None
,
before
=
before
,
after
=
after
):
return
create_styler
(
before
=
before
,
after
=
after
)
if
fmt
is
None
:
if
type
(
val
)
is
not
str
:
val
=
str
(
val
)
else
:
val
=
fmt
%
val
return
before
+
val
+
after
return
do_style
style_normal
=
""
style_normal
=
""
...
@@ -174,20 +177,13 @@ class ColorOnBlackTheme(AnsiColorTheme):
...
@@ -174,20 +177,13 @@ class ColorOnBlackTheme(AnsiColorTheme):
style_left
=
Color
.
cyan
+
Color
.
bold
style_left
=
Color
.
cyan
+
Color
.
bold
style_right
=
Color
.
red
+
Color
.
bold
style_right
=
Color
.
red
+
Color
.
bold
class
FormatTheme
(
ColorTheme
):
class
FormatTheme
(
ColorTheme
):
def
__getattr__
(
self
,
attr
):
def
__getattr__
(
self
,
attr
):
if
attr
.
startswith
(
"
__
"
):
if
attr
.
startswith
(
"
__
"
):
raise
AttributeError
(
attr
)
raise
AttributeError
(
attr
)
col
=
self
.
__class__
.
__dict__
.
get
(
"
style_%s
"
%
attr
,
"
%s
"
)
colfmt
=
self
.
__class__
.
__dict__
.
get
(
"
style_%s
"
%
attr
,
"
%s
"
)
def
do_style
(
val
,
fmt
=
None
,
col
=
col
):
return
create_styler
(
fmt2
=
colfmt
)
if
fmt
is
None
:
if
type
(
val
)
is
not
str
:
val
=
str
(
val
)
else
:
val
=
fmt
%
val
return
col
%
val
return
do_style
class
LatexTheme
(
FormatTheme
):
class
LatexTheme
(
FormatTheme
):
style_prompt
=
r
"
\textcolor{blue}{%s}
"
style_prompt
=
r
"
\textcolor{blue}{%s}
"
...
...
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