[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fab-user] accept single callable or name in provided_by require's argum
From: |
Akira Li |
Subject: |
[Fab-user] accept single callable or name in provided_by require's argument |
Date: |
Fri, 9 Oct 2009 18:16:16 +0400 |
Hi,
I'm wondering is it good idea to support single callable or name (not
just list of) in provided_by require()'s keyword argument?
That is to write:
require('name', provided_by=dev)
Instead of:
require('name', provided_by=[dev])
A possible way to implement it:
diff --git a/fabric/operations.py b/fabric/operations.py
index a8246e0..3e235ed 100644
--- a/fabric/operations.py
+++ b/fabric/operations.py
@@ -126,6 +126,9 @@ def require(*keys, **kwargs):
# And print provided_by if given
if 'provided_by' in kwargs:
funcs = kwargs['provided_by']
+ if not hasattr(funcs, '__iter__'):
+ # non-iterable is given, treat it as a list this single item
+ funcs = [funcs]
# Pluralize this too
if len(funcs) > 1:
command = "one of the following commands"
--
Akira.
fabric-provided_by-a8246e0_3e235ed.diff
Description: Text Data
- [Fab-user] accept single callable or name in provided_by require's argument,
Akira Li <=