From: Joshua Kugler Date: Sat, 9 Jul 2011 04:21:43 +0000 (-0800) Subject: Added a way to access the keys of the data dict as attributes, for "pretty" things... X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=fbc93291e97b0001fcfe926a76b8e091688a7247;p=apachelog.git 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'] --- 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