跳转到主要内容

asyncio有什么特别之处?

项目描述

aioseinfeld

asyncio有什么特别之处?

安装

aioseinfeld需要Python 3.7或更高版本。可以从PyPI安装

$ pip install aioseinfeld

aioseinfeld还依赖于使用Colin Pollick的脚本生成的脚本数据库的副本。您可以使用这些脚本构建自己的副本,或者使用以下命令下载预构建的副本

$ wget https://noswap.com/pub/seinfeld.db

使用方法

aioseinfeld使用上下文管理器来包装底层的sqlite数据库连接。通过传递到seinfeld.db数据库的路径来创建Seinfeld对象

from aioseinfeld import Seinfeld

async with Seinfeld(db_path) as seinfeld:
    ...

获取关于单个剧集或季度的信息

async with Seinfeld(db_path) as seinfeld:
    season = await seinfeld.season(1)
    episodes = await season.episodes
    episodes[0].title  # "Good News, Bad News"
    episodes[0].writers # ["Jerry Seinfeld"]
    episodes[0].date  # date(1990, 6, 14)

可以通过唯一ID检索引语

async with Seinfeld(db_path) as seinfeld:
    quote = await seinfeld.quote(34665)
    quote.speaker.name  # "George"
    quote.episode.title  # "The Pitch"
    quote.text  # "The show is about nothing."

也可以通过搜索查找引语

async with Seinfeld(db_path) as seinfeld:
    await seinfeld.search(speaker="Jerry", subject="keys")  # [Quote(...), ...]

您甚至可以使用可选搜索参数获取随机引语

async with Seinfeld(db_path) as seinfeld:
    await seinfeld.random()  # Quote(...)
    await seinfeld.random(subject="parking")  # Quote(...)

如果您想了解关于引语的更多背景,段落很有帮助

async with Seinfeld(db_path) as seinfeld:
    quote = await seinfeld.random()
    passage = await seinfeld.passage(quote, length=5)
    passage.quotes # [Quote(...), ...]

许可证

aiomultiprocess版权所有John Reese,并许可在MIT许可证下。我在此存储库下以开源许可证向您提供代码。这是我的个人存储库;您对我代码的许可证来自我,而不是来自我的雇主。有关详细信息,请参阅LICENSE文件。

项目详细信息


下载文件

下载适用于您平台的文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。

源代码分发

aioseinfeld-0.2.0.tar.gz (8.3 kB 查看散列值)

上传时间 源代码

构建分发

aioseinfeld-0.2.0-py3-none-any.whl (8.3 kB 查看散列值)

上传时间 Python 3

支持者