changelog shortlog tags manifest raw

changeset: Added new color theme because nsummary() didn't work with NoTheme

changeset 709: 4212949af3c4
parent 708:700cc9753173
child 710:2eb84f9506c3
author: Dirk Loss <mail@dirk-loss.de>
date: Sun Jul 22 21:55:47 2007 +0200 (16 months ago)
files: scapy.py
description: Added new color theme because nsummary() didn't work with NoTheme
--- a/scapy.py	Sun Jul 22 21:01:34 2007 +0200
+++ b/scapy.py	Sun Jul 22 21:55:47 2007 +0200
@@ -12562,7 +12562,20 @@ class ColorTheme:
 
 class NoTheme(ColorTheme):
     pass
-
+    
+class BasicTheme(ColorTheme):
+    """No colors, just using the Python's formatting options"""
+    def __getattr__(self, attr):
+        if attr.startswith("__"):
+            raise AttributeError(attr)
+        def do_style(val, fmt=None):
+            if fmt is None:
+                if type(val) is not str:
+                    val = str(val)
+            else:
+                val = fmt % val
+            return val
+        return do_style
 
 class AnsiColorTheme(ColorTheme):
     def __getattr__(self, attr):
@@ -12875,7 +12888,7 @@ AS_resolver: choose the AS resolver clas
         queso_base ="queso.conf"
         nmap_base ="C:\\nmap\\nmap-os-fingerprints"
         IPCountry_base = "C:\\geo\GeoIP.dat"
-        color_theme = NoTheme()
+        color_theme = BasicTheme()
     else:
         histfile = os.path.join(os.environ["HOME"], ".scapy_history")
         padding = 1