<s> import sublime <EOL> import json <EOL> from . base import CreateBaseCommand <EOL> from elasticsearch . helpers import scan <EOL> class HelperDumpIndexDataCommand ( CreateBaseCommand ) : <EOL> command_name = "<STR_LIT>" <EOL> def is_enabled ( self ) : <EOL> return True <EOL> def show_input_filename ( self , label , default , index , callback ) : <EOL> def on_done ( filename ) : <EOL> callback ( index = index , filename = filename ) <EOL> self . window . show_input_panel ( label , default , on_done , None , None ) <EOL> def save_filename ( self , filename ) : <EOL> self . settings . set ( "<STR_LIT>" , filename ) <EOL> self . settings . save ( ) <EOL> def run_request ( self , index = None , filename = None ) : <EOL> if not index : <EOL> self . show_index_list_panel ( self . run ) <EOL> return <EOL> if not filename : <EOL> self . show_input_filename ( <EOL> "<STR_LIT>" , self . settings . dump_file , index , self . run ) <EOL> return <EOL> options = dict ( <EOL> index = index , <EOL> scroll = self . settings . scroll_size <EOL> ) <EOL> count = <NUM_LIT:0> <EOL> with open ( filename , encoding = '<STR_LIT:utf-8>' , mode = '<STR_LIT:w>' ) as f : <EOL> for doc in scan ( self . client , ** options ) : <EOL> del doc [ '<STR_LIT>' ] <EOL> doc = "<STR_LIT>" . format ( json . dumps ( doc , ensure_ascii = False ) ) <EOL> f . write ( doc ) <EOL> count += <NUM_LIT:1> <EOL> sublime . status_message ( "<STR_LIT>" . format ( count ) ) <EOL> self . save_filename ( filename ) <EOL> return dict ( <EOL> command = self . command_name , <EOL> index = index , <EOL> filename = filename , <EOL> status = "<STR_LIT>" , <EOL> docs = count <EOL> ) </s>
