Skip to content

Commit

Permalink
- do_addchannels: cleanup and beautify
Browse files Browse the repository at this point in the history
No changes w.r.t. to semantics.
  • Loading branch information
marcus-h committed Jul 15, 2015
1 parent 8d10a3f commit 0daec6a
Showing 1 changed file with 14 additions and 20 deletions.
34 changes: 14 additions & 20 deletions osc/commandline.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,44 +462,38 @@ def do_addchannels(self, subcmd, opts, *args):
"""

apiurl = self.get_api_url()
project_dir = localdir = os.getcwd()
localdir = os.getcwd()
channel = None
command = "addchannels"
if len(args) == 0:
if not args:
if is_project_dir(localdir):
project = store_read_project(localdir)
apiurl = self.get_api_url()
elif is_package_dir(localdir):
project = store_read_project(localdir)
channel = store_read_package(localdir)
apiurl = self.get_api_url()
# XXX: error handling?
else:
project = args[0]
if subcmd == 'enablechannels' or subcmd == 'enablechannel':
command = "modifychannels"
mode="enable_all"
if len(args) > 1:
channel = args[1]
mode=""
if subcmd == 'enablechannels' or subcmd == 'enablechannel':
command = "enablechannel"
if channel == None:
command = "modifychannels"
mode="enable_all"

query = {'cmd': 'addchannels'}
if subcmd in ('enablechannels', 'enablechannel'):
query['cmd'] = 'enablechannel'
if channel is None:
query['cmd'] = 'modifychannels'
query['enable_all'] = '1'
else:
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:
mode+="&enable_all=1"
query['enable_all'] = '1'
elif opts.skip_disabled:
mode+="&skip_disabled=1"
query['skip_disabled'] = '1'

print("Looking for channels...")
query = 'cmd=' + command + mode
url = makeurl(apiurl, ['source', project], query=query)
if channel:
url = makeurl(apiurl, ['source', project, channel], query=query)
url = makeurl(apiurl, ['source', project, channel], query=query)
f = http_POST(url)

@cmdln.option('-f', '--force', action='store_true',
Expand Down

0 comments on commit 0daec6a

Please sign in to comment.