)]}'
{"tools/fix-mitaka-config.py":[{"author":{"_account_id":23630,"name":"Tovin Seven","email":"tovin07@gmail.com","username":"tovin07"},"change_message_id":"044622b12ed5db6e8cbc8ac844aeb345dd97c4e5","unresolved":false,"context_lines":[{"line_number":17,"context_line":""},{"line_number":18,"context_line":"def process(json_file, key):"},{"line_number":19,"context_line":"    try:"},{"line_number":20,"context_line":"        with open(json_file) as _json:"},{"line_number":21,"context_line":"            j \u003d json.load(_json)"},{"line_number":22,"context_line":"        a \u003d []"},{"line_number":23,"context_line":"        for v in j[\u0027config_files\u0027]:"}],"source_content_type":"text/x-python","patch_set":2,"id":"5a3905b3_e4bc40bd","line":20,"range":{"start_line":20,"start_character":32,"end_line":20,"end_character":37},"updated":"2017-01-23 06:53:38.000000000","message":"I understand that this will avoid conflicting with json lib, however, ``json_`` will be a better choice.\n\nFom PEP8[1]:\nsingle_trailing_underscore_ : used by convention to avoid conflicts with Python keyword, e.g.\n\n[1] https://www.python.org/dev/peps/pep-0008/#naming-conventions","commit_id":"ff93e3a082c4ebef681dc569f3a2e9885446f45c"},{"author":{"_account_id":24441,"name":"Cuong Nguyen","email":"cuongnv@vn.fujitsu.com","username":"cuongnv"},"change_message_id":"726214819e474e5790ff5a93accf323c5ac15f86","unresolved":false,"context_lines":[{"line_number":17,"context_line":""},{"line_number":18,"context_line":"def process(json_file, key):"},{"line_number":19,"context_line":"    try:"},{"line_number":20,"context_line":"        with open(json_file) as _json:"},{"line_number":21,"context_line":"            j \u003d json.load(_json)"},{"line_number":22,"context_line":"        a \u003d []"},{"line_number":23,"context_line":"        for v in j[\u0027config_files\u0027]:"}],"source_content_type":"text/x-python","patch_set":2,"id":"5a3905b3_bb7c13b6","line":20,"range":{"start_line":20,"start_character":32,"end_line":20,"end_character":37},"in_reply_to":"5a3905b3_e4bc40bd","updated":"2017-01-23 09:16:16.000000000","message":"Thanks Tovin, if flake8 doesn\u0027t complain about that I think it\u0027s ok  ;)","commit_id":"ff93e3a082c4ebef681dc569f3a2e9885446f45c"},{"author":{"_account_id":9237,"name":"Kevin Fox","email":"kevin@efox.cc","username":"kfox1111"},"change_message_id":"6f45b79a34379b2b4c7e00741cf8757377061e51","unresolved":false,"context_lines":[{"line_number":18,"context_line":"def process(json_file, key):"},{"line_number":19,"context_line":"    try:"},{"line_number":20,"context_line":"        with open(json_file) as _json:"},{"line_number":21,"context_line":"            j \u003d json.load(_json)"},{"line_number":22,"context_line":"        a \u003d []"},{"line_number":23,"context_line":"        for v in j[\u0027config_files\u0027]:"},{"line_number":24,"context_line":"            if v[\u0027source\u0027] \u003d\u003d \u0027/var/lib/kolla/config_files/ceph.*\u0027:"}],"source_content_type":"text/x-python","patch_set":2,"id":"5a3905b3_7ef0e267","line":21,"updated":"2017-01-23 05:14:10.000000000","message":"Purely for my own education question.\n\nWhile I can normally see the advantage of using \"with\",\nwhat advantage does it have in this case? It takes more code and some temporary vars to make work.","commit_id":"ff93e3a082c4ebef681dc569f3a2e9885446f45c"},{"author":{"_account_id":24441,"name":"Cuong Nguyen","email":"cuongnv@vn.fujitsu.com","username":"cuongnv"},"change_message_id":"4945c13dac94d0832e3f00f6c64b43332ceb5cbe","unresolved":false,"context_lines":[{"line_number":18,"context_line":"def process(json_file, key):"},{"line_number":19,"context_line":"    try:"},{"line_number":20,"context_line":"        with open(json_file) as _json:"},{"line_number":21,"context_line":"            j \u003d json.load(_json)"},{"line_number":22,"context_line":"        a \u003d []"},{"line_number":23,"context_line":"        for v in j[\u0027config_files\u0027]:"},{"line_number":24,"context_line":"            if v[\u0027source\u0027] \u003d\u003d \u0027/var/lib/kolla/config_files/ceph.*\u0027:"}],"source_content_type":"text/x-python","patch_set":2,"id":"5a3905b3_8460dcd0","line":21,"in_reply_to":"5a3905b3_7ef0e267","updated":"2017-01-23 06:40:14.000000000","message":"I think file object created by `open(json_file)` will not be destroyed after used. That\u0027s why I replaced it by context manager. Pls correct if i\u0027m wrong in this.","commit_id":"ff93e3a082c4ebef681dc569f3a2e9885446f45c"},{"author":{"_account_id":2834,"name":"Steven Dake","email":"steven.dake@gmail.com","username":"sdake"},"change_message_id":"5b74a22c785ad76443a06810778e17eb7d1fe3da","unresolved":false,"context_lines":[{"line_number":18,"context_line":"def process(json_file, key):"},{"line_number":19,"context_line":"    try:"},{"line_number":20,"context_line":"        with open(json_file) as _json:"},{"line_number":21,"context_line":"            j \u003d json.load(_json)"},{"line_number":22,"context_line":"        a \u003d []"},{"line_number":23,"context_line":"        for v in j[\u0027config_files\u0027]:"},{"line_number":24,"context_line":"            if v[\u0027source\u0027] \u003d\u003d \u0027/var/lib/kolla/config_files/ceph.*\u0027:"}],"source_content_type":"text/x-python","patch_set":2,"id":"5a3905b3_a45078d5","line":21,"in_reply_to":"5a3905b3_7ef0e267","updated":"2017-01-23 06:48:30.000000000","message":"Kevin,\n\nThe general usage of context managers in python is to prevent leaks of any kind including fds.  In this case, the try clause would GC the file descriptor so no close at all is necessary, however, context managers are generally more suitable then using try as most python developers understand a context manager will always GC the indented code in the context manager.  While it does require more variables, its easier for python developers to parse and is more \"pythonic\".\n\nTo expand, mentally mapping an open to a corresponding close with 15-20 lines of code in-between is difficult for some developers to process, especially in gerrit which may not show the full context of the change.\n\nHope that makes sense.\n\nPersonally I prefer open followed by close as it is more \"systems programming like\", however, with gerrit in the picture it makes that model a bit more difficult to review.\n\nLets hope the code doesn\u0027t become so pythonic that it is unreadable by mere mortals :)","commit_id":"ff93e3a082c4ebef681dc569f3a2e9885446f45c"},{"author":{"_account_id":24441,"name":"Cuong Nguyen","email":"cuongnv@vn.fujitsu.com","username":"cuongnv"},"change_message_id":"12388fba51703363d62446b7e673f8e73111d0cb","unresolved":false,"context_lines":[{"line_number":18,"context_line":"def process(json_file, key):"},{"line_number":19,"context_line":"    try:"},{"line_number":20,"context_line":"        with open(json_file) as _json:"},{"line_number":21,"context_line":"            j \u003d json.load(_json)"},{"line_number":22,"context_line":"        a \u003d []"},{"line_number":23,"context_line":"        for v in j[\u0027config_files\u0027]:"},{"line_number":24,"context_line":"            if v[\u0027source\u0027] \u003d\u003d \u0027/var/lib/kolla/config_files/ceph.*\u0027:"}],"source_content_type":"text/x-python","patch_set":2,"id":"5a3905b3_fb7f7bdd","line":21,"in_reply_to":"5a3905b3_a45078d5","updated":"2017-01-23 09:14:15.000000000","message":"Hi Steven,\n\n\u003e In this case, the try clause would GC the file descriptor so no close at all is necessary,\n\nThanks for this and your detail explanation, I used to be confused about that point, but I chose to go with context manager for safe.","commit_id":"ff93e3a082c4ebef681dc569f3a2e9885446f45c"},{"author":{"_account_id":9237,"name":"Kevin Fox","email":"kevin@efox.cc","username":"kfox1111"},"change_message_id":"d4138249603a31123a5edf3bb5284e86e1769676","unresolved":false,"context_lines":[{"line_number":18,"context_line":"def process(json_file, key):"},{"line_number":19,"context_line":"    try:"},{"line_number":20,"context_line":"        with open(json_file) as _json:"},{"line_number":21,"context_line":"            j \u003d json.load(_json)"},{"line_number":22,"context_line":"        a \u003d []"},{"line_number":23,"context_line":"        for v in j[\u0027config_files\u0027]:"},{"line_number":24,"context_line":"            if v[\u0027source\u0027] \u003d\u003d \u0027/var/lib/kolla/config_files/ceph.*\u0027:"}],"source_content_type":"text/x-python","patch_set":2,"id":"5a3905b3_7d128858","line":21,"in_reply_to":"5a3905b3_fb7f7bdd","updated":"2017-01-23 16:14:04.000000000","message":"Best to avoid confusion and just make it explicit, like this ps does.","commit_id":"ff93e3a082c4ebef681dc569f3a2e9885446f45c"}]}
