当前位置: 首页>>代码示例>>Python>>正文


Python oscargs.OscArgs类代码示例

本文整理汇总了Python中osc2.oscargs.OscArgs的典型用法代码示例。如果您正苦于以下问题:Python OscArgs类的具体用法?Python OscArgs怎么用?Python OscArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了OscArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test12

 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'))
开发者ID:bergmannf,项目名称:osc2,代码行数:29,代码来源:test_oscargs.py

示例2: test26

 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)
开发者ID:bergmannf,项目名称:osc2,代码行数:25,代码来源:test_oscargs.py

示例3: test13

 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, '', '')
开发者ID:bergmannf,项目名称:osc2,代码行数:29,代码来源:test_oscargs.py

示例4: test_alternative3

 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'))
开发者ID:bergmannf,项目名称:osc2,代码行数:30,代码来源:test_oscargs.py

示例5: test7

 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')
开发者ID:bergmannf,项目名称:osc2,代码行数:29,代码来源:test_oscargs.py

示例6: test3

 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:////')
开发者ID:bergmannf,项目名称:osc2,代码行数:30,代码来源:test_oscargs.py

示例7: test33

 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')
开发者ID:bergmannf,项目名称:osc2,代码行数:8,代码来源:test_oscargs.py

示例8: test_alternative1

 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'))
开发者ID:bergmannf,项目名称:osc2,代码行数:8,代码来源:test_oscargs.py

示例9: test_alternative2

 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'))
开发者ID:bergmannf,项目名称:osc2,代码行数:8,代码来源:test_oscargs.py

示例10: test35

 def test35(self):
     """specify the same oargs multiple times (solve name clashes)"""
     oargs = OscArgs('foo', 'foo', 'bar', 'foo', ignore_clashes=False)
     args = ('foo1', 'foo2', 'bar1', 'foo3')
     info = oargs.resolve(*args)
     # foo is expected multiple times => use list
     self.assertEqual(info.foo, ['foo1', 'foo2', 'foo3'])
     # bar is expected only once => no list
     self.assertEqual(info.bar, 'bar1')
开发者ID:bergmannf,项目名称:osc2,代码行数:9,代码来源:test_oscargs.py

示例11: test36

 def test36(self):
     """specify the same oargs multiple times (mix entry types)"""
     oargs = OscArgs('plain_foo', 'foo', 'api://project', 'api://project',
                     ignore_clashes=False)
     args = ('foo/bar', 'xyz', 'api://abc', 'obs://prj')
     info = oargs.resolve(*args)
     self.assertEqual(info.foo, ['foo/bar', 'xyz'])
     self.assertEqual(info.apiurl, ['api', 'obs'])
     self.assertEqual(info.project, ['abc', 'prj'])
开发者ID:bergmannf,项目名称:osc2,代码行数:9,代码来源:test_oscargs.py

示例12: test21

 def test21(self):
     """test mix between @ and / separators"""
     oargs = OscArgs('[email protected]/[email protected]')
     args = '[email protected]/[email protected]'
     info = oargs.resolve(args)
     self.assertEqual(info.foo, 'x')
     self.assertEqual(info.bar, 'y')
     self.assertEqual(info.baz, 'z')
     self.assertEqual(info.foobar, 'w')
开发者ID:bergmannf,项目名称:osc2,代码行数:9,代码来源:test_oscargs.py

示例13: test17

 def test17(self):
     """test @ separator"""
     oargs = OscArgs('api://project/[email protected]')
     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')
开发者ID:bergmannf,项目名称:osc2,代码行数:9,代码来源:test_oscargs.py

示例14: test37

 def test37(self):
     """specify the same oargs multiple times (optional args)"""
     oargs = OscArgs('repo/arch?', 'repo/arch', ignore_clashes=False)
     args = ('repo_only', 'some_repo/x86_64')
     info = oargs.resolve(*args)
     # hopefully nobody is using it this way (examining the results
     # is difficult/ambiguous - see test38 how it should be used)
     self.assertEqual(info.repo, ['repo_only', 'some_repo'])
     # arch was only specified once (by the user!) => no list
     self.assertEqual(info.arch, 'x86_64')
开发者ID:bergmannf,项目名称:osc2,代码行数:10,代码来源:test_oscargs.py

示例15: test1

 def test1(self):
     """test simple"""
     oargs = OscArgs('api://project/package')
     args = 'http://localhost://foo/bar'
     info = oargs.resolve(args)
     self.assertEqual(info.apiurl, 'http://localhost')
     self.assertEqual(info.project, 'foo')
     self.assertEqual(info.package, 'bar')
     # error
     self.assertRaises(ValueError, oargs.resolve,
                       'http://localhost://project/package/')
     self.assertRaises(ValueError, oargs.resolve,
                       'http://localhost://project/')
开发者ID:bergmannf,项目名称:osc2,代码行数:13,代码来源:test_oscargs.py


注:本文中的osc2.oscargs.OscArgs类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。