def boolean_of_arg(arg):
# TODO: ""
- assert arg.lower() in ("true", "t", "1", "false", "f", "0", "on", "off")
+ if arg.lower() not in ("true", "t", "1", "false", "f", "0", "on", "off"):
+ raise WebError("invalid boolean argument: %r" % (arg,), http.BAD_REQUEST)
return arg.lower() in ("true", "t", "1", "on")
def parse_replace_arg(replace):
if replace.lower() == "only-files":
return replace
- else:
+ try:
return boolean_of_arg(replace)
+ except WebError:
+ raise WebError("invalid replace= argument: %r" % (replace,), http.BAD_REQUEST)
def get_format(req, default="CHK"):
elif file_format == "MDMF":
return MDMF_VERSION
else:
+ # this is also used to identify which formats are mutable. Use
+ # if get_mutable_type(file_format) is not None:
+ # do_mutable()
+ # else:
+ # do_immutable()
return None