From fbc93291e97b0001fcfe926a76b8e091688a7247 Mon Sep 17 00:00:00 2001 From: Joshua Kugler Date: Fri, 8 Jul 2011 20:21:43 -0800 Subject: [PATCH] Added a way to access the keys of the data dict as attributes, for "pretty" things like line.remote_ip, instead of line['remote_ip'] --- apachelog.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apachelog.py b/apachelog.py index f6724f0..d38476c 100755 --- a/apachelog.py +++ b/apachelog.py @@ -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 -- 2.26.2