CFFI与溧阳的绑定

libyang的Python项目详细描述


python cffi绑定到libyang

pypi-projectpython-versionsbuild-statuslicense

安装

pip install libyang

您需要安装以下系统依赖项:

  • python开发标题
  • 海合会
  • cmake(构建libyang c代码)
  • lib pcre开发头(构建libyang c代码)

在debian/ubuntu系统上:

sudo apt-get install python3-dev build-essential cmake libpcre3-dev

注意

默认情况下,C库将被编译并与 python_libyang.so扩展名。

如果您的系统上已经安装了libyang.so,则 开发头),您可以通过导出 运行pip时的LIBYANG_INSTALL=system变量:

LIBYANG_INSTALL=system pip install libyang

示例

>>> importlibyang>>> ctx=libyang.Context('/usr/local/share/yang/modules')>>> module=ctx.load_module('ietf-system')>>> print(module)module: ietf-system
  +--rw system
  |  +--rw contact?          string
  |  +--rw hostname?         ietf-inet-types:domain-name
  |  +--rw location?         string
  |  +--rw clock
  |  |  +--rw (timezone)?
  |  |     +--:(timezone-utc-offset)
  |  |        +--rw timezone-utc-offset?   int16
  |  +--rw dns-resolver
  |     +--rw search*    ietf-inet-types:domain-name
  |     +--rw server* [name]
  |     |  +--rw name          string
  |     |  +--rw (transport)
  |     |     +--:(udp-and-tcp)
  |     |        +--rw udp-and-tcp
  |     |           +--rw address    ietf-inet-types:ip-address
  |     +--rw options
  |        +--rw timeout?    uint8 <5>
  |        +--rw attempts?   uint8 <2>
  +--ro system-state
     +--ro platform
     |  +--ro os-name?      string
     |  +--ro os-release?   string
     |  +--ro os-version?   string
     |  +--ro machine?      string
     +--ro clock
        +--ro current-datetime?   ietf-yang-types:date-and-time
        +--ro boot-datetime?      ietf-yang-types:date-and-time

  rpcs:
    +---x set-current-datetime
    |  +---- input
    |     +---w current-datetime    ietf-yang-types:date-and-time
    +---x system-restart
    +---x system-shutdown

>>> xpath='/ietf-system:system/ietf-system:dns-resolver/ietf-system:server'>>> dnsserver=next(ctx.find_path(xpath))>>> dnsserver<libyang.schema.List: server [name]>
>>> print(dnsserver.description())List of the DNS servers that the resolver should query.

When the resolver is invoked by a calling application, it
sends the query to the first name server in this list.  If
no response has been received within 'timeout' seconds,
the resolver continues with the next server in the list.
If no response is received from any server, the resolver
continues with the first server again.  When the resolver
has traversed the list 'attempts' times without receiving
any response, it gives up and returns an error to the
calling application.

Implementations MAY limit the number of entries in this
list.
>>> dnsserver.ordered()True
>>> fornodeindnsserver:... print(repr(node))...<libyang.schema.Leaf: name string>
<libyang.schema.Container: udp-and-tcp>

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

推荐PyPI第三方库


热门话题
java连接在一个屏幕上成功下载,在第二个屏幕上用几乎相同的代码获得错误   java调用super。超级的方法,跳过超级。方法   使用Web服务连接到sharepoint 2013的Java应用程序   java我无法正确呈现editText   httpurlconnection如何在java中检查url连接状态   java Spring Security可以为同一用户接受多个密码吗?   java如何在PreparedStatement中使用自动生成的@Id?   java每个数组表示一个位模式   java我不确定如何记录鼠标在某个区域被点击的次数   spring如何解决:java。lang.NoSuchMethodError:javax。坚持不懈实体管理器。createStoredProcedureQuery(Ljava/lang/String;)   java如何为blackberry中listfield项内的不同字段触发事件   安卓使用Proguard混淆java代码   java在grails 2中与多个数据源有一个和一个域关联。十、   java在尝试在单击按钮时返回combobox值时一直出错   java我可以在setter中使用@Resource注释而不是字段吗?   java Eclipse调试步进不工作   java比较相同对象的两个表并选择不同的表