本文整理汇总了Python中osc2.oscargs.OscArgs.resolve方法的典型用法代码示例。如果您正苦于以下问题:Python OscArgs.resolve方法的具体用法?Python OscArgs.resolve怎么用?Python OscArgs.resolve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osc2.oscargs.OscArgs
的用法示例。
在下文中一共展示了OscArgs.resolve方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test12
# 需要导入模块: from osc2.oscargs import OscArgs [as 别名]
# 或者: from osc2.oscargs.OscArgs import resolve [as 别名]
def test12(self):
"""test project package with wc (package optional)"""
oargs = OscArgs('api://project/package?',
path=self.fixture_file('package'))
args = 'obs://openSUSE:Factory/osc'
info = oargs.resolve(args)
self.assertEqual(info.apiurl, 'obs')
self.assertEqual(info.project, 'openSUSE:Factory')
self.assertEqual(info.package, 'osc')
# empty args
args = ''
info = oargs.resolve(args)
self.assertEqual(info.apiurl, 'https://localhost')
self.assertEqual(info.project, 'foobar')
self.assertEqual(info.package, 'package')
# leave out package
args = 'obs://openSUSE:Factory'
info = oargs.resolve(args)
self.assertEqual(info.apiurl, 'obs')
self.assertEqual(info.project, 'openSUSE:Factory')
self.assertFalse(hasattr(info, 'package'))
# error (project wc)
# disable this behaviour for now (needs further thinking)
# path = self.fixture_file('project')
# self.assertRaises(ValueError, oargs.resolve, '', path=path)
info = oargs.resolve(args)
self.assertEqual(info.apiurl, 'obs')
self.assertEqual(info.project, 'openSUSE:Factory')
self.assertFalse(hasattr(info, 'package'))
示例2: test_alternative3
# 需要导入模块: from osc2.oscargs import OscArgs [as 别名]
# 或者: from osc2.oscargs.OscArgs import resolve [as 别名]
def test_alternative3(self):
"""test multiple alternatives"""
# actually, no clash occurs, but having clash support
# enabled might catch some (unexpected) glitches
oargs = OscArgs('api://project/package|repo/arch|repo',
ignore_clashes=False)
# match first alternative
args = 'obs://foo/bar'
info = oargs.resolve(args)
self.assertEqual(info.apiurl, 'obs')
self.assertEqual(info.project, 'foo')
self.assertEqual(info.package, 'bar')
self.assertFalse(hasattr(info, 'repo'))
self.assertFalse(hasattr(info, 'arch'))
# match second alternative
args = 'openSUSE_Factory/x86_64'
info = oargs.resolve(args)
self.assertEqual(info.repo, 'openSUSE_Factory')
self.assertEqual(info.arch, 'x86_64')
self.assertFalse(hasattr(info, 'apiurl'))
self.assertFalse(hasattr(info, 'project'))
self.assertFalse(hasattr(info, 'package'))
# match third alternative
args = 'openSUSE_Factory'
info = oargs.resolve(args)
self.assertEqual(info.repo, 'openSUSE_Factory')
self.assertFalse(hasattr(info, 'apiurl'))
self.assertFalse(hasattr(info, 'project'))
self.assertFalse(hasattr(info, 'package'))
self.assertFalse(hasattr(info, 'arch'))
示例3: test3
# 需要导入模块: from osc2.oscargs import OscArgs [as 别名]
# 或者: from osc2.oscargs.OscArgs import resolve [as 别名]
def test3(self):
"""test multiple optional args"""
oargs = OscArgs('api://project?/package?')
args = 'http://localhost://'
info = oargs.resolve(args)
self.assertEqual(info.apiurl, 'http://localhost')
self.assertFalse(hasattr(info, 'project'))
self.assertFalse(hasattr(info, 'package'))
# api://project
args = 'http://localhost://foobar'
info = oargs.resolve(args)
self.assertEqual(info.apiurl, 'http://localhost')
self.assertEqual(info.project, 'foobar')
self.assertFalse(hasattr(info, 'package'))
# api://project/package
args = 'http://localhost://foobar/somepkg'
info = oargs.resolve(args)
self.assertEqual(info.apiurl, 'http://localhost')
self.assertEqual(info.project, 'foobar')
self.assertEqual(info.package, 'somepkg')
# leave out project and package (pathological case)
args = 'http://localhost:///'
info = oargs.resolve(args)
self.assertEqual(info.apiurl, 'http://localhost')
self.assertFalse(hasattr(info, 'project'))
self.assertFalse(hasattr(info, 'package'))
# error
self.assertRaises(ValueError, oargs.resolve, 'foo')
# error: leave out project and package but append '/'
self.assertRaises(ValueError, oargs.resolve, 'http://localhost:////')
示例4: test7
# 需要导入模块: from osc2.oscargs import OscArgs [as 别名]
# 或者: from osc2.oscargs.OscArgs import resolve [as 别名]
def test7(self):
"""test > 2 components (optional)"""
oargs = OscArgs('foo?/bar?/baz')
args = 'a/b/c'
info = oargs.resolve(args)
self.assertEqual(info.foo, 'a')
self.assertEqual(info.bar, 'b')
self.assertEqual(info.baz, 'c')
# leave out foo
args = '/b/c'
info = oargs.resolve(args)
self.assertFalse(hasattr(info, 'foo'))
self.assertEqual(info.bar, 'b')
self.assertEqual(info.baz, 'c')
# leave out foo and bar
args = '//c'
info = oargs.resolve(args)
self.assertFalse(hasattr(info, 'foo'))
self.assertFalse(hasattr(info, 'bar'))
self.assertEqual(info.baz, 'c')
# leave out bar only
args = 'a//c'
info = oargs.resolve(args)
self.assertEqual(info.foo, 'a')
self.assertFalse(hasattr(info, 'bar'))
self.assertEqual(info.baz, 'c')
# error
self.assertRaises(ValueError, oargs.resolve, '/a/b/c')
self.assertRaises(ValueError, oargs.resolve, 'c')
示例5: test13
# 需要导入模块: from osc2.oscargs import OscArgs [as 别名]
# 或者: from osc2.oscargs.OscArgs import resolve [as 别名]
def test13(self):
"""test project with wc and multiple entries"""
path = self.fixture_file('project')
oargs = OscArgs('api://project?', 'api(tgt)://tgt_project', path=path)
args = ('obs://foo', 'local://bar')
info = oargs.resolve(*args)
self.assertEqual(info.apiurl, 'obs')
self.assertEqual(info.project, 'foo')
self.assertEqual(info.tgt_apiurl, 'local')
self.assertEqual(info.tgt_project, 'bar')
# leave out project
args = ('obs://', 'local://bar')
info = oargs.resolve(*args)
self.assertEqual(info.apiurl, 'obs')
self.assertFalse(hasattr(info, 'project'))
self.assertEqual(info.tgt_apiurl, 'local')
self.assertEqual(info.tgt_project, 'bar')
# read apiurl+project from project wc
args = ('', 'local://bar')
info = oargs.resolve(*args)
self.assertEqual(info.apiurl, 'http://localhost')
self.assertEqual(info.project, 'project')
self.assertEqual(info.tgt_apiurl, 'local')
self.assertEqual(info.tgt_project, 'bar')
# error: use package wc
path = self.fixture_file('package')
self.assertRaises(ValueError, oargs.resolve, 'local://bar', path=path)
# error: '' do not match second entry
self.assertRaises(ValueError, oargs.resolve, '', '')
示例6: test5
# 需要导入模块: from osc2.oscargs import OscArgs [as 别名]
# 或者: from osc2.oscargs.OscArgs import resolve [as 别名]
def test5(self):
"""no api"""
oargs = OscArgs('repository?/arch?')
args = 'repo/arch'
info = oargs.resolve(args)
self.assertEqual(info.repository, 'repo')
self.assertEqual(info.arch, 'arch')
# no arch
args = 'repo'
info = oargs.resolve(args)
self.assertEqual(info.repository, 'repo')
self.assertFalse(hasattr(info, 'arch'))
# no arch but with trailing slash
args = 'repo/'
info = oargs.resolve(args)
self.assertEqual(info.repository, 'repo')
self.assertFalse(hasattr(info, 'arch'))
# no repo but arch
args = '/x86_64'
info = oargs.resolve(args)
self.assertFalse(hasattr(info, 'repository'))
self.assertEqual(info.arch, 'x86_64')
# no repo and no arch
args = ''
info = oargs.resolve(args)
self.assertFalse(hasattr(info, 'repository'))
self.assertFalse(hasattr(info, 'arch'))
# error trailing slash
self.assertRaises(ValueError, oargs.resolve, '/i586/')
示例7: test_alternative4
# 需要导入模块: from osc2.oscargs import OscArgs [as 别名]
# 或者: from osc2.oscargs.OscArgs import resolve [as 别名]
def test_alternative4(self):
"""test ambiguous alternatives (first match (left to right) wins)"""
oargs = OscArgs('repo/arch?|repository')
# specify repo/arch
args = 'openSUSE_Factory/x86_64'
info = oargs.resolve(args)
self.assertEqual(info.repo, 'openSUSE_Factory')
self.assertEqual(info.arch, 'x86_64')
self.assertFalse(hasattr(info, 'repository'))
# specify repo only (first match (from left to right wins))
args = 'openSUSE_Factory'
info = oargs.resolve(args)
self.assertEqual(info.repo, 'openSUSE_Factory')
self.assertFalse(hasattr(info, 'arch'))
self.assertFalse(hasattr(info, 'repository'))
示例8: test_alternative5
# 需要导入模块: from osc2.oscargs import OscArgs [as 别名]
# 或者: from osc2.oscargs.OscArgs import resolve [as 别名]
def test_alternative5(self):
"""test ambiguous alternatives (see previous testcase)"""
oargs = OscArgs('repository|repo/arch?')
# specify repo only
args = 'openSUSE_Factory'
info = oargs.resolve(args)
self.assertEqual(info.repository, 'openSUSE_Factory')
self.assertFalse(hasattr(info, 'repo'))
self.assertFalse(hasattr(info, 'arch'))
# specify repo/arch
args = 'openSUSE_Factory/x86_64'
info = oargs.resolve(args)
self.assertEqual(info.repo, 'openSUSE_Factory')
self.assertEqual(info.arch, 'x86_64')
self.assertFalse(hasattr(info, 'repository'))
示例9: test26
# 需要导入模块: from osc2.oscargs import OscArgs [as 别名]
# 或者: from osc2.oscargs.OscArgs import resolve [as 别名]
def test26(self):
"""test wc path entry (cwd: package - filename)"""
oargs = OscArgs('wc_path')
path = self.fixture_file('prj1', 'added')
cwd = os.getcwd()
args = 'foo'
try:
os.chdir(path)
info = oargs.resolve(args)
project_path = self.fixture_file('prj1')
self.assertEqual(info.path.project, 'prj1')
self.assertEqual(info.path.project_path, project_path)
self.assertEqual(info.path.package, 'added')
self.assertEqual(info.path.package_path, path)
self.assertEqual(info.path.filename, 'foo')
self.assertEqual(info.path.filename_path, args)
# get objects
prj = info.path.project_obj()
self.assertIsNotNone(prj)
self.assertEqual(prj.apiurl, 'http://apiurl')
pkg = info.path.package_obj()
self.assertIsNotNone(pkg)
self.assertEqual(pkg.name, 'added')
finally:
os.chdir(cwd)
示例10: test18
# 需要导入模块: from osc2.oscargs import OscArgs [as 别名]
# 或者: from osc2.oscargs.OscArgs import resolve [as 别名]
def test18(self):
"""test @ separator (optional)"""
oargs = OscArgs('api://project/[email protected]?')
args = 'api://prj/pkg'
info = oargs.resolve(args)
self.assertEqual(info.apiurl, 'api')
self.assertEqual(info.project, 'prj')
self.assertEqual(info.package, 'pkg')
self.assertFalse(hasattr(info, 'rev'))
# this time with rev
args = 'api://prj/[email protected]'
info = oargs.resolve(args)
self.assertEqual(info.apiurl, 'api')
self.assertEqual(info.project, 'prj')
self.assertEqual(info.package, 'pkg')
self.assertEqual(info.rev, '123')
示例11: test33
# 需要导入模块: from osc2.oscargs import OscArgs [as 别名]
# 或者: from osc2.oscargs.OscArgs import resolve [as 别名]
def test33(self):
"""test combination with a component entry"""
oargs = OscArgs('api://project', 'plain_foo')
args = ('api://foo', 'api://bar/x')
info = oargs.resolve(*args)
self.assertEqual(info.apiurl, 'api')
self.assertEqual(info.project, 'foo')
self.assertEqual(info.foo, 'api://bar/x')
示例12: test10
# 需要导入模块: from osc2.oscargs import OscArgs [as 别名]
# 或者: from osc2.oscargs.OscArgs import resolve [as 别名]
def test10(self):
"""test project with project and package wc"""
oargs = OscArgs('api://project', path=self.fixture_file('project'))
args = 'obs://openSUSE:Factory'
info = oargs.resolve(args)
self.assertEqual(info.apiurl, 'obs')
self.assertEqual(info.project, 'openSUSE:Factory')
# empty args
args = ''
info = oargs.resolve(args)
self.assertEqual(info.apiurl, 'http://localhost')
self.assertEqual(info.project, 'project')
# error (package wc)
path = self.fixture_file('package')
self.assertRaises(ValueError, oargs.resolve, '', path=path)
# error
self.assertRaises(ValueError, oargs.resolve, 'obs://')
示例13: test_alternative1
# 需要导入模块: from osc2.oscargs import OscArgs [as 别名]
# 或者: from osc2.oscargs.OscArgs import resolve [as 别名]
def test_alternative1(self):
"""test a simple alternative"""
oargs = OscArgs('api://project|repo', ignore_clashes=False)
args = 'api://abc'
info = oargs.resolve(args)
self.assertEqual(info.apiurl, 'api')
self.assertEqual(info.project, 'abc')
self.assertFalse(hasattr(info, 'repo'))
示例14: test_alternative2
# 需要导入模块: from osc2.oscargs import OscArgs [as 别名]
# 或者: from osc2.oscargs.OscArgs import resolve [as 别名]
def test_alternative2(self):
"""test a simple alternative (alternative matches)"""
oargs = OscArgs('api://project|repo')
args = 'openSUSE_Factory'
info = oargs.resolve(args)
self.assertEqual(info.repo, 'openSUSE_Factory')
self.assertFalse(hasattr(info, 'apiurl'))
self.assertFalse(hasattr(info, 'project'))
示例15: test14
# 需要导入模块: from osc2.oscargs import OscArgs [as 别名]
# 或者: from osc2.oscargs.OscArgs import resolve [as 别名]
def test14(self):
"""test name clashes/wrong usage (ignore name clashes)"""
path = self.fixture_file('project')
oargs = OscArgs('api://project?', 'api://project/tgt_package',
path=path)
args = ('obs://openSUSE:Factory', 'local://prj/pkg')
info = oargs.resolve(*args)
self.assertEqual(info.apiurl, 'local')
self.assertEqual(info.project, 'prj')
self.assertEqual(info.tgt_package, 'pkg')
# empty args - 2nd entry has a project component
# so its also resolved via the project wc
args = ('', '')
info = oargs.resolve(*args)
self.assertEqual(info.apiurl, 'http://localhost')
self.assertEqual(info.project, 'project')
self.assertFalse(hasattr(info, 'package'))