From 703b5801427f908a83cc4704c05492b2ea64d1d8 Mon Sep 17 00:00:00 2001 From: Alberto Planas Date: Tue, 4 Mar 2014 15:30:49 +0100 Subject: [PATCH] Fix references from opts.move and opts.from_ --- osc-staging.py | 2 +- osclib/select_command.py | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/osc-staging.py b/osc-staging.py index ea8275ee..d44f6adc 100644 --- a/osc-staging.py +++ b/osc-staging.py @@ -263,7 +263,7 @@ def do_staging(self, subcmd, opts, *args): msg='Please recheck') elif cmd == 'select': tprj = api. prj_from_letter(args[1]) - return SelectCommand(api).perform(tprj, args[2:]) + return SelectCommand(api).perform(tprj, args[2:], opts.move, opts.from_) elif cmd == 'cleanup_rings': return CleanupRings(opts.apiurl).perform() elif cmd == 'list': diff --git a/osclib/select_command.py b/osclib/select_command.py index 5481aba6..c073cf21 100644 --- a/osclib/select_command.py +++ b/osclib/select_command.py @@ -1,25 +1,26 @@ -from osclib.stagingapi import StagingAPI +from osc import oscerr from osclib.request_finder import RequestFinder -class SelectCommand: - + +class SelectCommand(object): + def __init__(self, api): self.api = api - def select_request(self, rq, rq_prj): + def select_request(self, rq, rq_prj, move, from_): if 'staging' not in rq_prj: # Normal 'select' command self.api.rq_to_prj(rq, self.tprj) - elif 'staging' in rq_prj and opts.move: + elif 'staging' in rq_prj and move: # 'select' command becomes a 'move' fprj = None - if opts.from_: - fprj = self.api.prj_from_letter(opts.from_) + if from_: + fprj = self.api.prj_from_letter(from_) else: fprj = rq_prj['staging'] print('Moving "{}" from "{}" to "{}"'.format(rq, fprj, self.tprj)) self.api.move_between_project(fprj, rq, self.tprj) - elif 'staging' in rq_prj and not opts.move: + elif 'staging' in rq_prj and not move: # Previously selected, but not explicit move msg = 'Request {} is actually in "{}".\n' msg = msg.format(rq, rq_prj['staging']) @@ -29,12 +30,11 @@ class SelectCommand: else: raise oscerr.WrongArgs('Arguments for select are not correct.') - - def perform(self, tprj, requests): + def perform(self, tprj, requests, move=False, from_=None): if not self.api.prj_frozen_enough(tprj): print('Freeze the prj first') return False self.tprj = tprj for rq, rq_prj in RequestFinder.find_sr(requests, self.api.apiurl).items(): - self.select_request(rq, rq_prj) + self.select_request(rq, rq_prj, move, from_)