From d6c741d40bed6466537c452ff8dc7549ea7f9991 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Thu, 17 Sep 2015 14:31:49 +0200 Subject: [PATCH] Add getter method to OrderedLifoDict --- patacrep/songs/chordpro/ast.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/patacrep/songs/chordpro/ast.py b/patacrep/songs/chordpro/ast.py index 5cffbb86..cc0c0d63 100644 --- a/patacrep/songs/chordpro/ast.py +++ b/patacrep/songs/chordpro/ast.py @@ -39,6 +39,11 @@ class OrderedLifoDict: def __getitem__(self, key): return self._values[key] + def get(self, key, default=None): + if key not in self._keys: + return default + return self._values[key] + def _indent(string): """Return and indented version of argument.""" return "\n".join([" {}".format(line) for line in string.split('\n')])