コード例 #1
0
    def get_or_create(self, dte, rjson, inthread=False):
        '''
        Create or return an element associated with date 'dte'
        dte      date
        rjson    boolean. If true a check on timestamp is performed
        '''
        dte = get_livedate(dte)
        dt = dte.dateonly

        if rjson:
            lm = self.lastmodified()
            if lm > self.timestamp:
                self.timestamp = now()
                self.ts = dateseries()

        # thread safe creation
        self.__lock.acquire()
        try:
            if self.has_key(dt):
                return self.ts[dt]
            else:
                res = self.create(dte)
                if res:
                    self.ts[dt] = res
                self.build(res, inthread)
                return res
        except Exception, e:
            self.err(e)
            return None
コード例 #2
0
ファイル: tscache.py プロジェクト: OspreyX/flow
 def get_or_create(self, dte, rjson, inthread = False):
     '''
     Create or return an element associated with date 'dte'
     dte      date
     rjson    boolean. If true a check on timestamp is performed
     '''
     dte = get_livedate(dte)
     dt  = dte.dateonly
     
     if rjson:
         lm  = self.lastmodified()
         if lm > self.timestamp:
             self.timestamp = now()
             self.ts        = dateseries()
     
     # thread safe creation
     self.__lock.acquire()
     try:
         if self.has_key(dt):
             return self.ts[dt]
         else:
             res = self.create(dte)
             if res:
                 self.ts[dt] = res
             self.build(res,inthread)
             return res
     except Exception, e:
         self.err(e)
         return None
コード例 #3
0
    def timeseries(self, vfid):
        '''        
        @param vfid: vendor field id
        @see: jflow.core.rates.factory.factory.vendorfieldid 
        '''
        key = self.tsname(vfid)
        nts = self._timeseries.get(key, None)

        if nts == None:
            fts = self.backend.get(key, [])
            if vfid.numeric:
                nts = numericts(key)
            else:
                nts = dateseries(key)

            for d, v in fts:
                nts[todate(d)] = v

            self._timeseries[key] = nts

        return nts
コード例 #4
0
ファイル: cache.py プロジェクト: OspreyX/flow
 def timeseries(self, vfid):
     '''        
     @param vfid: vendor field id
     @see: jflow.core.rates.factory.factory.vendorfieldid 
     '''
     key    = self.tsname(vfid)
     nts    = self._timeseries.get(key,None)
          
     if nts == None:
         fts  = self.backend.get(key,[])
         if vfid.numeric:
             nts = numericts(key)
         else:
             nts = dateseries(key)
         
         for d,v in fts:
             nts[todate(d)] = v
         
         self._timeseries[key] = nts
                         
     return nts
コード例 #5
0
 def __init__(self, code, cache):
     super(CacheElement, self).__init__(cache)
     self.timestamp = now()
     self.ts = dateseries()
     self.object = self.get_object(code)
     self.__lock = Lock()
コード例 #6
0
ファイル: tscache.py プロジェクト: OspreyX/flow
 def __init__(self, code, cache):
     super(CacheElement,self).__init__(cache)
     self.timestamp = now()
     self.ts        = dateseries()
     self.object    = self.get_object(code)
     self.__lock    = Lock()