跳转到主要内容

用于连接Lizard-API的Python连接器。

项目描述

lizard-connector

警告:

Lizard API版本2将于2021年1月31日停用,请切换到默认API版本3

这可以通过在创建Client实例时不指定版本参数,或者创建指定版本3的Client实例来实现

简介

Python连接到Lizard api (例如 https://demo.lizard.net/api/v3) 的连接器。

包含:- 客户端(实验性/alpha)- 端点(轻松访问Lizard API端点)- 连接器(http处理)- 解析器,用于解析从端点查询中获得的json - 查询函数,用于特殊案例,如地理查询和时间相关查询,其他查询可以作为字典输入 - 异步数据处理的回调。

当安装了pandas和numpy时,客户端在ScientifResult对象中返回和/或`numpy.array`s。

示例用法

示例jupyter笔记本可以在Example_EN.ipynb中找到,或在荷兰语中:Voorbeeld_NL.ipynb

在Python中使用Endpoint类使用一个端点 https://demo.lizard.net/api/v3

from lizard_connector import Client
import lizard_connector.queries
import datetime

# Fill in your username and password (your password will be prompted)
client = lizard_connector.Client(
    username = "example.username"
)

endpoint = 'timeseries'
south_west = [48.0, -6.8]
north_east = [56.2, 18.9]

organisation_id = 'example_organisation_uuid'

start = datetime.datetime(1970, 1, 1)
end = datetime.datetime.now()

relevant_queries = [
    lizard_connector.queries.in_bbox(south_west, north_east, endpoint),
    lizard_connector.queries.organisation(organisation_id, endpoint),
    lizard_connector.queries.datetime_limits(start, end)
]

results = client.timeseries.get(*relevant_queries)

与PyQT的使用(用于Qgis插件)

你可以这样创建一个QThread工作线程

from PyQt4.QtCore import QThread
from PyQt4.QtCore import pyqtSignal


class Worker(QThread):
    """This class creates a worker thread for getting the data."""
    output = pyqtSignal(object)

    def __init__(self, parent=None, endpoint=None, *querydicts, **queries):
        """Initiate the Worker."""
        super(Worker, self).__init__(parent)
        self._endpoint = endpoint
        self._querydicts = querydicts
        self._queries = queries

    def run(self):
        """Called indirectly by PyQt if you call start().
        This method retrieves the data from Lizard and emits it via the
        output signal as dictionary.
        """
        data = self._endpoint._synchronous_get_async(
            *self._querydicts, **self._queries)
        self.output.emit(data)

致谢

lizard-connector的变更日志

0.7.3 (2020-12-17)

  • 从文档中删除了对v2 API的提及。

0.7.2 (2020-12-17)

  • 在v2 API中使用时添加了FutureWarnings(默认为V3)

  • 将REAMDE.md重命名为README.rst

0.7.1 (2018-04-17)

  • 尚未进行任何更改。

0.7 (2018-04-17)

  • 添加了客户端。

  • 添加了解析器(科学,json)。

  • 添加了回调。

  • 将Endpoint的< cite>download…方法重命名为< cite>get…。

0.6 (2018-02-07)

  • 添加了显式的py2/3导入,以减轻与future库的问题。

0.5 (2017-10-16)

  • 与python 2.7兼容。

  • 重构分页。

  • 添加了带有回调的异步下载。

  • 在Endpoint初始化中删除了max_result。

0.4 (2016-06-05)

  • 修复了在分页结果上迭代时的错误。

  • 当all_pages设置为False时,所有涉及get的方法都返回对象作为迭代器。

0.3 (2016-05-06)

  • 不允许http基本url,当baseurl不安全(即不以https开头)时抛出异常。

  • 修复了导致get运行两次的错误。

0.2 (2016-05-04)

  • 添加了数据类型类。

  • 将Endpoint的get和post重命名为download和upload。

0.1 (2016-03-29)

  • 基本设置

  • 添加了测试

  • 使用nensskel 1.37.dev0创建了初始项目结构。

项目详情


下载文件

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

源分布

lizard-connector-0.7.3.tar.gz (25.8 kB 查看散列)

上传

由以下支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页面