Skip to content

pipda.context

module

pipda.context

Provides the context to evaluate f.A and f['A']

By default, 1. in the context of select, both f.A and f['A'] return 'A' 2. in the context of evaluation, f.A returns data.A and f['A'] returns data['A'] 3. when it is pending, you will need to evaluate args and kwargs yourself.

Classes
class

pipda.context.ContextError()

Bases
Exception BaseException

Any errors related to contexts

abstract class

pipda.context.ContextBase()

The context abstract class, defining howthe Reference objects are evaluated

  • getattr defines how f.A is evaluated. Note that f.A.B will always be evaluated as getattr(f.A, 'B')
  • getitem defines how f[item] is evaluated. Note that the item here is an evaluated value defined by getref.
  • ref here defines how the reference/item in f.item is evaluated. Since we could do f[f.A].
Attributes
  • ref (ContextBase) Defines how item in f[item] is evaluated.
    This function should return a ContextBase object. </>
Methods
  • getattr(parent, ref, level) (any) Defines how f.A is evaluated</>
  • getitem(parent, ref, level) (any) Defines how f[item] is evaluated</>
abstract method

getattr(parent, ref, level) → any

Defines how f.A is evaluated

abstract method

getitem(parent, ref, level) → any

Defines how f[item] is evaluated

class

pipda.context.ContextSelect()

Context used in a select context

In this kind of context,

  • - f.A works as a shortcut of 'A';
  • - f[ref] works as a shortcut of ref. However, ref is needed to be
      evaluated by a context returned by getref

Attributes
  • ref (ContextBase) Defines how item in f[item] is evaluated.
    This function should return a ContextBase object. </>
Methods
  • getattr(parent, ref, level) (str) Get the ref directly, regardless of data</>
  • getitem(parent, ref, level) (any) Get the ref directly, which is already evaluated by f[ref]</>
method

getattr(parent, ref, level) → str

Get the ref directly, regardless of data

method

getitem(parent, ref, level) → any

Get the ref directly, which is already evaluated by f[ref]

class

pipda.context.ContextEval()

Context used in a data-evaluation context

In this kind of context, the expression is evaluated as-is. That is, f.A is evaluated as f.A and f[item] is evaluated as f[item]

Attributes
  • ref (ContextBase) Defines how item in f[item] is evaluated.
    This function should return a ContextBase object. </>
Methods
  • getattr(parent, ref, level) (any) How to evaluate f.A</>
  • getitem(parent, ref, level) (any) How to evaluate f[item]</>
method

getattr(parent, ref, level) → any

How to evaluate f.A

method

getitem(parent, ref, level) → any

How to evaluate f[item]

class

pipda.context.ContextPending()

Pending context, don't evaluate the expression,awaiting next avaiable context

Attributes
  • ref (ContextBase) Defines how item in f[item] is evaluated.
    This function should return a ContextBase object. </>
Methods
  • getattr(parent, ref, level) (str) Get the ref directly, regardless of data</>
  • getitem(parent, ref, level) (any) Get the ref directly, which is already evaluated by f[ref]</>
method

getattr(parent, ref, level) → str

Get the ref directly, regardless of data

method

getitem(parent, ref, level) → any

Get the ref directly, which is already evaluated by f[ref]

class

pipda.context.Context(value, names=None, module=None, qualname=None, type=None, start=1)

Bases
enum.Enum

Context to solve f.A and f['A']

PENDING: Context to leave the arguments to be evaluated inside the function SELECT: It select-based context EVAL: It evaluation-based context

Classes
class

enum.EnumMeta(cls, bases, classdict, **kwds)

Metaclass for Enum

Attributes
  • __members__ Returns a mapping of member name->value.
    This mapping lists all enum members, including aliases. Note that this is a read-only view of the internal mapping. </>
Methods
  • __bool__() classes/types should always be True.</>
  • __call__(cls, value, names, module, qualname, type, start) Either returns an existing member, or creates a new enum class.</>
  • __dir__() Specialized dir implementation for types.</>
  • __getattr__(cls, name) Return the enum member matching name</>
  • __iter__(cls) Returns members in definition order.</>
  • __reversed__(cls) Returns members in reverse definition order.</>
  • __setattr__(cls, name, value) Block attempts to reassign Enum members.</>
method
__bool__()

classes/types should always be True.

staticmethod
__call__(cls, value, names=None, module=None, qualname=None, type=None, start=1)

Either returns an existing member, or creates a new enum class.

This method is used both when an enum class is given a value to match to an enumeration member (i.e. Color(3)) and for the functional API (i.e. Color = Enum('Color', names='RED GREEN BLUE')).

When used for the functional API:

value will be the name of the new class.

names should be either a string of white-space/comma delimited names (values will start at start), or an iterator/mapping of name, value pairs.

module should be set to the module this class is being created in; if it is not set, an attempt to find that module will be made, but if it fails the class will not be picklable.

qualname should be set to the actual location this class can be found at in its module; by default it is set to the global scope. If this is not correct, unpickling will fail in some circumstances.

type, if set, will be mixed in as the first base class.

method
__dir__()

Specialized dir implementation for types.

staticmethod
__getattr__(cls, name)

Return the enum member matching name

We use getattr instead of descriptors or inserting into the enum class' dict in order to support name and value being both properties for enum members (which live in the class' dict) and enum members themselves.

staticmethod
__iter__(cls)

Returns members in definition order.

staticmethod
__reversed__(cls)

Returns members in reverse definition order.

staticmethod
__setattr__(cls, name, value)

Block attempts to reassign Enum members.

A simple assignment to the class namespace only changes one of the several possible ways to get an Enum member from the Enum class, resulting in an inconsistent Enumeration.