元素树的点符号;

objectifiedetree的Python项目详细描述


build-status-imagepypi-versionwheel

概述

对元素树使用点符号不是很好吗?这个包裹 允许:

tree=ET.fromstring('<root><a><b c="asdf" /></a></root>')a=tree.ab=a.bb.attrib['c']=="asdf"# True

tree.a将是 `Element<;https://docs.python.org/3.4/library/xml.etree.elementtree.html#xml.etree.ElementTree.Element>;。`_ 加上额外的 `__getattr__<;https://github.com/arve0/objectifiedetree/blob/master/objectifiedetree/__init__.py#L11-12>;。`_ 方法。这意味着您可以像使用 通常,但是xml中的名称会与python的方法或 必须通过tree.find(xpath)访问属性。

这个包使用了etree的python实现,这使得它 比在cpython中找到的etree慢。另一个选择是 猴子用补丁修补内置的 forbiddenfruit,但是我 还没调查过。

objectifiedetree已从复制了etree的python实现 CPython 3.4 Lib/xml/etree 可能只适用于Python3.4。

安装

使用pip

安装
pip install objectifiedetree

示例

fromobjectifiedetreeimport*tree=ET.parse('/path/to/file.xml')# dot notation :-)el=tree.xpath.to.your.element# use normal etree attributesprint(el.attrib)# access name crashesattrib_el=el.find('./attrib')

开发

安装依赖项并将objectifiedtree的开发版本链接到 管道:

git clone https://github.com/arve0/objectifiedetree
cd objectifiedetree
pip install -r requirements.txt # install dependencies and objectifiedetree-package

测试

tox

在本地生成文档

构建文档:

pip install -r docs/requirements.txt
make docs

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

推荐PyPI第三方库


热门话题
java SimpleFramework和工厂方法   Java适当地处理异常   java单例类不起作用   java小程序和Swing在eclipse中不显示组件   多个键上的java Redisson FastRemove不起作用   java验证请求正文不等于模式   在Java中从URL读取数据   eche RecyclerView项的java Set自定义字体   string Java如何从Date获取HH:mm:ss   当Java应用程序落后于负载均衡器时,在某些URL上强制使用SSL   使用esapi时发生java错误   java使用流根据第二个列表中的值更新一个列表中的对象   组织。openqa。硒。Java中的NoTouchElementException WebDriver?   从JSON字符串Java创建CSV文件