From 303048f9d0da1ba5f917a0abf1da4a090d7a3a49 Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Thu, 7 Apr 2011 03:27:06 -0400 Subject: Minor improvement to Extension settings API. Extension.getConfig now accepts a 'default' keyword and added Extension.getConfigs which returns a list of tuples of all settings without the descriptions. --- markdown/extensions/__init__.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'markdown/extensions/__init__.py') diff --git a/markdown/extensions/__init__.py b/markdown/extensions/__init__.py index 4c1dcba..3f36bb3 100644 --- a/markdown/extensions/__init__.py +++ b/markdown/extensions/__init__.py @@ -14,15 +14,19 @@ class Extension: """ self.config = configs - def getConfig(self, key): + def getConfig(self, key, default=''): """ Return a setting for the given key or an empty string. """ if key in self.config: return self.config[key][0] else: - return "" + return default + + def getConfigs(self): + """ Return all configs settings as a list of tuples. """ + return [(key, self.getConfig(key)) for key in self.config.keys()] def getConfigInfo(self): - """ Return all config settings as a list of tuples. """ + """ Return all config descriptions as a list of tuples. """ return [(key, self.config[key][1]) for key in self.config.keys()] def setConfig(self, key, value): -- cgit v1.2.3