Skip to content

Commit

Permalink
[offline-renderer] ensure correct binary representation
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Hall <hsw@openmoko.com>
  • Loading branch information
hxw committed Apr 8, 2010
1 parent 77b2b07 commit 178c4ab
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions host-tools/offline-renderer/ArticleIndex.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ def output_fnd(filename, article_index, language_processor, truncate_title):


PrintLog.message(u'Writing bigrams: {0:s}'.format(filename)) PrintLog.message(u'Writing bigrams: {0:s}'.format(filename))
start_time = time.time() start_time = time.time()
out_f = open(filename, 'w') out_f = open(filename, 'wb')


sortedgram = [ (value, key) for key, value in bigram.iteritems() ] sortedgram = [ (value, key) for key, value in bigram.iteritems() ]
sortedgram.sort() sortedgram.sort()
Expand Down Expand Up @@ -654,7 +654,7 @@ def output_fnd(filename, article_index, language_processor, truncate_title):
if utf8_common_length > 1: if utf8_common_length > 1:
utf8_title = chr(utf8_common_length - 1) + utf8_title[utf8_common_length:] utf8_title = chr(utf8_common_length - 1) + utf8_title[utf8_common_length:]


out_f.write(struct.pack('I', article_number) + '\0' + bigram_title + '\0' + utf8_title + '\0') out_f.write(struct.pack('<I', article_number) + '\0' + bigram_title + '\0' + utf8_title + '\0')


out_f.close() out_f.close()
PrintLog.message(u'Time: {0:7.1f}s'.format(time.time() - start_time)) PrintLog.message(u'Time: {0:7.1f}s'.format(time.time() - start_time))
Expand All @@ -678,7 +678,7 @@ def output_pfx(filename):


PrintLog.message(u'Writing: {0:s}'.format(filename)) PrintLog.message(u'Writing: {0:s}'.format(filename))
start_time = time.time() start_time = time.time()
out_f = open(filename, 'w') out_f = open(filename, 'wb')
list = '\0' + SearchKey.all_characters() list = '\0' + SearchKey.all_characters()
for k1 in list: for k1 in list:
for k2 in list: for k2 in list:
Expand All @@ -688,7 +688,7 @@ def output_pfx(filename):
offset = index_matrix[key] offset = index_matrix[key]
else: else:
offset = 0 offset = 0
out_f.write(struct.pack('I', offset)) out_f.write(struct.pack('<I', offset))


out_f.close() out_f.close()
PrintLog.message(u'Time: {0:7.1f}s'.format(time.time() - start_time)) PrintLog.message(u'Time: {0:7.1f}s'.format(time.time() - start_time))
Expand Down

0 comments on commit 178c4ab

Please sign in to comment.