TypedList

Typed list

class DIRAC.Core.Utilities.TypedList.BooleanList(iterable=None)

Bases: DIRAC.Core.Utilities.TypedList.TypedList

class BooleanList

A list holding only True or False items.

__init__(iterable=None)

c’tor

Parameters:
  • self – self reference
  • iterable (mixed) – initial values
allowedTypes()

allowed types getter

append(val)

append :val: to list

Parameters:
  • self – self reference
  • val (mixed) – value
count(value) → integer -- return number of occurrences of value
extend(iterable)

extend list with :iterable:

Parameters:
  • self – self referenace
  • iterable (mixed) – an interable
index(value[, start[, stop]]) → integer -- return first index of value.

Raises ValueError if the value is not present.

insert(i, val)

insert :val: at index :i:

Parameters:
  • self – self reference
  • i (int) – index
  • val (mixed) – value to set
pop([index]) → item -- remove and return item at index (default last).

Raises IndexError if list is empty or index is out of range.

remove()

L.remove(value) – remove first occurrence of value. Raises ValueError if the value is not present.

reverse()

L.reverse() – reverse IN PLACE

sort()

L.sort(cmp=None, key=None, reverse=False) – stable sort IN PLACE; cmp(x, y) -> -1, 0, 1

class DIRAC.Core.Utilities.TypedList.FloatList(iterable=None)

Bases: DIRAC.Core.Utilities.TypedList.TypedList

class FloatList

A list holding only float type items.

__init__(iterable=None)

c’tor

Parameters:
  • self – self reference
  • iterable (mixed) – initial values
allowedTypes()

allowed types getter

append(val)

append :val: to list

Parameters:
  • self – self reference
  • val (mixed) – value
count(value) → integer -- return number of occurrences of value
extend(iterable)

extend list with :iterable:

Parameters:
  • self – self referenace
  • iterable (mixed) – an interable
index(value[, start[, stop]]) → integer -- return first index of value.

Raises ValueError if the value is not present.

insert(i, val)

insert :val: at index :i:

Parameters:
  • self – self reference
  • i (int) – index
  • val (mixed) – value to set
pop([index]) → item -- remove and return item at index (default last).

Raises IndexError if list is empty or index is out of range.

remove()

L.remove(value) – remove first occurrence of value. Raises ValueError if the value is not present.

reverse()

L.reverse() – reverse IN PLACE

sort()

L.sort(cmp=None, key=None, reverse=False) – stable sort IN PLACE; cmp(x, y) -> -1, 0, 1

class DIRAC.Core.Utilities.TypedList.IntList(iterable=None)

Bases: DIRAC.Core.Utilities.TypedList.TypedList

class IntList

A list holding only int type items.

__init__(iterable=None)

c’tor

Parameters:
  • self – self reference
  • iterable (mixed) – initial values
allowedTypes()

allowed types getter

append(val)

append :val: to list

Parameters:
  • self – self reference
  • val (mixed) – value
count(value) → integer -- return number of occurrences of value
extend(iterable)

extend list with :iterable:

Parameters:
  • self – self referenace
  • iterable (mixed) – an interable
index(value[, start[, stop]]) → integer -- return first index of value.

Raises ValueError if the value is not present.

insert(i, val)

insert :val: at index :i:

Parameters:
  • self – self reference
  • i (int) – index
  • val (mixed) – value to set
pop([index]) → item -- remove and return item at index (default last).

Raises IndexError if list is empty or index is out of range.

remove()

L.remove(value) – remove first occurrence of value. Raises ValueError if the value is not present.

reverse()

L.reverse() – reverse IN PLACE

sort()

L.sort(cmp=None, key=None, reverse=False) – stable sort IN PLACE; cmp(x, y) -> -1, 0, 1

class DIRAC.Core.Utilities.TypedList.LongList(iterable=None)

Bases: DIRAC.Core.Utilities.TypedList.TypedList

class LongList

A list holding only long type items.

__init__(iterable=None)

c’tor

Parameters:
  • self – self reference
  • iterable (mixed) – initial values
allowedTypes()

allowed types getter

append(val)

append :val: to list

Parameters:
  • self – self reference
  • val (mixed) – value
count(value) → integer -- return number of occurrences of value
extend(iterable)

extend list with :iterable:

Parameters:
  • self – self referenace
  • iterable (mixed) – an interable
index(value[, start[, stop]]) → integer -- return first index of value.

Raises ValueError if the value is not present.

insert(i, val)

insert :val: at index :i:

Parameters:
  • self – self reference
  • i (int) – index
  • val (mixed) – value to set
pop([index]) → item -- remove and return item at index (default last).

Raises IndexError if list is empty or index is out of range.

remove()

L.remove(value) – remove first occurrence of value. Raises ValueError if the value is not present.

reverse()

L.reverse() – reverse IN PLACE

sort()

L.sort(cmp=None, key=None, reverse=False) – stable sort IN PLACE; cmp(x, y) -> -1, 0, 1

class DIRAC.Core.Utilities.TypedList.NumericList(iterable=None)

Bases: DIRAC.Core.Utilities.TypedList.TypedList

class NumericList

A list holding only int, long or float type items.

__init__(iterable=None)

c’tor

Parameters:
  • self – self reference
  • iterable (mixed) – initial values
allowedTypes()

allowed types getter

append(val)

append :val: to list

Parameters:
  • self – self reference
  • val (mixed) – value
count(value) → integer -- return number of occurrences of value
extend(iterable)

extend list with :iterable:

Parameters:
  • self – self referenace
  • iterable (mixed) – an interable
index(value[, start[, stop]]) → integer -- return first index of value.

Raises ValueError if the value is not present.

insert(i, val)

insert :val: at index :i:

Parameters:
  • self – self reference
  • i (int) – index
  • val (mixed) – value to set
pop([index]) → item -- remove and return item at index (default last).

Raises IndexError if list is empty or index is out of range.

remove()

L.remove(value) – remove first occurrence of value. Raises ValueError if the value is not present.

reverse()

L.reverse() – reverse IN PLACE

sort()

L.sort(cmp=None, key=None, reverse=False) – stable sort IN PLACE; cmp(x, y) -> -1, 0, 1

class DIRAC.Core.Utilities.TypedList.StrList(iterable=None)

Bases: DIRAC.Core.Utilities.TypedList.TypedList

class StrList

A list holding only str type items.

__init__(iterable=None)

c’tor

Parameters:
  • self – self reference
  • iterable (mixed) – initial values
allowedTypes()

allowed types getter

append(val)

append :val: to list

Parameters:
  • self – self reference
  • val (mixed) – value
count(value) → integer -- return number of occurrences of value
extend(iterable)

extend list with :iterable:

Parameters:
  • self – self referenace
  • iterable (mixed) – an interable
index(value[, start[, stop]]) → integer -- return first index of value.

Raises ValueError if the value is not present.

insert(i, val)

insert :val: at index :i:

Parameters:
  • self – self reference
  • i (int) – index
  • val (mixed) – value to set
pop([index]) → item -- remove and return item at index (default last).

Raises IndexError if list is empty or index is out of range.

remove()

L.remove(value) – remove first occurrence of value. Raises ValueError if the value is not present.

reverse()

L.reverse() – reverse IN PLACE

sort()

L.sort(cmp=None, key=None, reverse=False) – stable sort IN PLACE; cmp(x, y) -> -1, 0, 1

class DIRAC.Core.Utilities.TypedList.StringsList(iterable=None)

Bases: DIRAC.Core.Utilities.TypedList.TypedList

class StringsList

A list holding only str or unicode type items.

__init__(iterable=None)

c’tor

Parameters:
  • self – self reference
  • iterable (mixed) – initial values
allowedTypes()

allowed types getter

append(val)

append :val: to list

Parameters:
  • self – self reference
  • val (mixed) – value
count(value) → integer -- return number of occurrences of value
extend(iterable)

extend list with :iterable:

Parameters:
  • self – self referenace
  • iterable (mixed) – an interable
index(value[, start[, stop]]) → integer -- return first index of value.

Raises ValueError if the value is not present.

insert(i, val)

insert :val: at index :i:

Parameters:
  • self – self reference
  • i (int) – index
  • val (mixed) – value to set
pop([index]) → item -- remove and return item at index (default last).

Raises IndexError if list is empty or index is out of range.

remove()

L.remove(value) – remove first occurrence of value. Raises ValueError if the value is not present.

reverse()

L.reverse() – reverse IN PLACE

sort()

L.sort(cmp=None, key=None, reverse=False) – stable sort IN PLACE; cmp(x, y) -> -1, 0, 1

class DIRAC.Core.Utilities.TypedList.TDeque(iterable, allowedTypes=None)

Bases: collections.deque

__init__(iterable, allowedTypes=None)

x.__init__(…) initializes x; see help(type(x)) for signature

append()

Add an element to the right side of the deque.

appendleft()

Add an element to the left side of the deque.

clear()

Remove all elements from the deque.

count(value) → integer -- return number of occurrences of value
extend()

Extend the right side of the deque with elements from the iterable

extendleft()

Extend the left side of the deque with elements from the iterable

maxlen

maximum size of a deque or None if unbounded

pop()

Remove and return the rightmost element.

popleft()

Remove and return the leftmost element.

remove()

D.remove(value) – remove first occurrence of value.

reverse()

D.reverse() – reverse IN PLACE

rotate()

Rotate the deque n steps to the right (default n=1). If n is negative, rotates left.

class DIRAC.Core.Utilities.TypedList.TypedList(iterable=None, allowedTypes=None)

Bases: list

A list-like class holding only objects of specified type(s).

__init__(iterable=None, allowedTypes=None)

c’tor

Parameters:
  • self – self reference
  • iterable (mixed) – initial values
  • allowedTypes (tuple) – alowed types tuple
allowedTypes()

allowed types getter

append(val)

append :val: to list

Parameters:
  • self – self reference
  • val (mixed) – value
count(value) → integer -- return number of occurrences of value
extend(iterable)

extend list with :iterable:

Parameters:
  • self – self referenace
  • iterable (mixed) – an interable
index(value[, start[, stop]]) → integer -- return first index of value.

Raises ValueError if the value is not present.

insert(i, val)

insert :val: at index :i:

Parameters:
  • self – self reference
  • i (int) – index
  • val (mixed) – value to set
pop([index]) → item -- remove and return item at index (default last).

Raises IndexError if list is empty or index is out of range.

remove()

L.remove(value) – remove first occurrence of value. Raises ValueError if the value is not present.

reverse()

L.reverse() – reverse IN PLACE

sort()

L.sort(cmp=None, key=None, reverse=False) – stable sort IN PLACE; cmp(x, y) -> -1, 0, 1

class DIRAC.Core.Utilities.TypedList.Unsortable

Bases: list

__init__

x.__init__(…) initializes x; see help(type(x)) for signature

append()

L.append(object) – append object to end

count(value) → integer -- return number of occurrences of value
extend()

L.extend(iterable) – extend list by appending elements from the iterable

index(value[, start[, stop]]) → integer -- return first index of value.

Raises ValueError if the value is not present.

insert()

L.insert(index, object) – insert object before index

pop([index]) → item -- remove and return item at index (default last).

Raises IndexError if list is empty or index is out of range.

remove()

L.remove(value) – remove first occurrence of value. Raises ValueError if the value is not present.

reverse()

L.reverse() – reverse IN PLACE

sort(*args, **kwargs)

L.sort(cmp=None, key=None, reverse=False) – stable sort IN PLACE; cmp(x, y) -> -1, 0, 1