)]}'
{"glanceclient/v2/schemas.py":[{"author":{"_account_id":12000,"name":"Ian Cordasco","email":"sigmavirus24@gmail.com","username":"sigmavirus24"},"change_message_id":"876c90b5820f4ae87c97f8a15be95863de0b52f9","unresolved":false,"context_lines":[{"line_number":34,"context_line":"        if not self.get(\u0027tags\u0027):"},{"line_number":35,"context_line":"            tags_patch \u003d \u0027\u0027"},{"line_number":36,"context_line":"        else:"},{"line_number":37,"context_line":"            tags_patch \u003d \u0027{\"path\": \"/tags\", \"value\": [\"\u0027 + \u0027\", \"\u0027.join("},{"line_number":38,"context_line":"                self.get(\u0027tags\u0027)) + \u0027\"], \"op\": \"replace\"}\u0027"},{"line_number":39,"context_line":""},{"line_number":40,"context_line":"        if patch \u003d\u003d \u0027[]\u0027:"}],"source_content_type":"text/x-python","patch_set":2,"id":"9a80dd14_2d9ba773","line":37,"updated":"2015-03-10 20:28:23.000000000","message":"Probably a really stupid question, but why aren\u0027t we using the json library to serialize this? It seems like we could do\n\n\n    tags_patch \u003d jsonutils.dumps({\n        \u0027path\u0027: \u0027tags\u0027\n        \u0027value\u0027: [\u0027\u0027] + self.get(\u0027tags\u0027, []),\n        \u0027op\u0027: \u0027replace\u0027,\n    })\n\nBetter yet this whole method should only serialize the data at the end. Something like\n\n    if not self.get(\u0027tags\u0027):\n        tags_patch \u003d []\n    else:\n        tags_patch \u003d [{\n            \u0027path\u0027: \u0027tags\u0027\n            \u0027value\u0027: [\u0027\u0027] + self.get(\u0027tags\u0027, []),\n            \u0027op\u0027: \u0027replace\u0027,\n        }]\n\n    if patch \u003d\u003d \u0027[]\u0027:\n        return jsonutils.dumps(tags_patch)\n    else:\n        parsed_patch \u003d jsonutils.loads(patch)\n        return jsonutils.dumps(tags_patch + parsed_patch)\n\nThis will work because we seem to always be dealing with Arrays (a.k.a, lists). So if there\u0027s no \u0027tags\u0027, then tags_patch is an empty list which will satisfy the case below where patch \u003d \u0027[]\u0027 and tags_patch is (currently) \u0027\u0027. Otherwise we make a single item list (which satisfies the case where patch is \u0027[]\u0027). Both of these also satisfy the case where patch !\u003d \u0027[]\u0027. If you look carefully at the two cases, we\u0027re now adding two lists in the case where patch !\u003d \u0027[]\u0027. That means it\u0027ll be a list with tags_patch\u0027s items first and then the parsed items second (which is the same as the previous behaviour). When there are no tags, then nothing changes in patch (except perhaps the order of keys inside nested objects which is not important per the JSON RFC).","commit_id":"1ee0a02d75573dc638af0567d97dd1731382b9b7"},{"author":{"_account_id":12807,"name":"Steve Lewis (stevelle)","email":"stevelle@gmail.com","username":"stevelle"},"change_message_id":"8e28c0acf682764fb6f1f45b1e195d469fa303d0","unresolved":false,"context_lines":[{"line_number":34,"context_line":"        if not self.get(\u0027tags\u0027):"},{"line_number":35,"context_line":"            tags_patch \u003d \u0027\u0027"},{"line_number":36,"context_line":"        else:"},{"line_number":37,"context_line":"            tags_patch \u003d \u0027{\"path\": \"/tags\", \"value\": [\"\u0027 + \u0027\", \"\u0027.join("},{"line_number":38,"context_line":"                self.get(\u0027tags\u0027)) + \u0027\"], \"op\": \"replace\"}\u0027"},{"line_number":39,"context_line":""},{"line_number":40,"context_line":"        if patch \u003d\u003d \u0027[]\u0027:"}],"source_content_type":"text/x-python","patch_set":2,"id":"9a80dd14_a029eb9c","line":37,"in_reply_to":"9a80dd14_2d9ba773","updated":"2015-03-12 21:45:02.000000000","message":"I neglected to clean up the implementation.\nI think my cleaned up solution ended up more or less with what you suggested.","commit_id":"1ee0a02d75573dc638af0567d97dd1731382b9b7"},{"author":{"_account_id":12000,"name":"Ian Cordasco","email":"sigmavirus24@gmail.com","username":"sigmavirus24"},"change_message_id":"f54593b9736da7541ea3a89a9937f5592056329e","unresolved":false,"context_lines":[{"line_number":39,"context_line":"                          \"op\": \"replace\"}]"},{"line_number":40,"context_line":""},{"line_number":41,"context_line":"        patch_string \u003d jsonpatch.make_patch(original, new).to_string()"},{"line_number":42,"context_line":"        patch \u003d json.loads(patch_string)"},{"line_number":43,"context_line":"        if not patch:"},{"line_number":44,"context_line":"            return json.dumps(tags_patch)"},{"line_number":45,"context_line":"        else:"}],"source_content_type":"text/x-python","patch_set":3,"id":"9a80dd14_433bd9d0","line":42,"updated":"2015-03-12 21:44:30.000000000","message":"I think it\u0027s convention to use jsonutils from oslo_utils.","commit_id":"acce195fbf2f0c8fb68e378020407cfab69e9a91"},{"author":{"_account_id":12807,"name":"Steve Lewis (stevelle)","email":"stevelle@gmail.com","username":"stevelle"},"change_message_id":"ad94d2d64325b238d2d9fd22d170fd231d283a08","unresolved":false,"context_lines":[{"line_number":39,"context_line":"                          \"op\": \"replace\"}]"},{"line_number":40,"context_line":""},{"line_number":41,"context_line":"        patch_string \u003d jsonpatch.make_patch(original, new).to_string()"},{"line_number":42,"context_line":"        patch \u003d json.loads(patch_string)"},{"line_number":43,"context_line":"        if not patch:"},{"line_number":44,"context_line":"            return json.dumps(tags_patch)"},{"line_number":45,"context_line":"        else:"}],"source_content_type":"text/x-python","patch_set":3,"id":"9a80dd14_d60b05d4","line":42,"in_reply_to":"9a80dd14_433bd9d0","updated":"2015-03-12 22:19:33.000000000","message":"That convention doesn\u0027t seem to apply to glance client so I went with json","commit_id":"acce195fbf2f0c8fb68e378020407cfab69e9a91"},{"author":{"_account_id":12000,"name":"Ian Cordasco","email":"sigmavirus24@gmail.com","username":"sigmavirus24"},"change_message_id":"f54593b9736da7541ea3a89a9937f5592056329e","unresolved":false,"context_lines":[{"line_number":50,"context_line":"        \"\"\"Return a jsonpatch object representing the delta.\"\"\""},{"line_number":51,"context_line":"        original \u003d copy.deepcopy(self.__dict__[\u0027__original__\u0027])"},{"line_number":52,"context_line":"        new \u003d dict(self)"},{"line_number":53,"context_line":"        if self.__dict__[\u0027schema\u0027]:"},{"line_number":54,"context_line":"            for (name, prop) in six.iteritems(self.schema[\u0027properties\u0027]):"},{"line_number":55,"context_line":"                if (name not in original and name in new and"},{"line_number":56,"context_line":"                        prop.get(\u0027is_base\u0027, True)):"}],"source_content_type":"text/x-python","patch_set":3,"id":"9a80dd14_237185a8","line":53,"updated":"2015-03-12 21:44:30.000000000","message":"I really wish I knew why this was using self.__dict__ \u003d(","commit_id":"acce195fbf2f0c8fb68e378020407cfab69e9a91"},{"author":{"_account_id":12807,"name":"Steve Lewis (stevelle)","email":"stevelle@gmail.com","username":"stevelle"},"change_message_id":"ad94d2d64325b238d2d9fd22d170fd231d283a08","unresolved":false,"context_lines":[{"line_number":50,"context_line":"        \"\"\"Return a jsonpatch object representing the delta.\"\"\""},{"line_number":51,"context_line":"        original \u003d copy.deepcopy(self.__dict__[\u0027__original__\u0027])"},{"line_number":52,"context_line":"        new \u003d dict(self)"},{"line_number":53,"context_line":"        if self.__dict__[\u0027schema\u0027]:"},{"line_number":54,"context_line":"            for (name, prop) in six.iteritems(self.schema[\u0027properties\u0027]):"},{"line_number":55,"context_line":"                if (name not in original and name in new and"},{"line_number":56,"context_line":"                        prop.get(\u0027is_base\u0027, True)):"}],"source_content_type":"text/x-python","patch_set":3,"id":"9a80dd14_36e8e1e1","line":53,"in_reply_to":"9a80dd14_237185a8","updated":"2015-03-12 22:19:33.000000000","message":"I don\u0027t know and didn\u0027t like that either, fixed.","commit_id":"acce195fbf2f0c8fb68e378020407cfab69e9a91"}],"tests/v2/test_schemas.py":[{"author":{"_account_id":12000,"name":"Ian Cordasco","email":"sigmavirus24@gmail.com","username":"sigmavirus24"},"change_message_id":"e9761a48e21f3bef58e7b63f849af01f11e0f84e","unresolved":false,"context_lines":[{"line_number":202,"context_line":"        self.assertTrue(compare_json_patches(patch, expected))"},{"line_number":203,"context_line":""},{"line_number":204,"context_line":"    def test_patch_should_replace_tags(self):"},{"line_number":205,"context_line":"        obj \u003d {\u0027name\u0027: \u0027fred\u0027, }"},{"line_number":206,"context_line":""},{"line_number":207,"context_line":"        original \u003d self.model(obj)"},{"line_number":208,"context_line":"        original[\u0027tags\u0027] \u003d [\u0027tag1\u0027, \u0027tag2\u0027]"}],"source_content_type":"text/x-python","patch_set":4,"id":"9a80dd14_79c81ca8","line":205,"updated":"2015-03-16 15:19:08.000000000","message":"For a follow-up patch, Probably should remove the \", \".","commit_id":"f6f573316cfc2dd87ff7224590087e7f3be01b2e"},{"author":{"_account_id":12000,"name":"Ian Cordasco","email":"sigmavirus24@gmail.com","username":"sigmavirus24"},"change_message_id":"e9761a48e21f3bef58e7b63f849af01f11e0f84e","unresolved":false,"context_lines":[{"line_number":208,"context_line":"        original[\u0027tags\u0027] \u003d [\u0027tag1\u0027, \u0027tag2\u0027]"},{"line_number":209,"context_line":""},{"line_number":210,"context_line":"        patch \u003d original.patch"},{"line_number":211,"context_line":"        expected \u003d \u0027[{\"path\": \"/tags\", \"value\": [\"tag1\", \"tag2\"], \u0027 \\"},{"line_number":212,"context_line":"            \u0027\"op\": \"replace\"}]\u0027"},{"line_number":213,"context_line":"        self.assertTrue(compare_json_patches(patch, expected))"}],"source_content_type":"text/x-python","patch_set":4,"id":"9a80dd14_b94c5443","line":211,"updated":"2015-03-16 15:19:08.000000000","message":"You can use parentheses here for implicit concatenation instead of using a \\. (Again for a follow-up patch.)","commit_id":"f6f573316cfc2dd87ff7224590087e7f3be01b2e"}]}
