Commit 1e1ff0c826d48da59a9a4af2d0a2ecfae719721d

Authored by janek37
1 parent e55be3df

import korzysta z istniejących części mowy

dictionary/management/commands/import_data.py
... ... @@ -160,9 +160,11 @@ class ImportData(object):
160 160  
161 161  
162 162 def new_lexical_classes(self):
163   - yield LexicalClass(symbol=OTHER)
  163 + if not LexicalClass.objects.filter(symbol=OTHER).exists():
  164 + yield LexicalClass(symbol=OTHER)
164 165 for row in self.sqlite_cursor.execute('select distinct pos from wzory'):
165   - yield LexicalClass(symbol=row['pos'])
  166 + if not LexicalClass.objects.filter(symbol=row['pos']).exists():
  167 + yield LexicalClass(symbol=row['pos'])
166 168  
167 169 def cache_lc(self):
168 170 if 'lc' not in self.__dict__:
... ... @@ -176,13 +178,14 @@ class ImportData(object):
176 178 lcs[row[1]] = row[0]
177 179  
178 180 for row in self.sqlite_cursor.execute('SELECT * FROM klasygramatyczne'):
179   - lc = lcs.get(row['pos'], OTHER)
180   - yield PartOfSpeech(
181   - symbol=row['pos'],
182   - full_name=row['nazwakl'],
183   - index=row['klporz'],
184   - color_scheme=row['posind'],
185   - lexical_class = LexicalClass.objects.get(symbol=lc))
  181 + if not PartOfSpeech.objects.filter(symbol=row['pos']).exists():
  182 + lc = lcs.get(row['pos'], OTHER)
  183 + yield PartOfSpeech(
  184 + symbol=row['pos'],
  185 + full_name=row['nazwakl'],
  186 + index=row['klporz'],
  187 + color_scheme=row['posind'],
  188 + lexical_class = LexicalClass.objects.get(symbol=lc))
186 189  
187 190 def cache_pos(self):
188 191 if 'pos' not in self.__dict__:
... ... @@ -592,8 +595,8 @@ class ImportData(object):
592 595 #Vocabulary,
593 596 InflectionCharacteristic,
594 597 BaseFormLabel,
595   - PartOfSpeech,
596   - LexicalClass,
  598 + #PartOfSpeech,
  599 + #LexicalClass,
597 600 )
598 601 print 'deleting old data...'
599 602 for model in models:
... ...