From 410f0c5852f209c7ff35df1cb5747d2fa77f96c5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?G=C3=BCnter=20Milde?= Date: Tue, 4 Apr 2017 12:21:28 +0200 Subject: [PATCH] Kleine Fixes der Python-Skripte. --- skripte/python/edit_tools/abgleich_neueintraege.py | 3 +-- skripte/python/edit_tools/umformatierung.py | 2 +- skripte/python/edit_tools/wortliste.py | 10 +++++++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/skripte/python/edit_tools/abgleich_neueintraege.py b/skripte/python/edit_tools/abgleich_neueintraege.py index 3eb1df3..1843c39 100755 --- a/skripte/python/edit_tools/abgleich_neueintraege.py +++ b/skripte/python/edit_tools/abgleich_neueintraege.py @@ -849,7 +849,7 @@ if __name__ == '__main__': # Umschreiben in Dictionary, Aussortieren von Abkürzungen words = dict() for entry in wordfile: - if u'Abk.' in entry.comment: + if not entry or u'Abk.' in entry.comment: continue words[entry[0]] = entry @@ -870,7 +870,6 @@ if __name__ == '__main__': words.pop(unwort, None) - # Erstellen der neuen Einträge:: neue = [] diff --git a/skripte/python/edit_tools/umformatierung.py b/skripte/python/edit_tools/umformatierung.py index 7a8cdcc..784f321 100755 --- a/skripte/python/edit_tools/umformatierung.py +++ b/skripte/python/edit_tools/umformatierung.py @@ -119,7 +119,7 @@ from split_wortliste import split_a_z, write_a_z def convert_lines(lines, long2short=False): entries_dict = {} # zum Zusammenfassen - entries = [] # Kommentare als String, Einträge als WordEntry + entries = [] # for line in lines: # Dekodieren, Zeilenende entfernen diff --git a/skripte/python/edit_tools/wortliste.py b/skripte/python/edit_tools/wortliste.py index 0af08ad..82e78e6 100755 --- a/skripte/python/edit_tools/wortliste.py +++ b/skripte/python/edit_tools/wortliste.py @@ -690,13 +690,17 @@ class WordEntry(list): o_i = u'' else: conflict = True + # self.comment = other.comment or self.comment + if self.comment != other.comment: + conflict = True + if prune: other.prune() self.prune() + if conflict: raise AssertionError(u'Merge Error:\n %s\n %s ' % (unicode(self), unicode(other))) - self.comment = other.comment or self.comment # Prüfe auf Vorkommen von Regeländerungen der Orthographiereform 1996. @@ -956,6 +960,8 @@ class ShortEntry(WordEntry): # Löss=bo-den;-2-;Löss=bo-den;Löss=bo-den;Löss=bo-den # >>> print ShortEntry(WordEntry(u'Amnesty;Am-nes-ty # en.')) # Am-nes-ty;Am-nes-ty # en. +# >>> print ShortEntry(WordEntry(u'# nur Kommentar')) +# # nur Kommentar # # :: @@ -1200,6 +1206,8 @@ class ShortEntry(WordEntry): # print tag, repr(self), wort, rekonstruktion self.append(wort) return + if len(self) == 1 and not self[0]: + self.pop() # Einträge zusammenfassen -- 2.11.4.GIT