repopick: Address PEP8 warnings regarding indentations and variable naming

- Format variables into snake case
- Add spacing between # and text
- Space after ','
- Test for membership with "not in" instead
- Remove too many empty lines

Ref:
[0]: https://www.python.org/dev/peps/pep-0008/#function-and-variable-names
[1]: https://www.python.org/dev/peps/pep-0008/#block-comments
[2]: http://pep8online.com/

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
Change-Id: I16dedf465674056571782921983eb3ec4276a1f8
gugelfrei
Aayush Gupta 4 years ago committed by Rashed Abdel-Tawab
parent 5fd8e2b1ee
commit d395aa21eb

@ -75,7 +75,6 @@ def fetch_query_via_ssh(remote_url, query):
else:
raise Exception('Malformed URI: Expecting ssh://[user@]host[:port]')
out = subprocess.check_output(['ssh', '-x', '-p{0}'.format(port), userhost, 'gerrit', 'query', '--format=JSON --patch-sets --current-patch-set', query])
if not hasattr(out, 'encode'):
out = out.decode()
@ -98,7 +97,7 @@ def fetch_query_via_ssh(remote_url, query):
}
},
'commit': {
'parents': [{ 'commit': parent } for parent in patch_set['parents']]
'parents': [{'commit': parent} for parent in patch_set['parents']]
},
} for patch_set in data['patchSets']},
'subject': data['subject'],
@ -121,12 +120,12 @@ def fetch_query_via_http(remote_url, query):
parts = line.rstrip().split("|")
if parts[0] in remote_url:
auth = requests.auth.HTTPBasicAuth(username=parts[1], password=parts[2])
statusCode = '-1'
status_code = '-1'
if auth:
url = '{0}/a/changes/?q={1}&o=CURRENT_REVISION&o=ALL_REVISIONS&o=ALL_COMMITS'.format(remote_url, query)
data = requests.get(url, auth=auth)
statusCode = str(data.status_code)
if statusCode != '200':
status_code = str(data.status_code)
if status_code != '200':
#They didn't get good authorization or data, Let's try the old way
url = '{0}/changes/?q={1}&o=CURRENT_REVISION&o=ALL_REVISIONS&o=ALL_COMMITS'.format(remote_url, query)
data = requests.get(url)
@ -152,6 +151,7 @@ def fetch_query(remote_url, query):
else:
raise Exception('Gerrit URL should be in the form http[s]://hostname/ or ssh://[user@]host[:port]')
if __name__ == '__main__':
# Default to LineageOS Gerrit
default_gerrit = 'https://review.lineageos.org'
@ -255,8 +255,8 @@ if __name__ == '__main__':
remotes = xml_root.findall('remote')
default_revision = xml_root.findall('default')[0].get('revision')
#dump project data into the a list of dicts with the following data:
#{project: {path, revision}}
# dump project data into the a list of dicts with the following data:
# {project: {path, revision}}
for project in projects:
name = project.get('name')
@ -270,7 +270,7 @@ if __name__ == '__main__':
if revision is None:
revision = default_revision
if not name in project_name_to_data:
if name not in project_name_to_data:
project_name_to_data[name] = {}
revision = revision.split('refs/heads/')[-1]
project_name_to_data[name][revision] = path
@ -409,7 +409,7 @@ if __name__ == '__main__':
output = output.split()
if 'Change-Id:' in output:
head_change_id = ''
for j,t in enumerate(reversed(output)):
for j, t in enumerate(reversed(output)):
if t == 'Change-Id:':
head_change_id = output[len(output) - j]
break

Loading…
Cancel
Save