- self.conf = DoConf(self.filein)
- self.order = {}
- self.ordera = {}
- for i, section in enumerate(self.conf.conf.sections()) :
- if self.conf.conf.has_option(section, 'corpus_name') :
- self.corpora[section] = self.conf.getoptions(section)
- self.order[len(self.order)] = section
- else :
- self.analyses[section] = self.conf.getoptions(section)
- self.ordera[len(self.ordera)] = section
- todel = []
- for corpus in self.corpora :
- self.history[corpus] = copy(self.corpora[corpus])
- for analyse in self.analyses :
- if self.analyses[analyse]['corpus'] in self.corpora :
- if 'analyses' in self.history[self.analyses[analyse]['corpus']] :
- self.history[self.analyses[analyse]['corpus']]['analyses'].append(self.analyses[analyse])
- todel.append(analyse)
- else :
- self.history[self.analyses[analyse]['corpus']]['analyses'] = [self.analyses[analyse]]
- todel.append(analyse)
- else :
- self.history[analyse] = self.analyses[analyse]
- #for analyse in todel :
- # del self.analyses[analyse]
-
+ d = shelve.open(self.filein)
+ self.history = d.get('history', [])
+ self.ordercorpus = dict([[corpus['uuid'], i] for i, corpus in enumerate(self.history)])
+ self.corpus = dict([[corpus['uuid'], corpus] for i, corpus in enumerate(self.history)])
+ self.analyses = dict([[analyse['uuid'], analyse] for corpus in self.history for analyse in corpus.get('analyses', [])])
+ #corpusorder = d.get('corpusorder',[])
+ #self.analyseorder = d['analyseorder']
+ #self.order = [uuid for uuid in self.history]
+ #self.order = dict([[i, uuid] for i, uuid in enumerate(self.order)])
+ #self.order = dict([[i, corpus] for i, corpus in enumerate(corpusorder)])
+ #for uuid in self.history :
+ # if 'corpus_name' in self.history[uuid] :
+ # self.corpora[uuid] = self.history[uuid]
+ d.close()
+
+# def read(self) :
+# self.conf = DoConf(self.filein)
+# self.order = {}
+# self.ordera = {}
+# for i, section in enumerate(self.conf.conf.sections()) :
+# if self.conf.conf.has_option(section, 'corpus_name') :
+# self.corpora[section] = self.conf.getoptions(section)
+# self.order[len(self.order)] = section
+# else :
+# self.analyses[section] = self.conf.getoptions(section)
+# self.ordera[len(self.ordera)] = section
+# todel = []
+# for corpus in self.corpora :
+# self.history[corpus] = copy(self.corpora[corpus])
+# for analyse in self.analyses :
+# if self.analyses[analyse]['corpus'] in self.corpora :
+# if 'analyses' in self.history[self.analyses[analyse]['corpus']] :
+# self.history[self.analyses[analyse]['corpus']]['analyses'].append(self.analyses[analyse])
+# todel.append(analyse)
+# else :
+# self.history[self.analyses[analyse]['corpus']]['analyses'] = [self.analyses[analyse]]
+# todel.append(analyse)
+# else :
+# self.history[analyse] = self.analyses[analyse]
+# #for analyse in todel :
+# # del self.analyses[analyse]