Commit ff529875 authored by Hashar's avatar Hashar
Browse files

Add tox and flake8

Fix reported issues:

./bin/getwikirights.py

7:1: F401 'getpass' imported but unused
11:1: E302 expected 2 blank lines, found 1
23:16: E222 multiple spaces after operator
25:5: F841 local variable 'wap' is assigned to but never used
32:1: E305 expected 2 blank lines after class or function definition,
      found 1

There is a very long string for an URL, ignores it with 'noqa'. The code
should be refactored to pass a dict to requests.get.

./usertracker/UserTracker.py

12:1: F401 'sys' imported but unused
100:13: F841 local variable 'all_post_data' is assigned to but never used
274:37: E117 over-indented

Bug: T216801
Change-Id: I9e5bdccdb9d5d2f36d671d06eade37384bcd8ba5
parent da4433e8
......@@ -4,14 +4,14 @@ try:
import requests
except ImportError:
print('Install requests3 library')
import getpass
import sys
import json
def main():
user = sys.argv[1]
req = 'https://meta.wikimedia.org/w/api.php?action=query&format=json&meta=globaluserinfo&guiuser={}&guiprop=groups%7Crights%7Cmerged'
req = 'https://meta.wikimedia.org/w/api.php?action=query&format=json&meta=globaluserinfo&guiuser={}&guiprop=groups%7Crights%7Cmerged' # noqa
req_user = req.format(user)
r = requests.get(req_user)
results = json.loads(r.content.decode('utf-8'))
......@@ -20,14 +20,14 @@ def main():
else:
global_groups = ','.join(results['query']['globaluserinfo']['groups'])
print('global: {}'.format(global_groups))
wikis = results['query']['globaluserinfo']['merged']
wikis = results['query']['globaluserinfo']['merged']
wap = {}
for w in wikis:
if 'groups' in w:
wiki = w['wiki']
rights = ','.join(w['groups'])
print("{}: {}".format(wiki, rights))
if __name__ == '__main__':
main()
[tox]
envlist = flake8
# No setup.py / not distributed
skipsdist = True
[testenv]
basepython = python3
[testenv:flake8]
deps = flake8
commands = flake8 {posargs}
......@@ -9,7 +9,6 @@ import re
import requests
import smtplib
import socket
import sys
import syslog
import time
......@@ -94,10 +93,9 @@ class PhabricatorTracker():
def get_end_point_data(self, end_point_key, post_params):
""" Get JSON data from gerrit API, process and load """
all_post_data = {}
api_token_dict = {'api.token': self.phab_api_key}
if isinstance(post_params, dict):
all_post_data = api_token_dict.update(post_params)
api_token_dict.update(post_params)
else:
raise ValueError('Incorrect format for post_params')
......@@ -269,9 +267,9 @@ class GerritTracker():
gerrit_ps_id = obj2['_number']
if('owner' in obj2.keys() and
obj2['owner']['_account_id'] ==
self.gerrit_user_id):
user_info.append('Owner')
obj2['owner']['_account_id'] == self.gerrit_user_id
):
user_info.append('Owner')
if('submitter' in obj2.keys() and
obj2['submitter']['_account_id'] ==
self.gerrit_user_id):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment