summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEd Bartosh <eduard.bartosh@intel.com>2015-01-16 14:16:31 +0200
committerEd Bartosh <eduard.bartosh@intel.com>2015-01-23 14:51:32 +0200
commit0f7fab645b817204bc7aef09954fe795d0900272 (patch)
tree3f5aabf4eed602abe0be18f6a374374c18c9fd62
parent3e4ddd5152a55ebb54bf7a8abe9b8c4d6023d42c (diff)
downloadrepa-0f7fab645b817204bc7aef09954fe795d0900272.tar.gz
repa-0f7fab645b817204bc7aef09954fe795d0900272.tar.bz2
repa-0f7fab645b817204bc7aef09954fe795d0900272.zip
diff: Use difftype namedtuple
Introduced new sturcture difftype to handle project and manifest. This should fix 2 pylint warnings: 'Too many local variables' and 'Too many arguments'. Fixes: #2320 Change-Id: I9912193871da692ca9f297640f7ef593ecff9df5 Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
-rw-r--r--repa/diff.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/repa/diff.py b/repa/diff.py
index d456bdd..954321b 100644
--- a/repa/diff.py
+++ b/repa/diff.py
@@ -27,13 +27,14 @@ import sys
import os
import json
+from collections import namedtuple
+
import xml.etree.ElementTree as ET
from repa.common import RepaException, Colorizer, get_prerelease
from repa.obs import OBS
from repa.main import sub_main
-
def gen_data(manifest):
"""Parse manifest. Yield git path and revision for every entry."""
try:
@@ -58,16 +59,16 @@ def get_tag(obs, project, package):
return None
-def diff(obs, cmp_project, target_project, cmp_manifest,
- target_manifest, is_colorize=False):
+def diff(obs, cmpinfo, targetinfo, is_colorize=False):
"""
Show the difference between two projects in terms of
revisions and tags.
+ cmpinfo and target info are named tuples: (project, manifest)
"""
colorizer = Colorizer(is_colorize)
- target_data = dict(gen_data(target_manifest))
- cmp_data = dict(gen_data(cmp_manifest))
+ target_data = dict(gen_data(targetinfo.manifest))
+ cmp_data = dict(gen_data(cmpinfo.manifest))
for path in sorted(cmp_data):
rev_target = target_data.get(path)
@@ -76,12 +77,12 @@ def diff(obs, cmp_project, target_project, cmp_manifest,
package = os.path.basename(path)
# Get tag, accepted to cmp_project
- cmp_tag = get_tag(obs, cmp_project, package)
+ cmp_tag = get_tag(obs, cmpinfo.project, package)
status = ''
# Colorize tag if it's pending in target project
if cmp_tag:
try:
- prerelease = get_prerelease(cmp_tag, target_project)
+ prerelease = get_prerelease(cmp_tag, targetinfo.project)
if obs.exists(prerelease):
if is_colorize:
cmp_tag = colorizer.green(cmp_tag)
@@ -112,8 +113,9 @@ class Diff(object):
def run(argv):
"""Command line entry point. Called from [sub_]main."""
obs = OBS(argv.apiurl, argv.apiuser, argv.apipasswd)
- return diff(obs, argv.cmp_project, argv.project,
- argv.cmp_manifest, argv.manifest, argv.colorize)
+ difftype = namedtuple('diff', ['project', 'manifest'])
+ return diff(obs, difftype(argv.cmp_project, argv.cmp_manifest),
+ difftype(argv.project, argv.manifest), argv.colorize)
if __name__ == '__main__':
sys.exit(sub_main(sys.argv[1:], Diff()))