コード例 #1
0
 def load_or_save_patterns(self, patterns=None):
     ''' Get (if patterns is None) or Set the patterns in the database
         in & out = dictionary
     ''' 
     key = 'api.textseg.%s.patterns' % slugify(unicode(self.namespace))
     if patterns:
         KeyVal.setjs(key, patterns)
     else:
         patterns = KeyVal.getjs(key)
     self.patterns = patterns
     return patterns
コード例 #2
0
ファイル: patterns.py プロジェクト: suzypiat/digipal
 def load_or_save_patterns(self, patterns=None):
     ''' Get (if patterns is None) or Set the patterns in the database
         in & out = dictionary
     '''
     key = 'api.textseg.%s.patterns' % slugify(unicode(self.namespace))
     if patterns:
         KeyVal.setjs(key, patterns)
     else:
         patterns = KeyVal.getjs(key)
     self.patterns = patterns
     return patterns
コード例 #3
0
ファイル: search_indexer.py プロジェクト: kcl-ddh/digipal
    def write_state(self, state):
        state['updated'] = datetime.now()
        state['progress'] = 1.0 * sum([idx['progress']
                                       for idx in state['indexes'].values()]) / len(state['indexes'].keys())
        state['state'] = None
        for idx in state['indexes'].values():
            if idx['progress'] == 0.0:
                idx['state'] = 'queued'
            if idx['progress'] > 0.0:
                idx['state'] = 'indexing'
            if idx['progress'] == 1.0:
                idx['state'] = 'indexed'
            if state['state'] not in [None, idx['state']]:
                state['state'] = 'indexing'
            else:
                state['state'] = idx['state']

        # json conversion doesn't understand python dates
        self.convert_state_dates_to_strings(state)
        # print '-' * 20
        # print state
        KeyVal.setjs('indexer', state)
        self.convert_state_dates_to_objects(state)
コード例 #4
0
ファイル: search_indexer.py プロジェクト: kcl-ddh/digipal
    def write_state(self, state):
        state["updated"] = datetime.now()
        state["progress"] = (
            1.0 * sum([idx["progress"] for idx in state["indexes"].values()]) / len(state["indexes"].keys())
        )
        state["state"] = None
        for idx in state["indexes"].values():
            if idx["progress"] == 0.0:
                idx["state"] = "queued"
            if idx["progress"] > 0.0:
                idx["state"] = "indexing"
            if idx["progress"] == 1.0:
                idx["state"] = "indexed"
            if state["state"] not in [None, idx["state"]]:
                state["state"] = "indexing"
            else:
                state["state"] = idx["state"]

        # json conversion doesn't understand python dates
        self.convert_state_dates_to_strings(state)
        # print '-' * 20
        # print state
        KeyVal.setjs("indexer", state)
        self.convert_state_dates_to_objects(state)
コード例 #5
0
ファイル: search_indexer.py プロジェクト: suzypiat/digipal
    def write_state(self, state):
        state['updated'] = datetime.now()
        state['progress'] = 1.0 * sum([
            idx['progress'] for idx in state['indexes'].values()
        ]) / len(state['indexes'].keys())
        state['state'] = None
        for idx in state['indexes'].values():
            if idx['progress'] == 0.0:
                idx['state'] = 'queued'
            if idx['progress'] > 0.0:
                idx['state'] = 'indexing'
            if idx['progress'] == 1.0:
                idx['state'] = 'indexed'
            if state['state'] not in [None, idx['state']]:
                state['state'] = 'indexing'
            else:
                state['state'] = idx['state']

        # json conversion doesn't understand python dates
        self.convert_state_dates_to_strings(state)
        # print '-' * 20
        # print state
        KeyVal.setjs('indexer', state)
        self.convert_state_dates_to_objects(state)
コード例 #6
0
ファイル: search_indexer.py プロジェクト: kcl-ddh/digipal
 def read_state(self):
     ret = KeyVal.getjs("indexer")
     self.convert_state_dates_to_objects(ret)
     return ret
コード例 #7
0
ファイル: search_indexer.py プロジェクト: kcl-ddh/digipal
 def clear_state(self):
     KeyVal.setjs('indexer', {})
コード例 #8
0
ファイル: search_indexer.py プロジェクト: suzypiat/digipal
 def read_state(self):
     ret = KeyVal.getjs('indexer')
     self.convert_state_dates_to_objects(ret)
     return ret
コード例 #9
0
ファイル: search_indexer.py プロジェクト: suzypiat/digipal
 def clear_state(self):
     KeyVal.setjs('indexer', {})