1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-10 06:46:15 +01:00

unbreak osc init

This commit is contained in:
Michal Marek 2008-08-08 15:19:54 +00:00
parent 93e916eb39
commit d047b30aa8
2 changed files with 7 additions and 8 deletions

View File

@ -108,7 +108,7 @@ class Osc(cmdln.Cmdln):
return self._str(doc)
def do_init(self, subcmd, opts, project, package):
def do_init(self, subcmd, opts, project, package=None):
"""${cmd_name}: Initialize a directory as working copy
Initialize an existing directory to be a working copy of an
@ -130,14 +130,12 @@ class Osc(cmdln.Cmdln):
${cmd_option_list}
"""
if len(args) == 1:
init_project_dir(conf.config['apiurl'], os.curdir, args[0])
print 'Initializing %s (Project: %s)' % (os.curdir, args[0])
elif len(args) == 2:
init_package_dir(conf.config['apiurl'], args[0], args[1], os.path.curdir)
print 'Initializing %s (Project: %s, Package: %s)' % (os.curdir, args[0], args[1])
if not package:
init_project_dir(conf.config['apiurl'], os.curdir, project)
print 'Initializing %s (Project: %s)' % (os.curdir, project)
else:
raise oscerr.WrongArgs('Incorrect number of arguments')
init_package_dir(conf.config['apiurl'], project, package, os.path.curdir)
print 'Initializing %s (Project: %s, Package: %s)' % (os.curdir, project, package)
@cmdln.alias('ls')

View File

@ -1461,6 +1461,7 @@ def http_DELETE(*args, **kwargs): return http_request('DELETE', *args, **kwargs)
def init_project_dir(apiurl, dir, project):
if not os.path.exists(dir):
os.mkdir(dir)
if not os.path.exists(os.path.join(dir, store)):
os.mkdir(os.path.join(dir, store))
store_write_project(dir, project)