)]}'
{"nova/utils.py":[{"author":{"_account_id":1132,"name":"Brian Waldon","email":"brian@waldon.cc","username":"bcwaldon"},"change_message_id":"0b82e7fc2cacec7a4a6f6a47f91d9efa0b13317c","unresolved":false,"context_lines":[{"line_number":924,"context_line":"    \"\"\""},{"line_number":925,"context_line":"    if not isinstance(val, basestring):"},{"line_number":926,"context_line":"        return False"},{"line_number":927,"context_line":"    return _uuid_re.match(val) is not None"},{"line_number":928,"context_line":""},{"line_number":929,"context_line":""},{"line_number":930,"context_line":"def bool_from_str(val):"}],"source_content_type":"text/x-python","patch_set":1,"id":"AAAAC3%2F%2F73Q%3D","line":927,"updated":"2011-12-19 21:23:48.000000000","message":"Can you just try to cast it to a UUID and return False if it raises an exception? It\u0027s a lot simpler than a regex. This is what we use in glance:\n\ndef is_uuid_like(value):\n    try:\n        uuid.UUID(value)\n        return True\n    except Exception:\n        return False","commit_id":"16bea16405f0af15a382534dd19ba1cce227cbce"},{"author":{"_account_id":518,"name":"Soren Hansen","email":"soren@linux2go.dk","username":"soren"},"change_message_id":"c120d9c303dc4418f27feac2f12b3e8f85fe6560","unresolved":false,"context_lines":[{"line_number":922,"context_line":"    try:"},{"line_number":923,"context_line":"        uuid.UUID(val)"},{"line_number":924,"context_line":"        return True"},{"line_number":925,"context_line":"    except Exception:"},{"line_number":926,"context_line":"        return False"},{"line_number":927,"context_line":""},{"line_number":928,"context_line":""}],"source_content_type":"text/x-python","patch_set":3,"id":"AAAAC3%2F%2F7yA%3D","line":925,"updated":"2011-12-20 12:41:44.000000000","message":"Isn\u0027t there a more specific exception we can catch than this? Every time I see \"except Exception\", I get the heebie jeebies :)","commit_id":"487cae25b95eb04e478cbcf486d133851e73be66"},{"author":{"_account_id":1561,"name":"Russell Bryant","email":"rbryant@redhat.com","username":"russellb"},"change_message_id":"486bc6404ad473eb47c3b5fd02d3076bb4aa20f0","unresolved":false,"context_lines":[{"line_number":922,"context_line":"    try:"},{"line_number":923,"context_line":"        uuid.UUID(val)"},{"line_number":924,"context_line":"        return True"},{"line_number":925,"context_line":"    except Exception:"},{"line_number":926,"context_line":"        return False"},{"line_number":927,"context_line":""},{"line_number":928,"context_line":""}],"source_content_type":"text/x-python","patch_set":3,"id":"AAAAC3%2F%2F7xg%3D","line":925,"in_reply_to":"AAAAC3%2F%2F7yA%3D","updated":"2011-12-20 14:30:40.000000000","message":"That\u0027s probably a good reaction.  I\u0027ll take a look!","commit_id":"487cae25b95eb04e478cbcf486d133851e73be66"},{"author":{"_account_id":1132,"name":"Brian Waldon","email":"brian@waldon.cc","username":"bcwaldon"},"change_message_id":"661e73d3f2ecf2caa269a50d18d219311ef4f366","unresolved":false,"context_lines":[{"line_number":922,"context_line":"    try:"},{"line_number":923,"context_line":"        uuid.UUID(val)"},{"line_number":924,"context_line":"        return True"},{"line_number":925,"context_line":"    except Exception:"},{"line_number":926,"context_line":"        return False"},{"line_number":927,"context_line":""},{"line_number":928,"context_line":""}],"source_content_type":"text/x-python","patch_set":3,"id":"AAAAC3%2F%2F7xk%3D","line":925,"in_reply_to":"AAAAC3%2F%2F7yA%3D","updated":"2011-12-20 14:31:15.000000000","message":"Yeah, I thought that when I pasted it in my original comment. So we can either catch \u0027Exception\u0027 or \u0027(AttributeError, ValueError)\u0027. The reason I wrote Exception in Glance was that I wanted any failure to return False, no matter what it was (so if \u0027val\u0027 turned up to be a custom object that threw an unforeseen exception, the function would still return False). I do agree with you whole-heartedly about feeling weird using just \u0027Exception\u0027, but I feel this is one of the few cases it can be justified. I still wouldn\u0027t be against being more explicit, though, it\u0027s up to you guys :)","commit_id":"487cae25b95eb04e478cbcf486d133851e73be66"}]}
