From b2db0f37cd152e36853b22c675c915e7c7b37fe5 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 4 Dec 2022 20:59:20 -0500 Subject: [PATCH] Add monkey module as workaround for fabric/fabric#2090 --- CHANGES.rst | 5 +++++ jaraco/fabric/monkey.py | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 jaraco/fabric/monkey.py diff --git a/CHANGES.rst b/CHANGES.rst index c26100c..9eb14dc 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,3 +1,8 @@ +v5.3.0 +====== + +Added ``monkey`` module. + v5.2.1 ====== diff --git a/jaraco/fabric/monkey.py b/jaraco/fabric/monkey.py new file mode 100644 index 0000000..65a3d24 --- /dev/null +++ b/jaraco/fabric/monkey.py @@ -0,0 +1,16 @@ +import functools + + +def workaround_2090(func): + """ + Wrap a task func to work around fabric/fabric#2090. + """ + + @functools.wraps(func) + def wrapper(c, *args, **kwargs): + c.connect_kwargs['key_filename'][:] = [ + key + for key in c.connect_kwargs['key_filename'] + if __import__('os').path.exists(key) + ] + return func(c, *args, **kwargs)