/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 | Properties
Scraper::base::sourcecontext::SourceContext Class Reference

List of all members.

Public Member Functions

def __init__
def __repr__
def __str__
def jbits

Public Attributes

 table
 site
 subsite
 sitemask
 attjoin
 always single site assumption
 pfxjoin
 name

Properties

 isjoin = property(lambda self:self.table.find(":")>-1 )
 kln = property(lambda self:'Y%s' % self.name )
 ksite = property(lambda self:'k%s' % Site.AsString(self.site) )
 ksubsite = property(lambda self:'k%s' % DetectorId.AsString(self.subsite) )

Detailed Description

Associates a source DB tablename with a DBI context ``(site,subsite)`` in target DB
**Replaces DcsTableName**

#. more flexible and yet more enum constrained than DcsTableName 
#. avoids poor assumption of logical table naming in source DB

Definition at line 5 of file sourcecontext.py.


Constructor & Destructor Documentation

def Scraper::base::sourcecontext::SourceContext::__init__ (   self,
  table,
  ksite,
  ksubsite,
  attjoin = 'id',
  pfxjoin = 'P_',
  name = 'name' 
)
:param table: table name in source DB, or colon delimited list of 2 tablenames when using autojoin
:param ksite: attribute name of Site enum eg 'kDayabay' OR integer enum value
:param ksubsite: attribute name of DetectorId enum eg 'kAD1' specifying the logical (not physical) detector OR integer enum value
:param attjoin: attribute with which to join tables, only used when table param is a colon delimited list of tables
:param pfxjoin: string used to distinguish attribute names between 2 joined tables
:param name: unique name for this table (to facilitate multiple outputs from single DCS table)

Definition at line 14 of file sourcecontext.py.

00015                                                                                           :
00016         """
00017         :param table: table name in source DB, or colon delimited list of 2 tablenames when using autojoin
00018         :param ksite: attribute name of Site enum eg 'kDayabay' OR integer enum value
00019         :param ksubsite: attribute name of DetectorId enum eg 'kAD1' specifying the logical (not physical) detector OR integer enum value
00020         :param attjoin: attribute with which to join tables, only used when table param is a colon delimited list of tables
00021         :param pfxjoin: string used to distinguish attribute names between 2 joined tables
00022         :param name: unique name for this table (to facilitate multiple outputs from single DCS table)
00023 
00024         """
00025         katts = lambda enumcls:sorted(filter(lambda _:_[0]=='k',dir(enumcls)))
00026 
00027         site = ksite if type(ksite) == int else getattr( Site, ksite , None )
00028         if not site:
00029             msg = "ksite must be one of %s unlike %s " % ( katts(Site), ksite ) 
00030             log.fatal(msg)
00031             raise Exception(msg)
00032 
00033         subsite = ksubsite if type(ksubsite) == int else getattr( DetectorId, ksubsite )
00034         if not subsite:
00035             msg = "ksubsite must be one of %s unlike %s " % ( katts(DetectorId), ksubsite ) 
00036             log.fatal(msg)
00037             raise Exception(msg)
00038   
00039         self.table = table
00040         self.site = site
00041         self.subsite = subsite
00042         self.sitemask = site      ## always single site assumption
00043         self.attjoin = attjoin
00044         self.pfxjoin = pfxjoin
00045         if (name == 'name'):
00046             self.name = table
00047         else:
00048             self.name = name
00049 
00050         if self.isjoin:
00051             tabs = self.table.split(":")
00052             assert len(tabs) == 2, "join requires 2 colon delimited tablenames "


Member Function Documentation

def Scraper::base::sourcecontext::SourceContext::__repr__ (   self)

Definition at line 58 of file sourcecontext.py.

00059                       :
00060         return "%s('%s','%s','%s', attjoin='%s', pfxjoin='%s', name='%s')" % ( self.__class__.__name__ , self.table, self.ksite , self.ksubsite, self.attjoin, self.pfxjoin, self.name)  

def Scraper::base::sourcecontext::SourceContext::__str__ (   self)

Definition at line 61 of file sourcecontext.py.

00062                      :
00063         return self.table

def Scraper::base::sourcecontext::SourceContext::jbits (   self)

Definition at line 64 of file sourcecontext.py.

00065                    :
00066         assert self.isjoin
00067         a,b = self.table.split(":")
00068         j  = self.attjoin
00069         tb = self.pfxjoin   ## tiebreaker prefix to avoid name collisions 
00070         xa = SourceContext( a , self.ksite, self.ksubsite )
00071         xb = SourceContext( b , self.ksite, self.ksubsite )
00072         return xa,xb,j,tb
00073 


Member Data Documentation

Definition at line 22 of file sourcecontext.py.

Definition at line 22 of file sourcecontext.py.

Definition at line 22 of file sourcecontext.py.

Definition at line 22 of file sourcecontext.py.

always single site assumption

Definition at line 23 of file sourcecontext.py.

Definition at line 23 of file sourcecontext.py.

Definition at line 23 of file sourcecontext.py.


Property Documentation

Scraper::base::sourcecontext::SourceContext::isjoin = property(lambda self:self.table.find(":")>-1 ) [static]

Definition at line 53 of file sourcecontext.py.

Scraper::base::sourcecontext::SourceContext::kln = property(lambda self:'Y%s' % self.name ) [static]

Definition at line 54 of file sourcecontext.py.

Scraper::base::sourcecontext::SourceContext::ksite = property(lambda self:'k%s' % Site.AsString(self.site) ) [static]

Definition at line 55 of file sourcecontext.py.

Scraper::base::sourcecontext::SourceContext::ksubsite = property(lambda self:'k%s' % DetectorId.AsString(self.subsite) ) [static]

Definition at line 56 of file sourcecontext.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