Back to index

enigmail  1.4.3
Public Member Functions | Public Attributes | Static Public Attributes | Private Attributes | Static Private Attributes
pymake.data.Variables Class Reference

List of all members.

Public Member Functions

def __init__
def readfromenvironment
def get
def set
def append
def merge
def __iter__
def __contains__

Public Attributes

 parent

Static Public Attributes

int FLAVOR_RECURSIVE = 0
int FLAVOR_SIMPLE = 1
int FLAVOR_APPEND = 2
int SOURCE_OVERRIDE = 0
int SOURCE_COMMANDLINE = 1
int SOURCE_MAKEFILE = 2
int SOURCE_ENVIRONMENT = 3
int SOURCE_AUTOMATIC = 4
int SOURCE_IMPLICIT = 5

Private Attributes

 _map

Static Private Attributes

tuple __slots__ = ('parent', '_map')

Detailed Description

A mapping from variable names to variables. Variables have flavor, source, and value. The value is an 
expansion object.

Definition at line 218 of file data.py.


Constructor & Destructor Documentation

def pymake.data.Variables.__init__ (   self,
  parent = None 
)

Definition at line 237 of file data.py.

00237 
00238     def __init__(self, parent=None):
00239         self._map = {} # vname -> flavor, source, valuestr, valueexp
00240         self.parent = parent


Member Function Documentation

def pymake.data.Variables.__contains__ (   self,
  item 
)

Definition at line 345 of file data.py.

00345 
00346     def __contains__(self, item):
00347         return item in self._map

Definition at line 341 of file data.py.

00341 
00342     def __iter__(self):
00343         for k, (flavor, source, value, valueexp) in self._map.iteritems():
00344             yield k, flavor, source, value

def pymake.data.Variables.append (   self,
  name,
  source,
  value,
  variables,
  makefile 
)

Definition at line 312 of file data.py.

00312 
00313     def append(self, name, source, value, variables, makefile):
00314         assert source in (self.SOURCE_OVERRIDE, self.SOURCE_MAKEFILE, self.SOURCE_AUTOMATIC)
00315         assert isinstance(value, str)
00316 
00317         if name not in self._map:
00318             self._map[name] = self.FLAVOR_APPEND, source, value, None
00319             return
00320 
00321         prevflavor, prevsource, prevvalue, valueexp = self._map[name]
00322         if source > prevsource:
00323             # TODO: log a warning?
00324             return
00325 
00326         if prevflavor == self.FLAVOR_SIMPLE:
00327             d = parser.Data.fromstring(value, parserdata.Location("Expansion of variables '%s'" % (name,), 1, 0))
00328             valueexp, t, o = parser.parsemakesyntax(d, 0, (), parser.iterdata)
00329 
00330             val = valueexp.resolvestr(makefile, variables, [name])
00331             self._map[name] = prevflavor, prevsource, prevvalue + ' ' + val, None
00332             return
00333 
00334         newvalue = prevvalue + ' ' + value
00335         self._map[name] = prevflavor, prevsource, newvalue, None

Here is the caller graph for this function:

def pymake.data.Variables.get (   self,
  name,
  expand = True 
)
Get the value of a named variable. Returns a tuple (flavor, source, value)

If the variable is not present, returns (None, None, None)

@param expand If true, the value will be returned as an expansion. If false,
it will be returned as an unexpanded string.

Definition at line 245 of file data.py.

00245 
00246     def get(self, name, expand=True):
00247         """
00248         Get the value of a named variable. Returns a tuple (flavor, source, value)
00249 
00250         If the variable is not present, returns (None, None, None)
00251 
00252         @param expand If true, the value will be returned as an expansion. If false,
00253         it will be returned as an unexpanded string.
00254         """
00255         flavor, source, valuestr, valueexp = self._map.get(name, (None, None, None, None))
00256         if flavor is not None:
00257             if expand and flavor != self.FLAVOR_SIMPLE and valueexp is None:
00258                 d = parser.Data.fromstring(valuestr, parserdata.Location("Expansion of variables '%s'" % (name,), 1, 0))
00259                 valueexp, t, o = parser.parsemakesyntax(d, 0, (), parser.iterdata)
00260                 self._map[name] = flavor, source, valuestr, valueexp
00261 
00262             if flavor == self.FLAVOR_APPEND:
00263                 if self.parent:
00264                     pflavor, psource, pvalue = self.parent.get(name, expand)
00265                 else:
00266                     pflavor, psource, pvalue = None, None, None
00267 
00268                 if pvalue is None:
00269                     flavor = self.FLAVOR_RECURSIVE
00270                     # fall through
00271                 else:
00272                     if source > psource:
00273                         # TODO: log a warning?
00274                         return pflavor, psource, pvalue
00275 
00276                     if not expand:
00277                         return pflavor, psource, pvalue + ' ' + valuestr
00278 
00279                     pvalue = pvalue.clone()
00280                     pvalue.appendstr(' ')
00281                     pvalue.concat(valueexp)
00282 
00283                     return pflavor, psource, pvalue
00284                     
00285             if not expand:
00286                 return flavor, source, valuestr
00287 
00288             if flavor == self.FLAVOR_RECURSIVE:
00289                 val = valueexp
00290             else:
00291                 val = Expansion.fromstring(valuestr, "Expansion of variable '%s'" % (name,))
00292 
00293             return flavor, source, val
00294 
00295         if self.parent is not None:
00296             return self.parent.get(name, expand)
00297 
00298         return (None, None, None)

Here is the caller graph for this function:

def pymake.data.Variables.merge (   self,
  other 
)

Definition at line 336 of file data.py.

00336 
00337     def merge(self, other):
00338         assert isinstance(other, Variables)
00339         for k, flavor, source, value in other:
00340             self.set(k, flavor, source, value)

Here is the call graph for this function:

def pymake.data.Variables.readfromenvironment (   self,
  env 
)

Definition at line 241 of file data.py.

00241 
00242     def readfromenvironment(self, env):
00243         for k, v in env.iteritems():
00244             self.set(k, self.FLAVOR_SIMPLE, self.SOURCE_ENVIRONMENT, v)

Here is the call graph for this function:

def pymake.data.Variables.set (   self,
  name,
  flavor,
  source,
  value 
)

Definition at line 299 of file data.py.

00299 
00300     def set(self, name, flavor, source, value):
00301         assert flavor in (self.FLAVOR_RECURSIVE, self.FLAVOR_SIMPLE)
00302         assert source in (self.SOURCE_OVERRIDE, self.SOURCE_COMMANDLINE, self.SOURCE_MAKEFILE, self.SOURCE_ENVIRONMENT, self.SOURCE_AUTOMATIC, self.SOURCE_IMPLICIT)
00303         assert isinstance(value, str), "expected str, got %s" % type(value)
00304 
00305         prevflavor, prevsource, prevvalue = self.get(name)
00306         if prevsource is not None and source > prevsource:
00307             # TODO: give a location for this warning
00308             _log.info("not setting variable '%s', set by higher-priority source to value '%s'" % (name, prevvalue))
00309             return
00310 
00311         self._map[name] = flavor, source, value, None

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

tuple pymake.data.Variables.__slots__ = ('parent', '_map') [static, private]

Definition at line 224 of file data.py.

Definition at line 238 of file data.py.

Definition at line 228 of file data.py.

Definition at line 226 of file data.py.

Definition at line 227 of file data.py.

Definition at line 239 of file data.py.

Definition at line 234 of file data.py.

Definition at line 231 of file data.py.

Definition at line 233 of file data.py.

Definition at line 235 of file data.py.

Definition at line 232 of file data.py.

Definition at line 230 of file data.py.


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