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


Python Index.get方法代码示例

本文整理汇总了Python中curdling.index.Index.get方法的典型用法代码示例。如果您正苦于以下问题:Python Index.get方法的具体用法?Python Index.get怎么用?Python Index.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在curdling.index.Index的用法示例。


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

示例1: test_curd_package

# 需要导入模块: from curdling.index import Index [as 别名]
# 或者: from curdling.index.Index import get [as 别名]
def test_curd_package():
    "It should possible to convert regular packages to wheels"

    # Given that I have a storage containing a package
    index = Index(FIXTURE('storage1'))
    index.scan()

    # And a curdling using that index
    curdling = Curdler(**{'index': index})

    # When I request a curd to be created
    package = curdling.handle('main', {
        'tarball': index.get('gherkin==0.1.0;~whl'),
        'requirement': 'gherkin (0.1.0)',
    })

    # Then I see it's a wheel package.
    package['wheel'].should.match(
        FIXTURE('storage1/gherkin-0.1.0-py\d{2}-none-any.whl'))

    # And that it's present in the index
    package = index.get('gherkin==0.1.0;whl')

    # And that the file was created in the file system
    os.path.exists(package).should.be.true

    # And I delete the file
    os.unlink(package)
开发者ID:harobed,项目名称:curdling,代码行数:30,代码来源:test_main.py

示例2: test_curd_package

# 需要导入模块: from curdling.index import Index [as 别名]
# 或者: from curdling.index.Index import get [as 别名]
def test_curd_package():
    "It should possible to convert regular packages to wheels"

    # Given that I have a storage containing a package
    index = Index(FIXTURE('storage1'))
    index.scan()

    # And a curdling using that index
    curdling = Curdling(index=index)

    # When I request a curd to be created
    package = curdling.wheel('gherkin==0.1.0', ('main', {
        'path': index.get('gherkin==0.1.0;~whl')}))

    # Then I see it's a wheel package.
    package.should.equal({
        'path': FIXTURE('storage1/gherkin-0.1.0-py27-none-any.whl'),
    })

    # And that it's present in the index
    package = index.get('gherkin==0.1.0;whl')

    # And that the file was created in the file system
    os.path.exists(package).should.be.true

    # And I delete the file
    os.unlink(package)
开发者ID:pombredanne,项目名称:curdling,代码行数:29,代码来源:test_main.py

示例3: test_index_get_corner_case_pkg_name

# 需要导入模块: from curdling.index import Index [as 别名]
# 或者: from curdling.index.Index import get [as 别名]
def test_index_get_corner_case_pkg_name():
    "It should be possible to search for packages that contain `_` in their name"

    # Given that I have an index loaded with a couple package references
    index = Index("")
    index.storage = {"python-gherkin": {"0.1.0": ["python_gherkin-0.1.0.tar.gz"]}}

    index.get("python-gherkin==0.1.0;~whl").should.equal("python_gherkin-0.1.0.tar.gz")
开发者ID:MicahChambers,项目名称:curdling,代码行数:10,代码来源:test_index.py

示例4: test_index_scan

# 需要导入模块: from curdling.index import Index [as 别名]
# 或者: from curdling.index.Index import get [as 别名]
def test_index_scan():
    "It should be possible to scan for already existing folders"

    # Given that I have an index that points to a folder that already contains
    # packages
    index = Index(FIXTURE('storage1'))

    # When I scan the directory
    index.scan()

    # Then I can look for packages
    index.get('gherkin==0.1.0').should.equal(
        FIXTURE('storage1/gherkin-0.1.0.tar.gz'),
    )
开发者ID:pombredanne,项目名称:curdling,代码行数:16,代码来源:test_index.py

示例5: test_index_get_corner_case_pkg_name

# 需要导入模块: from curdling.index import Index [as 别名]
# 或者: from curdling.index.Index import get [as 别名]
def test_index_get_corner_case_pkg_name():
    "It should be possible to search for packages that contain `_` in their name"

    # Given that I have an index loaded with a couple package references
    index = Index('')
    index.storage = {
        'python-gherkin': {
            '0.1.0': [
                'python_gherkin-0.1.0.tar.gz',
            ]
        }
     }

    index.get('python-gherkin==0.1.0;~whl').should.equal('python_gherkin-0.1.0.tar.gz')
开发者ID:douglas,项目名称:curdling,代码行数:16,代码来源:test_index.py

示例6: test_downloader

# 需要导入模块: from curdling.index import Index [as 别名]
# 或者: from curdling.index.Index import get [as 别名]
def test_downloader():
    "It should be possible to download packages from pip repos"

    # Given the following downloader component
    sources = [PipSource(urls=['http://localhost:8000/simple'])]
    index = Index(FIXTURE('tmpindex'))
    downloader = DownloadManager(sources=sources, index=index)

    # When I try to retrieve a package from it
    package = downloader.retrieve('gherkin==0.1.0', 'main')

    # Then I see that the package was downloaded correctly to the storage
    index.get('gherkin==0.1.0').should_not.be.empty

    # And I cleanup the mess
    index.delete()
开发者ID:pombredanne,项目名称:curdling,代码行数:18,代码来源:test_main.py

示例7: test_index_from_data

# 需要导入模块: from curdling.index import Index [as 别名]
# 或者: from curdling.index.Index import get [as 别名]
def test_index_from_data():
    "It should be possible to index data from memory"

    # Given the following index
    index = Index(FIXTURE('index'))

    # When I index a file
    data = open(FIXTURE('storage1/gherkin-0.1.0.tar.gz'), 'rb').read()
    index.from_data(path='gherkin-0.1.0.tar.gz', data=data)

    # Then I see it inside of the index
    index.get('gherkin==0.1.0').should.equal(
        FIXTURE('index/gherkin-0.1.0.tar.gz'),
    )

    # And I clean the mess
    index.delete()
开发者ID:pombredanne,项目名称:curdling,代码行数:19,代码来源:test_index.py

示例8: test_index_from_file

# 需要导入模块: from curdling.index import Index [as 别名]
# 或者: from curdling.index.Index import get [as 别名]
def test_index_from_file():
    "It should be possible to index packages from files"

    # Given the following index
    index = Index(FIXTURE('index'))

    # When I index a file
    index.from_file(FIXTURE('storage1/gherkin-0.1.0.tar.gz'))

    # Then I see it inside of the index
    index.get('gherkin==0.1.0;gz').should.equal(
        FIXTURE('index/gherkin-0.1.0.tar.gz'),
    )

    # And that there's no wheel available yet
    index.get.when.called_with('gherkin==0.1.0;whl').should.throw(
        PackageNotFound,
    )

    # And I clean the mess
    index.delete()
开发者ID:pombredanne,项目名称:curdling,代码行数:23,代码来源:test_index.py

示例9: test_downloader

# 需要导入模块: from curdling.index import Index [as 别名]
# 或者: from curdling.index.Index import get [as 别名]
def test_downloader():
    "It should be possible to download packages from pip repos"

    # Given that I have a finder pointing to our local pypi server
    finder = Finder(**{"conf": {"pypi_urls": ["http://localhost:8000/simple"]}})

    # And a downloader pointing to a temporary index
    index = Index(FIXTURE("tmpindex"))
    downloader = Downloader(**{"index": index})

    # When I find the link
    link = finder.handle("tests", {"requirement": "gherkin (== 0.1.0)"})

    # And When I try to retrieve a package from it
    downloader.handle("main", link)

    # Then I see that the package was downloaded correctly to the storage
    index.get("gherkin==0.1.0").should_not.be.empty

    # And I cleanup the mess
    index.delete()
开发者ID:qrees,项目名称:curdling,代码行数:23,代码来源:test_main.py

示例10: test_downloader

# 需要导入模块: from curdling.index import Index [as 别名]
# 或者: from curdling.index.Index import get [as 别名]
def test_downloader():
    "It should be possible to download packages from pip repos"

    # Given that I have a finder pointing to our local pypi server
    finder = Finder(**{
        'conf': {'pypi_urls': ['http://localhost:8000/simple']},
    })

    # And a downloader pointing to a temporary index
    index = Index(FIXTURE('tmpindex'))
    downloader = Downloader(**{'index': index})

    # When I find the link
    link = finder.handle('tests', {'requirement': 'gherkin (== 0.1.0)'})

    # And When I try to retrieve a package from it
    downloader.handle('main', link)

    # Then I see that the package was downloaded correctly to the storage
    index.get('gherkin==0.1.0').should_not.be.empty

    # And I cleanup the mess
    index.delete()
开发者ID:harobed,项目名称:curdling,代码行数:25,代码来源:test_main.py

示例11: test_install_package

# 需要导入模块: from curdling.index import Index [as 别名]
# 或者: from curdling.index.Index import get [as 别名]
def test_install_package():
    "It should possible to install wheels"

    # Given that I have an installer configured with a loaded index
    index = Index(FIXTURE("storage2"))
    index.scan()
    installer = Installer(**{"index": index})

    # When I request a curd to be created
    installer.handle("main", {"requirement": "gherkin==0.1.0", "wheel": index.get("gherkin==0.1.0;whl")})

    # Then I see that the package was installed
    Database.check_installed("gherkin==0.1.0").should.be.true

    # And I uninstall the package
    Database.uninstall("gherkin==0.1.0")
开发者ID:qrees,项目名称:curdling,代码行数:18,代码来源:test_main.py

示例12: test_install_package

# 需要导入模块: from curdling.index import Index [as 别名]
# 或者: from curdling.index.Index import get [as 别名]
def test_install_package():
    "It should possible to install wheels"

    # Given that I have an installer configured with a loaded index
    index = Index(FIXTURE('storage2'))
    index.scan()
    installer = Installer(index=index)

    # When I request a curd to be created
    installer.install('gherkin==0.1.0', ('main', {
        'path': index.get('gherkin==0.1.0;whl')}))

    # Then I see that the package was installed
    Env({}).check_installed('gherkin==0.1.0').should.be.true

    # And I uninstall the package
    Env({}).uninstall('gherkin==0.1.0')
开发者ID:pombredanne,项目名称:curdling,代码行数:19,代码来源:test_main.py

示例13: test_install_package

# 需要导入模块: from curdling.index import Index [as 别名]
# 或者: from curdling.index.Index import get [as 别名]
def test_install_package():
    "It should possible to install wheels"

    # Given that I have an installer configured with a loaded index
    index = Index(FIXTURE('storage2'))
    index.scan()
    installer = Installer(**{'index': index})

    # When I request a curd to be created
    installer.handle('main', {
        'requirement': 'gherkin==0.1.0',
        'wheel': index.get('gherkin==0.1.0;whl'),
    })

    # Then I see that the package was installed
    Database.check_installed('gherkin==0.1.0').should.be.true

    # And I uninstall the package
    Database.uninstall('gherkin==0.1.0')
开发者ID:harobed,项目名称:curdling,代码行数:21,代码来源:test_main.py

示例14: test_index_get

# 需要导入模块: from curdling.index import Index [as 别名]
# 或者: from curdling.index.Index import get [as 别名]
def test_index_get():
    "It should be possible to search for packages using different criterias"

    # Given that I have an index loaded with a couple package references
    index = Index('')
    index.storage = {
        'gherkin': {
            '0.2.0': [
                'gherkin-0.2.0.tar.gz',
            ],
            '0.1.5': [
                'gherkin-0.2.0.tar.gz',
            ],
            '0.1.1': [
                'gherkin-0.1.1.tar.gz',
            ],
            '0.1.0': [
                'gherkin-0.1.0.tar.gz',
                'gherkin-0.1.0-py27-none-any.whl',
            ],
        }
    }

    # Let's do some random assertions

    # No version: Always brings the newest
    index.get('gherkin').should.equal('gherkin-0.2.0.tar.gz')

    # With a range of versions: Always brings the newest
    index.get('gherkin>0.1.0').should.equal('gherkin-0.2.0.tar.gz')

    # With a handful of version specs: Find the matching version and prefer whl
    index.get('gherkin>=0.1.0,<0.1.5,!=0.1.1').should.equal('gherkin-0.1.0-py27-none-any.whl')

    # With version: Always prefers the wheel
    index.get('gherkin==0.1.0,<=0.2.0').should.equal('gherkin-0.1.0-py27-none-any.whl')

    # With version and format: Prefers anything but `whl'
    index.get('gherkin==0.1.0;~whl').should.equal('gherkin-0.1.0.tar.gz')

    # With version range and no format: Finds the highest version with the :)
    index.get.when.called_with('gherkin==0.1.1;whl').should.throw(
        PackageNotFound, (
            "The index does not have the requested package: "
            "gherkin==0.1.1 (whl)"))

    # With version and a format that is not available: Blows up! :)
    index.get.when.called_with('gherkin==0.1.1;whl').should.throw(
        PackageNotFound, (
            "The index does not have the requested package: "
            "gherkin==0.1.1 (whl)"))

    # With a version we simply don't have: Blows up! :)
    index.get.when.called_with('gherkin==0.2.1').should.throw(
        PackageNotFound, (
            "The index does not have the requested package: "
            "gherkin==0.2.1"))

    # With a package we simply don't have: Blows up! :)
    index.get.when.called_with('nonexisting==0.2.1').should.throw(
        PackageNotFound, (
            "The index does not have the requested package: "
            "nonexisting==0.2.1"))
开发者ID:pombredanne,项目名称:curdling,代码行数:65,代码来源:test_main.py

示例15: test_index_get

# 需要导入模块: from curdling.index import Index [as 别名]
# 或者: from curdling.index.Index import get [as 别名]
def test_index_get():
    "It should be possible to search for packages using different criterias"

    # Given that I have an index loaded with a couple package references
    index = Index("")
    index.storage = {
        "gherkin": {
            "0.2.0": ["gherkin-0.2.0.tar.gz"],
            "0.1.5": ["gherkin-0.2.0.tar.gz"],
            "0.1.1": ["gherkin-0.1.1.tar.gz"],
            "0.1.0": ["gherkin-0.1.0.tar.gz", "gherkin-0.1.0-py27-none-any.whl"],
        }
    }

    # Let's do some random assertions

    # No version: Always brings the newest
    index.get("gherkin").should.equal("gherkin-0.2.0.tar.gz")

    # With a range of versions: Always brings the newest
    index.get("gherkin (> 0.1.0)").should.equal("gherkin-0.2.0.tar.gz")

    # With a handful of version specs: Find the matching version and prefer whl
    index.get("gherkin (>= 0.1.0, < 0.1.5, != 0.1.1)").should.equal("gherkin-0.1.0-py27-none-any.whl")

    # With version: Always prefers the wheel
    index.get("gherkin (== 0.1.0, <= 0.2.0)").should.equal("gherkin-0.1.0-py27-none-any.whl")

    # With version and format: Prefers anything but `whl'
    index.get("gherkin (== 0.1.0);~whl").should.equal("gherkin-0.1.0.tar.gz")

    # With version range and no format: Finds the highest version with the :)
    index.get.when.called_with("gherkin (== 0.1.1);whl").should.throw(
        PackageNotFound, ("The index does not have the requested package: " "gherkin (0.1.1) (whl)")
    )

    # With version and a format that is not available: Blows up! :)
    index.get.when.called_with("gherkin (== 0.1.1);whl").should.throw(
        PackageNotFound, ("The index does not have the requested package: " "gherkin (0.1.1) (whl)")
    )

    # With a version we simply don't have: Blows up! :)
    index.get.when.called_with("gherkin (== 0.2.1)").should.throw(
        PackageNotFound, ("The index does not have the requested package: " "gherkin (0.2.1)")
    )

    # With a package we simply don't have: Blows up! :)
    index.get.when.called_with("nonexisting (== 0.2.1)").should.throw(
        PackageNotFound, ("The index does not have the requested package: " "nonexisting (0.2.1)")
    )

    # Case insensitive
    index.get("Gherkin").should.equal("gherkin-0.2.0.tar.gz")
开发者ID:MicahChambers,项目名称:curdling,代码行数:55,代码来源:test_index.py


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