Package ClusterShell :: Module NodeSet :: Class NodeSetBase
[hide private]
[frames] | no frames]

Class NodeSetBase

source code


Base class for NodeSet.

This class allows node set base object creation from specified string pattern and rangeset object. If optional copy_rangeset boolean flag is set to True (default), provided rangeset object is copied (if needed), otherwise it may be referenced (should be seen as an ownership transfer upon creation).

This class implements core node set arithmetics (no string parsing here).

Example:

>>> nsb = NodeSetBase('node%s-ipmi', RangeSet('1-5,7'), False)
>>> str(nsb)
'node[1-5,7]-ipmi'
>>> nsb = NodeSetBase('node%s-ib%s', RangeSetND([['1-5,7', '1-2']]), False)
>>> str(nsb)
'node[1-5,7]-ib[1-2]'
Instance Methods [hide private]
 
__init__(self, pattern=None, rangeset=None, copy_rangeset=True, autostep=None, fold_axis=None)
New NodeSetBase object initializer
source code
 
get_autostep(self)
Get autostep value (property)
source code
 
set_autostep(self, val)
Set autostep value (property)
source code
 
_iter(self)
Iterator on internal item tuples (pattern, indexes, padding, autostep).
source code
 
_iterbase(self)
Iterator on single, one-item NodeSetBase objects.
source code
 
__iter__(self)
Iterator on single nodes as string.
source code
 
striter(self)
Iterator on single nodes as string.
source code
 
nsiter(self)
Object-based NodeSet iterator on single nodes.
source code
 
contiguous(self)
Object-based NodeSet iterator on contiguous node sets.
source code
 
__len__(self)
Get the number of nodes in NodeSet.
source code
 
_iter_nd_pat(self, pat, rset)
Take a pattern and a RangeSetND object and iterate over nD computed nodeset strings while following fold_axis constraints.
source code
 
__str__(self)
Get ranges-based pattern of node list.
source code
 
copy(self)
Return a shallow copy.
source code
 
__contains__(self, other)
Is node contained in NodeSet ?
source code
 
_binary_sanity_check(self, other) source code
 
issubset(self, other)
Report whether another nodeset contains this nodeset.
source code
 
issuperset(self, other)
Report whether this nodeset contains another nodeset.
source code
 
__eq__(self, other)
NodeSet equality comparison.
source code
 
__le__(self, other)
Report whether another nodeset contains this nodeset.
source code
 
__ge__(self, other)
Report whether this nodeset contains another nodeset.
source code
 
__lt__(x, y)
x<y
source code
 
__gt__(x, y)
x>y
source code
 
_extractslice(self, index)
Private utility function: extract slice parameters from slice object `index` for an list-like object of size `length`.
source code
 
__getitem__(self, index)
Return the node at specified index or a subnodeset when a slice is specified.
source code
 
_add_new(self, pat, rangeset)
Add nodes from a (pat, rangeset) tuple.
source code
 
_add(self, pat, rangeset, copy_rangeset=True)
Add nodes from a (pat, rangeset) tuple.
source code
 
union(self, other)
s.union(t) returns a new set with elements from both s and t.
source code
 
__or__(self, other)
Implements the | operator.
source code
 
add(self, other)
Add node to NodeSet.
source code
 
update(self, other)
s.update(t) returns nodeset s with elements added from t.
source code
 
updaten(self, others)
s.updaten(list) returns nodeset s with elements added from given list.
source code
 
clear(self)
Remove all nodes from this nodeset.
source code
 
__ior__(self, other)
Implements the |= operator.
source code
 
intersection(self, other)
s.intersection(t) returns a new set with elements common to s and t.
source code
 
__and__(self, other)
Implements the & operator.
source code
 
intersection_update(self, other)
``s.intersection_update(t)`` returns nodeset s keeping only elements also found in t.
source code
 
__iand__(self, other)
Implements the &= operator.
source code
 
difference(self, other)
``s.difference(t)`` returns a new NodeSet with elements in s but not in t.
source code
 
__sub__(self, other)
Implement the - operator.
source code
 
difference_update(self, other, strict=False)
``s.difference_update(t)`` removes from s all the elements found in t.
source code
 
__isub__(self, other)
Implement the -= operator.
source code
 
remove(self, elem)
Remove element elem from the nodeset.
source code
 
symmetric_difference(self, other)
``s.symmetric_difference(t)`` returns the symmetric difference of two nodesets as a new NodeSet.
source code
 
__xor__(self, other)
Implement the ^ operator.
source code
 
symmetric_difference_update(self, other)
``s.symmetric_difference_update(t)`` returns nodeset s keeping all nodes that are in exactly one of the nodesets.
source code
 
__ixor__(self, other)
Implement the ^= operator.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __subclasshook__

Instance Variables [hide private]
  fold_axis
iterable over nD 0-indexed axis
Properties [hide private]
  autostep
Get autostep value (property)

Inherited from object: __class__

Method Details [hide private]

__init__(self, pattern=None, rangeset=None, copy_rangeset=True, autostep=None, fold_axis=None)
(Constructor)

source code 

New NodeSetBase object initializer

Overrides: object.__init__

contiguous(self)

source code 

Object-based NodeSet iterator on contiguous node sets.

Contiguous node set contains nodes with same pattern name and a contiguous range of indexes, like foobar[1-100].

__str__(self)
(Informal representation operator)

source code 

Get ranges-based pattern of node list.

Overrides: object.__str__

_add_new(self, pat, rangeset)

source code 

Add nodes from a (pat, rangeset) tuple. Predicate: pattern does not exist in current set. RangeSet object is referenced (not copied).

_add(self, pat, rangeset, copy_rangeset=True)

source code 

Add nodes from a (pat, rangeset) tuple. `pat' may be an existing pattern and `rangeset' may be None. RangeSet or RangeSetND objects are copied if re-used internally when provided and if copy_rangeset flag is set.

__or__(self, other)
(Or operator)

source code 

Implements the | operator. So s | t returns a new nodeset with elements from both s and t.

__ior__(self, other)

source code 

Implements the |= operator. So ``s |= t`` returns nodeset s with elements added from t. (Python version 2.5+ required)

__and__(self, other)
(And operator)

source code 

Implements the & operator. So ``s & t`` returns a new nodeset with elements common to s and t.

__iand__(self, other)

source code 

Implements the &= operator. So ``s &= t`` returns nodeset s keeping only elements also found in t. (Python version 2.5+ required)

__sub__(self, other)
(Subtraction operator)

source code 

Implement the - operator. So ``s - t`` returns a new nodeset with elements in s but not in t.

difference_update(self, other, strict=False)

source code 

``s.difference_update(t)`` removes from s all the elements found in t.

:raises KeyError: an element cannot be removed (only if strict is
    True)

__isub__(self, other)

source code 

Implement the -= operator. So ``s -= t`` returns nodeset s after removing elements found in t. (Python version 2.5+ required)

remove(self, elem)

source code 

Remove element elem from the nodeset. Raise KeyError if elem is not contained in the nodeset.

:raises KeyError: elem is not contained in the nodeset

symmetric_difference(self, other)

source code 

``s.symmetric_difference(t)`` returns the symmetric difference of two nodesets as a new NodeSet.

(ie. all nodes that are in exactly one of the nodesets.)

__xor__(self, other)
(Exclusive-Or operator)

source code 

Implement the ^ operator. So ``s ^ t`` returns a new NodeSet with nodes that are in exactly one of the nodesets.

__ixor__(self, other)

source code 

Implement the ^= operator. So ``s ^= t`` returns nodeset s after keeping all nodes that are in exactly one of the nodesets. (Python version 2.5+ required)


Property Details [hide private]

autostep

Get autostep value (property)

Get Method:
get_autostep(self) - Get autostep value (property)
Set Method:
set_autostep(self, val) - Set autostep value (property)