1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-02-02 09:46:16 +01:00

- do_addchannels: cleanup and beautify

No changes w.r.t. to semantics.
This commit is contained in:
Marcus Huewe 2015-07-15 20:41:31 +02:00
parent 8d10a3f76f
commit 0daec6a5f1

View File

@ -462,41 +462,35 @@ class Osc(cmdln.Cmdln):
""" """
apiurl = self.get_api_url() apiurl = self.get_api_url()
project_dir = localdir = os.getcwd() localdir = os.getcwd()
channel = None channel = None
command = "addchannels" if not args:
if len(args) == 0:
if is_project_dir(localdir): if is_project_dir(localdir):
project = store_read_project(localdir) project = store_read_project(localdir)
apiurl = self.get_api_url()
elif is_package_dir(localdir): elif is_package_dir(localdir):
project = store_read_project(localdir) project = store_read_project(localdir)
channel = store_read_package(localdir) channel = store_read_package(localdir)
apiurl = self.get_api_url() # XXX: error handling?
else: else:
project = args[0] project = args[0]
if subcmd == 'enablechannels' or subcmd == 'enablechannel':
command = "modifychannels"
mode="enable_all"
if len(args) > 1: if len(args) > 1:
channel = args[1] channel = args[1]
mode="" query = {'cmd': 'addchannels'}
if subcmd == 'enablechannels' or subcmd == 'enablechannel': if subcmd in ('enablechannels', 'enablechannel'):
command = "enablechannel" query['cmd'] = 'enablechannel'
if channel == None: if channel is None:
command = "modifychannels" query['cmd'] = 'modifychannels'
mode="enable_all" query['enable_all'] = '1'
else: else:
if opts.enable_all and opts.skip_disabled: if opts.enable_all and opts.skip_disabled:
sys.exit('--enable-all and --skip-disabled option are exclusive') raise oscerr.WrongOptions('--enable-all and --skip-disabled options are mutually exclusive')
elif opts.enable_all: elif opts.enable_all:
mode+="&enable_all=1" query['enable_all'] = '1'
elif opts.skip_disabled: elif opts.skip_disabled:
mode+="&skip_disabled=1" query['skip_disabled'] = '1'
print("Looking for channels...") print("Looking for channels...")
query = 'cmd=' + command + mode
url = makeurl(apiurl, ['source', project], query=query) url = makeurl(apiurl, ['source', project], query=query)
if channel: if channel:
url = makeurl(apiurl, ['source', project, channel], query=query) url = makeurl(apiurl, ['source', project, channel], query=query)