libfdisk python bindings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, recently I've started working on python bindings for libfdisk. Just
a C extension for CPython, like the libmount python bindings.

Early WIP can be found at https://github.com/pvxe/python-libfdisk/

After reading the mailing list archive and previous github issues
related to python bindings, I'm wondering if patches would be accepted,
or python bindings are preferred separate from the util-linux tree.

As of now, I'm only using these bindings to fetch label information and
partition fields using fdisk_partition_to_string. But the idea is also
being able to modify the partition table in the future.

 >>> import fdisk
 >>> cxt = fdisk.Context(device="/dev/sda")
 >>> cxt.label
 <libfdisk.Label object at 0x7f609a8e4f90, name=gpt>
 >>> l = cxt.label
 >>> l.
 l.name  l.type
 >>> l.name
 'gpt'
 >>> l.type
 32
 >>> cxt.nsectors
 3907029168
 >>> cxt.sector_size
 512
 >>> cxt.parts
 [<libfdisk.Partition object at 0x7f8f69f64fb0>,
  <libfdisk.Partition object at 0x7f8f69f64fd0>]
 >>> p = cxt.parts[1]
 >>> cxt.partition_to_string(p, fdisk.FDISK_FIELD_FSTYPE)
 'LVM2_member'


Regards,
Jose



[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux