flux.idset module

class flux.idset.IDset(arg='', flags=_flux._idset.lib.IDSET_FLAG_RANGE, handle=None)

Bases: WrapperPimpl

A Flux idset object

The IDset class wraps libflux-idset, and encapsulates a set of unordered non-negative integers. See idset_create(3).

A Python IDset object may be created from a valid RFC22 idset string, e.g. "0", "0-3", "0,5,7", or any Python iterable type as long as the iterable contains only non-negative integers. For example:

>>> ids = IDset("0-3")
>>> ids2 = IDset([0, 1, 2, 3])
>>> ids3 = IDset({0, 1, 2, 3})
class InnerWrapper(arg='', handle=None)

Bases: Wrapper

add(arg)

Add all ids or values in arg to IDset :param: arg: IDset, string, or iterable of integers to add

clear(start, end=None)

Clear an id or range of ids in an IDset :param: start: The first id to clear :param: end: (optional) The last id in a range to clear

Returns a copy of self so that this will work: >>> print(IDset("0-9").clear(0,3))

copy()
count()

Return the number of integers in an IDset

difference(*args)

Return the set difference of the target IDset and all args

All args will be converted to IDsets if possible, i.e. any IDset, valid idset string, or iterable composted of integers will work.

encode(flags=None)

Encode an IDset to a string. :param: flags: (optional) flags to influence encoding

equal(idset)
expand()

Expand an IDset into a list of integers

first()

Return the first id set in an IDset

intersect(*args)

Return the set intersection of the target IDset and all args

All args will be converted to IDsets if possible, i.e. any IDset, valid idset string, or iterable composed of integers will work.

last()

Return the greatest id set in an IDset

next(i)

Return the next id set in an IDset after value i

set(start, end=None)

Set an id or range of ids in an IDset :param: start: The first id to set :param: end: (optional) The last id in a range to set

Returns a copy of self so that this will work: >>> print(IDset().set(0,3))

set_flags(flags)

Set default flags for IDset encoding: valid flags are IDSET_FLAG_RANGE and IDSET_FLAG_BRACKETS

subtract(arg)

subtract all ids or values in arg from IDset :param: arg: IDset, string, or iterable of integers to subtract

test(i)

Test if an id is set in an IDset :param: i: the id to test

union(*args)

Return the union of the current IDset and all args

All args will be converted to IDsets if possible, i.e. any IDset, valid idset string, or iterable composed of integers will work.

class flux.idset.IDsetIterator(idset)

Bases: object

flux.idset.decode(string)

Decode an idset string and return IDset object