X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=m_librarian%2Finp.py;h=3789dd2e2d986c5969a7688d9651b8cfd2219095;hb=b9f69add9565dbf230080f82601b1d9b8c173cbe;hp=4b772aff703f050d69117e2ef1725eb575d157c8;hpb=24b8388fe8972e17c7982bbe0768eca2e54b8f1e;p=m_librarian.git diff --git a/m_librarian/inp.py b/m_librarian/inp.py index 4b772af..3789dd2 100644 --- a/m_librarian/inp.py +++ b/m_librarian/inp.py @@ -72,13 +72,20 @@ def import_inp_line(archive, parts): book.addGenre(genre_row) +def tounicode(s): + if isinstance(s, bytes): + return s.decode('utf-8') + else: + return s + + def import_inp(archive, inp): archives = set() files = set() connection = sqlhub.processConnection for file, in connection.queryAll(connection.sqlrepr( Select(Book.q.file, Book.q.archive == archive))): - files.add((archive, file)) + files.add((archive, tounicode(file))) for line in inp: line = line.decode('utf-8') _archive, parts = split_line(line) @@ -86,7 +93,7 @@ def import_inp(archive, inp): archives.add(_archive) for file, in connection.queryAll(connection.sqlrepr( Select(Book.q.file, Book.q.archive == _archive))): - files.add((_archive, file)) + files.add((_archive, tounicode(file))) file = parts[5] if (_archive or archive, file) not in files: files.add((_archive or archive, file))