/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 | Static Public Attributes | Private Member Functions
Scraper::pmthv::PmtHvScraper Class Reference
Inheritance diagram for Scraper::pmthv::PmtHvScraper:
Inheritance graph
[legend]
Collaboration diagram for Scraper::pmthv::PmtHvScraper:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def changed
def propagate
def seed

Static Public Attributes

tuple lcr_matcher = LCR()

Private Member Functions

def _lcrdict

Detailed Description

Definition at line 48 of file pmthv.py.


Member Function Documentation

def Scraper::pmthv::PmtHvScraper::changed (   self,
  sv 
)
:param sv: source vector instance :py:class:`Scraper.base.sourcevector.SourceVector` 

Decide if sufficient change to propagate based on differences between the first and last elements of `SourceVector` instance argument

Definition at line 51 of file pmthv.py.

00052                            :
00053         """
00054         :param sv: source vector instance :py:class:`Scraper.base.sourcevector.SourceVector` 
00055 
00056         Decide if sufficient change to propagate based on differences between the first and last elements of `SourceVector` instance argument
00057         """
00058         p = self._lcrdict( sv[0] )
00059         c = self._lcrdict( sv[-1] )
00060         for lcr in sorted(p.keys()):
00061             pv = p[lcr]
00062             cv = c[lcr]
00063             if abs(pv['pw']-cv['pw']) > 0:
00064                 return True
00065             if abs(pv['voltage']-cv['voltage']) > self.threshold:
00066                 return True
00067         return False

def Scraper::pmthv::PmtHvScraper::propagate (   self,
  sv 
)
:param sv: source vector instance :py:class:`Scraper.base.sourcevector.SourceVector` 

Yield write ready DybDbi target dicts to base class, note that a single source vector
instance is yielding multiple target dicts. The keys of the target dict must match
the specified attributes of the ``DybDbi`` target class. 

Here the output is based entirely on the last element of the source vector. A smarter
implementation might average the first and last to smooth variations.
The python ``yield`` command makes it possible to iterate over a what is returned by 
a function/method.

Definition at line 68 of file pmthv.py.

00069                             :
00070         """
00071         :param sv: source vector instance :py:class:`Scraper.base.sourcevector.SourceVector` 
00072 
00073         Yield write ready DybDbi target dicts to base class, note that a single source vector
00074         instance is yielding multiple target dicts. The keys of the target dict must match
00075         the specified attributes of the ``DybDbi`` target class. 
00076 
00077         Here the output is based entirely on the last element of the source vector. A smarter
00078         implementation might average the first and last to smooth variations.
00079         The python ``yield`` command makes it possible to iterate over a what is returned by 
00080         a function/method.
00081 
00082         """
00083         dd = self._lcrdict(sv[-1])
00084         n = 0
00085         for (l,c,r),v in sorted(dd.items()):
00086             d = dict(Ladder=l,Column=c,Ring=r,Voltage=float(v['voltage']),Pw=v['pw'])
00087             n += 1
00088             yield d 
00089         log.debug("yielded %s target dicts for  %s " % ( n, sv ))
00090 

def Scraper::pmthv::PmtHvScraper::seed (   self,
  sc 
)
Used for seeding target DB when testing into empty tables

:param sc: source class, potentially different seeds will be needed 
   for each source that feeds into a single target

Definition at line 91 of file pmthv.py.

00092                       :
00093         """
00094         Used for seeding target DB when testing into empty tables
00095 
00096         :param sc: source class, potentially different seeds will be needed 
00097                    for each source that feeds into a single target
00098         """
00099         return dict(Ladder=1,Column=1,Ring=1,Voltage=0,Pw=0)
00100 

def Scraper::pmthv::PmtHvScraper::_lcrdict (   self,
  inst 
) [private]
:param inst:  SQLAlchemy source instance

Examines source instance, extracting ladder,col,ring and values and collecting into a dict.
Note the source is an instance of an SQLAlchmemy dynamic class that maps to the join of 
two tables.

This method is not not fulfilling any particular interface, it is just a helper to the 
other methods, and thus avoids duplication. 

Definition at line 101 of file pmthv.py.

00102                             :
00103         """
00104         :param inst:  SQLAlchemy source instance
00105 
00106         Examines source instance, extracting ladder,col,ring and values and collecting into a dict.
00107         Note the source is an instance of an SQLAlchmemy dynamic class that maps to the join of 
00108         two tables.
00109 
00110         This method is not not fulfilling any particular interface, it is just a helper to the 
00111         other methods, and thus avoids duplication. 
00112         """ 
00113         dd = {}
00114         for k,v in inst.asdict.items():
00115             if k in 'P_id id date_time P_date_time'.split():
00116                 continue 
00117             qty,kk = ('pw',k[2:]) if k.startswith('P_') else ('voltage',k)
00118             lcr = self.lcr_matcher(kk)  
00119             if dd.has_key(lcr):
00120                 dd[lcr].update({qty:v})
00121             else:
00122                 dd[lcr] = {qty:v}
00123         return dd
00124 


Member Data Documentation

Definition at line 49 of file pmthv.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:50:03 for Scraper by doxygen 1.7.4