summaryrefslogtreecommitdiffstats
path: root/command.py
diff options
context:
space:
mode:
authorJan Pokorný <jpokorny@redhat.com>2014-06-16 17:55:36 +0200
committerJan Pokorný <jpokorny@redhat.com>2014-06-16 18:57:17 +0200
commitf1a9f5e75c420a8710c46203163119b49bb48f4a (patch)
tree1b042e480b8231f4233107ae4b4b33d7639cb7d5 /command.py
parent2489b45814189739ad832aed32b13db693848207 (diff)
downloadclufter-f1a9f5e75c420a8710c46203163119b49bb48f4a.tar.gz
clufter-f1a9f5e75c420a8710c46203163119b49bb48f4a.tar.xz
clufter-f1a9f5e75c420a8710c46203163119b49bb48f4a.zip
command: add behavior of deferring to _common as already doc'd
(in doc/HACKING in the previous commit) Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
Diffstat (limited to 'command.py')
-rw-r--r--command.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/command.py b/command.py
index 014cae2..9a49709 100644
--- a/command.py
+++ b/command.py
@@ -31,7 +31,8 @@ from .utils_func import apply_aggregation_preserving_depth, \
tailshake, \
zip_empty
from .utils_prog import cli_decor, \
- longopt_letters_reprio
+ longopt_letters_reprio, \
+ defer_common
log = logging.getLogger(__name__)
@@ -66,7 +67,6 @@ class Command(object):
# commands being instantiated initially, while presumably only one
# of them will be run later on
self._desc_opts = None
- self._fnc_defaults_varnames = None
self._filter_chain_analysis = None # will be dict
#
@@ -163,6 +163,7 @@ class Command(object):
def _figure_fnc_defaults_varnames(self):
"""Dissect self._fnc to arg defaults (dict) + all arg names (tuple)"""
+ # XXX deprecated, _fnc_defaults_varnames set on the "birth" of class
try:
fnc = self._fnc
except:
@@ -541,11 +542,13 @@ class Command(object):
def deco_fnc(fnc):
log.debug("Command: deco for {0}"
.format(fnc))
+ fnc_defaults, fnc_varnames, wrapped = defer_common(fnc, skip=1)
attrs = {
- '__module__': fnc.__module__,
- '__doc__': fnc.__doc__,
+ '__module__': fnc.__module__, # original
+ '__doc__': wrapped.__doc__,
'_filter_chain': args2sgpl(filter_chain),
- '_fnc': staticmethod(fnc),
+ '_fnc': staticmethod(wrapped),
+ '_fnc_defaults_varnames': (fnc_defaults, fnc_varnames),
}
# optimization: shorten type() -> new() -> probe
ret = cls.probe(fnc.__name__, (cls, ), attrs)