本文整理汇总了Python中config.conf.color_theme方法的典型用法代码示例。如果您正苦于以下问题:Python conf.color_theme方法的具体用法?Python conf.color_theme怎么用?Python conf.color_theme使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类config.conf
的用法示例。
在下文中一共展示了conf.color_theme方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __repr__
# 需要导入模块: from config import conf [as 别名]
# 或者: from config.conf import color_theme [as 别名]
def __repr__(self):
# stats=dict.fromkeys(self.stats,0) ## needs python >= 2.3 :(
stats = dict(map(lambda x: (x,0), self.stats))
other = 0
for r in self.res:
f = 0
for p in stats:
if self._elt2pkt(r).haslayer(p):
stats[p] += 1
f = 1
break
if not f:
other += 1
s = ""
ct = conf.color_theme
for p in self.stats:
s += " %s%s%s" % (ct.packetlist_proto(p.name),
ct.punct(":"),
ct.packetlist_value(stats[p]))
s += " %s%s%s" % (ct.packetlist_proto("Other"),
ct.punct(":"),
ct.packetlist_value(other))
return "%s%s%s%s%s" % (ct.punct("<"),
ct.packetlist_name(self.listname),
ct.punct(":"),
s,
ct.punct(">"))
示例2: nsummary
# 需要导入模块: from config import conf [as 别名]
# 或者: from config.conf import color_theme [as 别名]
def nsummary(self,prn=None, lfilter=None):
"""prints a summary of each packet with the packet's number
prn: function to apply to each packet instead of lambda x:x.summary()
lfilter: truth function to apply to each packet to decide whether it will be displayed"""
for i in range(len(self.res)):
if lfilter is not None:
if not lfilter(self.res[i]):
continue
print conf.color_theme.id(i,fmt="%04i"),
if prn is None:
print self._elt2sum(self.res[i])
else:
print prn(self.res[i])
示例3: hexraw
# 需要导入模块: from config import conf [as 别名]
# 或者: from config.conf import color_theme [as 别名]
def hexraw(self, lfilter=None):
"""Same as nsummary(), except that if a packet has a Raw layer, it will be hexdumped
lfilter: a truth function that decides whether a packet must be displayed"""
for i in range(len(self.res)):
p = self._elt2pkt(self.res[i])
if lfilter is not None and not lfilter(p):
continue
print "%s %s %s" % (conf.color_theme.id(i,fmt="%04i"),
p.sprintf("%.time%"),
self._elt2sum(self.res[i]))
if p.haslayer(conf.raw_layer):
hexdump(p.getlayer(conf.raw_layer).load)
示例4: hexdump
# 需要导入模块: from config import conf [as 别名]
# 或者: from config.conf import color_theme [as 别名]
def hexdump(self, lfilter=None):
"""Same as nsummary(), except that packets are also hexdumped
lfilter: a truth function that decides whether a packet must be displayed"""
for i in range(len(self.res)):
p = self._elt2pkt(self.res[i])
if lfilter is not None and not lfilter(p):
continue
print "%s %s %s" % (conf.color_theme.id(i,fmt="%04i"),
p.sprintf("%.time%"),
self._elt2sum(self.res[i]))
hexdump(p)
示例5: padding
# 需要导入模块: from config import conf [as 别名]
# 或者: from config.conf import color_theme [as 别名]
def padding(self, lfilter=None):
"""Same as hexraw(), for Padding layer"""
for i in range(len(self.res)):
p = self._elt2pkt(self.res[i])
if p.haslayer(Padding):
if lfilter is None or lfilter(p):
print "%s %s %s" % (conf.color_theme.id(i,fmt="%04i"),
p.sprintf("%.time%"),
self._elt2sum(self.res[i]))
hexdump(p.getlayer(Padding).load)
示例6: autorun_get_text_interactive_session
# 需要导入模块: from config import conf [as 别名]
# 或者: from config.conf import color_theme [as 别名]
def autorun_get_text_interactive_session(cmds, **kargs):
ct = conf.color_theme
try:
conf.color_theme = NoTheme()
s,res = autorun_get_interactive_session(cmds, **kargs)
finally:
conf.color_theme = ct
return s,res
示例7: autorun_get_ansi_interactive_session
# 需要导入模块: from config import conf [as 别名]
# 或者: from config.conf import color_theme [as 别名]
def autorun_get_ansi_interactive_session(cmds, **kargs):
ct = conf.color_theme
try:
conf.color_theme = DefaultTheme()
s,res = autorun_get_interactive_session(cmds, **kargs)
finally:
conf.color_theme = ct
return s,res
示例8: autorun_get_html_interactive_session
# 需要导入模块: from config import conf [as 别名]
# 或者: from config.conf import color_theme [as 别名]
def autorun_get_html_interactive_session(cmds, **kargs):
ct = conf.color_theme
to_html = lambda s: s.replace("<","<").replace(">",">").replace("#[#","<").replace("#]#",">")
try:
try:
conf.color_theme = HTMLTheme2()
s,res = autorun_get_interactive_session(cmds, **kargs)
except StopAutorun,e:
e.code_run = to_html(e.code_run)
raise
finally:
conf.color_theme = ct
return to_html(s),res
示例9: autorun_get_latex_interactive_session
# 需要导入模块: from config import conf [as 别名]
# 或者: from config.conf import color_theme [as 别名]
def autorun_get_latex_interactive_session(cmds, **kargs):
ct = conf.color_theme
to_latex = lambda s: tex_escape(s).replace("@[@","{").replace("@]@","}").replace("@`@","\\")
try:
try:
conf.color_theme = LatexTheme2()
s,res = autorun_get_interactive_session(cmds, **kargs)
except StopAutorun,e:
e.code_run = to_latex(e.code_run)
raise
finally:
conf.color_theme = ct
return to_latex(s),res
示例10: show
# 需要导入模块: from config import conf [as 别名]
# 或者: from config.conf import color_theme [as 别名]
def show(self, indent=3, lvl="", label_lvl=""):
"""Prints a hierarchical view of the packet. "indent" gives the size of indentation for each layer."""
ct = conf.color_theme
print "%s%s %s %s" % (label_lvl,
ct.punct("###["),
ct.layer_name(self.name),
ct.punct("]###"))
for f in self.fields_desc:
if isinstance(f, ConditionalField) and not f._evalcond(self):
continue
if isinstance(f, Emph) or f in conf.emph:
ncol = ct.emph_field_name
vcol = ct.emph_field_value
else:
ncol = ct.field_name
vcol = ct.field_value
fvalue = self.getfieldval(f.name)
if isinstance(fvalue, Packet) or (f.islist and f.holds_packets and type(fvalue) is list):
print "%s \\%-10s\\" % (label_lvl+lvl, ncol(f.name))
fvalue_gen = SetGen(fvalue,_iterpacket=0)
for fvalue in fvalue_gen:
fvalue.show(indent=indent, label_lvl=label_lvl+lvl+" |")
else:
begn = "%s %-10s%s " % (label_lvl+lvl,
ncol(f.name),
ct.punct("="),)
reprval = f.i2repr(self,fvalue)
if type(reprval) is str:
reprval = reprval.replace("\n", "\n"+" "*(len(label_lvl)
+len(lvl)
+len(f.name)
+4))
print "%s%s" % (begn,vcol(reprval))
self.payload.show(indent=indent, lvl=lvl+(" "*indent*self.show_indent), label_lvl=label_lvl)
示例11: padding
# 需要导入模块: from config import conf [as 别名]
# 或者: from config.conf import color_theme [as 别名]
def padding(self, lfilter=None):
"""Same as hexraw(), for Padding layer"""
for i in range(len(self.res)):
p = self._elt2pkt(self.res[i])
if p.haslayer(conf.padding_layer):
if lfilter is None or lfilter(p):
print "%s %s %s" % (conf.color_theme.id(i,fmt="%04i"),
p.sprintf("%.time%"),
self._elt2sum(self.res[i]))
hexdump(p.getlayer(conf.padding_layer).load)
示例12: show
# 需要导入模块: from config import conf [as 别名]
# 或者: from config.conf import color_theme [as 别名]
def show(self, indent=3, lvl="", label_lvl=""):
"""Prints a hierarchical view of the packet. "indent" gives the size of indentation for each layer."""
ct = conf.color_theme
print "%s%s %s %s" % (label_lvl,
ct.punct("###["),
ct.layer_name(self.name),
ct.punct("]###"))
for f in self.fields_desc:
if isinstance(f, ConditionalField) and not f._evalcond(self):
continue
if isinstance(f, Emph) or f in conf.emph:
ncol = ct.emph_field_name
vcol = ct.emph_field_value
else:
ncol = ct.field_name
vcol = ct.field_value
fvalue = self.getfieldval(f.name)
if isinstance(fvalue, Packet) or (f.islist and f.holds_packets and type(fvalue) is list):
print "%s \\%-10s\\" % (label_lvl+lvl, ncol(f.name))
fvalue_gen = SetGen(fvalue,_iterpacket=0)
for fvalue in fvalue_gen:
fvalue.show(indent=indent, label_lvl=label_lvl+lvl+" |")
else:
print "%s %-10s%s %s" % (label_lvl+lvl,
ncol(f.name),
ct.punct("="),
vcol(f.i2repr(self,fvalue)))
self.payload.show(indent=indent, lvl=lvl+(" "*indent*self.show_indent), label_lvl=label_lvl)