[Twisted-Python] t.p.usage suggestion: '--option='

Tommi Virtanen tv at twistedmatrix.com
Sun Dec 29 12:13:00 EST 2002


	As it is now, twisted.python.usage will not
	allow parameters to have empty strings as
	values. That is, these are invalid currently:

		--foo=
		--foo=''  (the same thing, more explicitly)
		--foo ''

	I think t.p.usage should not be dictating
	such policy for its users.

	It seems this only concerns optParameters users, "def
	opt_foo(self, x)" seems to be immune to this problem if
	I'm reading the code correctly.

	All the above cases are easily detectable, Here's a suggested
	patch; tell me if you want me to commit.

Index: twisted/python/usage.py
===================================================================
RCS file: /cvs/Twisted/twisted/python/usage.py,v
retrieving revision 1.36
diff -u -r1.36 usage.py
--- twisted/python/usage.py	10 Nov 2002 10:45:36 -0000	1.36
+++ twisted/python/usage.py	29 Dec 2002 17:06:03 -0000
@@ -242,7 +242,7 @@
         self.opts[flagName] = 1
 
     def _generic_parameter(self, parameterName, value):
-        if value in ('', None):
+        if value is None:
             raise UsageError, ("Parameter '%s' requires an argument."
                                % (parameterName,))
 

-- 
:(){ :|:&};:




More information about the Twisted-Python mailing list