Traced

mod:Traced
synopsis:watched mutable metaclass

watched mutable metaclass tracing all updated indexes or keys

class DIRAC.Core.Utilities.Traced.Traced

Bases: type

class Traced

metaclass telling if some attrs was updated

overwrites __setattr__ and __setitem__ adds updated member function and __updated__ attribute

__init__

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

mro() → list

return a type’s method resolution order

class DIRAC.Core.Utilities.Traced.TracedDict

Bases: dict

traced dict

__init__

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

clear() → None. Remove all items from D.
copy() → a shallow copy of D
fromkeys(S[, v]) → New dict with keys from S and values equal to v.

v defaults to None.

get(k[, d]) → D[k] if k in D, else d. d defaults to None.
has_key(k) → True if D has a key k, else False
items() → list of D's (key, value) pairs, as 2-tuples
iteritems() → an iterator over the (key, value) items of D
iterkeys() → an iterator over the keys of D
itervalues() → an iterator over the values of D
keys() → list of D's keys
pop(k[, d]) → v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised

popitem() → (k, v), remove and return some (key, value) pair as a

2-tuple; but raise KeyError if D is empty.

setdefault(k[, d]) → D.get(k,d), also set D[k]=d if k not in D
update(seq)

for dict only

updated(element=None, reset=False)

updates and returns __updated__ list

Parameters:
  • self – self reference
  • element (mixed) – key name or list index
  • reset (bool) – flag to zero __updated__ list
Returns:

__updated__ list when called without arguments

values() → list of D's values
viewitems() → a set-like object providing a view on D's items
viewkeys() → a set-like object providing a view on D's keys
viewvalues() → an object providing a view on D's values
class DIRAC.Core.Utilities.Traced.TracedList

Bases: list

traced list

__init__

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

append(item)

append for list

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()

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

updated(element=None, reset=False)

updates and returns __updated__ list

Parameters:
  • self – self reference
  • element (mixed) – key name or list index
  • reset (bool) – flag to zero __updated__ list
Returns:

__updated__ list when called without arguments