Added a way to access the keys of the data dict as attributes, for "pretty" things...
authorJoshua Kugler <joshua@azariah.com>
Sat, 9 Jul 2011 04:21:43 +0000 (20:21 -0800)
committerJoshua Kugler <joshua@azariah.com>
Sat, 9 Jul 2011 04:21:43 +0000 (20:21 -0800)
apachelog.py

index f6724f0ea6900b8afa5e65cd7d4c0fb55e04fa3f..d38476cfa652feab9a32428e89d9a55f51480822 100755 (executable)
@@ -100,6 +100,14 @@ import re
 class ApacheLogParserError(Exception):
     pass
 
+class AttrDict(dict):
+    """
+    Allows dicts to be accessed via dot notation as well as subscripts
+    Makes using the friendly names nicer
+    """
+    def __getattr__(self, name):
+        return self[name]
+
 class parser:
     format_to_name = {
         # Explanatory comments copied from