/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::adtemp::AdTempScraper Class Reference
Inheritance diagram for Scraper::adtemp::AdTempScraper:
Inheritance graph
[legend]
Collaboration diagram for Scraper::adtemp::AdTempScraper:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def changed
def propagate
def seed

Static Public Attributes

tuple ptx_matcher = PTX()

Private Member Functions

def _ptxdict

Detailed Description

Specialization of generic scraper for AD temperature tables

Definition at line 44 of file adtemp.py.


Member Function Documentation

def Scraper::adtemp::AdTempScraper::changed (   self,
  sv 
)
returns changed decision to base class

Caution DB/SQLAlchemy is providing decimal.Decimal
values... unify types to float before comparison to avoid surprises

Definition at line 50 of file adtemp.py.

00051                            :
00052         """
00053         returns changed decision to base class
00054 
00055         Caution DB/SQLAlchemy is providing decimal.Decimal
00056         values... unify types to float before comparison to avoid surprises
00057         """
00058         pd = self._ptxdict( sv[0] )
00059         ud = self._ptxdict( sv[-1] )
00060 
00061         #log.info("sv[0]\n" + str(sv[0]))
00062         #log.info("sv[-1]\n" + str(sv[-1]))
00063 
00064         log.debug("prev %s " % pd )
00065         log.debug("curr %s " % ud )
00066         for ptx in sorted(pd.keys()):
00067             pv = float(pd[ptx])    ## often decimal.Decimal types
00068             uv = float(ud[ptx])
00069             df = abs(pv-uv) 
00070             if float(df) > float(self.threshold):
00071                 chg = True
00072             else:
00073                 chg = False
00074             log.debug("pv %r uv %r df %r threshold %s change %s  " % (pv,uv,df, self.threshold, chg)) 
00075             if chg:
00076                 return True
00077         return False

def Scraper::adtemp::AdTempScraper::propagate (   self,
  sv 
)
yields one or more target dicts ready for writing to target DB

Definition at line 78 of file adtemp.py.

00079                             :
00080         """yields one or more target dicts ready for writing to target DB"""
00081         dd = self._ptxdict(sv[-1])
00082         log.debug("propagate %r " % dd)
00083         yield dd

def Scraper::adtemp::AdTempScraper::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 84 of file adtemp.py.

00085                       :
00086         """
00087         Used for seeding target DB when testing into empty tables
00088 
00089         :param sc: source class, potentially different seeds will be needed 
00090                    for each source that feeds into a single target
00091         """
00092         return dict(Temp1=1,Temp2=2,Temp3=3,Temp4=4)

def Scraper::adtemp::AdTempScraper::_ptxdict (   self,
  inst 
) [private]
converts source instance into target dicts

Definition at line 93 of file adtemp.py.

00094                              :
00095         """converts source instance into target dicts"""
00096         dd = {}
00097         for k,v in inst.asdict.items():
00098             if k in 'id date_time'.split():
00099                 continue
00100             ptx = self.ptx_matcher(k)
00101             if ptx and ptx != "5":      ## SKIPPING Temp5 AS NO LONGER IN SPEC
00102                 dd['Temp%s'%ptx] = v
00103         return dd 
00104 


Member Data Documentation

Definition at line 48 of file adtemp.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