@@ -22,18 +22,21 @@ def __init__(self, window):
2222 else :
2323 self .platform = NixPlatform ()
2424
25-
2625 def __generate_default_root (self ):
27- default_root = self .__get_default_root (self .settings .get (DEFAULT_ROOT_SETTING ))
26+ default_root = self .__get_default_root (
27+ self .settings .get (DEFAULT_ROOT_SETTING ))
2828 if default_root == "path" :
29- self .root = os .path .expanduser (self .settings .get (DEFAULT_PATH_SETTING ))
29+ self .root = os .path .expanduser (
30+ self .settings .get (DEFAULT_PATH_SETTING ))
3031 default_root = ""
3132 return self .split_path (default_root )
3233
3334 def __generate_alias_root (self ):
34- alias_root = self .__get_default_root (self .settings .get (ALIAS_ROOT_SETTING ), True )
35+ alias_root = self .__get_default_root (
36+ self .settings .get (ALIAS_ROOT_SETTING ), True )
3537 if alias_root == "path" :
36- self .alias_root = os .path .expanduser (self .settings .get (ALIAS_PATH_SETTING ))
38+ self .alias_root = os .path .expanduser (
39+ self .settings .get (ALIAS_PATH_SETTING ))
3740 alias_root = ""
3841 return self .split_path (alias_root , True )
3942
@@ -81,7 +84,8 @@ def __get_aliases(self):
8184 def __get_default_root (self , string , is_alias = False ):
8285 root = ""
8386 self .alias_folder_index = self .settings .get (ALIAS_FOLDER_INDEX_SETTING )
84- self .default_folder_index = self .settings .get (DEFAULT_FOLDER_INDEX_SETTING )
87+ self .default_folder_index = self .settings .get (
88+ DEFAULT_FOLDER_INDEX_SETTING )
8589 if string == "home" :
8690 root = "~/"
8791 elif string == "current" :
@@ -110,7 +114,7 @@ def split_path(self, path="", is_alias=False):
110114 try :
111115 root , path = self .platform .split (path )
112116 # Parse if alias
113- if TOP_LEVEL_SPLIT_CHAR in path and root == None :
117+ if TOP_LEVEL_SPLIT_CHAR in path and root is None :
114118 parts = path .rsplit (TOP_LEVEL_SPLIT_CHAR , 1 )
115119 root , path = self .__translate_alias (parts [0 ])
116120 path_list = []
@@ -123,10 +127,11 @@ def split_path(self, path="", is_alias=False):
123127 root , path_offset = self .platform .parse_nix_path (root , path )
124128 path = path [path_offset :]
125129 # Parse if tilde used
126- elif re .match (HOME_REGEX , path ) and root == None :
130+ elif re .match (HOME_REGEX , path ) and root is None :
127131 root = os .path .expanduser ("~" )
128132 path = path [2 :]
129- elif re .match (r"^\.{1,2}[/\\]" , path ) and self .settings .get (RELATIVE_FROM_CURRENT_SETTING , False ):
133+ elif (re .match (r"^\.{1,2}[/\\]" , path ) and
134+ self .settings .get (RELATIVE_FROM_CURRENT_SETTING , False )):
130135 path_index = 2
131136 root = os .path .dirname (self .view .file_name ())
132137 if re .match (r"^\.{2}[/\\]" , path ):
@@ -135,7 +140,7 @@ def split_path(self, path="", is_alias=False):
135140 path = path [path_index :]
136141
137142 # Default
138- if root == None :
143+ if root is None :
139144 if is_alias :
140145 root = self .alias_root
141146 folder_index = self .alias_folder_index
@@ -160,9 +165,10 @@ def __translate_alias(self, path):
160165 join_index = len (split_path ) - 1
161166 target = path
162167 root_found = False
168+ use_folder_name = self .settings .get (USE_FOLDER_NAME_SETTING )
163169 while join_index >= 0 and not root_found :
164170 # Folder aliases
165- for name , folder in get_project_folder_data (self . settings . get ( USE_FOLDER_NAME_SETTING ) ):
171+ for name , folder in get_project_folder_data (use_folder_name ):
166172 if name == target :
167173 root = folder
168174 root_found = True
@@ -172,7 +178,8 @@ def __translate_alias(self, path):
172178 if alias == target :
173179 alias_path = self .aliases .get (alias )
174180 if re .search (HOME_REGEX , alias_path ) is None :
175- root = self .platform .get_alias_absolute_path (self .alias_root , alias_path )
181+ root = self .platform .get_alias_absolute_path (
182+ self .alias_root , alias_path )
176183 if root is not None :
177184 break
178185 root = os .path .expanduser (alias_path )
@@ -189,7 +196,8 @@ def __translate_alias(self, path):
189196 else :
190197 # Add to index so we re
191198 join_index += 2
192- return os .path .abspath (root ), TOP_LEVEL_SPLIT_CHAR .join (split_path [join_index :])
199+ return (os .path .abspath (root ),
200+ TOP_LEVEL_SPLIT_CHAR .join (split_path [join_index :]))
193201
194202 def input_panel_caption (self ):
195203 return ""
@@ -201,7 +209,8 @@ def show_filename_input(self, initial):
201209 )
202210
203211 self .input_panel_view .set_name (VIEW_NAME )
204- self .input_panel_view .settings ().set ("auto_complete_commit_on_tab" , False )
212+ self .input_panel_view .settings ().set ("auto_complete_commit_on_tab" ,
213+ False )
205214 self .input_panel_view .settings ().set ("tab_completion" , False )
206215 self .input_panel_view .settings ().set ("translate_tabs_to_spaces" , False )
207216 self .input_panel_view .settings ().set ("anf_panel" , True )
@@ -215,11 +224,13 @@ def __update_filename_input(self, path_in):
215224 if path_in .endswith ("\t " ):
216225 new_content = self .completion .completion (path_in .replace ("\t " , "" ))
217226 if new_content != path_in :
218- self .input_panel_view .run_command ("anf_replace" , {"content" : new_content })
227+ self .input_panel_view .run_command ("anf_replace" ,
228+ {"content" : new_content })
219229 else :
220230 base , path = self .split_path (path_in )
221231
222- creation_path = generate_creation_path (self .settings , base , path , True )
232+ creation_path = generate_creation_path (self .settings , base , path ,
233+ True )
223234 if self .settings .get (SHOW_PATH_SETTING , False ):
224235 self .update_status_message (creation_path )
225236
@@ -249,9 +260,9 @@ def entered_filename(self, filename):
249260 base , path = self .split_path (filename )
250261 file_path = generate_creation_path (self .settings , base , path , True )
251262 # Check for invalid alias specified.
252- if TOP_LEVEL_SPLIT_CHAR in filename and \
253- not ( PLATFORM == "windows" and re . match ( WIN_ROOT_REGEX , base )) and \
254- not ( PLATFORM != "windows" and re . match ( NIX_ROOT_REGEX , base )) :
263+ is_valid = ( TOP_LEVEL_SPLIT_CHAR in filename and
264+ self . platform . is_absolute_path ( base ))
265+ if is_valid :
255266 if base == "" :
256267 error_message = "Current file cannot be resolved."
257268 else :
@@ -264,7 +275,8 @@ def open_file(self, file_path):
264275 new_view = None
265276 if os .path .isdir (file_path ):
266277 if not re .search (r"(/|\\)$" , file_path ):
267- sublime .error_message ("Cannot open view for '" + file_path + "'. It is a directory. " )
278+ sublime .error_message ("Cannot open view for '" + file_path +
279+ "'. It is a directory. " )
268280 else :
269281 new_view = self .window .open_file (file_path )
270282 return new_view
@@ -277,7 +289,7 @@ def refresh_sidebar(self):
277289 pass
278290
279291 def clear (self ):
280- if self .view != None :
292+ if self .view is not None :
281293 self .view .erase_status ("AdvancedNewFile" )
282294 self .view .erase_status ("AdvancedNewFile2" )
283295
@@ -313,14 +325,13 @@ def create_folder(self, path):
313325 if self .is_python :
314326 creation_path = os .path .join (entry , '__init__.py' )
315327 open (creation_path , 'a' ).close ()
316- if file_permissions != "" :
328+ if file_permissions != "" :
317329 os .chmod (creation_path , int (file_permissions , 8 ))
318- if folder_permissions != "" :
330+ if folder_permissions != "" :
319331 os .chmod (entry , int (folder_permissions , 8 ))
320332
321-
322333 def get_cursor_path (self ):
323- if self .view == None :
334+ if self .view is None :
324335 return ""
325336
326337 view = self .view
@@ -337,7 +348,6 @@ def get_cursor_path(self):
337348
338349 return path
339350
340-
341351 def _find_open_file (self , file_name ):
342352 window = self .window
343353 if IS_ST3 :
0 commit comments