AttributeError: ‘list’ object has no attribute ‘replace’

If you just want to get rid of \ns in your list, the following code would do it.

gerritinfo = [
    '{"project":... ... Locked for preflight"}]}\n',
    '{"type":"stats","rowCount":1,"runTimeMilliseconds":4}\n'
]
print ''.join([item.rstrip('\n') for item in gerritinfo])

UPDATE

The following code may work. If I didn’t misunderstand your question.

import json
# gerritinfo = [....]
dict_data =json.loads(gerritinfo[0])
for c in dict_data['comments']:
    if c['reviewer']['name'].startswith('Klocwork'): # you can use exact search
        print c['message']

output:

Patch Set 1:

This change is being verified in klocwork for the following manifests along with other changes as detailed below:

=====================================================================================

git-android.quicinc.com/platform/manifest:kk:default.xml

=====================================================================================

https://commander.qualcomm.com/commander/pages/SimplifiedJobView/LoadComponent_run?jobId=3217513

https://review-android.quicinc.com/#change,

Please note that verification of all changes in this batch need to be successful before this change can be merged.

PLEASE DO NOT UPLOAD A NEW PATCH SET, OR REMOVE APPROVALS UNTIL THE VERIFICATION IS COMPLETE.

Patch Set 1: Verified

Successful klocwork verification. You may find the results of the verification by following the link(s) below:

https://commander.qualcomm.com/commander/pages/SimplifiedJobView/LoadComponent_run?jobId=3217513

Leave a Comment