连接到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无法使用mainthread的上下文类加载器将web应用程序添加到@SpringBootApplication的内置Tomcat中   为什么Java递归调用不释放局部变量内存   java堆栈重设堆栈奇偶范围   java如何分组,然后使用java8流列出toMap   JavaEclipse在引导仪表板上展示了“安装本地云服务”如何解决这个问题?   java多个backpress跳过该活动   concat向流中添加两个Java8流或一个额外元素   java在ToolTipText上使用图标   调试java。jvisulavm中添加JMXConnection时的lang.SecurityException   java如何通过JavaFX中的单选按钮对最大可选复选框进行约束?   Spring引导上下文一直试图连接到JavaRMI服务器,但失败了   java Spring cache@cacheexecute匹配列表中的键?   java导出报告并使用JasperReports保存在某个位置   java发布构建失败   java在活动中隐藏特定视图   java定义由canvas2image生成的图像的属性,例如alt标记   java如何将POJO转换为JSON,反之亦然?