连接到octopart的python库

pyoctopart的Python项目详细描述


octopart公共rest api的简单python客户端前端。

有关详细的api文档,请参阅Octopart APIv2 documentation

这是Joe Baker工作的一个分支,而且 这个fork与python 2发行版不兼容!

你会发现这个项目的来源 https://github.com/guyzmo/pyoctopart

用法

安装

只要做:

python3 setup.py install

您可以从python repl获得它:

% python3
>>> from pyoctopart.octopart import Octopart
>>> o = Octopart.api(apikey="yourapikey")

当lib被认为足够稳定时,我将把它上传到 pipy

% pip install pyoctopart

发展

如果您只是想发展,可以这样做:

% buildout

它将下载依赖项并在 bin/

% bin/python3
>>> from pyoctopart.octopart import Octopart
>>> o = Octopart.api(apikey="yourapikey")

您可以使用以下命令运行回归测试:

% bin/test

注释

API V3转换

目前只有三种方法被切换到新的api:

parts_search()
parts_match()
parts_get()

测试需要更新。只有这些方法 用于`pyparts<;https://github.com/guyzmo/pyparts>;。`_ 不过,是项目。

方法/参数语法(用于API v3)

v3 api中的许多参数使用的语法不是 与python的语法兼容,例如include[]=datasheets。到 强制参数的类型检查并与api保持兼容 参数转换为布尔值,用 下划线,使其成为include_datasheets,因此对于Part模型 您有以下匹配项:

包括

include_short_description     → include[]=short_description
include_datasheets            → include[]=datasheets
include_compliance_documents  → include[]=compliante_documents
include_descriptions          → include[]=descriptions
include_imagesets             → include[]=imagesets
include_specs                 → include[]=specs
include_category_uids         → include[]=category_uids
include_external_links        → include[]=external_links
include_reference_designs     → include[]=reference_designs
include_cad_models            → include[]=cad_models

显示

show_uid                      → show[]=uid
show_mpn                      → show[]=mpn
show_manufacturer             → show[]=manufacturer
show_brand                    → show[]=brand
show_octopart_url             → show[]=octopart_url
show_offers                   → show[]=offers
show_broker_listings          → show[]=broker_listings
show_short_description        → show[]=short_description
show_datasheets               → show[]=datasheets
show_compliance_documents     → show[]=compliante_documents
show_descriptions             → show[]=descriptions
show_imagesets                → show[]=imagesets
show_specs                    → show[]=specs
show_category_uids            → show[]=category_uids
show_external_links           → show[]=external_links
show_reference_designs        → show[]=reference_designs
show_cad_models               → show[]=cad_models

隐藏

hide_uid                      → hide[]=uid
hide_mpn                      → hide[]=mpn
hide_manufacturer             → hide[]=manufacturer
hide_brand                    → hide[]=brand
hide_octopart_url             → hide[]=octopart_url
hide_offers                   → hide[]=offers
hide_broker_listings          → hide[]=broker_listings
hide_short_description        → hide[]=short_description
hide_datasheets               → hide[]=datasheets
hide_compliance_documents     → hide[]=compliante_documents
hide_descriptions             → hide[]=descriptions
hide_imagesets                → hide[]=imagesets
hide_specs                    → hide[]=specs
hide_category_uids            → hide[]=category_uids
hide_external_links           → hide[]=external_links
hide_reference_designs        → hide[]=reference_designs
hide_cad_models               → hide[]=cad_models

作为参考,检查include/show/hide directives sections of the manual

方法/参数语法(用于API v2)

在octopart api文档中有许多参数 名称中包含句点。当传递这些参数时 python,用下划线代替任何句点。

类似地,用下划线替换方法名中的反斜杠。

例如:

>>> o = Octopart()
>>> o.parts_get(1881614252472, optimize.hide_datasheets=True)
SyntaxError: keyword can't be an expression

Instead, pass the argument as:
>>> o.parts_get(1881614252472, optimize_hide_datasheets=True)

库将在内部执行翻译。

路线图

  • [X]切换到Python 3
  • [X]创建构建
  • [X]使用函数注释
  • [O]切换到v3 API
  • []改进和修复测试

作者

  • 由bernardGuyzmopratz提供
  • 原著作者Joe Baker

许可证

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何使用Spring和JSF向客户端授予临时权限   java除了Array/ArrayList之外,还有其他保存矩阵元素的方法吗   java BeanValidation不适用于单选按钮   通过java程序连接到配置单元数据库时出错   java如何使用maven解决二级依赖关系   JfreeChart/Java中带有图例的数据表   合并数组时发生java运行时错误   安全性如何在JavaEE中保护WebSocket端点?   java有没有一种方法可以使用insert方法为树插入值   java编程“静态”的另一种方式:代码可以吗?   java阅读文本文件时如何跳过3行   %04X在C中的含义以及如何在java中编写   java我如何验证一个方法不是仅在一个测试范围内对模拟调用的?   java如何在mac中使用启动appium desktop 1.6.1。球棒   仅匹配最多10位小数的java正则表达式