<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import <EOL> from io import open <EOL> import os <EOL> import zipfile <EOL> from penelope . dictionary_ebook import DictionaryEbook <EOL> from penelope . utilities import create_temp_directory <EOL> from penelope . utilities import delete_directory <EOL> from penelope . utilities import print_debug <EOL> from penelope . utilities import print_error <EOL> from penelope . utilities import print_info <EOL> __author__ = "<STR_LIT>" <EOL> __copyright__ = "<STR_LIT>" <EOL> __license__ = "<STR_LIT>" <EOL> __version__ = "<STR_LIT>" <EOL> __email__ = "<STR_LIT>" <EOL> __status__ = "<STR_LIT>" <EOL> def read ( dictionary , args , input_file_paths ) : <EOL> print_error ( "<STR_LIT>" ) <EOL> return None <EOL> def write ( dictionary , args , output_file_path ) : <EOL> result = None <EOL> output_file_path_absolute = os . path . abspath ( output_file_path ) <EOL> dictionary . sort ( by_headword = True , ignore_case = args . sort_ignore_case ) <EOL> special_group , group_keys , group_dict = dictionary . group ( <EOL> prefix_function_path = args . group_by_prefix_function , <EOL> prefix_length = int ( args . group_by_prefix_length ) , <EOL> merge_min_size = int ( args . group_by_prefix_merge_min_size ) , <EOL> merge_across_first = args . group_by_prefix_merge_across_first <EOL> ) <EOL> all_group_keys = group_keys <EOL> if special_group is not None : <EOL> all_group_keys += [ u"<STR_LIT>" ] <EOL> epub = DictionaryEbook ( ebook_format = DictionaryEbook . EPUB2 , args = args ) <EOL> for key in all_group_keys : <EOL> if key == u"<STR_LIT>" : <EOL> group_entries = special_group <EOL> else : <EOL> group_entries = group_dict [ key ] <EOL> epub . add_group ( key , group_entries ) <EOL> if args . epub_no_compress : <EOL> print_debug ( "<STR_LIT>" ) <EOL> epub . write ( output_file_path_absolute , compress = False ) <EOL> else : <EOL> print_debug ( "<STR_LIT>" % ( output_file_path_absolute ) , args . debug ) <EOL> epub . write ( output_file_path_absolute , compress = True ) <EOL> result = [ output_file_path ] <EOL> print_debug ( "<STR_LIT>" % ( output_file_path_absolute ) , args . debug ) <EOL> tmp_path = epub . get_tmp_path ( ) <EOL> if args . epub_no_compress : <EOL> print_info ( "<STR_LIT>" % ( tmp_path ) ) <EOL> result = [ tmp_path ] <EOL> elif args . keep : <EOL> print_info ( "<STR_LIT>" % ( tmp_path ) ) <EOL> if result is None : <EOL> result = [ tmp_path ] <EOL> else : <EOL> epub . delete ( ) <EOL> print_debug ( "<STR_LIT>" % ( tmp_path ) , args . debug ) <EOL> return result </s>
