From 3d26097342ecbda755135dc3cf39517d75c027aa Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Wed, 22 Oct 2014 13:02:35 -0500 Subject: Options: fix path canonicalization and file-like objects This fixes canonicalizing PathOption values when the default value of a config file-only option is used. It also fixes PathOptions that get a file-like object instead of a filename string. --- src/lib/Bcfg2/Options/Options.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/lib/Bcfg2/Options/Options.py b/src/lib/Bcfg2/Options/Options.py index 36148c279..f1a201f1e 100644 --- a/src/lib/Bcfg2/Options/Options.py +++ b/src/lib/Bcfg2/Options/Options.py @@ -364,25 +364,20 @@ class PathOption(Option): def _get_default(self): """ Getter for the ``default`` property """ - if self.__class__.repository is None or self._default is None: + if not hasattr(self._default, "replace"): return self._default else: - return self._default.replace("", - self.__class__.repository) + return self._type(self._default) default = property(_get_default, Option._set_default) def _type(self, value): """Type function that fixes up macros.""" if self.__class__.repository is None: - _debug("Cannot fix up macros yet for %s" % self) return value else: - rv = self._original_type(Types.path( + return self._original_type(Types.path( value.replace("", self.__class__.repository))) - _debug("Fixing up macros in %s: %s -> %s" % - (self, value, rv)) - return rv class _BooleanOptionAction(argparse.Action): -- cgit v1.2.3-1-g7c22