git://git.onelab.eu
/
sfa.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
a little nicer wrt pep8
[sfa.git]
/
sfatables
/
commands
/
moo.py
diff --git
a/sfatables/commands/moo.py
b/sfatables/commands/moo.py
index
6564e9b
..
8104b24
100644
(file)
--- a/
sfatables/commands/moo.py
+++ b/
sfatables/commands/moo.py
@@
-1,5
+1,6
@@
import os, time
import os, time
+
class Command:
commandline_options = []
help = "Add a new rule"
class Command:
commandline_options = []
help = "Add a new rule"
@@
-57,7
+58,7
@@
class Command:
# Indent struct fields and mixed types
if isinstance(param, dict):
# Indent struct fields and mixed types
if isinstance(param, dict):
- for name, subparam in param.ite
rite
ms():
+ for name, subparam in param.items():
text += param_text(name, subparam, indent + step, step)
elif isinstance(param, Mixed):
for subparam in param:
text += param_text(name, subparam, indent + step, step)
elif isinstance(param, Mixed):
for subparam in param:
@@
-90,8
+91,8
@@
class Command:
"""
# Inspect call. Remove self from the argument list.
"""
# Inspect call. Remove self from the argument list.
- max_args = self.call.
func_code.co_varnames[1:self.call.func_code
.co_argcount]
- defaults = self.call.
func_defaults
+ max_args = self.call.
__code__.co_varnames[1:self.call.__code__
.co_argcount]
+ defaults = self.call.
__defaults__
if defaults is None:
defaults = ()
if defaults is None:
defaults = ()
@@
-122,7
+123,7
@@
class Command:
try:
self.type_check(name, value, item, args)
return
try:
self.type_check(name, value, item, args)
return
- except
GeniInvalidArgument,
fault:
+ except
SfaInvalidArgument as
fault:
pass
raise fault
pass
raise fault
@@
-152,7
+153,7
@@
class Command:
# Strings are a special case. Accept either unicode or str
# types if a string is expected.
# Strings are a special case. Accept either unicode or str
# types if a string is expected.
- if
expected_type in StringTypes and isinstance(value, StringTypes
):
+ if
issubclass(expected_type, str) and isinstance(value, str
):
pass
# Integers and long integers are also special types. Accept
pass
# Integers and long integers are also special types. Accept
@@
-161,29
+162,29
@@
class Command:
pass
elif not isinstance(value, expected_type):
pass
elif not isinstance(value, expected_type):
- raise
Geni
InvalidArgument("expected %s, got %s" % \
+ raise
Sfa
InvalidArgument("expected %s, got %s" % \
(xmlrpc_type(expected_type),
xmlrpc_type(type(value))),
name)
# If a minimum or maximum (length, value) has been specified
(xmlrpc_type(expected_type),
xmlrpc_type(type(value))),
name)
# If a minimum or maximum (length, value) has been specified
- if
expected_type in StringTypes
:
+ if
issubclass(expected_type, str)
:
if min is not None and \
len(value.encode(self.api.encoding)) < min:
if min is not None and \
len(value.encode(self.api.encoding)) < min:
- raise
GeniInvalidArgument, "%s must be at least %d bytes long" % (name, min
)
+ raise
SfaInvalidArgument("%s must be at least %d bytes long" % (name, min)
)
if max is not None and \
len(value.encode(self.api.encoding)) > max:
if max is not None and \
len(value.encode(self.api.encoding)) > max:
- raise
GeniInvalidArgument, "%s must be at most %d bytes long" % (name, max
)
+ raise
SfaInvalidArgument("%s must be at most %d bytes long" % (name, max)
)
elif expected_type in (list, tuple, set):
if min is not None and len(value) < min:
elif expected_type in (list, tuple, set):
if min is not None and len(value) < min:
- raise
GeniInvalidArgument, "%s must contain at least %d items" % (name, min
)
+ raise
SfaInvalidArgument("%s must contain at least %d items" % (name, min)
)
if max is not None and len(value) > max:
if max is not None and len(value) > max:
- raise
GeniInvalidArgument, "%s must contain at most %d items" % (name, max
)
+ raise
SfaInvalidArgument("%s must contain at most %d items" % (name, max)
)
else:
if min is not None and value < min:
else:
if min is not None and value < min:
- raise
GeniInvalidArgument, "%s must be > %s" % (name, str(min
))
+ raise
SfaInvalidArgument("%s must be > %s" % (name, str(min)
))
if max is not None and value > max:
if max is not None and value > max:
- raise
GeniInvalidArgument, "%s must be < %s" % (name, str(max
))
+ raise
SfaInvalidArgument("%s must be < %s" % (name, str(max)
))
# If a list with particular types of items is expected
if isinstance(expected, (list, tuple, set)):
# If a list with particular types of items is expected
if isinstance(expected, (list, tuple, set)):
@@
-197,14
+198,14
@@
class Command:
# If a struct with particular (or required) types of items is
# expected.
elif isinstance(expected, dict):
# If a struct with particular (or required) types of items is
# expected.
elif isinstance(expected, dict):
- for key in
value.keys(
):
+ for key in
list(value.keys()
):
if key in expected:
self.type_check(name + "['%s']" % key, value[key], expected[key], args)
if key in expected:
self.type_check(name + "['%s']" % key, value[key], expected[key], args)
- for key, subparam in expected.ite
rite
ms():
+ for key, subparam in expected.items():
if isinstance(subparam, Parameter) and \
subparam.optional is not None and \
if isinstance(subparam, Parameter) and \
subparam.optional is not None and \
- not subparam.optional and key not in
value.keys(
):
- raise
Geni
InvalidArgument("'%s' not specified" % key, name)
+ not subparam.optional and key not in
list(value.keys()
):
+ raise
Sfa
InvalidArgument("'%s' not specified" % key, name)
#if auth is not None:
# auth.check(self, *args)
#if auth is not None:
# auth.check(self, *args)