Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
BastionClass Class Reference

Public Member Functions

def __init__
 
def __repr__
 
def __getattr__
 

Detailed Description

Helper class used by the Bastion() function.

You could subclass this and pass the subclass as the bastionclass
argument to the Bastion() function, as long as the constructor has
the same signature (a get() function and a name for the object).

Definition at line 34 of file Bastion.py.

Constructor & Destructor Documentation

def __init__ (   self,
  get,
  name 
)
Constructor.

Arguments:

get - a function that gets the attribute value (by name)
name - a human-readable name for the original object
       (suggestion: use repr(object))

Definition at line 44 of file Bastion.py.

References BastionClass._get_, and BastionClass._name_.

44 
45  def __init__(self, get, name):
46  """Constructor.
47 
48  Arguments:
49 
50  get - a function that gets the attribute value (by name)
51  name - a human-readable name for the original object
52  (suggestion: use repr(object))
53 
54  """
55  self._get_ = get
56  self._name_ = name

Member Function Documentation

def __getattr__ (   self,
  name 
)
Get an as-yet undefined attribute value.

This calls the get() function that was passed to the
constructor.  The result is stored as an instance variable so
that the next time the same attribute is requested,
__getattr__() won't be invoked.

If the get() function raises an exception, this is simply
passed on -- exceptions are not cached.

Definition at line 67 of file Bastion.py.

References BastionClass._get_, and Bastion.Bastion().

67 
68  def __getattr__(self, name):
69  """Get an as-yet undefined attribute value.
70 
71  This calls the get() function that was passed to the
72  constructor. The result is stored as an instance variable so
73  that the next time the same attribute is requested,
74  __getattr__() won't be invoked.
75 
76  If the get() function raises an exception, this is simply
77  passed on -- exceptions are not cached.
78 
79  """
80  attribute = self._get_(name)
81  self.__dict__[name] = attribute
82  return attribute
83 
def __repr__ (   self)
Return a representation string.

This includes the name passed in to the constructor, so that
if you print the bastion during debugging, at least you have
some idea of what it is.

Definition at line 57 of file Bastion.py.

References BastionClass._name_.

57 
58  def __repr__(self):
59  """Return a representation string.
60 
61  This includes the name passed in to the constructor, so that
62  if you print the bastion during debugging, at least you have
63  some idea of what it is.
64 
65  """
66  return "<Bastion for %s>" % self._name_

The documentation for this class was generated from the following file: