/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Member Functions | Public Attributes | Static Public Attributes | Properties | Private Member Functions
DybPython::vlut::vlutspec::VlutSpec Class Reference
Collaboration diagram for DybPython::vlut::vlutspec::VlutSpec:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __str__
def __repr__
def copy
def varycopy
def spawn
def prune
def level_
def make_vlut
def dumpstat
def rstat
def write_rstat
def make_scan
def make_toc
def __init__
def fmt_
def dbconf_name
def opts_name
def dir_name
def depth_
 internal, not an external switch
def leveldir_
def indexpath_
def indextitle_
def opts_
def dbconf_
def dir_
def name_
def title_
def coords_

Public Attributes

 stat
 children
 promote to hashable ctxdict
 parent

Static Public Attributes

 base = BASE
string sphinxroot = "/sphinx"
tuple levels = Levels(['category','tn','ctx','dbconf'])
tuple depth = dict(category=0,tn=1,ctx=2,dbconf=3)
tuple defaults = dict(dbconf=None,tn=None,ctx=None,opts=None,category='cache',base=None,vary={})
tuple fmt_ = classmethod( fmt_ )
tuple dbconf_name = classmethod( dbconf_name )
tuple opts_name = classmethod( opts_name )
tuple dir_name = classmethod( dir_name )

Properties

 abspath = property(_abspath)
 relpath = property(_relpath)
 level = property( level_ )
 rescan = property(lambda self:self['opts']['_rescan'])
 recompare = property(lambda self:self['opts']['_recompare'])
 force = property(lambda self:self['opts']['_force'])
 retoc = property(lambda self:self['opts']['_retoc'])
 plain = property(lambda self:self['opts']['_plain'])
 txtscan = property(lambda self:self['opts']['_txtscan'])
 onlydiff = property(lambda self:self['opts']['_onlydiff'])
 aligned = property(lambda self:self['opts']['_aligned'])
 digest = property(lambda self:self['opts']['_digest'])
 compare = property(lambda self:self['opts'].get('_compare',False))
 path = property(lambda self:os.path.join( self.dir_(), self.name_() ))
 dbconf = property(lambda self:self.dbconf_() )
 opts = property(_opts)

Private Member Functions

def _abspath
def _relpath
def _opts

Detailed Description

Path/hierarcy handling of VLUTs and derivatives

Definition at line 34 of file vlutspec.py.


Constructor & Destructor Documentation

def DybPython::vlut::vlutspec::VlutSpec::__init__ (   self,
  args,
  kwargs 
)
:param tn: table name
:param ctx: a dict specifiying context 
:param dbconf: config section name
:param opts: dict with any extra variations (such as non standard validity ordering), 
    kv pairs from dict are added to the filename if the key does not start with "_"
:param category: 

Definition at line 198 of file vlutspec.py.

00199                                         :
00200         """
00201         :param tn: table name
00202         :param ctx: a dict specifiying context 
00203         :param dbconf: config section name
00204         :param opts: dict with any extra variations (such as non standard validity ordering), 
00205                     kv pairs from dict are added to the filename if the key does not start with "_"
00206         :param category: 
00207 
00208         """
00209         log.debug("creating VlutSpec instance from args %s kwargs %s " % ( args, kwargs ))
00210         dict.__init__(self, *args, **kwargs )
00211         for k,v in self.defaults.items():
00212             if k not in self:
00213                 self[k] = v        
00214         if type(self['ctx']) == dict:
00215             self['ctx'] = ctxdict(self['ctx'])    ## promote to hashable ctxdict 
00216 
00217         self.children = []
00218         self.parent = None


Member Function Documentation

def DybPython::vlut::vlutspec::VlutSpec::__str__ (   self)

Definition at line 47 of file vlutspec.py.

00048                      :
00049         return self.abspath

def DybPython::vlut::vlutspec::VlutSpec::_abspath (   self) [private]
sphinxroot relative path

Definition at line 50 of file vlutspec.py.

00051                       :
00052         """sphinxroot relative path"""
        return os.path.relpath(self.path, self.sphinxroot )
def DybPython::vlut::vlutspec::VlutSpec::_relpath (   self) [private]
parent relative path

Definition at line 55 of file vlutspec.py.

00056                       :
00057         """parent relative path"""
        return os.path.relpath(self.path, self.parent.path) if self.parent else self.path
def DybPython::vlut::vlutspec::VlutSpec::__repr__ (   self)

Definition at line 60 of file vlutspec.py.

00061                       :
00062         vs = []
00063         for k,v in self.items(): 
00064             if self.defaults[k] != v:
00065                 vs.append( (k,v) )
00066         return "%s(" % self.__class__.__name__ + ",".join(["%s=\"%s\""% kv for kv in vs ])    + ") ; level='%s' " % self.level

def DybPython::vlut::vlutspec::VlutSpec::copy (   self,
  kwargs 
)
Copies just the dict level content, with no implied hierarcy 
... hmm dict aleady has a copy

Definition at line 67 of file vlutspec.py.

00068                               :
00069         """
00070         Copies just the dict level content, with no implied hierarcy 
00071         ... hmm dict aleady has a copy
00072 
00073         """  
00074         return VlutSpec( deepcopy(self) , **kwargs )

def DybPython::vlut::vlutspec::VlutSpec::varycopy (   self,
  idx 
)
:param idx: index of variation 

Makes variation in the `cf` directin specified by the `opts['_compare']` value

Definition at line 75 of file vlutspec.py.

00076                              :
00077         """
00078         :param idx: index of variation 
00079 
00080         Makes variation in the `cf` directin specified by the `opts['_compare']` value
00081 
00082         """
00083         vr = self.copy()
00084 
00085         cf = vr['opts'].pop('_compare')      ## pop to make leaf 
00086         ncf = len(self[cf])
00087 
00088         assert cf in ('vary','dbconf',), ("variation not supported", self, cf )
00089         assert not vr.compare,           ("must be leaf", vr ) 
00090         assert idx < ncf ,               ("variation idx out of range", idx, ncf, cf ) 
00091 
00092         vdict = { cf:self[cf][idx] }
00093         log.debug("varycopy idx %s %s " % ( idx, vdict ) )
00094         vr.update( vdict )
00095         return vr 

def DybPython::vlut::vlutspec::VlutSpec::spawn (   self,
  kwargs 
)
Returns a child `VlutSpec` instance, taking care of 
the family tree wiring 

:param kwargs: VlutSpec ctor kwargs
:return: VlutSpec child instance 

dict ctor copying only does shallow copies, which means that 
changing a contained dict (eg the opts) propagates back... thus must use the deepcopy

Definition at line 96 of file vlutspec.py.

00097                                :
00098         """
00099         Returns a child `VlutSpec` instance, taking care of 
00100         the family tree wiring 
00101 
00102         :param kwargs: VlutSpec ctor kwargs
00103         :return: VlutSpec child instance 
00104 
00105         dict ctor copying only does shallow copies, which means that 
00106         changing a contained dict (eg the opts) propagates back... thus must use the deepcopy
00107 
00108         """
00109         child = VlutSpec( deepcopy(self) , **kwargs )
00110         child.parent = self
00111         self.children.append( child )
00112         return child 

def DybPython::vlut::vlutspec::VlutSpec::prune (   self,
  child 
)
:param child: 

Remove child from the list of children, preventing appearance in table of contents. 

Definition at line 113 of file vlutspec.py.

00114                             :
00115         """
00116         :param child: 
00117 
00118         Remove child from the list of children, preventing appearance in table of contents. 
00119         """
00120         assert child in self.children, "%s is not in the children list "
00121         assert child.parent == self, "parent of child is not me "
00122         child.parent = None
00123         self.children.remove( child )  

def DybPython::vlut::vlutspec::VlutSpec::level_ (   self)
Level as determined by the last non-None content in levels order

Definition at line 124 of file vlutspec.py.

00125                     :
00126         """
00127         Level as determined by the last non-None content in levels order
00128         """
00129 
00130         vals = map( lambda lev:self.get(lev,None) , self.levels )
00131         vals += [None]              ## something to find when fully resolved 
00132 
00133         lval = vals.index(None)     ## 1st miss
00134         levl = self.levels[lval-1] 
00135         log.debug("level_ vals %s lval %s levl %s " % ( vals, lval, levl ))
        return levl
def DybPython::vlut::vlutspec::VlutSpec::make_vlut (   self)

Definition at line 138 of file vlutspec.py.

00139                          :
00140         vlut = Vlut.get_or_create( self )
00141         assert not hasattr( self, 'stat' ) , "make_vlut preexisting stat %s %s " % ( self, self.stat )
00142         self.stat = deepcopy( vlut.stat )  
00143         return vlut

def DybPython::vlut::vlutspec::VlutSpec::dumpstat (   self)

Definition at line 144 of file vlutspec.py.

00145                       :
00146         stat = self.stat if hasattr(self,'stat') else "-" 
00147         if stat != "-":
00148             log.info("dumpstat %s %s " % (self, stat ) )
00149         for c in self.children:
00150             c.dumpstat()

def DybPython::vlut::vlutspec::VlutSpec::rstat (   self)

Definition at line 151 of file vlutspec.py.

00152                    :
00153         d = {}
00154         stat = self.stat if hasattr(self,'stat') else None
00155         if stat:
00156             d[self.abspath] = stat
00157         for c in self.children:
00158             d.update(c.rstat())
00159         return d

def DybPython::vlut::vlutspec::VlutSpec::write_rstat (   self,
  level 
)

Definition at line 160 of file vlutspec.py.

00161                                  :
00162         path  = self.indexpath_(levelname=level, name="smry.pc" )
00163         rstat = perdict(self.rstat())
00164         log.info("save rstat summary at level %s to %s " % (level,path) )
00165         rstat.save( path )

def DybPython::vlut::vlutspec::VlutSpec::make_scan (   self)

Definition at line 166 of file vlutspec.py.

00167                          :
00168         return Scan.get_or_create( self )

def DybPython::vlut::vlutspec::VlutSpec::make_toc (   self,
  level = None,
  overwrite = True 
)
Make a toc index document

:param level: eg `tn` `ctx` 

hierarchy  tn/ctx/dbconf/

Definition at line 169 of file vlutspec.py.

00170                                                       :
00171         """
00172         Make a toc index document
00173 
00174         :param level: eg `tn` `ctx` 
00175 
00176         hierarchy  tn/ctx/dbconf/
00177 
00178         """
00179         _level = level if level else self.level 
00180         log.debug("make_toc levels vs/arg/use  %s %s %s " % ( self.level, level, _level ) )
00181         nextlevel = self.levels.next( _level )
00182         path = self.indexpath_( _level )
00183         title = self.indextitle_( _level )
00184  
00185         if os.path.exists(path) and not overwrite:
00186             log.debug("make_toc not overwriting %s " % path )
00187             return None    
00188 
00189         toc = Toc(base=path, title=title )
00190         for vs in self.children:            ## the kids should know the level they are at ?
00191             if nextlevel == None:           ## fully resolved LEAF 
00192                 toc.append( vs.path )
00193             else:
00194                 toc.append( vs.indexpath_(nextlevel) )
00195 
00196         toc.write()
00197         return toc 

def DybPython::vlut::vlutspec::VlutSpec::fmt_ (   cls,
  category 
)

Definition at line 219 of file vlutspec.py.

00220                              :
        return "pc" if category == 'cache' else 'rst'

Definition at line 223 of file vlutspec.py.

00224                                   :
00225         if type(dbconf) == list:
00226             if len(dbconf) == 1:
00227                 dbn = dbconf[0]
00228             elif len(dbconf) == 2:
00229                 dbn = "_cf_".join(dbconf)
00230             else:
00231                 raise Exception("path_ unexpected dbconf %s " % dbconf )
00232         else:
00233             dbn = dbconf
        return dbn

Definition at line 236 of file vlutspec.py.

00237                               :
00238         optsmry = lambda _:"_".join(["%s%s" % kv for kv in filter(lambda kv:not kv[0].startswith("_") and kv[1] != "",_.items())])
00239         if type(opts) == dict:
00240             ext = optsmry(opts)
00241         elif type(opts) == list:
00242             ext = "_cf_".join(map(optsmry,opts)) 
00243         else:
00244             raise Exception("opts_name %s " % opts )
        return ext.replace(" ","") 
def DybPython::vlut::vlutspec::VlutSpec::dir_name (   cls,
  dbconf,
  tn,
  ctx,
  category,
  levelname 
)
Compose directory path at the desired level 

Definition at line 247 of file vlutspec.py.

00248                                                               :
00249         """
00250         Compose directory path at the desired level 
00251         """
00252         ucat = 'cache' if category == 'cache' else 'sphinx'
00253         elems = [cls.base, ucat ]      ## these are never None
00254 
00255         if levelname == None:
00256             levelname = cls.levels[-1]
00257 
00258         if tn and cls.depth[levelname] >= cls.depth['tn']:
00259             elems += [tn]
00260         if ctx and cls.depth[levelname] >= cls.depth['ctx']:
00261             elems += [str(ctx)]
00262         if dbconf and cls.depth[levelname] >= cls.depth['dbconf']:
00263             elems += [dbconf] 
00264 
00265         # variations feed into leaf filename .. dont mint a directory for them 
00266         #if vary and cls.depth[levelname] >= cls.depth['vary']:
00267         #    elems += [vary] 
00268 
00269         dir = os.path.join(*filter(None,elems))       
00270         if not os.path.exists(dir):
00271             os.makedirs(dir)
        return dir
def DybPython::vlut::vlutspec::VlutSpec::depth_ (   self,
  levelname 
)

internal, not an external switch

Definition at line 286 of file vlutspec.py.

00286 :return self.levels.index(levelname)
def DybPython::vlut::vlutspec::VlutSpec::leveldir_ (   self,
  levelname 
)

Definition at line 287 of file vlutspec.py.

00287 :return self.dir_name( self.dbconf_(), self['tn'], self['ctx'], self['category'], levelname ) 
def DybPython::vlut::vlutspec::VlutSpec::indexpath_ (   self,
  levelname,
  name = 'index.rst' 
)

Definition at line 288 of file vlutspec.py.

00288 :return os.path.join( self.leveldir_(levelname), name )
def DybPython::vlut::vlutspec::VlutSpec::indextitle_ (   self,
  levelname 
)

Definition at line 289 of file vlutspec.py.

00289                                      :return str(self[levelname]) 
00290 
def DybPython::vlut::vlutspec::VlutSpec::opts_ (   self)

Definition at line 291 of file vlutspec.py.

00291 :return self.opts_name( self.opts )             ## incorps variations into leaf name
def DybPython::vlut::vlutspec::VlutSpec::dbconf_ (   self)

Definition at line 292 of file vlutspec.py.

00292 :return self.dbconf_name( self['dbconf'] )
def DybPython::vlut::vlutspec::VlutSpec::dir_ (   self)

Definition at line 293 of file vlutspec.py.

00293 :return self.dir_name( self.dbconf_(), self['tn'] , self['ctx'] ,  self['category'], self.level ) 
def DybPython::vlut::vlutspec::VlutSpec::name_ (   self)

Definition at line 294 of file vlutspec.py.

00294 :return "%s%s.%s" % (self['category'],self.opts_(),self.fmt_(self['category']))   
def DybPython::vlut::vlutspec::VlutSpec::title_ (   self)

Definition at line 295 of file vlutspec.py.

00295 :return "%s %s %s " % ( self.dbconf_() , self['category'], self.opts_()  )
def DybPython::vlut::vlutspec::VlutSpec::coords_ (   self)

Definition at line 296 of file vlutspec.py.

00296                      :return self['dbconf'], self['tn'], self['ctx'], self.opts
00297 
def DybPython::vlut::vlutspec::VlutSpec::_opts (   self) [private]
When `vary` is a list return a list of so varied dicts otherwise just the singly varied opts.
The default `vary` of an empty dict corresponds to an unvaried opts. 

Definition at line 301 of file vlutspec.py.

00302                    :
00303         """
00304         When `vary` is a list return a list of so varied dicts otherwise just the singly varied opts.
00305         The default `vary` of an empty dict corresponds to an unvaried opts. 
00306         """
00307         if type(self['vary']) in (list,tuple): 
00308             return map(lambda _:dict(self['opts'], **_), self['vary']) 
00309         else:
            return dict(self['opts'], **self['vary'] )

Member Data Documentation

Definition at line 39 of file vlutspec.py.

Definition at line 40 of file vlutspec.py.

tuple DybPython::vlut::vlutspec::VlutSpec::levels = Levels(['category','tn','ctx','dbconf']) [static]

Definition at line 41 of file vlutspec.py.

tuple DybPython::vlut::vlutspec::VlutSpec::depth = dict(category=0,tn=1,ctx=2,dbconf=3) [static]

Definition at line 42 of file vlutspec.py.

tuple DybPython::vlut::vlutspec::VlutSpec::defaults = dict(dbconf=None,tn=None,ctx=None,opts=None,category='cache',base=None,vary={}) [static]

Definition at line 43 of file vlutspec.py.

tuple DybPython::vlut::vlutspec::VlutSpec::fmt_ = classmethod( fmt_ ) [static]

Definition at line 221 of file vlutspec.py.

Definition at line 234 of file vlutspec.py.

Definition at line 245 of file vlutspec.py.

Definition at line 272 of file vlutspec.py.

Definition at line 138 of file vlutspec.py.

promote to hashable ctxdict

Definition at line 207 of file vlutspec.py.

Definition at line 207 of file vlutspec.py.


Property Documentation

DybPython::vlut::vlutspec::VlutSpec::abspath = property(_abspath) [static]

Definition at line 53 of file vlutspec.py.

DybPython::vlut::vlutspec::VlutSpec::relpath = property(_relpath) [static]

Definition at line 58 of file vlutspec.py.

DybPython::vlut::vlutspec::VlutSpec::level = property( level_ ) [static]

Definition at line 136 of file vlutspec.py.

DybPython::vlut::vlutspec::VlutSpec::rescan = property(lambda self:self['opts']['_rescan']) [static]

Definition at line 274 of file vlutspec.py.

DybPython::vlut::vlutspec::VlutSpec::recompare = property(lambda self:self['opts']['_recompare']) [static]

Definition at line 275 of file vlutspec.py.

DybPython::vlut::vlutspec::VlutSpec::force = property(lambda self:self['opts']['_force']) [static]

Definition at line 276 of file vlutspec.py.

DybPython::vlut::vlutspec::VlutSpec::retoc = property(lambda self:self['opts']['_retoc']) [static]

Definition at line 277 of file vlutspec.py.

DybPython::vlut::vlutspec::VlutSpec::plain = property(lambda self:self['opts']['_plain']) [static]

Definition at line 278 of file vlutspec.py.

DybPython::vlut::vlutspec::VlutSpec::txtscan = property(lambda self:self['opts']['_txtscan']) [static]

Definition at line 279 of file vlutspec.py.

DybPython::vlut::vlutspec::VlutSpec::onlydiff = property(lambda self:self['opts']['_onlydiff']) [static]

Definition at line 280 of file vlutspec.py.

DybPython::vlut::vlutspec::VlutSpec::aligned = property(lambda self:self['opts']['_aligned']) [static]

Definition at line 281 of file vlutspec.py.

DybPython::vlut::vlutspec::VlutSpec::digest = property(lambda self:self['opts']['_digest']) [static]

Definition at line 282 of file vlutspec.py.

DybPython::vlut::vlutspec::VlutSpec::compare = property(lambda self:self['opts'].get('_compare',False)) [static]

Definition at line 284 of file vlutspec.py.

DybPython::vlut::vlutspec::VlutSpec::path = property(lambda self:os.path.join( self.dir_(), self.name_() )) [static]

Definition at line 298 of file vlutspec.py.

DybPython::vlut::vlutspec::VlutSpec::dbconf = property(lambda self:self.dbconf_() ) [static]

Definition at line 299 of file vlutspec.py.

DybPython::vlut::vlutspec::VlutSpec::opts = property(_opts) [static]

Definition at line 310 of file vlutspec.py.


The documentation for this class was generated from the following file:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:55:41 for DybPython by doxygen 1.7.4