@@ -11,55 +11,15 @@ def is_enabled(self):
1111
1212 def run (self , edit , prop_name = None , choices = None , caption = None ):
1313 self .window = self .view .window ()
14- if not prop_name :
15- self .window .open_file (self .project .json_path , sublime .TRANSIENT )
16- return
17- self .prop_name = prop_name
18- initial_value = getattr (self .project , prop_name )
19- if choices :
20- self .show_choices (choices , initial_value )
21- else :
22- self .window .show_input_panel (caption , initial_value , self .on_finished , None , None )
23-
24- def show_choices (self , choices , initial_value ):
25- self .norm_choices = [choice .lower () for choice in choices ]
26- try :
27- # ValueError: $initial_value is not in list
28- initial_index = self .norm_choices .index (initial_value .lower ())
29- # ST2: Boost.Python.ArgumentError: Python argument types
30- self .window .show_quick_panel (choices , self .on_choice , selected_index = initial_index )
31- except : # simplest control flow
32- if not is_ST2 ():
33- log_string ('project.logging.invalid_choice' , initial_value )
34- self .window .show_quick_panel (choices , self .on_choice )
35-
36- def on_choice (self , index ):
37- if index != - 1 :
38- self .on_finished (self .norm_choices [index ])
39-
40- def on_finished (self , value ):
41- setattr (self .project , self .prop_name , value )
42- keys = self .project ._last_updated_key_path
43- if keys :
44- sublime .status_message (get_string ('project.updated' , '.' .join (keys ), value ))
45-
46- BUILD_KEY = ('sublime-build' ,)
47- MAIN_KEY = BUILD_KEY + ('main' ,)
48- HTML_KEY = BUILD_KEY + ('html' ,)
49- OUTPUT_KEY = BUILD_KEY + ('output' ,)
50- OUTPUT_PATH_KEY = OUTPUT_KEY + ('path' ,)
51- OUTPUT_COMP_KEY = OUTPUT_KEY + ('components' ,)
52- OUTPUT_DIR_KEY = OUTPUT_COMP_KEY + ('dir' ,)
53- OUTPUT_NAME_KEY = OUTPUT_COMP_KEY + ('name' ,)
54- OUTPUT_EXT_KEY = OUTPUT_COMP_KEY + ('ext' ,)
14+ self .window .open_file (self .project .json_path , sublime .TRANSIENT )
5515
5616class ElmProject (object ):
5717
5818 @classmethod
5919 def find_json (cls , dir_path ):
6020 if not fs .isdir (fs .abspath (dir_path )):
6121 return None
62- file_path = fs .abspath (fs .join (dir_path , 'elm-package .json' ))
22+ file_path = fs .abspath (fs .join (dir_path , 'elm.json' ))
6323 if fs .isfile (file_path ):
6424 return file_path
6525 parent_path = fs .join (dir_path , fs .pardir )
@@ -128,52 +88,3 @@ def exists(self):
12888 @property
12989 def working_dir (self ):
13090 return fs .dirname (self .json_path ) if self .json_path else None
131-
132- @property
133- def main_path (self ):
134- return self [MAIN_KEY ] or fs .relpath (self .file_path , self .working_dir )
135-
136- @main_path .setter
137- def main_path (self , value ):
138- self [MAIN_KEY ] = value
139-
140- @property
141- def html_path (self ):
142- return self [HTML_KEY ] or self .output_path
143-
144- @html_path .setter
145- def html_path (self , value ):
146- self [HTML_KEY ] = value
147-
148- @property
149- def output_path (self ):
150- output_path = fs .join (self .output_dir , self .output_name + '.' + self .output_ext )
151- return self [OUTPUT_PATH_KEY ] or fs .normpath (output_path )
152-
153- @output_path .setter
154- def output_path (self , value ):
155- self [OUTPUT_PATH_KEY ] = value
156-
157- @property
158- def output_dir (self ):
159- return self [OUTPUT_DIR_KEY ] or 'build'
160-
161- @output_dir .setter
162- def output_dir (self , value ):
163- self [OUTPUT_DIR_KEY ] = value
164-
165- @property
166- def output_name (self ):
167- return self [OUTPUT_NAME_KEY ] or fs .splitext (fs .basename (self .main_path ))[0 ]
168-
169- @output_name .setter
170- def output_name (self , value ):
171- self [OUTPUT_NAME_KEY ] = value
172-
173- @property
174- def output_ext (self ):
175- return self [OUTPUT_EXT_KEY ] or 'html'
176-
177- @output_ext .setter
178- def output_ext (self , value ):
179- self [OUTPUT_EXT_KEY ] = value
0 commit comments