33# @Author: lime
44# @Date: 2013-10-28 13:39:48
55# @Last Modified by: Lime
6- # @Last Modified time: 2015-01-12 09:51:33
6+ # @Last Modified time: 2015-09-10 10:47:07
77
88import os
99import sys
3838
3939sys .path .insert (0 , PLUGIN_PATH )
4040
41+
4142def plugin_loaded ():
4243 '''ST3'''
4344
@@ -113,7 +114,7 @@ def get_template_part(syntax_type, part):
113114 template_file = open (tmpl_file , 'r' )
114115 contents = template_file .read ()
115116 template_file .close ()
116- except Exception as e :
117+ except :
117118 contents = ''
118119 return contents
119120
@@ -237,7 +238,7 @@ def get_st2_time():
237238 'last_modified_time' : m_time .strftime (format ),
238239 'file_name' : file_name ,
239240 'file_name_without_extension' : file_name_without_extension ,
240- 'file_path' : file_path
241+ 'file_path' : file_path
241242 })
242243
243244 if IS_ST3 :
@@ -348,7 +349,7 @@ def new_file(self, path, syntax_type):
348349
349350 try :
350351 block (new_file ,
351- new_file .set_syntax_file , get_syntax_file (syntax_type ))
352+ new_file .set_syntax_file , get_syntax_file (syntax_type ))
352353 except :
353354 pass
354355
@@ -412,7 +413,7 @@ def __init__(self, path):
412413
413414 def run (self ):
414415 syntax_type = get_syntax_type (self .path )
415- header = render_template (syntax_type , 'header' , {'path' : path })
416+ header = render_template (syntax_type , 'header' , {'path' : self . path })
416417
417418 try :
418419 with open (self .path , 'r' ) as f :
@@ -474,7 +475,6 @@ def can_add_to_dir(path):
474475 if not os .path .exists (path ):
475476 return False
476477
477- file_suffix_mapping = Settings ().get ('file_suffix_mapping' )
478478 enable_add_to_hidden_dir = Settings ().get (
479479 'enable_add_header_to_hidden_dir' )
480480 enable_add_to_hidden_file = Settings ().get (
@@ -548,8 +548,9 @@ def run(self, paths=[]):
548548 return
549549
550550 Window ().run_command ('hide_panel' )
551- Window ().show_input_panel ('Modified File or Directory:' , initial_text ,
552- self .on_done , None , None )
551+ Window ().show_input_panel (
552+ 'Modified File or Directory:' ,
553+ initial_text , self .on_done , None , None )
553554
554555
555556class FileHeaderReplaceCommand (sublime_plugin .TextCommand ):
@@ -566,8 +567,8 @@ def run(self, edit, a, b, strings):
566567FILE_NAME_WITHOUT_EXTENSION = 'FILE_NAME_WITHOUT_EXTENSION'
567568FILE_PATH = 'FILE_PATH'
568569
569- class FileHeaderListener (sublime_plugin .EventListener ):
570570
571+ class FileHeaderListener (sublime_plugin .EventListener ):
571572 LAST_MODIFIED_BY_REGEX = re .compile ('\{\{\s*last_modified_by\s*\}\}' )
572573 LAST_MODIFIED_TIME_REGEX = re .compile ('\{\{\s*last_modified_time\s*\}\}' )
573574 FILE_NAME_REGEX = re .compile ('\{\{\s*file_name\s*\}\}' )
@@ -602,6 +603,7 @@ def update_automatically(self, view, what):
602603 var = search .group ()
603604 index = line .find (var )
604605
606+ line_header = ''
605607 for i in range (index - 1 , 0 , - 1 ):
606608 if line [i ] != ' ' :
607609 space_start = i + 1
@@ -689,9 +691,10 @@ def on_pre_save(self, view):
689691 self .update_automatically (view , LAST_MODIFIED_TIME )
690692
691693 def on_activated (self , view ):
692- block (view , self .update_automatically , view , FILE_NAME )
693- block (view , self .update_automatically , view , FILE_NAME_WITHOUT_EXTENSION )
694694 block (view , self .update_automatically , view , FILE_PATH )
695+ block (view , self .update_automatically , view , FILE_NAME )
696+ block (view , self .update_automatically ,
697+ view , FILE_NAME_WITHOUT_EXTENSION )
695698
696699 settings = view .settings ()
697700 c_time , _ = get_time (view .file_name ())
0 commit comments